ADR-0012 — Machine-Readable ADR Traceability Kit¶
Status¶
Accepted
Context¶
The estate's architecture decisions live in docs/adrs/ as markdown with
YAML front-matter, and every Rego policy carries a __rego__metadoc__ block
that cites its governing ADR. That substrate is rich, but it is inert:
- Supersede chains are traversed by hand. When ADR-0009 supersedes
ADR-0004, a reader must follow the
supersedesrefs themselves; nothing resolves "what is the current decision on X?" - Traceability is hand-maintained.
docs/traceability/index.mdis a stale, hand-drawn diagram; it already predates ADR-0010 and ADR-0011. - Decisions have no territory. Nothing fails a pull request that
changes a boundary-affecting file (say
policies/orterraform/) without citing the ADR that governs it. The decision record and the change stream are disconnected.
The doc-coverage gate (ADR-0006) protects documentation currency; no comparable gate protects decision currency.
Decision¶
Adopt a four-part traceability kit, all under example/:
- Catalog —
scripts/scan-architecture.pyextracts ADR front-matter, policy metadoc blocks, and MoSCoW requirement ids into a single machine-readable catalog,docs/generated/architecture-catalog.json. The scan is metadata-only (front-matter and metadoc literals, no semantic analysis) and byte-deterministic across runs. - Policies —
policies/architecture/consumes the catalog: validate.rego— loud findings over the catalog itself: duplicate ADR ids, unknown or cyclicsupersedesrefs, status/chain mismatches, ADRs without requirements or governed paths, dangling requirement refs, policy metadoc defects. Every finding carries a severity, a rule name, a message, and a JSON path back into the catalog.chain.rego— supersede-chain traversal:effective[id]resolves the current ADR of each decision. Rego forbids recursion, so the traversal is a bounded 8-hop closure with an explicit still-growing check (catalog/chain-depth-exceeded); the cap is loud, never silent. (graph.reachableis deliberately not used: in OPA 0.69 it stops after one hop when the graph object is produced by a rule rather than a literal.)gate.rego— the PR boundary gate: a changed path governed by an Accepted ADR requires that ADR (id cited in the PR description) to be linked, or the gate fails and names the governing ADRs. Links to superseded ADRs are rejected and redirected to the successor resolved by the chain traversal.- Generator —
scripts/generate-traceability.pyregeneratesdocs/generated/traceability.drawio, a book-convention drawio diagram (MoSCoW → ADR → policy → implementation columns, supersede edges dashed red) from the catalog, byte-identically across runs. The hand-drawn mermaid indocs/traceability/index.mdbecomes historical. - CI gate —
scripts/architecture-gate.shruns scan → validate → gate on every pull request (architecturejob in the pipeline), andscripts/architecture-demo.shproves the done-when scenario end-to-end with inverted expectations: a boundary change is blocked without a linked ADR and passes with one, the traceability diagram regenerates byte-identically.
Consequences¶
Positive¶
- Supersede chains are machine-traversed; "what is the current decision?"
has one authoritative answer (
chain.effective). - The traceability diagram can never silently drift — it is regenerated from the same catalog the policies validate.
- A boundary-affecting change without a decision record is a red PR, with a message that names the ADR to cite.
- The kit is honest about its scope: a metadata scan, not semantic analysis; findings are loud and path-cited.
Negative / Trade-offs¶
- One more PR gate to satisfy: a change under a governed path now requires citing the governing ADR id in the PR description.
- Chains deeper than seven supersede hops are rejected, not traversed
(flagged as
catalog/chain-depth-exceeded) — a deliberate cap that keeps the closure non-recursive. - ADR front-matter gains a
governskey; ADR authors must maintain it (the validator flags Accepted ADRs with none).
Alternatives Considered¶
| Alternative | Rejected Because |
|---|---|
| Hand-maintained traceability page | Already stale before ADR-0010; humans forget |
graph.reachable for chains |
OPA 0.69 stops after one hop on rule-produced graphs |
| Semantic AST analysis of ADR prose | Out of scope; metadata is sufficient for the gate |
Related¶
- ADR-0002 — OPA for Policy
- ADR-0006 — Documentation Coverage Gate
- MoSCoW requirements: S-006, M-005, D-001