Repository navigation
feat: use webhook snapshots for non-mutating GitHub reads - #1167
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 6:22 AM ET / 10:22 UTC. ClawSweeper reviewWhat this changesAdds a signed webhook-backed snapshot store for non-mutating GitHub reads, with freshness checks and live-poll repair fallbacks for planning, dashboard, placeholder recovery, and comment routing. Merge readinessKeep open for normal merge review: both prior blockers are resolved, and the branch has strong current behavior proof; production webhook-subscription activation remains a maintainer operational choice. Priority: P2 Review scores
Verification
How this fits togetherGitHub App webhooks enter the dashboard Worker and are materialized in the exact-review queue’s Durable Object. Planning and observability consumers use fresh complete snapshots, while incomplete or stale state falls back to live GitHub reads and repairs the cache. flowchart LR
A[GitHub App deliveries] --> B[Signed webhook ingress]
B --> C[Durable snapshot store]
C --> D{Fresh and complete?}
D -->|yes| E[Planning and dashboard readers]
D -->|no| F[Live GitHub poll and repair]
F --> C
E --> G[Review and health views]
Decision needed
Why: The PR cannot configure the deployed GitHub App itself; its safe fallback preserves current behavior, but only a maintainer can choose the production subscription scope. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Enable and verify the documented GitHub App subscriptions, then monitor the degraded-read telemetry while preserving the live-read mutation boundary. Do we have a high-confidence way to reproduce the issue? Not applicable — this is a feature PR; its Docker-backed proof exercises signed deliveries, snapshot misses, gaps, stale state, and live fallback behavior. Is this the best way to solve the issue? Yes — a bounded, freshness-labelled snapshot cache with explicit live fallbacks is an appropriate way to reduce non-mutating GitHub reads without weakening mutation guards. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 386730fc41ae. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…ntom queued runs (#1169) Fixes the phantom queued run that put operational health into a false "degraded" state after #1167 (production evidence: queued_over_threshold=1 aging 54->58->61min across probes while zero queued runs older than 30min existed in any of the nine involved repos - the App's Workflow runs/jobs subscriptions are not yet enabled, so a run whose terminal transition fell between repair polls stuck in the snapshot forever). Root cause: repository-wide census freshness let unconfirmed queued rows reach health calculation with no per-run confirmation age. Fix, hardened across three review rounds: per-run confirmation timestamps; bounded exact rechecks (batch of 10 per refresh, oldest-stale first, two five-way waves under the 20s cadence - a 200-stale-row snapshot now issues exactly 10 reads instead of 205 and stays fast); race-safe terminal/404 eviction with telemetry; verification failures report unknown, never a phantom alert; omitted unconfirmed rows are unknown and never count toward thresholds; live polling remains authoritative without subscriptions; no rechecks beyond the 24h zombie boundary. Genuine stuck runs still alert. Proof: red reproduced the phantom-degraded state and the 205-read stall; green 22/22 focused, backlog drains in 21 refreshes; full gate 3466/0 host and container; Crabbox local-container receipt at this exact head, machine-verified provenance. Verdict clean (no actionable correctness finding) on 26d446e.
What Problem This Solves
ClawSweeper still spent thousands of GitHub REST reads per hour on planning, dashboard health, placeholder recovery, and repair-loop routing after the first four quota-saving changes. Those reads repeatedly hydrated state that GitHub App webhooks already describe, but there was no durable, freshness-labelled read model safe for non-mutating consumers.
Measured residual from the post-PRs 1–4 four-hour window:
repository_actions:item_metadatarepository_actions:commentsreviewsWhy This Change Was Made
This adds a signed-webhook materialized read model to the exact-review queue Durable Object. It stores bounded, monotonic item, comment, review, review-comment, workflow-run, workflow-job, and check snapshots; serves publisher-HMAC reads with an explicit watermark and freshness; and moves four measured consumers to snapshot-first reads with live polling on miss, gap, staleness, or missing event-class coverage.
The read model is evidence for planning, discovery, hydration, and dashboards only. Apply mutation guards, the two-sided lease check, final post-mutation verification, and placeholder deletion revalidation remain live GitHub reads.
Review round 1 dispositions
workflow_jobdelivery still forces the live poll. The cold/partial and per-run coverage cases are in the refreshed Crabbox proof.CLAWSWEEPER_WEBHOOK_SECRET; forged tuple tests return 409, and the capability exposes no repair/write route.Both applicable rank-up moves were applied: the proof now includes a cold/partial workflow census scenario and a secret-free exact-review lease-reader scenario.
Required GitHub App event subscriptions
The owner must enable delivery of all of these repository events for the corresponding savings to activate:
Readiness is tracked per exact event class. A related class cannot unlock a consumer. If a class has never arrived, the consumer keeps polling and emits one structured
github_read_model_degradedline; the 30-minute probe window is reported rather than silently assuming App configuration.Poller migrations and request formulas
1issue GET per selected item0GitHub requests2general/completed run scans +5active-status scans +Jjob pages0GitHub requests while fresh8 → 02state searches +Pper-item comment pages0GitHub requests while the index is fresh3 → 0Rper-item complete comment-list reads0GitHub requests on complete fresh collections1 → 0The composed dashboard response cache increases from 20 seconds to 60 seconds. Read-model TTLs are 15 minutes for items, 30 minutes for comment/review collections, 5 minutes for workflow state, and 6 hours for placeholder index repair coverage.
Read-model schema and ordering
User Impact
Operators get the same planning, recovery, routing, and dashboard decisions with substantially fewer GitHub REST requests once the required App subscriptions have delivered at least one event. Missing webhook configuration, lost deliveries, late events, and stale snapshots degrade to the existing poll path instead of changing decisions or weakening safety.
OpenClaw Bay Impact
OpenClaw Bay is unaffected. This changes internal read transport only; the public observer schema and observer-only/no-action boundary are unchanged. Bay still cannot trigger queue, workflow, GitHub, DLQ, recovery, deployment, or rollback actions.
Documentation Lifecycle
docs/github-webhook-read-model.mdis active architecture/operator documentation. It names the dashboard/queue maintainer role, owning source files, update triggers, required App subscriptions, TTLs, schema bounds, and safety boundary.docs/proof/webhook-read-model/**is historical proof under the existing proof lifecycle classification.Evidence
Real Behavior Proof
LiveReadGeneration, and final bypass reads.provider=local-container, imagenode:24-bookworm, leasecbx_7451f463bac8;docs/proof/webhook-read-model/run-proof.sh d563120f3b7be59b3e6df6bb928c8a1933dec4f3 386730fc41ae0b1b63a7dbbd648404be6bd65c66.jqaccepted the behavior report; dashboard-strict passed with the new module enrolled; fullpnpm run checkpassed 3,455 tests with 0 failures and 8 skips. Poller fixtures produced identical decisions at1 → 0,8 → 0,3 → 0, and1 → 0GitHub requests. Cold/partial workflow rows remained unusable until census coverage; missing job subscription retained live polling; the scoped exact-review lease reader succeeded without the webhook secret and rejected a forged tuple. Apply-generation and final-bypass counters each observed one live hit and zero read-model guard hits.docs/proof/webhook-read-model/receipt.json,behavior-report.json, andcontainer-transcript-summary.txt. Crabbox reportsleaseStopped: true.d563120f3b7be59b3e6df6bb928c8a1933dec4f3; final headdf35ef612fadds only the refreshed receipt/report/summary files.Additional validation:
origin/main: clean, no accepted/actionable findings.CI note:
production automerge flowcurrently fails its hermetic GitHub-quota expectation (retryable_failureexpected,permanent_failureobserved). The exact targeted Docker scenario fails identically on this PR and on archivedorigin/main@386730fc41, so this is an inherited base failure outside this PR's changed surface. The PR'spnpm checkand refreshed Docker proof are green.