Repository navigation
fix(publication): keep throttled batch publications on the transient retry budget - #1089
Conversation
…retry budget Batch publication classified every non-2xx and every transport error as `unknown_failure`, which carries a 14-attempt / 1-hour budget, while the single-item path in publish-event-result.ts already mapped network errors, 429s, and 5xx to `state_contention` (48 attempts / 24 hours). Batch is the dominant production path, so a GitHub throttling episode dead-lettered finished reviews about an hour in. Of 721 `retry_exhausted` dead letters sampled from the live queue, 706 (98%) had spent fewer than 14 attempts and the minimum lifespan was exactly 60.0 minutes -- the age cap, not attempt exhaustion. `state_contention` is already in the Worker's allowlist for `retryable_failure`, so this needs no protocol or deployment-ordering change. Also records in the PR 674 observation runbook that its per-item telemetry producer never landed (PR closed unmerged 2026-07-21), which is why /api/review-observability reports 0 terminal attempts against 6194 expected.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 10:36 PM ET / August 10, 2026, 02:36 UTC. ClawSweeper reviewWhat this changesThe PR classifies transient batch publication failures as Merge readinessThis PR remains necessary: current main sends batch no-status, 429, and 5xx publication failures to the short Priority: P1 Review scores
Verification
How this fits togetherFinished reviews are published in batches to the exact-review Durable Object queue. The publisher’s completion reason determines whether the queue schedules another attempt or eventually moves the publication to the dead-letter store. flowchart LR
Reviews[Finished reviews] --> Publisher[Batch publisher]
Publisher --> Transport[Signed publication request]
Transport --> Classifier[Failure classification]
Classifier --> Queue[Durable review queue]
Queue --> Outcome[Retry schedule or dead letter]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the narrow reason-code mapping with its focused regression cases and retain the Worker/Durable Object proof as the publication-retry regression evidence. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source shows the batch path emits Is this the best way to solve the issue? Yes. Aligning the batch path with the established single-item classification and preserving that reason through completion is the narrowest compatible repair. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 13f8ffdea32a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
Ports the durable command-intake pipeline for the "@clawsweeper re-review" command from the abandoned Aug-8 WIP (snapshot 4cad8de on codex/fix-command-review-publication) onto current main. Commands are now durably recorded pre-acknowledgement (intake/watermark/receipt/revision tables, 16-item intake, 15s-15m bounded retries, 30-day receipts), verified against the live comment and head, fenced through verify/enqueue/effects stages, and superseded by full version identity - including equal-timestamp edits (review-caught P1). Acknowledgement and reaction effects are idempotent; router runs that throttle mid-command now recover instead of stranding the command (live instance: openclaw/openclaw#116562 was acked then lost when both router runs throttled). Superseded snapshot pieces were dropped, not ported: retry jitter (#1076/#1077), quota headroom (#1086), retry budgets (#1089), parked reconciliation (#1111), branch guard (#962); dashboard-monolith diffs were reworked around the #1116/#1124/#1132 splits. Proof: committed receipt at this exact head (docs/proof/durable-command-intake/), real Wrangler Worker + DO comparison with durable throttled recovery, GitHub confined to loopback API; full gate 7056 passed / 0 failed; strict check green. Verdict clean (Findings: None) on 9eb957e.
…ications (#1168) Fixes a real regression the "automerge quota-fixture" check caught on main: throttled publications (403 rate-limit / 429) were classified permanent_failure instead of retryable_failure, routing throttle victims toward the permanent dead-letter path instead of the transient retry budget - the exact failure class #1089 fixed at the start of this effort. The check was red on main because it was RIGHT. The publisher now preserves quota metadata through the publication path and restores retryable classification: 403/429 cases assert [1,1] requests with retryable_failure; delete paths [0,0]. Introduced during the quota campaign refactors; the fixture (asserting classification, not just counts) was the only gate that saw it. Proof: red/green on the exact fixture, full gates green including the previously-red automerge check, Crabbox local-container receipt at this head, machine-verified provenance. Verdict clean (no findings, proof sufficient) on 0014afe.
Problem
The exact-review publication lane has been
criticalin production, dead-lettering finished Codex reviews at roughly 20-30 per hour. Sampling the live queue endpoint over ~21 minutes showed the store growing monotonically, and only in one bucket:Each row is a review that was computed and then never posted.
Root cause
A publication dead letter is labelled
retry_exhaustedonly when the reason code isunknown_failure, andunknown_failurecarries by far the tightest budget indashboard/exact-review-publication-retry.ts: 14 attempts or one hour, against 48 attempts / 24 hours for every other retryable reason.The two publication paths disagreed about the same transport failure.
postDirectPublicationResultreturns onlyacceptedorfallback, so every non-2xx and every network error arrives asfallbackwith an optional status:src/repair/publish-event-result.ts) already mapped no-status / 429 / 5xx tostate_contention, i.e. the generous transient budget.src/repair/exact-review-batch-cli.ts) special-cased only fence-ownership and 400/413, funnelled everything else intounknown_failure, and then discarded even that computed reason code by hardcodingunknown_failurein the completion mapper.Batch is the dominant production path (batching enabled, 8 concurrent, 8 items each). So during a GitHub throttling episode — and the review lane confirms one, with 38 of 41 pending items in
throttle_retrybackoff — every batch publication landed on the one-hour budget.The dead-letter inventory confirms the mechanism rather than merely fitting it. Of the 721
retry_exhaustedrows:UNKNOWN_RETRY_MAX_AGE_MSage cap, evaluated on the first failure after the hour mark.Change
In
src/repair/exact-review-batch-cli.tsonly: classify no-status / 429 / 5xx asstate_contention, and propagate the computed reason code throughpublicationCompletioninstead of hardcodingunknown_failure. The receipt validator accepts the widened code.400/413keep their permanenttuple_protocol_invalidmapping, fence-ownership is untouched, and the genuinely unknown-cause branches (hasPendingPostEffects, non-eligible) keep the tight budget deliberately. No retry constant changed.state_contentionis already in the Worker's allowlist forretryable_failureindashboard/exact-review-queue.ts, so there is no protocol change and no deployment-ordering constraint between Worker and publisher.OpenClaw Bay
Not affected. This changes only how the batch publisher classifies its own transport failures before reporting a completion the queue protocol already accepts. No lifecycle state, status field, telemetry shape, or dashboard data contract changes.
pr-behavior-proof
retryable_failure/state_contention; the real queue accepts that tuple, returns the publication topending, increments its attempt count, schedules its next attempt, and creates no open dead letter.dist/repair/exact-review-batch-cli.jscommitandcompletecommands over real localhost TLS sockets, followed by signed enqueue/claim/complete traffic through a pinned local Wrangler Worker and the realExactReviewQueueDurable Object.127.0.0.1returns a connection reset, 429, and 503 in separate CLI runs and captures the HMAC-signed completion envelopes. The captured 429 tuple is then posted unchanged to a real local Worker/DO batch. A second fresh item repeats the Worker/DO sequence with onlyreason_code: "unknown_failure"as an attempt-one control. Nofetchor timer monkeypatch is used, no production endpoint is contacted, and no real secret is loaded.docs/proof/csw-1089/run-proof.shon macOS with Node 24,npx --yes [email protected] dev --local --persist-to ..., disposable local persistence, and loopback-only listeners.retryable_failure/state_contention. After the captured 429 tuple crosses the real Worker/DO, item status ispendingat attempt 1 withbackoff_reason: "publication_retry", a schedulednext_attempt_at, anddead_letters: []. The attempt-oneunknown_failurecontrol is also pending with no dead letter, as required before its old budget is exhausted.docs/proof/csw-1089/; raw completion envelopes indocs/proof/csw-1089/artifacts/completion-{no-status,429,503}.json; socket/HMAC trace intransport-requests.json; Worker/DO status before and after inqueue-state-*.json; consolidated observations inruntime-transcript.mdandproof-summary.json.pnpm run lint:repair,pnpm run format:check, source-blind behavior validation, and the fullpnpm run checkall pass.unknown_failureretry_exhausteddead letter or the same-attempt terminal contrast. It does not fake time, edit DO storage, or change a retry constant.Crabbox provenance
The proof re-ran unchanged on reviewed head
d54d60abf5de708713e0fbedce496cd5a21dd251inside Docker-backed Crabboxlocal-containerleasecbx_9797931e8d4d, using imagenode:24-bookwormand Crabbox CLI 0.39.0, from a clean--fresh-prcheckout. It exited 0 with all 21 assertions passing. See the machine-readable provenance and captured stdout.Also included
docs/pr-674-observation-runbook.mdrecords that the per-item telemetry producer this contract was written for never landed — PR #674 was closed unmerged on 2026-07-21 — which is why/api/review-observabilityreports 0 terminal attempts against 6194 expected and a 100% abnormal rate. Those numbers describe a missing producer, not failing reviews. Documentation only; no behavior change.