ADR-0162: A configuration key is named in three places, or not read
- Status: Accepted
- Date: 2026-09-16
- Deciders: Workstream 012, NEXT row "Configuration-key parity gate"
Context
The readiness assessment of 2026-09-02 found twenty-nine keys the config
loader read that neither .env.example nor docs/DEPLOYMENT.md named —
every LIFECYCLE_* window, both ARCHIVE_* keys, every HOSTING_* bound —
and a gateway table in the deployment guide that named keys the loader never
read. Each was a deployment decision an operator could not discover, or a
knob that did nothing. The repair landed by hand on 2026-09-09 (#607). Nothing
kept it repaired: the next key added to lifecycle.go would have drifted the
same way, because the loader, the example file and the guide are edited in
three different PRs by three different reasons.
Decision
npm run check:config-keys holds the three to each other and is part of
verify. Every key apps/api/internal/config/*.go reads (through
getEnv, getEnvInt, getEnvBool, envBytes, os.Getenv or
os.LookupEnv, literal or package constant) must appear in
docs/DEPLOYMENT.md's Environment Variables section and in .env.example;
every key either document names must be one the loader reads; and a package
outside config/ may read the environment only for a key the loader already
declares.
.env.example is the baseline, not the full table — it says so itself and
lists sandbox switches but not gateway credentials. That difference is a
ledger, scripts/config-keys-ledger.json: the credential families, by
prefix and provider, that the example file defers to the guide. A family
row that exempts nothing fails the gate, and a _SANDBOX switch is never
exempt, because a switch is a deployment decision whatever its prefix.
Consequences
- A new key is three lines in one PR — the read, the
.env.exampleline with its default, the guide row with the decision it carries — or the build is red. That is the intended cost. - A new third-party integration adds a ledger row naming its provider, so the exemption is reviewed where the credential is introduced.
- The loader is the one place a key is named.
middleware/logging.goreadsENVdirectly and passes becauseconfig.godeclaresENV; a second direct read of a new key fails until the loader declares it. - The gate reads the Go source as text. A key read some other way — built from a string, looked up through a map — is invisible to it, which is the reason the read helpers are the convention.
Alternatives considered
- Generate
.env.exampleand the guide's tables from the loader — rejected: the guide's rows carry the decision each key represents and the ADR that made it, which no generator has. - Move every credential into
.env.exampleso the check is a plain three-way equality — rejected: ninety-four commented credential lines would bury the twenty an operator must actually decide.
Source: docs/decisions/0162-a-configuration-key-is-named-in-three-places-or-not-read.md