Skip to content

perf(github): add durable ETag read broker - #1164

Merged
steipete merged 4 commits into
mainfrom
steipete/etag-read-broker
Aug 14, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/etag-read-broker

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

Add the rank-4 durable ETag response broker for cross-run GitHub REST revalidation. The quota-savings analysis basis is rank 4, “Conditional requests,” with observed repeat floors of 21.5% for item metadata, 17.6% for comments, and 19.5% for reviews. The predecessor boundaries are the GraphQL activity cursor (#1159), apply read generations (#1161), and the publisher-scoped durable cache pattern (#1163).

The queue Durable Object stores bounded JSON bodies with their ETag, SHA-256 digest, response timestamp, validation timestamp, and expiry. Runners use publisher-scoped HMAC lookup/store/confirm endpoints. Lookup never returns a body: only a live GitHub 304 followed by a matching durable ETag/digest confirmation can return cached bytes. A failed lookup or confirmation falls back to an unconditional live read, preserving final pre/post-mutation guard authority.

Key and bounds

The version-1 key schema is [1, credential_pool, route_with_sorted_query, media_type]. Collection routes materialize per_page and page=1, so page 1 can never validate page 2. Credential pools are repository_actions, target_app, and public_read_fallback; raw tokens are never persisted.

Storage is capped at 2,048 entries and 512 KiB of UTF-8 JSON per body, with 30-day retention aligned to the existing exact-review receipt convention. Missing ETags, malformed JSON, oversized bodies, unavailable broker calls, and failed confirmations are fail-open cache skips.

Integration sites

  • Exact publication/apply: single-object issue and pull GETs in src/clawsweeper-github-runtime.ts.
  • Exact publication/apply: explicit, independently keyed pages for issue comments, pull comments, and pull reviews. Existing improve(apply): reduce duplicate live GitHub reads #1161 generation memoization remains the in-run owner; the broker sees only real GitHub reads across runs or invalidated generations.
  • Dashboard health: Actions run census/status pages and run-job pages in dashboard/worker.ts.
  • Workflow wiring: direct and batch publishers receive the existing queue URL plus publisher webhook secret. Final guards still perform a wire request; a 304 is the authoritative answer, not a bare cache hit.

Telemetry

broker_lookup and conditional_response are separate units. Outcomes distinguish cache_hit, cache_miss, cache_skip, cache_200_stored, and cache_304_served. A lookup hit is not reported as quota savings; only cache_304_served proves a zero-point conditional response. Existing invocation and wire-attempt rows remain unchanged.

Behavior proof

Final head bd2ef9502f5988219a475d2cba83723b0c1038b0 passed Docker-backed Crabbox with provider=local-container, lease cbx_0cdf5e2b4f54, image node:24-bookworm:

  • first read: 200 + durable store;
  • unchanged read: If-None-Match on the wire, 304, durable confirmation, byte-identical body and asserted digest;
  • changed resource: new 200 replaces the entry;
  • page 2 never carries page 1’s ETag;
  • final-guard-style read revalidates and never uses a bare cached body;
  • 5 logical reads produced 5 wire calls but only 3 quota-charged 200s;
  • publisher HMAC returned 200; operator-secret substitution returned 401;
  • focused tests: 16/16; pnpm run check:dashboard-strict: pass; pnpm run check: 3,454 tests, 3,446 passed, 8 skipped, 0 failed;
  • committed proof receipt: docs/proof/etag-read-broker/receipt.json; static jq, commit-object cross-checks, and TruffleHog all passed.

This reduces quota charges, not wire requests. The loopback GitHub and credentials are deterministic fixtures; production GitHub and production Worker state were not mutated.

OpenClaw Bay

OpenClaw Bay is unaffected. This changes internal read transport and closed telemetry dimensions only; the public observer payload remains read-only and exposes no queue, recovery, deploy, rollback, or mutation action.

@steipete
steipete requested a review from a team as a code owner August 14, 2026 06:15
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 2:17 AM ET / 06:17 UTC.

ClawSweeper review

What this changes

The PR adds a Durable Object-backed ETag broker that conditionally revalidates selected GitHub REST reads across publication and dashboard runs.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

This PR remains necessary: it adds a distinct cross-run conditional-revalidation layer not present on the current main baseline. The supplied loopback proof is strong, but the review environment could not execute read-only repository inspection because its sandbox failed before commands ran, so source-level approval should wait for a fresh review-capable run.

Priority: P2
Reviewed head: bd2ef9502f5988219a475d2cba83723b0c1038b0

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The behavior proof is strong, while the review environment prevented an independent complete source-level correctness pass.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The committed receipt describes Docker-backed loopback evidence through production broker logic, Worker routing, Durable Object storage, a confirmed 304 replay, and denied operator-secret access.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The committed receipt describes Docker-backed loopback evidence through production broker logic, Worker routing, Durable Object storage, a confirmed 304 replay, and denied operator-secret access.
Evidence reviewed 4 items Distinct proposed layer: The supplied PR diff adds a GitHub ETag cache contract, durable response store, read broker, runtime integration, and Worker routes; current main is the PR base and therefore does not contain this branch change.
Real behavior proof: The PR body and committed receipt report Docker-backed loopback coverage of initial storage, 304 revalidation and digest confirmation, changed-resource replacement, page isolation, final-guard revalidation, and publisher-secret rejection.
Adjacent predecessor on main: The provided related-item history identifies merged PR #1163 at current-main commit 6a358d2; it caches artifact bundles, not conditional REST JSON reads.
Findings None None.
Security None None.

How this fits together

ClawSweeper’s publisher and dashboard read GitHub REST data to review items and show operational health. This change supplies cached validators before live reads and returns stored JSON only after a matching GitHub 304 confirmation.

flowchart LR
  A[Publication and dashboard readers] --> B[ETag key builder]
  B --> C[Durable ETag broker]
  C --> D[Live GitHub conditional read]
  D --> E{Response status}
  E -->|200| F[Store bounded JSON and ETag]
  E -->|304 plus confirmation| G[Return confirmed stored JSON]
  F --> H[Review and health decisions]
  G --> H[Review and health decisions]
Loading

Before merge

  • Resolve merge risk (P1) - This changes exact-review automation’s live GitHub-read path; cache skips, failed confirmations, and unavailable queue calls must preserve the existing unconditional-read semantics.
  • Resolve merge risk (P1) - The sandbox failure prevented independent review of the complete source diff, call sites, and history in this run.
  • Complete next step (P2) - This is an active implementation PR with strong supplied proof; it needs a review-capable source pass, not a separate repair lane.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed surface 25 files, +2,126 / -17 lines The PR spans workflow configuration, Durable Object storage, GitHub runtime reads, dashboard telemetry, tests, and proof artifacts.

Merge-risk options

Maintainer options:

  1. Complete source-level compatibility review (recommended)
    Verify the full runtime wrapper and all call sites preserve existing GitHub response and fallback behavior before merging this automation-path change.

Technical review

Best possible solution:

Preserve the existing live-read behavior on every cache failure path while using the broker only to add authenticated conditional revalidation and confirmed 304 replay.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug report; the PR supplies a controlled loopback exercise of the proposed conditional-read behavior.

Is this the best way to solve the issue?

Unclear pending independent source review; the stated live-304-plus-confirmation design is a conservative fit if all fallback paths retain current behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6a358d239c1e.

Labels

Label changes:

  • add P2: This is a bounded internal GitHub-read performance and reliability improvement.
  • add merge-risk: 🚨 compatibility: The broker wraps existing publication and dashboard GitHub reads whose fallback response behavior must remain unchanged.
  • add merge-risk: 🚨 automation: The patch changes exact-review workflow environment wiring and authenticated Worker automation endpoints.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The committed receipt describes Docker-backed loopback evidence through production broker logic, Worker routing, Durable Object storage, a confirmed 304 replay, and denied operator-secret access.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The committed receipt describes Docker-backed loopback evidence through production broker logic, Worker routing, Durable Object storage, a confirmed 304 replay, and denied operator-secret access.

Label justifications:

  • P2: This is a bounded internal GitHub-read performance and reliability improvement.
  • merge-risk: 🚨 compatibility: The broker wraps existing publication and dashboard GitHub reads whose fallback response behavior must remain unchanged.
  • merge-risk: 🚨 automation: The patch changes exact-review workflow environment wiring and authenticated Worker automation endpoints.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The committed receipt describes Docker-backed loopback evidence through production broker logic, Worker routing, Durable Object storage, a confirmed 304 replay, and denied operator-secret access.
  • proof: sufficient: Contributor real behavior proof is sufficient. The committed receipt describes Docker-backed loopback evidence through production broker logic, Worker routing, Durable Object storage, a confirmed 304 replay, and denied operator-secret access.

Evidence

What I checked:

  • Distinct proposed layer: The supplied PR diff adds a GitHub ETag cache contract, durable response store, read broker, runtime integration, and Worker routes; current main is the PR base and therefore does not contain this branch change. (src/github-etag-read-broker.ts:1, 418625799d4f)
  • Real behavior proof: The PR body and committed receipt report Docker-backed loopback coverage of initial storage, 304 revalidation and digest confirmation, changed-resource replacement, page isolation, final-guard revalidation, and publisher-secret rejection. (docs/proof/etag-read-broker/receipt.json:1, bd2ef9502f59)
  • Adjacent predecessor on main: The provided related-item history identifies merged PR perf(review): cache exact-review bundles in R2 #1163 at current-main commit 6a358d2; it caches artifact bundles, not conditional REST JSON reads. (dashboard/exact-review-queue.ts:1, 6a358d239c1e)
  • Inspection infrastructure failure: A read-only command failed before repository output with bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted; current source, history, and the complete patch could not be independently inspected in this review environment.

Likely related people:

  • steipete: The supplied history shows steipete authored the merged adjacent durable publisher-cache work and this proposed ETag-broker layer. (role: recent area contributor; confidence: medium; commits: 6a358d239c1e, bd2ef9502f59; files: dashboard/exact-review-queue.ts, src/clawsweeper-github-runtime.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Run a fresh source-level review of the current head once read-only repository inspection is available.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit dc67620 into main Aug 14, 2026
19 checks passed
@steipete
steipete deleted the steipete/etag-read-broker branch August 14, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant