| 1 | --- |
| 2 | type: decision |
| 3 | id: dcr-439b771 |
| 4 | status: decided |
| 5 | title: Reuse verification results when a change's base advances |
| 6 | created: 2026-08-06 |
| 7 | source: design conversation, 2026-08-06 |
| 8 | --- |
| 9 | |
| 10 | # Reuse verification results when a change's base advances |
| 11 | |
| 12 | When other changes land before a submitted change, the integrator determines which of that change's |
| 13 | verification results still apply. It checks that the change can be applied cleanly and that the |
| 14 | evidence remains valid for the resulting tree. Checks whose evidence still applies can be reused; |
| 15 | the contributor supplies new evidence for the others. The integrator does not run the checks itself. |
| 16 | |
| 17 | This is the rule for transferring attestations to a new base, the question raised in |
| 18 | [[ida-cbcbb3c]](../ideas/ida-cbcbb3c-attestations-bind-to-a-base.md). |
| 19 | |
| 20 | ## Apply the change and validate its evidence |
| 21 | |
| 22 | The integrator first tries to apply the change's delta to the current target tip. The delta is the |
| 23 | difference the contributor wants to land, as defined in |
| 24 | [[ida-93e4f91]](../ideas/ida-93e4f91-changes-not-branches.md). |
| 25 | |
| 26 | A conflict requires the contributor to author a resolution and attest it. Until that resolution |
| 27 | exists, the integrator has no resulting tree against which to compare check inputs. A conflict |
| 28 | therefore requires new evidence for every required check. |
| 29 | |
| 30 | If the change applies cleanly, the integrator evaluates the evidence for each required check. Policy |
| 31 | selects the runner and therefore whether the pure or effectful transfer rule applies. An attestation |
| 32 | whose declared type contradicts that runner is rejected. Allowing the attestation to choose its own |
| 33 | rule would let its author bypass the required verification. |
| 34 | |
| 35 | Several signers may have supplied attestations for the same check. The integrator uses the first |
| 36 | admissible attestation. An invalid note must not be silently replaced by a valid note found later. |
| 37 | Evidence must pass validation before the transfer rules are applied. Forged or malformed evidence |
| 38 | ends the judgement with a rejection; it is not treated as a stale result that needs another run. |
| 39 | |
| 40 | The current collector needs review against the rule for multiple notes; the observed selection |
| 41 | behavior is recorded in [open questions](../../design/openquestions.md#integration-and-evidence). |
| 42 | |
| 43 | ## Pure checks transfer by closure-digest equality |
| 44 | |
| 45 | A pure check produces a deterministic result from content-addressed inputs |
| 46 | ([verification.md](../../design/verification.md)). Its **input closure** includes all the sources, |
| 47 | dependencies, and check definitions used in that computation. The closure has a digest derived from |
| 48 | its contents, which the attestation records |
| 49 | ([[dcr-0de694f]](dcr-0de694f-phase2-attestation-shape.md)). |
| 50 | |
| 51 | The reference implementation records an input digest and a separate derivation digest. The |
| 52 | integrator recomputes both for the tree that would land: |
| 53 | |
| 54 | - If both match the attested values, the check identifies the same computation over the same inputs |
| 55 | and its result can be reused. |
| 56 | - If either differs, that check is stale and requires new evidence. |
| 57 | |
| 58 | For example, a documentation change can land while an application change is being checked. If the |
| 59 | documentation is outside a particular check's input closure, that check's evidence still applies |
| 60 | after the application change is rebased. A change to a dependency inside the closure makes that |
| 61 | check's evidence stale even when the rebase has no text conflicts. |
| 62 | |
| 63 | Pure attestations do not expire: time is not an input to a pure check. A conflicting result on |
| 64 | identical inputs challenges the claimed purity or the evidence. It is handled by the re-verification |
| 65 | and trust mechanisms in [verification.md](../../design/verification.md). |
| 66 | |
| 67 | ## Effectful checks transfer while their scope is untouched and the observation is fresh |
| 68 | |
| 69 | An effectful check observes mutable external state, such as a running service. That state may change |
| 70 | between the observation and integration, including when the check runs immediately before |
| 71 | integration. An input digest cannot establish that the observation is still true. Policy instead |
| 72 | sets a limit on how old the observation may be. |
| 73 | |
| 74 | An effectful result can be reused only when both conditions hold: |
| 75 | |
| 76 | 1. No intervening landed change touched the paths in the policy class that requires the check. |
| 77 | 2. The observation is younger than the check's declared validity window, Δ. |
| 78 | |
| 79 | A **policy class** is a named set of path patterns with required checks, defined in |
| 80 | [[dcr-f41f718]](dcr-f41f718-declared-verification-policy.md). The validity window follows the same |
| 81 | policy layering: a template can supply a default, a project can override an overridable value, and a |
| 82 | valley can mandate a value in its floor. |
| 83 | |
| 84 | Reading immutable, content-addressed data over a network can still be a pure read. The validity |
| 85 | window is needed for observations of mutable state. |
| 86 | |
| 87 | ## Staleness is per-check and computable |
| 88 | |
| 89 | When evidence cannot transfer, the integrator emits one `request-stale` event listing the checks |
| 90 | that need new evidence. The contributor reruns those checks where the change is authored. The |
| 91 | remaining evidence can be reused. This gives the staleness result described in |
| 92 | [architecture.md](../../design/architecture.md#integration-through-a-controller) an explicit set of |
| 93 | next actions. |
| 94 | |
| 95 | Checking and rechecking happen outside the serialized integration step. That step compares digests |
| 96 | and updates the target ref, so it does not wait for test execution. |
| 97 | |
| 98 | ## Record the contributor's results and the integration decision |
| 99 | |
| 100 | Each landing records the evidence it used and the integrator's decision: |
| 101 | |
| 102 | 1. The integrator adds its signature to the contributor's original statement. The statement text |
| 103 | stays unchanged, and the signatures are separate lines in the same note, as specified in |
| 104 | [[dcr-0de694f]](dcr-0de694f-phase2-attestation-shape.md). |
| 105 | 2. The integrator writes a **transfer statement**. It identifies the original statement by the |
| 106 | digest of its signed text and records each check's verdict and the check definitions used. |
| 107 | |
| 108 | For the floor's checks, those definitions must come from the valley's own pinned source. The |
| 109 | submitted tree must not supply the definitions that judge it. The implementation gap is tracked in |
| 110 | [[bd-eaefe82]](../bugs/bd-eaefe82-check-definitions-come-from-the-branch.md). |
| 111 | |
| 112 | Every landing gets a transfer statement, even when policy requires no checks. This can happen when |
| 113 | all changed paths belong to classes that require nothing, or when the delta touches no paths. The |
| 114 | statement explicitly records that no checks were required. The text format cannot represent an empty |
| 115 | verdict list, so it uses a line stating that result |
| 116 | ([[dcr-de9d996]](dcr-de9d996-statement-text-and-signed-note.md)). |
| 117 | |
| 118 | The contributor's statement describes the tree it checked. The transfer statement describes the tree |
| 119 | that lands. Each is stored under the ref for its subject digest. If the base advanced and the trees |
| 120 | differ, the statements occupy two refs; if the trees are identical, they share one ref. |
| 121 | |
| 122 | The integrator composes the transfer statement before updating the target ref. If a prerequisite |
| 123 | fails before the ref update, the change has not landed and can be considered on a later pass. Once |
| 124 | the ref is updated, the change has landed. The integrator then completes its recording steps, |
| 125 | reports any failures, and consumes the request so it cannot be processed again as an empty delta. |
| 126 | |
| 127 | ## Relationship to optimistic concurrency control and caching |
| 128 | |
| 129 | These rules apply **optimistic concurrency control** to integration. Contributors work against a |
| 130 | fixed tree while other changes proceed. At integration, the system checks whether the assumptions |
| 131 | behind their results still hold. A change lands as one unit, and one integrator writes each target |
| 132 | stream, establishing a serial order of landed changes. |
| 133 | |
| 134 | The correspondence gives database theory a concrete place to start: |
| 135 | |
| 136 | | Database concept | Repository counterpart | |
| 137 | | ---------------- | ------------------------------------------------------------------ | |
| 138 | | Transaction | A proposed change that lands as a unit | |
| 139 | | Snapshot | The tree used to produce the evidence | |
| 140 | | Read set | Inputs and definitions on which the required checks depend | |
| 141 | | Write set | The change's delta | |
| 142 | | Validation | Clean application and evidence transfer against the current target | |
| 143 | | Commit | The successful protected-ref update | |
| 144 | | Retry | Refreshing the change or the checks whose evidence became stale | |
| 145 | |
| 146 | This is a model of evidence validity. A check's inputs do not capture every assumption a contributor |
| 147 | made while authoring a change. Governing policy and signer state also affect admission. A serial |
| 148 | order of ref updates therefore does not by itself prove that concurrent authorship is equivalent to |
| 149 | serial execution. Effectful observations have the bounded-staleness semantics described above. These |
| 150 | limits are part of the formalization still to do. |
| 151 | |
| 152 | An attestation serves as a signed cache entry for a check result. Pure results are keyed by input |
| 153 | content; effectful observations have a time limit. Integration determines which entries remain |
| 154 | usable on the tree that would land. |
| 155 | |
| 156 | ## Throughput and contention: a connection to explore |
| 157 | |
| 158 | Database concurrency theory offers tools for studying how much work a repository can integrate and |
| 159 | when adding more contributors stops helping. The chosen integration rule makes this a useful |
| 160 | research direction; it does not establish a throughput guarantee. |
| 161 | |
| 162 | Kung and Robinson's |
| 163 | [optimistic concurrency control paper](https://www.eecs.harvard.edu/~htk/publication/1981-tods-kung-robinson.pdf) |
| 164 | separates transaction work from validation and writing. It also examines conflict assumptions and |
| 165 | starvation. The repository analogue is to prepare changes independently, then validate their |
| 166 | remaining evidence before landing them. |
| 167 | |
| 168 | Three quantities need separate measurement: |
| 169 | |
| 170 | - **Integration capacity:** how many requests the controller can evaluate and land per unit of time. |
| 171 | Policy resolution, input evaluation, signature verification, and Git operations all take time. |
| 172 | - **Evidence-production capacity:** how much check work contributors and builders can complete per |
| 173 | unit of time, including work repeated after invalidation. |
| 174 | - **Contention:** how often landings invalidate evidence for pending work. Overlap between changed |
| 175 | files and check inputs matters more than the number of contributors alone. |
| 176 | |
| 177 | Moving tests outside the integrator removes their execution from its serial work. Long tests can |
| 178 | still reduce useful throughput: more changes may land while a test runs, and refreshing its evidence |
| 179 | uses capacity that could have served another change. More parallel workers may help produce evidence |
| 180 | or may spend their time repeating invalidated work. Which effect dominates is a workload question. |
| 181 | |
| 182 | A shared build definition is a possible hotspot because many checks depend on it. Narrower, complete |
| 183 | input closures reduce unnecessary overlap. Batching can let several changes share one checked tree. |
| 184 | A reservation can give repeatedly invalidated work time to finish, at the cost of delaying competing |
| 185 | landings. These are candidate policies to compare, not consequences already proved by the analogy. |
| 186 | |
| 187 | A useful experiment would vary check duration, input overlap, arrival rate, and builder capacity. |
| 188 | Measure successful landings per unit of time, time from submission to landing, repeated check work, |
| 189 | and the longest waits. High total throughput can coexist with starvation of a particular request. |
| 190 | [[bd-c324184]](../bugs/bd-c324184-occ-starvation-under-contention.md) records that failure |
| 191 | condition. |
| 192 | |
| 193 | The open theoretical question is which database results still apply when validation is per-check, |
| 194 | retry can reuse part of the evidence, and authoring is not a deterministic transaction that can |
| 195 | simply be replayed. A model should state those assumptions before predicting a benefit from |
| 196 | batching, reservations, or additional concurrency. |
| 197 | |
| 198 | ## Consequences |
| 199 | |
| 200 | - A clean textual rebase can still invalidate check evidence. Changes inside a pure check's input |
| 201 | closure require that check to run again, covering dependencies that text-conflict detection alone |
| 202 | would miss. |
| 203 | - Smaller, accurately declared input closures let more results survive unrelated changes. Every |
| 204 | actual dependency still has to be included for reuse to be valid. This is the same requirement |
| 205 | that makes a build hermetic. |
| 206 | - Verification performed in the contributor's environment can count at integration. Checks use the |
| 207 | same runtime wherever they execute. Integration throughput depends on conflicts and the capacity |
| 208 | to produce new evidence in parallel, without serializing test execution. These are the |
| 209 | requirements in [requirements.md](../../design/requirements.md), need 2. |
| 210 | |
| 211 | ## Prior art |
| 212 | |
| 213 | The design combines optimistic concurrency control from databases with content-addressed build |
| 214 | caching and early cutoff, as used in Nix and Bazel. It uses signed evidence and per-check digests to |
| 215 | decide whether earlier verification results apply when a change lands. |
| 216 | |
| 217 | ## Open |
| 218 | |
| 219 | - Queue behavior under contention remains undecided. Possible approaches include checking several |
| 220 | pending changes together, giving a long-waiting change a brief reservation, and splitting work |
| 221 | across target streams. The integration rule must allow these approaches. |
| 222 | - A statement needs a way to identify the change it concerns independently of the exact tree it |
| 223 | checked. The corresponding member of the subject digest set remains undecided. |
| 224 | - How the integrator integrates changes to itself remains open in |
| 225 | [openquestions.md](../../design/openquestions.md). |
| 226 | |
| 227 | ## Related |
| 228 | |
| 229 | - Attestations when a change's base moves: |
| 230 | [[ida-cbcbb3c]](../ideas/ida-cbcbb3c-attestations-bind-to-a-base.md) |
| 231 | - Change identity across rebases: [[ida-93e4f91]](../ideas/ida-93e4f91-changes-not-branches.md) |
| 232 | - Attestation format and multiple signatures: |
| 233 | [[dcr-0de694f]](dcr-0de694f-phase2-attestation-shape.md) |
| 234 | - Required checks, path classes, and validity windows: |
| 235 | [[dcr-f41f718]](dcr-f41f718-declared-verification-policy.md) |
| 236 | - Check definitions supplied by the governing valley: |
| 237 | [[bd-eaefe82]](../bugs/bd-eaefe82-check-definitions-come-from-the-branch.md) |
| 238 | - Pure and effectful checks, and verification of their claims: |
| 239 | [verification.md](../../design/verification.md) |
| 240 | - The integration controller and how it reports stale requests: |
| 241 | [architecture.md](../../design/architecture.md#integration-through-a-controller) |