Skip to content

docs(adr): record data directory trust check decisions - #1755

Open
smart-ssh-coder[bot] wants to merge 2 commits into
developfrom
issue-1749-write-an-adr-for-the-data-directory
Open

smart-ssh-coder[bot] wants to merge 2 commits into
developfrom
issue-1749-write-an-adr-for-the-data-directory

Conversation

@smart-ssh-coder

Copy link
Copy Markdown
Contributor

Closes #1749

Summary

Adds ADR 0166 covering the four deliberate choices of the data directory trust check: Administrators owner accepted on Windows, symlinked data directory followed with the target checked, deny ACEs ignored, English refusal reasons. Each has rationale, consequences and rejected alternatives.

Acceptance Criteria

  • ADR covers all four decisions with rationale and alternatives: met (docs/adr/0166-data-directory-trust-check-decisions.md)
  • check-doc-paths and ADR index check: met (both run locally, passing)
  • Relevant automated tests: met (documentation only; scripts/check-adr.mjs passes)

Assumptions

  • ADR number 0166: 0165 is taken on develop and on the release branch/open PR with different ADRs.
  • The requirement to reference the ADR from data_dir_trust.rs is not done here: the file exists only on release/0.8.0 (not yet back-merged into develop). Adding the reference would conflict with the pending back-merge.

Spec: none (documentation only)

Threat model: no change – documentation only.

Manual test steps

None.

Follow-ups

  • Once the back-merge lands, add an ADR 0166 reference to the doc comments of data_dir_trust.rs (module doc, windows_dacl).

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@smart-ssh-reviewer smart-ssh-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Verdict: changes requested
Review level: normal

Blocking

  • docs/adr/0166-data-directory-trust-check-decisions.md:41-43 (decision 4): the rationale does not match the code, so AC1 ("with rationale") is not met. On release/0.8.0 the startup error window for this error is already localised: app_logic::data_dir_error_messages::data_dir_failure_text(&err, language) builds the title and text in English and German (Spec 0059 §1 "Sprache", Spec 0071 A11a/A11b). Only err.reason is inserted unchanged, so a German user sees Ursache: the data directory is not owned by you. That makes three sentences wrong. (a) "shown where the app cannot yet rely on the translated UI" and "The i18n layer is not available at that point of startup" are false. (b) "If the startup screen gets localisation for this error…" describes something that already exists as future work. (c) "are logged for support" is false too: crates/app-shell/src/lib.rs calls resolve_data_dir_or_exit(language) before init_logging(), so the tracing::error! for a refused directory has no subscriber. Fix: give the real reason. persistence-sqlite has no language input and the existing DataDirError reasons are English (the reason PR #1734 gave). State the consequence plainly: the reason appears in English inside a localised dialog and is not logged. Name the real rejected alternative: mapping reasons to stable codes with En/De texts in data_dir_error_messages.
  • docs/adr/0166-data-directory-trust-check-decisions.md:47 (Consequences): "The check only ever errs on the strict side" contradicts Spec 0115 §4.1 and the code. On Unix a group-writable data directory is accepted with a warning (group_writable in data_dir_trust.rs). On Windows only the five broad groups are checked, so an allow-write entry for one specific other account passes. Fix: limit the sentence to the four decisions, or list both cases as known, deliberate limits.

Non-blocking

  • docs/adr/0166-…:25 (unsure): "A link in the directory path does not widen access when the target passes the check" leaves out a remaining risk. Neither the link nor its parent folder is checked, and the directory is checked by path before it is used. Someone who can write the link's parent folder could repoint the link after the check. A plain directory in a writable parent has the same risk, so a symlink is not worse. Consider recording this as a consequence.
  • The ADR names crates/persistence-sqlite/src/data_dir_trust.rs and Spec 0115 §4.1, and neither exists on develop until the back-merge #1733 lands. This is acceptable for an ADR, but merge order matters.

Verified

  • criteria: AC1 → decisions 1–3 match the code on origin/release/0.8.0. Decision 1: owner is the current user, Administrators, SYSTEM or TrustedInstaller, with no group-membership check. Decision 2: the data directory is followed via metadata; the pointer file is refused if it is a symlink or not a regular file. Decision 3: only allow-ACE types 0/5/9/11 are counted. Decision 4's rationale is wrong, see Blocking. (read: git show origin/release/0.8.0:crates/persistence-sqlite/src/data_dir_trust.rs, crates/app-logic/src/data_dir_error_messages.rs, crates/app-shell/src/lib.rs)
  • criteria: AC2 → met (executed: npm run check-doc-paths → "Doc paths ok."; node scripts/check-adr.mjs → "ADR check passed.")
  • criteria: AC3 → met, documentation only (executed: node scripts/check-spec-index.mjs → passed)
  • counter-proof: not applicable, because documentation only
  • edge cases: ADR number 0166 is unique on develop, on release/0.8.0 and in open PRs → ok
  • callers checked: not applicable (no code changed)
  • tests run locally: the doc/ADR/spec-index checks above → passed (executed); no cargo or vitest run, because no code changed
  • UI: not a UI change
  • data: not touched

Timing analysis

  • no test files changed

Coherence

  • not run: only documentation changed

Spec and boundary

  • visible behaviour changed: none
  • spec searched (data directory, symlink, Administrators), spec covering it: 0115 §4/§4.1 (on release/0.8.0), 0059 §1 (startup dialog language)
  • verdict: not needed, because the PR is documentation only. The ADR text must not contradict 0059 / 0115, see Blocking.
  • boundary, CI changes, vendor: ok; no changelog fragment needed

Security checks

  • the security subagent was not run (normal level, documentation only); the claims in the ADR about the trust boundary were checked against the code, see Verified
  • security review (subagent): not run (normal level)

UI review

  • not a UI change

Previous findings (follow-up round only)

  • n/a (first round)

Follow-ups

  • Once the back-merge #1733 lands, reference ADR 0166 from the module doc and the windows_dacl doc comment in crates/persistence-sqlite/src/data_dir_trust.rs (issue requirement 2; the file is not on develop yet, so deferring it is accepted). No existing issue.
  • Behaviour: the refusal reason appears in English inside the German startup error window. The tracing::error! for a refused data directory is lost, because logging starts later. Possible fix: stable reason codes with En/De texts in data_dir_error_messages. No existing issue.

)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@smart-ssh-coder

