Skip to content

docs(adr): ADR-0029 — config file v1: schema, parser crate, StrictModes checks - #127

Merged
gonzafg2 merged 4 commits into
mainfrom
docs/adr-0029-config-v1
Jul 19, 2026
Merged

gonzafg2 merged 4 commits into
mainfrom
docs/adr-0029-config-v1

Conversation

@gonzafg2

Copy link
Copy Markdown
Owner

What

The implementing ADR for RFC-0010 (Accepted, #112/#116) — the keystone Phase-2 workstream in #109. Per project practice, the ADR lands before the implementation. It locks the operative details the RFC deferred:

RFC-0010 open question ADR-0029 decision
Exact keys / sections v1 = exactly today's surface: schema_version, [server] listen/host_key/handshake_timeout, [auth] authorized_keys, [logging] format. Deferred policy ([limits], [session].accept_env, trusted_user_ca_keys) lands with its features, pre-freeze — fail-closed refuses it until then, which is correct
Value grammars Integer seconds for durations (symmetric with --handshake-timeout <SECS>); paths/addresses as strings through the same std parsers the flags use
TOML crate basic-toml + serde derive: serde is already in the binary's build graph (tracing-subscriber JSON), so the lockfile delta is one crate; deny_unknown_fields gives the fail-closed schema with zero first-party parser code. Full toml (winnow/indexmap/toml_datetime/serde_spanned) rejected on surface
Retained flags All five + --config; file optional-but-primary; CLI > config > default
Config required? Optional (Alternative 5 records why required was rejected)
StrictModes Full OpenSSH predicate set (writability + ownership + ancestor chain; host key also non-readable) over rustix — applied to the trusted files whether named by flag or config

Honest costs called out: StrictModes is a behaviour change for flag-only deployments (dev setups with sloppy modes will now refuse to start — the interop harness must chmod its fixtures), and serde_derive starts compiling.

Status: Proposed — flips to Accepted when the implementing PR merges (#86 pattern).

Refs #109. Implements RFC-0010.

https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa

…es checks

Implementing ADR for RFC-0010, locking what the RFC left open:

- Schema v1 = exactly today's surface (schema_version, [server],
  [auth], [logging]); deferred policy sections land with their
  features, before the 0.1.0 freeze.
- Durations as integer seconds (symmetric with --handshake-timeout);
  no bespoke value grammars.
- Parser: basic-toml + serde derive with deny_unknown_fields — serde
  is already in the binary's build graph via tracing-subscriber, so
  the lockfile delta is one crate.
- All five Phase-1 flags retained as overrides plus --config; the
  file is optional-but-primary per the RFC's recommendation.
- StrictModes: full integrity + confidentiality predicate set over
  rustix, applied to the trusted-file set whether paths come from
  flags or config.

Status: Proposed — flips when the implementing PR merges.

Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa
Signed-off-by: Gonzalo Fleming <[email protected]>
Copilot AI review requested due to automatic review settings July 19, 2026 20:54
@gonzafg2 gonzafg2 added the documentation Improvements or additions to documentation label Jul 19, 2026
@opencode-agent

Copy link
Copy Markdown

Here is my review of ADR-0029 against the review criteria.


Review: ADR-0029 — Configuration file v1

The ADR implements RFC-0010 by locking the operative details the RFC deferred. It is a design doc; this review assesses design soundness against the MANIFIESTO commitments and threat model, not code correctness.

Verdict: Approve with two minor notes

All five MANIFIESTO commitments are satisfied. The design is sound and well-justified. Two minor edge-case observations for the implementing PR follow.


MANIFIESTO #1 — Memory-safe by construction ✓

No first-party unsafe is introduced. StrictModes checks use rustix::fs::stat/statat, a safe syscall wrapper already in the tree. ADR-0018 explicitly names rustix as the correct bridge to the kernel under unsafe_code = "forbid".

MANIFIESTO #2 — Post-quantum by default ✓

The v1 schema covers only the five Phase-1 flags (server.listen/host_key/handshake_timeout, auth.authorized_keys, logging.format). No KEX or cipher configuration exists, so there is nothing to downgrade. RFC-0010 already bounds future config surface: "no non-hybrid or classical-only KEX may ever be expressible via config" (RFC-0010:342-345).

MANIFIESTO #3 — Zero legacy ✓

No legacy crypto, compression, or authentication modes are introduced. The deferred keys (trusted_user_ca_keys, accept_env, [limits]) are scoped to their implementing PRs and carry no legacy baggage.

MANIFIESTO #4 — Small surface, sharp edges ✓

The lockfile delta is one crate (basic-toml). The ADR's chain of rejected alternatives (full toml crate → +4 transitive crates; toml_edit → +2 + ~200 lines of hand-rolled traversal; bespoke parser → the exact sshd_config accretion trap RFC-0010 rejected) demonstrates disciplined surface reasoning. The deny_unknown_fields approach means the fail-closed schema costs zero first-party parser code — correct for a security-sensitive config file. The cargo deny gate is correctly deferred to the implementation PR (line 65).

MANIFIESTO #5 — Permanently open ✓

All proposed crates (basic-toml, serde, rustix) are MIT/Apache-2.0 dual-licensed — compatible with deny.toml's allow-list and the project's Apache-2.0 posture.


Threat model alignment

Rule How the ADR satisfies it
§4.1 Pre-auth path Config is parsed in the binary's synchronous startup, never on the pre-auth path. The library stays protocol-only.
§4.2 Process boundary StrictModes directly enforces the file-permission obligations on host key material, authorized_keys, and configuration files — applied to the resolved trusted-file set regardless of whether the path came from a flag or config.
§4.4 Configuration boundary deny_unknown_fields + fail-closed schema + schema_version handling implement the trust boundary's requirement that parsed config matches operator intent.
§5.5.3 Host key confidentiality The confidentiality check (not group/world-readable) directly implements the threat model's mandate — and extends it to also reject group-readable (0640), per RFC-0010's tightening.
ADR-0024 audit schema All failure modes use the existing server.config_error event (insecure_permissions, schema_error, version_unsupported) — no new event names minted, respecting the Phase 2 schema freeze. The info-level precedence override log is correctly scoped.
ADR-0017 workspace split Config module in the thin binary crate, not in quantumssh-core. The library's server::Config type remains the typed handoff — correct.

Two minor notes for the implementing PR

1. Under-specified error classification for ancestor-walk stat failures (§Negative, line 119). The ADR maps all StrictModes failures to insecure_permissions. However, there is a gap between "permissions are genuinely too permissive" (a security policy violation — stat succeeds, predicates fail) and "I cannot stat this path to check" (an operational error — ENOENT, EACCES on a parent directory owned by someone else). The RFC-0010 failure-mode table already distinguishes insecure_permissions from missing-file refusal. The implementation should carry that distinction through the ancestor walk: a stat that fails with EACCES because the process cannot traverse a parent should not be reported as insecure_permissions (the policy didn't fail; the check couldn't run). This is an implementation detail, not a design flaw — but the ADR's blanket "failures refuse to start with insecure_permissions" is imprecise here.

2. serde_derive build-cost claim (line 119). The ADR states it "was in the lock but unbuilt." If tracing-subscriber's json feature activates serde/derive via tracing-serde → serde_json, then serde_derive is already in today's compilation pipeline — the incremental cost of adding first-party #[derive(Deserialize)] may be negligible. This doesn't affect the design decision (the cost is explicitly accepted), but the accuracy of the claim is worth checking in the implementation PR.


Classification

Per the review criteria for docs/adr/ changes: the design is sound against all five MANIFIESTO commitments and the threat model. The two notes above are implementation-scope edge cases, not design blockers.

github run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds ADR-0029, the implementing ADR for RFC-0010, to lock down the Phase-2 TOML config-file v1 details (schema surface, parsing approach, CLI precedence, and StrictModes-style permission checks) ahead of implementation work.

Changes:

  • Define config v1 schema keys/sections and value grammars (integer seconds, std parsers for paths/addrs).
  • Choose basic-toml + serde derive with fail-closed deny_unknown_fields.
  • Specify StrictModes startup permission predicates for config + trusted files (host key + authorized_keys) and where the implementation should live (binary crate).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

… error classes, fix wording

Review feedback on #127:

- Symlink bypass closed: trusted paths are canonicalised
  (std::fs::canonicalize) before the predicate walk, so the check runs
  over the real file's ancestors, not a symlink's — matching OpenSSH
  secure_filename() on the resolved path (claude-review).
- A predicate failure (insecure_permissions) is now distinct from a
  check that could not run (ENOENT/EACCES/dangling symlink → the
  missing-file class); the audit trail must not conflate them
  (opencode).
- schema_version carved out of the every-key-is-optional blanket
  (claude-review).
- Links section describes the workspace-pins layout instead of
  implying crate-local versions (Copilot).

Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa
Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2

Copy link
Copy Markdown
Owner Author

Re the two opencode notes:

  1. Error classification in the ancestor walk — adopted in 592bb34: a failed predicate is insecure_permissions; a check that cannot run (ENOENT/EACCES/dangling symlink on canonicalisation or stat) refuses to start as the missing-file class instead, so the audit trail never conflates "policy failed" with "check could not run".
  2. serde_derive build-cost claim — verified, the claim stands: cargo tree -i serde_json shows it built today via tracing-subscriber, but cargo tree -i serde_derive returns nothing to print — serde_json does not activate serde/derive, so serde_derive is genuinely in the lock but unbuilt, and first-party #[derive(Deserialize)] is what starts compiling it. The ADR's Negative bullet is accurate as written.

@opencode-agent

Copy link
Copy Markdown

Review: ADR-0029 — Configuration file v1

The ADR implements RFC-0010 by locking the operative details the RFC left open. It is a design document only (no Rust changed). Per the review criteria, this assessment is of design soundness against the MANIFIESTO commitments and threat model.


Verdict: Approve with one note

Three prior review findings were addressed in commit 592bb34 (canonicalisation, error-class split, dependency-layout wording). All five MANIFIESTO commitments are satisfied. One remaining design-contract inaccuracy follows.


MANIFIESTO #1 — Memory-safe by construction ✓

rustix::fs::stat/statat are safe syscall wrappers. ADR-0018:1-20 explicitly names rustix as the correct bridge to the kernel under unsafe_code = "forbid". The ADR's placement in the binary crate respects the library/binary split (ADR-0017).

MANIFIESTO #2 — Post-quantum by default ✓

The v1 schema covers only the five Phase-1 flags — no KEX or cipher configuration, so nothing to downgrade. RFC-0010:342-345 already bounds the future surface: "no non-hybrid or classical-only KEX may ever be expressible via config."

MANIFIESTO #3 — Zero legacy ✓

No legacy crypto, compression, or authentication modes are introduced. Deferred keys (trusted_user_ca_keys, accept_env, [limits]) are scoped to their implementing PRs.

MANIFIESTO #4 — Small surface, sharp edges ✓

One new crate (basic-toml). The chain of rejected alternatives demonstrates disciplined surface reasoning. cargo deny gate correctly deferred to the implementing PR.

MANIFIESTO #5 — Permanently open ✓

All proposed crates (basic-toml, serde, rustix) are MIT/Apache-2.0 — compatible with deny.toml and the project's Apache-2.0 posture.


Threat-model alignment

Rule ADR treatment
§4.1 Pre-auth path Config is parsed at startup in the binary crate; the library stays protocol-only.
§4.2 Process boundary StrictModes directly enforces the file-permission obligations on host key, authorized_keys, and config — regardless of whether paths came from flags or config.
§4.4 Configuration boundary deny_unknown_fields + fail-closed schema + schema_version handling implement the trust boundary's requirement.
§5.5.3 Host key confidentiality The confidentiality check (not group/world-readable) directly implements §5.5.3 line 1135-1136: "refuse to start if host-key file permissions are world-readable." The ADR extends this to also reject group-readable (0640), per RFC-0010's tightening.
ADR-0024 audit schema All failure modes use the existing server.config_error event — no new event names minted.

The canonicalisation-first order (line 81-84) now correctly closes the symlink-bypass gap. The error-class split (lines 96-100: insecure_permissions vs. missing-file) eliminates the classification ambiguity that the first-pass review flagged.


One note for the implementing PR

rustix feature gap (line 80). The ADR states that rustix::fs::stat/statat is "already in the tree, no new dependency" for StrictModes — but the current rustix feature set in the workspace Cargo.toml:38 is ["std", "process"]. The fs::stat functions live under rustix's fs feature gate, which is not enabled today. The claim that no dependency change is needed is therefore inaccurate: the implementation must add "fs" to the rustix feature set. The ADR could note this explicitly to avoid giving the implementing PR a false expectation that stat is already available under the current feature gate. This is a contract-accuracy issue in the ADR, not a design flaw — rustix is already in the lockfile, adding a feature flag to an existing crate is the minimal surface expansion, and it complies with ADR-0018.

github run

…endency-change claim

opencode's re-review on #127: the workspace pins rustix with
features ["std", "process"] only; rustix::fs::stat is gated behind
the fs feature. The ADR now states the implementation adds fs to the
existing pin — a feature flag on a crate already in the tree, not a
new dependency.

Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa
Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2

Copy link
Copy Markdown
Owner Author

Re the remaining note — adopted in b0974a0: verified against Cargo.toml:38 (features = ["std", "process"], no fs). The ADR now states the implementation adds the fs feature to the existing rustix pin, and the Links bullet carries the same delta. Thanks — the "no new dependency" claim was crate-accurate but feature-imprecise.

@opencode-agent

Copy link
Copy Markdown

Review: ADR-0029 — Final pass

The ADR has been through three rounds of automated review (opencode, claude, copilot). All five prior flagged issues are resolved in the current HEAD (commits 592bb34 and b0974a0). This is a design document only — no Rust changed.

Verdict: Approve

All five MANIFIESTO commitments are satisfied. No remaining high-signal findings.


Issues resolved in earlier rounds

# Finding Resolution
1 schema_version declared mandatory and optional in conflicting prose 592bb34: line 40 now reads "Every key except the mandatory schema_version is optional"
2 Symlink bypass in ancestor walk (canonicalisation missing) 592bb34: lines 84-90 require std::fs::canonicalize before the walk
3 Error-class conflation (all ancestor stat failures → insecure_permissions) 592bb34: lines 100-103 split into insecure_permissions (predicate failed) vs missing-file class (check couldn't run)
4 Dependency layout guidance conflicting with repo convention 592bb34: Links section now describes workspace = true pattern
5 rustix feature gap (fs not in current ["std", "process"] set) b0974a0: lines 81-83 now explicitly state the fs feature must be added

Cross-reference verification

  • RFC-0010: All six deferred open questions (keys, grammars, crate, retained flags, optional config, StrictModes) are locked. No deviation.
  • ADR-0018: rustix correctly cited at line 6 as the unsafe-free bridge. Feature-gap note is accurate (verified against Cargo.toml:38: features = ["std", "process"]).
  • ADR-0024: Failure modes reuse server.config_error with three message values (insecure_permissions, schema_error, version_unsupported) — no new event names minted. The info-level override log is properly scoped as not-an-error.
  • ADR-0017 / ADR-0022: Config module placement in the binary crate respects the library/binary split.
  • Threat model §5.5.3: The ADR's host-key confidentiality check correctly extends the §5.5.3 mandate (world-readable rejection) to also reject group-readable (0640), citing it as derived from RFC-0010's tightening rather than claiming the threat model already requires it — accurate.

No remaining issues

The document is internally consistent, correctly cross-references all authority documents, and faithfully implements RFC-0010 without introducing scope creep. Ready to flip to Accepted when the implementing PR lands.

github run

…le_unavailable

claude-review on #127, second pass:

- deny_unknown_fields is a per-container serde attribute; only root
  coverage rejects an unknown section, so "on every section" left the
  deferred [limits]/[session] tables fail-open. The ADR now mandates
  the attribute on the root document struct and every section struct.
- The stat/canonicalisation failure path gets a named message value,
  file_unavailable, so the implementing PR has an authoritative
  structured value instead of a prose label (ADR-0024 discipline).

Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa
Signed-off-by: Gonzalo Fleming <[email protected]>
@opencode-agent

Copy link
Copy Markdown

Review: ADR-0029 — Configuration file v1 (final pass)

This is a design document only (no Rust changed). I assess design soundness against the MANIFIESTO commitments and threat model. The ADR has been through four prior rounds of automated review; all flagged issues are resolved in the current HEAD (commits 592bb34 and 6415fcd).

Verdict: Approve

All five MANIFIESTO commitments are satisfied. No remaining high-signal findings.


MANIFIESTO cross-check

# Commitment Verdict
1 Memory-safe by construction rustix::fs::stat/statat are safe syscall wrappers under unsafe_code = "forbid" (ADR-0018). Canonicalisation via std::fs::canonicalize is safe.
2 Post-quantum by default v1 schema covers only the five Phase-1 flags — no KEX/cipher surface exists to downgrade. RFC-0010:342-345 already bounds future surface.
3 Zero legacy No legacy crypto, compression, or auth modes. Deferred keys scoped to their implementing PRs.
4 Small surface, sharp edges One new crate (basic-toml). rustix gains fs feature on existing pin. deny_unknown_fields on root + section structs gives airtight fail-closed schema.
5 Permanently open All proposed crates are MIT/Apache-2.0 — compatible with deny.toml.

Threat-model alignment

  • §4.1 — Config parsed at startup in binary crate; library stays protocol-only.
  • §4.2 / §4.4 / §5.5.3 — StrictModes enforces permission obligations on all trusted files regardless of how they were named (flag or config). Canonicalisation-first order (line 87-91) closes the symlink-bypass gap. file_unavailable error class (line 105) prevents conflation of "policy failed" with "check couldn't run."
  • ADR-0024 — Failure modes reuse server.config_error with four named message values (insecure_permissions, version_unsupported, schema_error, file_unavailable) — no new event names minted.

Issues resolved in prior rounds (confirmed)

# Finding Fix
1 schema_version mandatory/optional contradiction 592bb34: line 40 now reads "Every key except the mandatory schema_version is optional"
2 Symlink bypass in ancestor walk (no canonicalisation) 592bb34: lines 87-91 require std::fs::canonicalize before the walk
3 Error-class conflation (all stat failures → insecure_permissions) 592bb34: split into insecure_permissions vs file_unavailable
4 deny_unknown_fields only on section structs (not root) 6415fcd: now mandates attribute on root + every section struct
5 Missing-file class had no named message value 6415fcd: added file_unavailable
6 rustix feature gap (fs not in current ["std", "process"]) b0974a0: now explicitly states fs feature must be added
7 Links/Implementation bullet described wrong dep layout 592bb34: now describes workspace = true pattern

Verified cross-references

  • Cargo.toml:38 confirms rustix features are ["std", "process"] — no fs. The ADR now accurately notes this gap (line 84-87).
  • RFC-0010 §Unresolved questions lists six deferred items — all six are locked by this ADR.
  • All cross-referenced ADRs/RFCs (0017, 0018, 0022, 0024, 0028, RFC-0007, RFC-0008, RFC-0010) exist at their stated paths.

github run

@claude

claude Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@gonzafg2
gonzafg2 merged commit 5a9f087 into main Jul 19, 2026
15 checks passed
@gonzafg2
gonzafg2 deleted the docs/adr-0029-config-v1 branch July 19, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants