gunk-dev/the-valley

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

source5820f67029d8main's published tip history
9.0 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. Second, per required check, the evidence must transfer —
37by the rules below.
38
39## Pure checks transfer by closure-digest equality
40
41A pure check is a computation with content-addressed inputs and a deterministic result
42([verification.md](../../design/verification.md)). Its attestation records the digest of its input
43closure ([[dcr-0de694f]]
44([dcr-0de694f-phase2-attestation-shape.md](./dcr-0de694f-phase2-attestation-shape.md))). At commit,
45the integrator recomputes each closure digest over the rebased tree. Equality means the rebased tree
46presents the same computation over the same inputs, so the recorded result is the result on the new
47base too — the argument that makes a content-addressed build cache sound. Inequality means that
48check, and only that check, is stale. Content-addressed evidence does not age: a pure attestation
49carries no expiry, because time is not among its inputs.
50
51A pure check that fails on identical inputs is a falsified purity claim, and belongs to
52re-verification and trust measurement — the mechanism stack in
53[verification.md](../../design/verification.md) — never to a validity window.
54
55## Effectful checks transfer while their scope is untouched and the observation is fresh
56
57An effectful check reads mutable world state — real networks, external services
58([verification.md](../../design/verification.md)). Mutable state has no digest, so the equality rule
59cannot apply, and serializable semantics against it — every observation reading as if it happened at
60the instant its change landed — are unattainable in principle: even a check re-run at integration
61observes the world some interval before the ref moves. The honest semantics are bounded staleness:
62an observation is accepted while nothing relevant has changed under it and it is recent enough.
63Concretely, an effectful observation transfers iff both hold: no intervening landed change touched
64the paths of the policy class that requires the check — a policy class being [[dcr-f41f718]]'s
65([dcr-f41f718-declared-verification-policy.md](./dcr-f41f718-declared-verification-policy.md)) unit
66of mapping, a named set of path patterns carrying required checks — and the observation is younger
67than a validity window Δ. Δ is declared policy, per check: a template default a project may
68override, floor-mandatable by the group, in that decision's two layers. A network read of immutable,
69content-addressed data is a pure read; Δ exists only for reads of mutable world.
70
71## Staleness is per-check and computable
72
73A failed transfer surfaces as one `request-stale` event naming the invalidated checks — the
74staleness failure mode
75[architecture.md's integrator bet](../../design/architecture.md#bet-a-pull-based-integrator-not-a-pre-receive-gate)
76commits to, made precise. Retry is partial: only the named checks need new evidence. Retry is
77decentralized: re-attestation happens where the change is authored. The serialized critical section
78at the commit point is digest comparison and a ref write; verification latency never enters it.
79
80## The evidence composes as siblings
81
82The landed change carries the contributor's original attestation and the integrator's transfer
83statement side by side in one note, composing as [[dcr-0de694f]]
84([dcr-0de694f-phase2-attestation-shape.md](./dcr-0de694f-phase2-attestation-shape.md)) already
85provides. The transfer statement cites the original by digest and records the per-check verdicts and
86the check definitions used. Those definitions are resolved from the instance's own pin, never from
87the tree being gated — the direction [[bd-eaefe82]]
88([bd-eaefe82-check-definitions-come-from-the-branch.md](../bugs/bd-eaefe82-check-definitions-come-from-the-branch.md))
89names, adopted here for the floor's checks.
90
91## The reframe this rests on
92
93An attestation is a signed cache entry for a content-addressed computation, and integration is a
94cache lookup. The attestation store holds two standard entry classes: content-keyed entries for pure
95checks, and time-bounded entries for effectful ones.
96
97## Consequences
98
99- Re-verification concentrates exactly where semantic-conflict risk concentrates: a check is
100 re-demanded precisely when landed changes touched what it reads. A textually clean rebase over a
101 semantically interfering change is caught by construction, because the interfering change is
102 inside the invalidated closure.
103- Granularity is the economic lever: the finer a check's declared source set, the more evidence
104 survives integration. Declaring closures honestly and making builds hermetic are the same act, so
105 the incentive gradient points toward the purity [verification.md](../../design/verification.md)
106 already asks for.
107- The requirements this serves ([requirements.md](../../design/requirements.md), need 2):
108 verification performed where a change is authored counts across the integration boundary; checks
109 run in one runtime everywhere; integration throughput is bounded by conflict rate and author-side
110 re-attestation parallelism, never by check latency on the critical path.
111
112## Prior art
113
114Optimistic concurrency control is from the database literature. Content-addressed build caching and
115early cutoff are from the Nix and Bazel lineage. The composition — commit-time conflict detection
116via per-check content digests over signed evidence — is this design's own.
117
118## Open
119
120- Queue semantics under contention: batching (attesting once over several pending changes' combined
121 tree), aging as pressure granting a brief reservation, and stream sharding are the known knobs;
122 none is designed, and the core must not preclude them.
123- The change-identity member of the subject digest set — naming what change a statement is about,
124 distinct from which exact tree — is a separate small decision.
125- Integrator self-integration remains open where it already is
126 ([openquestions.md](../../design/openquestions.md)).
127
128## Related
129
130- The binding this designs the consequence of: [[ida-cbcbb3c]]
131 ([ida-cbcbb3c-attestations-bind-to-a-base.md](../ideas/ida-cbcbb3c-attestations-bind-to-a-base.md))
132- The transaction's unit, stable across rebases: [[ida-93e4f91]]
133 ([ida-93e4f91-changes-not-branches.md](../ideas/ida-93e4f91-changes-not-branches.md))
134- The statement the transfer rules read from, and the sibling composition the transfer statement
135 uses: [[dcr-0de694f]]
136 ([dcr-0de694f-phase2-attestation-shape.md](./dcr-0de694f-phase2-attestation-shape.md))
137- The policy classes whose paths scope an effectful check, and the layering Δ is declared in:
138 [[dcr-f41f718]]
139 ([dcr-f41f718-declared-verification-policy.md](./dcr-f41f718-declared-verification-policy.md))
140- The resolution of check definitions from the instance's pin: [[bd-eaefe82]]
141 ([bd-eaefe82-check-definitions-come-from-the-branch.md](../bugs/bd-eaefe82-check-definitions-come-from-the-branch.md))
142- The two kinds of checks and the mechanism stack behind falsified purity:
143 [verification.md](../../design/verification.md)
144- The integrator bet and staleness as the unified failure mode:
145 [architecture.md](../../design/architecture.md#bet-a-pull-based-integrator-not-a-pre-receive-gate)