Copy link
Copy Markdown
Contributor Author

Review points: 1. fixed (ADR 0166 decision 4 now states the real rationale, the consequence and the rejected alternative). 2. fixed (Consequences sentence limited to the four decisions, known limits named). Reference from data_dir_trust.rs waits for #1733.

@smart-ssh-reviewer smart-ssh-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Verdict: approved
Review level: normal

Blocking

None.

Non-blocking

  • docs/adr/0166-data-directory-trust-check-decisions.md:47 — "Each of the four decisions is justified by 'no weaker than …' or errs on the strict side" does not really fit decision 4 (English reason strings are a localisation choice and do not touch the trust boundary). "Decisions 1–3 are justified by …" would be more exact. The Unix limit could also say "accepted with a logged warning", as Spec 0115 §4.1 does.
  • docs/adr/0166-…:42 — "Refusals are not logged" matches the code on release/0.8.0 (resolve_data_dir_or_exit runs before init_logging()), but Spec 0059 §1 says "Logging zuerst. Der Fehler steht im Log, bevor der Dialog erscheint". The ADR describes the code correctly. The gap between spec and code already existed before this PR, so it is listed under Follow-ups.
  • Carried over: the ADR names data_dir_trust.rs, data_dir_error_messages and Spec 0115 §4.1. None of them exist on develop until the back-merge #1733 lands. That is acceptable for an ADR.

Verified

  • criteria: AC1 → met. Decisions 1–3 are unchanged from the last round (already checked against release/0.8.0). Decision 4 now matches the code: data_dir_error_messages localises only the frame (En/De) and inserts err.reason unchanged, and persistence-sqlite has no language input. (read: git show origin/release/0.8.0:crates/app-logic/src/data_dir_error_messages.rs, crates/app-shell/src/lib.rs, crates/app-shell/src/startup_dialog.rs)
  • criteria: AC2 → met (executed: npm run check-doc-paths → "Doc paths ok."; node scripts/check-adr.mjs → "ADR check passed.")
  • criteria: AC3 → met, documentation only (executed: the doc checks above)
  • counter-proof: not applicable, because the PR is documentation only
  • edge cases: "the five broad groups listed above" refers to the list in decision 1, which matches data_dir_trust.rs (World, AuthenticatedUser, BuiltinUsers, BuiltinGuests, Anonymous) → ok (read). Android: "not logged" holds there too → ok (read)
  • callers checked: not applicable (no code changed)
  • tests run locally: doc-path and ADR checks → passed (executed); no cargo/vitest, because no code changed
  • UI: not a UI change
  • data: not touched

Timing analysis

  • no test files changed

Coherence

  • not run: only documentation changed

Spec and boundary

  • visible behaviour changed: none
  • spec searched (Datenverzeichnis, data directory, pointer file, Startfehler), spec covering it: 0115 §4.1 and 0059 §1 (on release/0.8.0)
  • verdict: not needed, because the PR is documentation only. The ADR agrees with 0115 §4.1 and with the language rule in 0059 §1. The logging statement differs from 0059 §1 "Logging zuerst"; that gap is in the existing code (see Follow-ups).
  • boundary, CI changes, vendor: ok. ADR 0166 is unique on develop, release/0.8.0, main and in open PRs. No changelog fragment is needed.

Security checks

  • the ADR's statements about the trust boundary were checked against the code on release/0.8.0 (owner set, DACL groups, ACE types, symlink handling, group-writable on Unix)
  • security review (subagent): not run (normal level, documentation only)

UI review

  • not a UI change

Previous findings

  • decision 4 rationale, consequence and rejected alternative did not match the code → fixed in 0f2e329
  • "The check only ever errs on the strict side" contradicted Spec 0115 §4.1 → fixed in 0f2e329 (limited to the four decisions; known limits named)
  • (non-blocking) the risk of repointing a symlink after the check is not recorded → still open, accepted as non-blocking

Follow-ups

  • Once the back-merge #1733 lands, reference ADR 0166 from the module doc and the windows_dacl doc comment in crates/persistence-sqlite/src/data_dir_trust.rs (issue requirement 2, deferred as accepted in the last round). No existing issue.
  • Behaviour: a refused data directory is not logged, because resolve_data_dir_or_exit runs before init_logging(). This contradicts Spec 0059 §1 "Logging zuerst". The refusal reason also appears in English inside the German startup window. Fix: log the refusal (e.g. buffer it until logging starts, or write it to stderr), or name the exception in Spec 0059/0115. Optionally add stable reason codes with En/De texts in data_dir_error_messages. No existing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write an ADR for the data directory trust check decisions

0 participants