|
| 1 | +# Apply read generations proof |
| 2 | + |
| 3 | +- Status: historical proof artifact |
| 4 | +- Owner: ClawSweeper publication maintainers |
| 5 | +- Tested source: `openclaw/clawsweeper@82d9a3b14961793d13f3d0b113078eb84e4caf00` |
| 6 | +- Update when: apply generation keys, mutation observation, lease/proof barriers, or PR hydration watermarks change |
| 7 | + |
| 8 | +## Claim and exercised surface |
| 9 | + |
| 10 | +The controlled loopback exercises the production `LiveReadGeneration`, apply |
| 11 | +guard memoization, two-sided lease guard, and PR hydration coordinator through |
| 12 | +real HTTP endpoints. Identical fetch/context/policy reads share one value only |
| 13 | +inside a generation. An observed GitHub mutation advances the generation, |
| 14 | +clears its entries, and makes a previously bound context fail a runtime |
| 15 | +generation assertion. |
| 16 | + |
| 17 | +The pre-comment and pre-close lease barriers deliberately bypass a warm |
| 18 | +generation. Each barrier therefore performs two live pull-head reads around one |
| 19 | +live complete comment-list read. Fixtures advance the generation after a |
| 20 | +concurrent head change and after a new durable comment; both cases block apply. |
| 21 | + |
| 22 | +Apply parses the persisted PR hydration snapshot from report front matter and |
| 23 | +validates the live head SHA, `updated_at`, file/commit/inline-comment counts, |
| 24 | +and the just-in-time activity revision before reuse. Existing v2 snapshots can |
| 25 | +reuse commits and inline comments while reading their missing file window. |
| 26 | +Current v3 snapshots also retain that bounded file window, so a validated v3 |
| 27 | +hit performs zero pull-file, commit, or inline-comment list reads. Any mismatch |
| 28 | +uses the normal full list path. |
| 29 | + |
| 30 | +OpenClaw Bay is unaffected. This changes internal publication reads and |
| 31 | +cache-only report metadata, not Bay's observer contract or action boundary. |
| 32 | + |
| 33 | +## Generation and invalidation inventory |
| 34 | + |
| 35 | +| Event | Generation behavior | Covered mutation surfaces | |
| 36 | +| --- | --- | --- | |
| 37 | +| Apply starts one item | Create one generation and bind guard reads to it | item fetch, context hydration, policy guards | |
| 38 | +| Mutation runner reports accepted | Advance generation and discard bound context | lease post/delete, label definition/item labels, durable comment post/patch, placeholder delete, recovery label removal, close comment, item close | |
| 39 | +| Mutation runner reports ambiguous outcome | Advance generation before propagating the error | every observed GitHub write attempt whose non-mutation cannot be proven | |
| 40 | +| Mutation runner reports rejected/no-op | Preserve generation | guard rejection and explicitly known no-mutation errors only | |
| 41 | +| Final proof, comment, or close guard | Bypass generation cache | final `fetchItem`/context freshness and low-signal policy checks | |
| 42 | +| Two-sided lease verification | Bypass generation cache | head/source, comments, head/source | |
| 43 | + |
| 44 | +## Counted formula and safety result |
| 45 | + |
| 46 | +For the representative apply slice, `F` is the first item fetch, `C` context |
| 47 | +hydration, `P` policy reads, `L` the irreducible lease barrier, and `U` the six |
| 48 | +unique generation reads: |
| 49 | + |
| 50 | +```text |
| 51 | +before = F(1) + C(4) + P(6) + L(3) = 14 |
| 52 | +after = U(6) + L_live(3) = 9 |
| 53 | +``` |
| 54 | + |
| 55 | +The `L(3)` floor is unchanged. With the generation already warm, both the |
| 56 | +pre-comment and pre-close barriers still recorded two `/pull` requests and one |
| 57 | +`/comments` request. Concurrent head and comment changes were both rejected. |
| 58 | +A validated v3 snapshot recorded files=0, commits=0, inline-comments=0. |
| 59 | + |
| 60 | +## Environment and commands |
| 61 | + |
| 62 | +The exact source passed the complete host gate on Node 24.19.0: |
| 63 | + |
| 64 | +```bash |
| 65 | +pnpm run check |
| 66 | +``` |
| 67 | + |
| 68 | +Result: 3,444 tests, 3,435 passed, 9 platform skips, 0 failures. Coverage was |
| 69 | +81.57% lines, 74.01% branches, and 87.39% functions. Static checks included |
| 70 | +`check:dashboard-strict`, docs, limits, formatting, all TypeScript builds, and |
| 71 | +all linters. |
| 72 | + |
| 73 | +The deterministic transport proof ran through Crabbox's explicitly requested |
| 74 | +Docker-backed `local-container` provider on Ubuntu 26.04/arm64 with Node |
| 75 | +24.19.0 and pnpm 11.10.0. The successful fresh-PR lease was |
| 76 | +`cbx_0241049e673e` (`golden-barnacle-01a8`) and stopped automatically. |
| 77 | + |
| 78 | +```bash |
| 79 | +proof_source_head="$(git rev-parse HEAD)" |
| 80 | +proof_source_tree="$(git rev-parse 'HEAD^{tree}')" |
| 81 | +git cat-file -e "${proof_source_head}^{commit}" |
| 82 | +git cat-file -e "${proof_source_tree}^{tree}" |
| 83 | +PROOF_SOURCE_HEAD="$proof_source_head" PROOF_SOURCE_TREE="$proof_source_tree" \ |
| 84 | + /Users/steipete/Projects/crabbox/bin/crabbox run \ |
| 85 | + --provider local-container \ |
| 86 | + --fresh-pr openclaw/clawsweeper#1161 \ |
| 87 | + --no-hydrate \ |
| 88 | + --allow-env PROOF_SOURCE_HEAD,PROOF_SOURCE_TREE \ |
| 89 | + --preflight --timing-json --ttl 30m --shell -- \ |
| 90 | + "awk '/^echo CRABBOX_PHASE:check$/{exit} {print}' scripts/e2e/run-apply-read-generations-container.sh | bash" |
| 91 | +``` |
| 92 | + |
| 93 | +The successful receipt covers the checked-in toolchain, all three builds, |
| 94 | +source identity, and loopback behavior phases. A separate Linux full-gate |
| 95 | +attempt reached the repository workflow fixtures but those macOS-authored |
| 96 | +cursor-trace fixtures reject Linux filesystem metadata; the exact same complete |
| 97 | +gate is green on the required Node 24 host. No product assertion relies on that |
| 98 | +platform-specific shard. |
| 99 | + |
| 100 | +## Static verification recipe |
| 101 | + |
| 102 | +Run from the repository root. The final diff check permits only this proof |
| 103 | +directory after the tested source commit. |
| 104 | + |
| 105 | +```bash |
| 106 | +receipt="docs/proof/apply-read-generations/receipt.json" |
| 107 | +jq -e ' |
| 108 | + .schema_version == 1 and |
| 109 | + .crabbox.provider == "local-container" and |
| 110 | + .crabbox.runtime == "docker" and |
| 111 | + .crabbox.exit_code == 0 and |
| 112 | + .crabbox.run_status == "succeeded" and |
| 113 | + .crabbox.lease_stopped == true and |
| 114 | + .requests.before == 14 and |
| 115 | + .requests.after == 9 and |
| 116 | + .requests.barrier == {"pull": 2, "comments": 1} and |
| 117 | + .requests.validated_snapshot == {"files": 0, "commits": 0, "inline_comments": 0} and |
| 118 | + .assertions.concurrent_head_blocked == true and |
| 119 | + .assertions.concurrent_comment_blocked == true and |
| 120 | + .assertions.generation_bound_value_rejected == true and |
| 121 | + .full_gate.dashboard_strict == true and |
| 122 | + .full_gate.fail == 0 |
| 123 | +' "$receipt" |
| 124 | +tested_head="$(jq -r '.source.head' "$receipt")" |
| 125 | +tested_tree="$(jq -r '.source.tree' "$receipt")" |
| 126 | +git cat-file -e "${tested_head}^{commit}" |
| 127 | +git cat-file -e "${tested_tree}^{tree}" |
| 128 | +test "$(git rev-parse "${tested_head}^{tree}")" = "$tested_tree" |
| 129 | +test -z "$(git diff --name-only "$tested_head"..HEAD -- . \ |
| 130 | + ':(exclude)docs/proof/apply-read-generations/**')" |
| 131 | +``` |
| 132 | + |
| 133 | +## Limits |
| 134 | + |
| 135 | +The behavior fixture uses deterministic loopback endpoints, not live target |
| 136 | +mutations. It proves request ownership, invalidation, barrier transport, and |
| 137 | +race decisions; it does not claim production latency. v2 records cannot avoid |
| 138 | +the one file-list read because that schema did not persist files. No Worker, |
| 139 | +dashboard, queue, or target repository state was mutated by the proof. |
0 commit comments