gunk-dev/the-valley

dcr-439b771-integration-occ-over-content-addressed-evidence.md

source789346c9fc16main's published tip history
12.2 KiB · Rendered
1---
2type: decision
3id: dcr-439b771
4status: decided
5title: Integration is optimistic concurrency control over content-addressed evidence
6created: 2026-08-06
7source: design conversation, 2026-08-06
8---
9
10# Integration is optimistic concurrency control over content-addressed evidence
11
12Integration is optimistic concurrency control over content-addressed evidence. Optimistic
13concurrency control is the discipline, from the database literature, in which work proceeds without
14locks against a fixed snapshot of the data, and a commit point later checks whether anything the
15work read has moved; work whose reads still hold commits as if nothing had intervened, and work
16whose reads have moved is redone. This node maps Phase 3 integration onto that discipline exactly,
17and in doing so answers the question [[ida-cbcbb3c]]
18([ida-cbcbb3c-attestations-bind-to-a-base.md](../ideas/ida-cbcbb3c-attestations-bind-to-a-base.md))
19left open: what happens to a change's attestations when its base moves.
20
21## The transaction model
22
23A change ([[ida-93e4f91]],
24[ida-93e4f91-changes-not-branches.md](../ideas/ida-93e4f91-changes-not-branches.md)) is a
25transaction — a unit of work that lands whole or not at all. Its snapshot — the state the work was
26performed against — is the base tree its attestations were produced over. Its read set — everything
27its validity depends on having read — is the union of its required checks' input closures, held per
28check. A check's input closure is the complete set of inputs the check's computation consumes — the
29sources it reads, the dependencies it builds against, its own definition — each named by a digest of
30its content, so the closure as a whole has one digest. Its write set — what the transaction changes
31— is its delta. The integrator is the commit point: a single writer per target stream, so landed
32changes form one serial order per stream.
33
34The commit rule has two parts. First, the delta must apply cleanly to the current tip. A conflict
35means resolving it would produce a tree nobody has authored; the resolution is new authorship, and
36new authorship requires a new attestation. A conflict therefore invalidates every required check,
37not a subset: staleness is per-check only where the transaction's read set is what moved, and a tree
38nobody has written has no read set to compare against. Second, per required check, the evidence must
39transfer — by the rules below.
40
41Which rule governs a check is the policy's to say. The policy names the check's runner, and the
42runner is what makes the check pure or effectful; the attestation's own predicate type is a claim
43about itself, not a licence to choose the rule it is judged under. An attestation whose predicate
44type contradicts the runner the policy names is refused rather than judged, because judging it by
45the rule it nominated is how an attester opts out of closure comparison.
46
47Where several attestations are stored for one check — one per signer, as the storage rule provides —
48the first admissible one is the evidence, and a note that does not verify at all stands rather than
49being displaced by a good one found after it. Admissibility is settled before any transfer rule
50runs, and a check whose evidence is inadmissible in the way a forgery is inadmissible ends the
51judgement there: the change is not behind, and nothing about redoing work would change the answer.
52
53## Pure checks transfer by closure-digest equality
54
55A pure check is a computation with content-addressed inputs and a deterministic result
56([verification.md](../../design/verification.md)). Its attestation records the digest of its input
57closure ([[dcr-0de694f]]
58([dcr-0de694f-phase2-attestation-shape.md](./dcr-0de694f-phase2-attestation-shape.md))). At commit,
59the integrator recomputes each closure digest over the rebased tree. Equality means the rebased tree
60presents the same computation over the same inputs, so the recorded result is the result on the new
61base too — the argument that makes a content-addressed build cache sound. Inequality means that
62check, and only that check, is stale. Content-addressed evidence does not age: a pure attestation
63carries no expiry, because time is not among its inputs.
64
65A pure check that fails on identical inputs is a falsified purity claim, and belongs to
66re-verification and trust measurement — the mechanism stack in
67[verification.md](../../design/verification.md) — never to a validity window.
68
69## Effectful checks transfer while their scope is untouched and the observation is fresh
70
71An effectful check reads mutable world state — real networks, external services
72([verification.md](../../design/verification.md)). Mutable state has no digest, so the equality rule
73cannot apply, and serializable semantics against it — every observation reading as if it happened at
74the instant its change landed — are unattainable in principle: even a check re-run at integration
75observes the world some interval before the ref moves. The honest semantics are bounded staleness:
76an observation is accepted while nothing relevant has changed under it and it is recent enough.
77Concretely, an effectful observation transfers iff both hold: no intervening landed change touched
78the paths of the policy class that requires the check — a policy class being [[dcr-f41f718]]'s
79([dcr-f41f718-declared-verification-policy.md](./dcr-f41f718-declared-verification-policy.md)) unit
80of mapping, a named set of path patterns carrying required checks — and the observation is younger
81than a validity window Δ. Δ is declared policy, per check: a template default a project may
82override, floor-mandatable by the valley, in that decision's two layers. A network read of
83immutable, content-addressed data is a pure read; Δ exists only for reads of mutable world.
84
85## Staleness is per-check and computable
86
87A failed transfer surfaces as one `request-stale` event naming the invalidated checks — the
88staleness failure mode
89[architecture.md's integrator bet](../../design/architecture.md#bet-a-pull-based-integrator-not-a-pre-receive-gate)
90commits to, made precise. Retry is partial: only the named checks need new evidence. Retry is
91decentralized: re-attestation happens where the change is authored. The serialized critical section
92at the commit point is digest comparison and a ref write; verification latency never enters it.
93
94## The evidence composes as siblings
95
96The landed change carries two statements side by side. The contributor's original attestation gains
97the integrator's signature as a sibling line under the text it already carries, which is the
98composition [[dcr-0de694f]]
99([dcr-0de694f-phase2-attestation-shape.md](./dcr-0de694f-phase2-attestation-shape.md)) provides. The
100integrator's transfer statement is the second: it cites the original by a digest of the bytes that
101original's signature covers, and records the per-check verdicts and the check definitions used.
102Those definitions are resolved from the instance's own pin, never from the tree being gated — the
103direction [[bd-eaefe82]]
104([bd-eaefe82-check-definitions-come-from-the-branch.md](../bugs/bd-eaefe82-check-definitions-come-from-the-branch.md))
105names, adopted here for the floor's checks.
106
107A transfer statement is written for every landing, including one the policy required no check of.
108Requiring nothing is an ordinary result of the commit rule — every path the delta touches is covered
109by a class that asks for nothing, or the delta touches no path at all — so the statement says so in
110a line rather than carrying an empty list of verdicts, which is a container the written form cannot
111write down at all ([[dcr-de9d996]]
112([dcr-de9d996-statement-text-and-signed-note.md](./dcr-de9d996-statement-text-and-signed-note.md))).
113The commit point records what it decided in every case it can decide, or there are landings nothing
114attests to.
115
116The order around the commit point follows from what a commit point is. The ref write is the commit;
117everything that can fail while the transaction is still deciding happens before it, and composing
118the transfer statement is part of deciding rather than of recording — a claim the integrator cannot
119write down is a claim it has not made. A failure before the commit is a transaction abandoned, which
120costs a pass and strands nothing. After the commit the landing is in the serial order whatever else
121happens, so the steps that record it run to the end and report what they could not do, and the
122request is consumed there rather than left to be judged again against a delta that is now empty.
123
124The two are separate statements because they are about two different trees. A contributor's
125statement is about the tree it was produced over; a transfer statement is about the tree that
126landed, which is a different tree exactly when something intervened. An attestation is stored at a
127ref keyed by its subject digest, so the two statements are keyed by the two trees, and a landing
128where the base moved writes two refs. Where nothing intervened the trees are one tree and the two
129statements sit under one ref — which is the case the phrase "side by side" describes, and it is the
130common one rather than the general one.
131
132## The reframe this rests on
133
134An attestation is a signed cache entry for a content-addressed computation, and integration is a
135cache lookup. The attestation store holds two standard entry classes: content-keyed entries for pure
136checks, and time-bounded entries for effectful ones.
137
138## Consequences
139
140- Re-verification concentrates exactly where semantic-conflict risk concentrates: a check is
141 re-demanded precisely when landed changes touched what it reads. A textually clean rebase over a
142 semantically interfering change is caught by construction, because the interfering change is
143 inside the invalidated closure.
144- Granularity is the economic lever: the finer a check's declared source set, the more evidence
145 survives integration. Declaring closures honestly and making builds hermetic are the same act, so
146 the incentive gradient points toward the purity [verification.md](../../design/verification.md)
147 already asks for.
148- The requirements this serves ([requirements.md](../../design/requirements.md), need 2):
149 verification performed where a change is authored counts across the integration boundary; checks
150 run in one runtime everywhere; integration throughput is bounded by conflict rate and author-side
151 re-attestation parallelism, never by check latency on the critical path.
152
153## Prior art
154
155Optimistic concurrency control is from the database literature. Content-addressed build caching and
156early cutoff are from the Nix and Bazel lineage. The composition — commit-time conflict detection
157via per-check content digests over signed evidence — is this design's own.
158
159## Open
160
161- Queue semantics under contention: batching (attesting once over several pending changes' combined
162 tree), aging as pressure granting a brief reservation, and stream sharding are the known knobs;
163 none is designed, and the core must not preclude them.
164- The change-identity member of the subject digest set — naming what change a statement is about,
165 distinct from which exact tree — is a separate small decision.
166- Integrator self-integration remains open where it already is
167 ([openquestions.md](../../design/openquestions.md)).
168
169## Related
170
171- The binding this designs the consequence of: [[ida-cbcbb3c]]
172 ([ida-cbcbb3c-attestations-bind-to-a-base.md](../ideas/ida-cbcbb3c-attestations-bind-to-a-base.md))
173- The transaction's unit, stable across rebases: [[ida-93e4f91]]
174 ([ida-93e4f91-changes-not-branches.md](../ideas/ida-93e4f91-changes-not-branches.md))
175- The statement the transfer rules read from, and the sibling composition the transfer statement
176 uses: [[dcr-0de694f]]
177 ([dcr-0de694f-phase2-attestation-shape.md](./dcr-0de694f-phase2-attestation-shape.md))
178- The policy classes whose paths scope an effectful check, and the layering Δ is declared in:
179 [[dcr-f41f718]]
180 ([dcr-f41f718-declared-verification-policy.md](./dcr-f41f718-declared-verification-policy.md))
181- The resolution of check definitions from the instance's pin: [[bd-eaefe82]]
182 ([bd-eaefe82-check-definitions-come-from-the-branch.md](../bugs/bd-eaefe82-check-definitions-come-from-the-branch.md))
183- The two kinds of checks and the mechanism stack behind falsified purity:
184 [verification.md](../../design/verification.md)
185- The integrator bet and staleness as the unified failure mode:
186 [architecture.md](../../design/architecture.md#bet-a-pull-based-integrator-not-a-pre-receive-gate)