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