Repository navigation
improve(apply): reduce duplicate live GitHub reads - #1161
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 12:53 AM ET / 04:53 UTC. ClawSweeper reviewWhat this changesThis PR reuses identical GitHub reads within a mutation-bounded apply generation and extends validated PR hydration snapshots to reuse pull-file data. Merge readinessKeep open: this is a coherent, unmerged apply-lane optimization with supplied controlled transport proof and no concrete patch defect identified. Independent checkout and history inspection could not run because the read-only executor failed before commands began. Priority: P2 Review scores
Verification
How this fits togetherThe publication apply lane reads GitHub item state, checks safety and review evidence, then publishes a review comment or closes an eligible item. This change adds bounded read reuse before those live mutation barriers while retaining direct reads for final guards. flowchart LR
A[Stored review record] --> B[Apply item processing]
B --> C[Generation scoped GitHub reads]
C --> D[Hydrated PR snapshot]
C --> E[Live lease and proof barriers]
D --> E
E --> F[Comment or close mutation]
F --> G[Generation invalidation]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain mutation-bounded invalidation and live final barriers, then land only with the recorded proof still matching the functional head and normal maintainer review of the apply safety boundary. Do we have a high-confidence way to reproduce the issue? Not applicable as a user bug report; the supplied PR includes a controlled loopback HTTP exercise of the changed internal apply path. Is this the best way to solve the issue? Yes, based on the supplied diff and proof: a per-item, mutation-bounded cache with explicit bypasses is a narrow way to reduce duplicate reads without making final guards stale. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 82d9ba983abd. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…arges (#1164) Quota campaign PR 4/5: durable ETag read broker - unchanged GitHub responses stop costing quota. No wrapper sent If-None-Match before this; every repeat read paid a full quota charge (measured repeat floors: item_metadata 21.5%, comments 17.6%, reviews 19.5%). The broker persists ETag + body + digest in the queue DO (publisher-HMAC endpoints per the #1163 pattern; 30-day TTL; 2048-entry/512KiB bounds), keyed by credential pool, sorted route/query, media type, and page - a page-1 304 can never validate page 2. Cached bodies are released only after a live 304 plus digest confirmation; final pre/post-mutation guards always revalidate (a 304 is a live authoritative answer, but no guard ever consumes an unrevalidated cache). Composes with #1161: generations cover within-run reuse, the broker covers cross-run revalidation. Integrated at the highest-repeat sites first: apply issue/pull metadata, paged comment/review collections, dashboard run/job health reads. Telemetry counts 200-with-store, 304-from-cache, miss, and skip as distinct units - this PR reduces QUOTA CHARGES, not wire requests (5 wire calls / 3 charged 200s in the counted fixture). Proof: loopback ETag semantics with byte-identical 304 replay (digest asserted), page isolation, final-guard revalidation; full gate 3446/0 + dashboard-strict; Crabbox local-container receipt at this exact head, machine-verified provenance. Verdict clean (no actionable findings, proof sufficient) on bd2ef95.
What Problem This Solves
Publication apply repeatedly reads the same issue, pull request, comments, timeline, policy, and lease state inside one item decision. The 2026-08-13 GitHub API savings analysis ranked this as opportunity 2, specifically its “Publication apply” and “Lease and mutation barriers” findings: duplicate reads are reducible, but the final mutation guards must remain authoritative and live.
Why This Change Was Made
Apply now creates one explicit
LiveReadGenerationper item. Identical reads share one generation-owned result, every observed GitHub mutation advances the generation, and generation-bound context cannot cross that boundary without a runtime assertion. The two-sided lease checks and final proof/comment/close guards use an explicit cache-bypass option.Apply also consumes the persisted PR hydration snapshot. Existing v2 snapshots immediately reuse commits and inline comments after live validation; v3 snapshots additionally carry the bounded pull-file window. A v3 hit therefore removes all three REST list reads. Any head,
updated_at, count, or just-in-time activity-revision mismatch takes the normal full-read path.Generation semantics:
fetchItem, context hydration, and policy reads may share identical keysUser Impact
Operators should see fewer GitHub REST reads during apply without any reduction in race protection. There is no end-user UI change.
OpenClaw Bay Impact
OpenClaw Bay is unaffected. This changes internal publication-apply reads and persisted cache metadata only; Bay’s observer-only data contract and action boundary do not change.
Documentation Lifecycle
The proof package under
docs/proof/apply-read-generations/is historical validation evidence owned by ClawSweeper publication maintainers. No active runbook or public product documentation changes.Evidence
pnpm run check: 3,444 tests, 3,435 passed, 9 platform skips, 0 failures; dashboard-strict, builds, lint, docs, formatting, and coverage thresholds passed. Coverage: 81.57% lines, 74.01% branches, 87.39% functions.local-containerreceipt:cbx_0241049e673e(golden-barnacle-01a8), Ubuntu 26.04/arm64, fresh PR checkout, exit 0, automatically stopped. Static receipt:docs/proof/apply-read-generations/receipt.json.Real Behavior Proof
Claim: Apply shares identical reads only within an explicit generation, invalidates on every observed GitHub mutation, and still blocks concurrent head/comment changes at its live barriers. A validated v3 hydration snapshot performs zero pull-file, commit, or inline-comment REST list reads.
Exercised surface: Production
LiveReadGeneration, apply guard memoization, two-sided lease guard, mutation-boundary wiring, andhydratePrLists, backed by real loopback HTTP endpoints.Scenario: Warm pull/comment reads; run pre-comment and pre-close lease barriers; advance the generation after a concurrent head change or new durable comment; validate a persisted v3 snapshot against live pull and activity watermarks.
Command/environment: Node 24.19.0 and pnpm 11.10.0, locally and through Crabbox Docker
provider=local-containeron Ubuntu 26.04/arm64.Observable result: Each warm-cache barrier still issued two live pull reads and one live comment read. Both concurrent changes blocked apply. The representative formula changed from
F(1)+C(4)+P(6)+L(3)=14requests toU(6)+L_live(3)=9; the irreducibleL(3)stayed live. Validated snapshot list counts were files=0, commits=0, inline-comments=0.Artifact/trace:
scripts/e2e/apply-read-generations-loopback.mjs, its Node test, and the static receipt indocs/proof/apply-read-generations/. The receipt binds tested source82d9a3b14961793d13f3d0b113078eb84e4caf00, treefeb92bdcd220ed054fe9a73e1615bb327802d0d5, provider, lease, image, timings, formulas, assertions, and full-gate totals.Limits: The controlled transport is deterministic loopback HTTP, not a live target mutation. Old v2 snapshots lack files, so they reuse validated commits/comments while performing one normal file-list read; new v3 snapshots reach zero for all three lists. The successful Crabbox run covers toolchain/build/source/proof. The exact-source complete gate is recorded on the Node 24 host because Linux cursor-trace workflow fixtures reject Linux filesystem metadata. No latency claim is made.