Skip to content

Commit 321fdad

Browse files
committed
docs(proof): record apply read-generation validation
1 parent 82d9a3b commit 321fdad

2 files changed

Lines changed: 214 additions & 0 deletions

File tree

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"schema_version": 1,
3+
"recorded_at": "2026-08-14T04:48:48Z",
4+
"claim": "Apply reuses identical GitHub reads only within one mutation-bounded generation while preserving live final barriers and validated snapshot safety.",
5+
"source": {
6+
"head": "82d9a3b14961793d13f3d0b113078eb84e4caf00",
7+
"tree": "feb92bdcd220ed054fe9a73e1615bb327802d0d5",
8+
"commit_object_verified": true,
9+
"tree_object_verified": true,
10+
"pull_request": 1161
11+
},
12+
"crabbox": {
13+
"provider": "local-container",
14+
"lease_id": "cbx_0241049e673e",
15+
"slug": "golden-barnacle-01a8",
16+
"runtime": "docker",
17+
"image": "ubuntu:26.04",
18+
"architecture": "arm64",
19+
"node": "v24.19.0",
20+
"pnpm": "11.10.0",
21+
"exit_code": 0,
22+
"run_status": "succeeded",
23+
"lease_stopped": true,
24+
"sync_ms": 13856,
25+
"command_ms": 11421,
26+
"total_ms": 25278
27+
},
28+
"transport": "loopback HTTP from a Crabbox fresh-PR checkout",
29+
"requests": {
30+
"formula_before": "F(1)+C(4)+P(6)+L(3)=14",
31+
"formula_after": "U(6)+L_live(3)=9",
32+
"before": 14,
33+
"after": 9,
34+
"barrier": {
35+
"pull": 2,
36+
"comments": 1
37+
},
38+
"validated_snapshot": {
39+
"files": 0,
40+
"commits": 0,
41+
"inline_comments": 0
42+
}
43+
},
44+
"assertions": {
45+
"generation_bound_value_rejected": true,
46+
"mutation_advances_generation": true,
47+
"barriers_bypass_warm_generation": true,
48+
"concurrent_head_blocked": true,
49+
"concurrent_comment_blocked": true,
50+
"snapshot_mismatch_full_fallback": true,
51+
"v2_snapshot_compatibility": true
52+
},
53+
"full_gate": {
54+
"environment": "macOS host, Node v24.19.0, pnpm 11.10.0",
55+
"command": "pnpm run check",
56+
"tests": 3444,
57+
"pass": 3435,
58+
"fail": 0,
59+
"skip": 9,
60+
"coverage_lines_percent": 81.57,
61+
"coverage_branches_percent": 74.01,
62+
"coverage_functions_percent": 87.39,
63+
"dashboard_strict": true,
64+
"docs": true,
65+
"format": true,
66+
"lint": true,
67+
"build_all": true
68+
},
69+
"limits": [
70+
"The behavior proof uses deterministic loopback GitHub endpoints rather than live target mutations.",
71+
"Persisted v2 snapshots still require one pull-file list read because v2 did not contain files.",
72+
"The successful Crabbox receipt covers toolchain, build, source identity, and behavior proof; the exact-source complete gate is recorded separately because Linux cursor-trace fixtures reject Linux filesystem metadata.",
73+
"The receipt source commit is followed only by this proof package; the verification recipe rejects intervening non-proof changes."
74+
]
75+
}

0 commit comments

Comments
 (0)