Appendix A - 2. The model-coherence stack

A two-page synthesis of the model-coherence stack. Six patterns let a context-bounded agent reason through a typed map of the system instead of the whole territory — and keep the map equal to the territory, so what the agent queries is what is true.

The capability

Give a bounded-context agent a typed map it can reason through, and hold that map equal to the code so the map never lies. It answers two capabilities at once — maintain authoritative system knowledge and keep representations equal to reality. The models are executable data, not prose — read live, checked against reality by a gate, derived where a derived edge cannot drift, and generated back into the system. An agent that cannot hold the whole codebase queries the map instead, and the map is trustworthy because machinery, not hope, keeps it current.

When to adopt this stack

Use this stack when:

Typical domains:

Failure classes it covers

Composition

The model-coherence stack: reason through the map, keep it equal to the territory Six parts run left to right in two capability lanes. Authoritative knowledge (fleet blue): DATA models the system as executable typed data; CONSUME reads the model live and never copies a snapshot; EMIT generates real artifacts back from the model. Equal to reality (governed green): PARITY fails the build when a model and reality disagree in either direction; DERIVE anchors every model-to-code edge on a resolvable symbol a lint re-checks, so a derived edge cannot drift. The final part, SEAL (accent umber), routes all mutation of a shipped format through one typed model held sole by a ban-lint — model coherence applied to the product. Read together: the map is executable, read live, held equal to the territory, and generated back into it. The model-coherence stack — reason through the map, keep it equal to the territory authoritative knowledge — the model is the source of truth equal to reality — the map cannot silently drift product seam — one typed door DATA executable data CONSUME live-query PARITY parity gate DERIVE derived edges EMIT codegen SEAL one-door seam structure as data read, never copy map equals territory derive the join model makes the code one mutation door The map is executable, read live, and held equal to the territory — so a context-bounded agent can trust what it queries.
Figure A.2-1. The model-coherence stack in one picture. Six parts run left to right in two capability lanes plus the sealed-format part. Authoritative knowledge (fleet blue): DATA models the system as executable typed data; CONSUME reads it live and never snapshots; EMIT generates artifacts back from the model. Equal to reality (governed green): PARITY fails the build when a model and reality disagree either way; DERIVE anchors every model-to-code edge on a resolvable symbol a lint re-checks, so a derived edge cannot drift. SEAL (accent) routes all mutation of a shipped format through one typed model held sole by a ban-lint. The map is executable, read live, held equal to the territory, and generated back into it.

The stack has two lanes. Three parts make the map authoritative — model it as data, read it live, generate from it. Two parts hold it equal to reality — a parity gate and derived edges. One part seals the same discipline onto a shipped product format.

The constituent parts

Six parts build the guarantee in rungs: model the system as executable data, read that data live instead of copying it, hold it equal to reality with a parity gate, raise parity to a derived graph, generate real artifacts from the model, and apply the same discipline to a shipped file format.

DATA — model the system as executable data

Make the system machine-readable. Model the system as executable data the tools import and run on, so a program reads the structure and catches it the moment it moves. (DATA.)

Receives — the system's own structure: its components, its state machines, its service topology, its registries. Nothing precedes it; this is the ground the rest stand on.

Guarantees — a machine-readable model a tool loads on every run and generates real artifacts from. A query returns the live fact where a stale sentence cannot. The structure lives as data, so a program can check it, not merely a reader who happens to look.

Hands to CONSUME — a typed object every part below stands on. The consumer queries it, the parity gate checks it against reality, the generator emits from it, the traceability graph anchors its edges to it. The data is authoritative in name only until the parity gate three rungs down holds it equal to the code; on its own it is just well-typed documentation.

Deeper treatment: Appendix B - 17. Executable source-of-truth models.

CONSUME — read the model, don't copy it

Read the fact, never a copy of it. Each consumer resolves the fact it needs by querying the live model, so no second copy exists to fall out of date. (CONSUME.)

Receives — the typed model DATA published, and a consumer that needs one of its facts: a queue name, a component boundary, a policy value.

Guarantees — one authoritative value and no second copy to fall out of date. The consumer reads the model in place, so the fact it acts on is the fact the model holds now. A copy-detecting lint catches the one consumer that smuggles a constant back in.

Hands to PARITY — a single value to check, not a scatter of copies to reconcile. Because every consumer reads live, "source of truth" becomes true in practice rather than in aspiration, and the parity gate downstream has one authoritative value to hold against reality instead of a dozen drifting snapshots. This is the discipline that makes the DATA above it worth trusting.

Deeper treatment: Appendix B - 20. Meta-model consumption discipline (read, don't hardcode).

PARITY — fail the build when the map and territory disagree

Catch drift mechanically. A fleet of deterministic lints fails the build whenever a model and the reality it mirrors disagree, in either direction. (PARITY.)

Receives — the executable model and the reality it claims to mirror: the code, the artifacts, the things on disk it names.

Guarantees — bidirectional parity or a red gate. Every model row resolves to a real thing, and every real thing carries its row; a meta-sync contract names, per model, what reality it mirrors and when it must be re-derived. So the map cannot quietly lie while the fleet reasons through it.

Hands to DERIVE — trusted data the rest of the stack can build on. The gate converts "the model is probably right" into "the model is right or the build is red," so the executable data, its live consumers, and the emitted artifacts can all be trusted at once. Drop it and every part around it degrades into optimistic documentation.

Deeper treatment: Appendix B - 16. Drift & parity gates.

DERIVE — anchor every model-to-code edge to a symbol

Make every join refactor-proof. Anchor each model-to-code edge on a resolvable symbol a lint re-checks, so moving the code reddens the scan instead of silently breaking the link. (DERIVE.)

Receives — the parity-held models and the code symbols they connect to: the functions, the classes, the checks that give each edge a real endpoint.

Guarantees — edges that cannot drift. Each terminates on a resolvable symbol, never a line number, and is a derived obligation a lint re-checks at scan time. Move the code and the symbol either stays resolvable or the scan reddens; the broken link turns mechanically visible instead of rotting in someone's head.

Hands to EMIT — a graph of trustworthy connections to generate from. Where PARITY asserts a model matches reality, DERIVE computes the join, so those edges need no hand-authored parity rule at all — the higher rung. It leaves the generator standing on links that a refactor cannot silently break.

Deeper treatment: Appendix B - 22. Symbol-anchored traceability graph (derived edges).

EMIT — generate real artifacts from the model

Generate from the model, don't restate it. A generator emits real artifacts from the model — policy, wiring, catalogs, contract types — each carrying a provenance header. (EMIT.)

Receives — the parity-held, traceable model, consumed the way a compiler consumes a source file.

Guarantees — generated artifacts that cannot silently drift from the model. Each is emitted from the model, so the model drives the system rather than merely describing it. A provenance header names the emitter and the regen path, so a hand-edit to a generated file is caught on the next run and reverted.

Hands to SEAL — a model that now writes the territory, not just maps it. Because the artifact is derived, the parity gate treats it as generated output, not a second source to reconcile. What remains is to apply the same one-model discipline to a shipped file format, which the last part does on the product side.

Deeper treatment: Model-driven codegen (online).

SEAL — route a file format through one model

Give the format one mutation surface. Route every read and write of a complex file format through one structured model, with raw library access banned (our instance: a PDF model over the canonical PDF library). (SEAL.)

Purpose — apply the same one-model discipline to a shipped file format, where mutation would otherwise scatter across a hundred raw library calls with nowhere to encode the format's invariants.

Mechanism — one typed model is the sole door; a ban-lint forbids the raw library, so every change passes through code that encodes the format's invariants. Every mutation a remediation pass wants to make routes here rather than through a raw call site.

Guarantee — a single, compiler-checked mutation surface. A malformed write can no longer land from just anywhere, and a fix to an invariant holds everywhere at once. This is also the single door the provenance stack's stamp-writer needs to cover, so the two stacks meet at exactly this seam.

Deeper treatment: Appendix B - 24. PdfModel (sole PDF mutation surface).

A DocAble example, end to end

DocAble's PDF remediation is where SEAL earns its place. Every tag-tree read and write routes through one typed PDF model; a ban-lint forbids raw calls to the underlying library, so the format's invariants live in exactly one place and a fix holds across every call site at once. The surrounding lanes govern the wider system. The component-and-zone model, the job-lifecycle machines, the domain registries are all DATA — executable, not prose. Tools CONSUME them live: a check resolves "which service owns this seam" by querying the model, never by a copied constant. PARITY gates fail the build if a model row names a service that no longer exists, or a service ships with no row. DERIVE anchors each model-to-code edge on a symbol, so a refactor that moves the code reddens the scan instead of silently breaking the link. And EMIT regenerates catalogs and wiring from the models with provenance headers, so the generated files cannot quietly fall behind their source.

Tradeoffs and adoption order

  1. DATA and CONSUME are the floor. Typed data plus read-don't-copy costs a query in place of a constant. Without them there is no model to keep honest.
  2. PARITY is mandatory, not optional. The executable data is worth nothing without the gate that holds it equal to reality; drop it and every model degrades into optimistic documentation. Its cost is a gate per model.
  3. DERIVE raises the ceiling. Where the gate asserts a match, derived edges make parity unnecessary for those joins — symbol-anchored edges survive refactors that line numbers would not.
  4. EMIT and SEAL are targeted. Codegen pays off where the model implies boilerplate; the sealed format model pays off on a complex shipped format, at the cost of building the model and migrating every call site.

The whole stack leans on one presumption: consumers read live and mutations route through the sanctioned surface. A smuggled snapshot or an escaped raw call is where it weakens — each held by its own lint.

Choosing a rung for one fact — hold the join at the highest affordable rung

The stack's parts are also a strength ladder for a single fact that lives on two surfaces. Whenever the same fact is written in two places — a value in the model and a copy in the code, a spec and a sample, a status recorded once and read somewhere else — the two can fall out of step. The parts above say how firmly you can hold them together, strongest first:

The rule: for each two-surface fact, hold the join at the highest rung the two boundaries afford — not the highest rung imaginable. Some facts cannot climb. A config value and its documented sample must exist as two real artifacts on two sides of a boundary; a model row and the code it governs are legitimately separate. Those honest non-climbs are sanctioned — you hold them at PARITY or DERIVE and stop. What the rule forbids is holding a join below its affordable rung: a fact synced by a comment that a parity gate could have caught, a hand-mirrored pair that codegen could have generated, two copies that agree only because nobody has touched either yet.

A join held below its affordable rung is a latent drift class, and a close-time audit treats it as a failure. The reflex to reach for, whenever a change puts the second copy of a fact on disk, is to ask which rung this pair can climb to and hold it there. The close-time review that keeps an effort honest (the derived defends, snapshotted drifts discipline behind the Definition-of-Done) makes the same check at the end: a fact left on a weaker rung than it afforded is flagged, not shipped. An audit of one such review pass found most of its drift instances were exactly this defect — a join a rung too low — rather than an outright missing check.

The everyday shape is a status or summary field that is read to make a decision but written by hand. Left as a hand-edited line, it drifts the moment real work moves past it and the next reader trusts a stale value. Derive it instead from the artifacts that already record the truth — a projection over the underlying files and history — and it cannot drift, because there is no second surface to fall behind. That is the ladder applied to one field: climb from a hand-kept copy (comment rung) to a derived projection (UNIFY/DERIVE) and the whole drift class closes.

The full treatment

Each constituent links to its full pattern — in this appendix for the flagship members, online for the rest. The stack is the substrate under the provenance + fidelity stack (its sanctioned door is this stack's sealed seam) and the specification + verification stack (whose state machines are DATA this stack keeps honest). The full 83-mechanism catalogue is online in the web edition.

© James C. Davis, 2026–present