Files
archie/docs/prds/config-example-drift.md
T
sam 65e6b2f65b docs(prds): normalise statuses and remove writing dated to its own day
Three defects the first sweep left behind, each caught by a rule the guard
did not yet have.

Statuses. RULES.md gives three; the tree had 25 values, and the free-text ones
were carrying progress. "Implemented (wiring landed)" and "Ratified (rev. 2e).
Rev. 2e adds the OpenTaskByPR lookup. Rev. 2d revised section 10..." were both
changelogs living in the one field the other rules exempt. Every PRD now
declares Draft, Approved or Finalised and nothing else; five that declared
nothing now declare one. A revision number moves to **Revision:**, a pointer
to the authoritative document to **Authority:**, and what a past revision
changed to git. CLAUDE.md's citation of state-store-contract rev. 2e still
resolves.

Stale cross-references. "Supersedes the 2026-09-03 open question", "this
bullet previously said", "an earlier draft of this document claimed" all point
at text the reader cannot see, because it was replaced. A supersede marker
survives only when it names a file, a section or a symbol that can be found.

Temporal hedges. 100 uses of today, currently and right now across 31 files.
Each dates its sentence to the day it was written: "[notify] today is one
webhook URL, read in one place" stops being true the moment this design lands,
while still reading as the premise it rests on.

The header-field exemption was also too wide. "**Date:** 2026-09-03, Channel
resolved 2026-09-22" smuggled a dated status into the one line the rules did
not read; the exemption is now a Date holding only a date and a Status holding
only one of the three.
2026-09-22 00:38:35 +10:00

6.1 KiB

Example-config and generated-config drift — decision

Status: Approved Date: 2026-09-15 Closes: the checked-in-config half of audit findings config-1 and repo-root-deployment-2; strengthens doc-drift findings generally. Authority: extends docs/architecture/generated-documentation.md and docs/prds/config-schema.md; does not replace either.

Question

Should config.example.toml and deployments/*.toml be generated, so they cannot drift from the config code?

Decision

No — do not generate them. Gate them instead. Neither file is a projection of the schema, and generating either would destroy the thing that makes it useful. Three verified reasons, in order of weight:

  1. config.example.toml's value is its comments. It documents 137 keys (measured: active and commented-out), and those hand-written comments are the file's purpose — docs/architecture/configuration.md states outright that "config.example.toml carries documentation users are meant to hand-edit". TOML round-tripping does not preserve comments, which is exactly why tomlwrite does line-oriented edits rather than decode/encode. A generator would emit a correct file with the documentation deleted.
  2. docs/prds/config-schema.md forbids building on config.Config. That PRD rejects "a reflection-based schema over config.Config" because the struct is "scheduled for dissolution". A generator deriving the example from its struct tags would build on a foundation this repo has already decided to remove.
  3. docs/architecture/generated-documentation.md prohibits it. "Adding another hardcoded type list to docsgen is prohibited" — so any generator must consume a domain-owned registry, which does not exist for configuration yet. Creating one is the config-domain migration's job, not this change's.

The deployment profiles are also not a projection: they set 3-46 keys against the example's 137, and they are curated overlays ("a complete config, not an overlay", per their own headers), not near-duplicates. Generating them would add machinery to remove duplication that largely is not there.

The gap that is real

Unknown config keys are silently ignored. Verified at internal/infrastructure/configuration/decode.go:

if _, err := toml.DecodeFile(path, target); err != nil {

There is no MetaData.Undecoded() check, so a typo — max_concurrancy = 4 — parses clean, validates clean, and does nothing. That is the same failure shape this repo's audit found repeatedly: a setting that looks applied and is not. It is also detectable without any hand-maintained list, because BurntSushi/toml reports exactly which keys the target did not consume.

Note the second, separate gap already admitted in writing: generated-documentation.md — "task check does not run docs:check, so generated drift is ungated."

What to build

1. Unknown-key detection at the loader (behaviour). Decode with metadata and collect Undecoded(). Report it as a warning at startup listing the offending keys, and expose it so tests can assert emptiness.

Deliberately a warning, not a fatal error. configuration.md's settled startup policy is "a missing credential disables a capability; only an invalid config stops the daemon". A stray key is far more likely to be an operator typo in a file they are otherwise happy with than a reason to refuse to boot, and [web] is documented as landing in a different binary (internal/app/archieui), so a key unknown to one process is legitimately known to another. Failing closed here would break working deployments on upgrade.

2. A checked-in-config contract test (gate). Load config.example.toml and every deployments/*.toml through the real loader and assert Undecoded() is empty, with an explicit allowlist for keys another binary owns. This is the mechanism that would have caught a renamed key left behind in an example, and it needs no inventory.

3. Gate generated data in task check. Done. task docs:check runs in the gate, closing the admitted "generated drift is ungated" hole. The check mode did not exist when this was written; it was added for issue #855, which also made the check non-destructive so the gate can never rewrite the artifact it is judging.

4. Explicitly NOT now: a generated key inventory. configuration.md's completion criteria want "generated documentation lists every external key, default, constraint, mutability class, owner". That is a real target and it is the config domain's, once a domain-owned registry exists — the prohibition above means it cannot be bootstrapped from a list inside docsgen. Recorded as deferred, not rejected.

Non-goals

  • No generation of config.example.toml or deployments/*.toml.
  • No reflection-based schema over config.Config.
  • No new type list inside docsgen.
  • No change to archied setup's template: configtemplate.Example stays the verbatim embedded example, hand-maintained, and setup continues to edit it via tomlwrite rather than regenerate it.

A withdrawn premise, recorded so it is not reused

An earlier measurement claimed 17 keys were "set by a profile but documented by no example", and used it to argue for generation. It was an artifact: the extractor stripped comment markers and tracked a single table variable, so commented blocks were mis-attributed. Re-checking refuted it — providers.<name>.api_key_env is a real, documented backwards-compatible field (internal/config/config.go, config.example.toml) and [[identities]] is documented at config.example.toml. The decision above does not rest on that measurement.

Acceptance criteria

  1. A config file containing an unknown key surfaces those keys to the operator at startup, and the daemon still starts.
  2. config.example.toml and every deployments/*.toml are loaded by a test that fails if any key is undecoded, except keys explicitly attributed to another binary.
  3. task check fails when committed generated data is stale.
  4. Introducing a renamed key into config.example.toml fails the gate (prove it by doing it, not by asserting it).