SYSTEM.md contract — rationale
Generated by bootstrap-system-md. The header in SYSTEM.md states the rules; this file states why, for humans auditing an agent's edit or disputing one.
Why one file. Split docs fail by disagreeing: a partial update leaves two
files contradicting each other and no reader can tell which is current. The
orientation tier (what/layout/invariants/env/ledgers) therefore stays in one
file. Reference material (entity lifecycles, UI conventions, surface
catalogs) has low contradiction risk and high volume, so it may extract to
docs/ with an index left behind.
Why update-after-change (rule 1). Documentation maintenance follows a burst-then-taper pattern when it is a separate task. Making the update a completion criterion of the change itself, performed by whoever holds the freshest knowledge, is the only version that survives. Note the honest limit: this bounds staleness to one round of work, not to zero — the file is accurate at merge boundaries and can drift mid-round.
Why integrate-don't-append (rule 2). Agents honor rule 1 by appending dated paragraphs, because appending never risks breaking someone else's prose. The file then grows monotonically as a changelog and a reader must replay history to learn current behavior. Dates in descriptive sections are the fingerprint of this failure; the gate greps for them.
Why log lessons (rule 3). Gotchas are the highest value-per-line content: they are the failures that recur across agents and models. They are cheap to write immediately after paying for them and impossible to reconstruct later.
Why ledgers shrink (rule 4). An append-only ledger without eviction is just bloat with a nicer name. Deferred items without a trigger are read every session and acted on never. A gotcha whose cause is now enforced by a test has done its job — it promotes into the invariants section, where it is checkable, instead of accumulating.
Why the cap is in bytes. A line cap is satisfied by widening lines: dense 200-character bullets cost the same tokens as the lines they replaced and read worse, and the file is rewritten in place to stay "under" a number that measures nothing. Bytes track tokens closely and cannot be gamed by reflowing. Lines are still reported, as a readability signal only.
Why the gate writes the stamp. Any field a human must remember to update by hand will drift; a "last revision" line a hundred commits old is worse than none because it looks maintained. Metadata the gate can derive from git, the gate writes.
Why a routing table. Agents read in slices and always have; the file's cost is the first-visit tax of finding the slice. Naming the slice per kind of work cuts the average read more than any extraction, because it changes the read pattern rather than the file.
Why the decision record carries rejected alternatives. When planning, the fact an agent most often lacks is why the obvious alternative was not taken. If the repo does not own that, it ends up in an agent's per-user memory store, which the next agent, model, or vendor does not have.
Why extraction warnings escalate. A candidate flagged three audits running and still present is how an orientation file becomes reference material without anyone deciding it should. A warning that persists across two baselines is no longer advice.
Why caps are earned (rule 5). Raising the size cap when it is hit is the document-shaped version of re-baselining past a regression. A cap raise is legal only after a grooming or extraction pass proved the content incompressible, with a recorded reason.
Why anchors, not ordinals. Section numbers get cited from code, configs, and handoff docs; a grooming pass renumbers; every citation silently points at the wrong section. Anchors and rule IDs survive; if numbers are used they are frozen.
Why invariants name their enforcement point. A rule with a test is checkable; a rule alone is a wish. Pinned invariants are the part of the file that can be trusted without re-reading the code, and the gate can verify the named test still exists.
Why the shims. The dominant failure of a correct file is that nobody
opens it. Root CLAUDE.md/AGENTS.md shims make every auto-loading tool
reach SYSTEM.md without duplicating a single fact.
Why no secret values. This file is committed and injected into every agent's context window. Names and locations only.