Repository navigation
fix(publish): retry transient queue failures during batch publication - #1368
Conversation
Recover from the two observed failure classes: heartbeat queue 500s that immediately stopped batch admission, and post-effect queue 500s after canonical materialization had already succeeded. Retry heartbeat and post-effect network errors, timeouts, and HTTP 5xx up to three attempts within 45 seconds, with 20-second attempt limits, jittered exponential backoff, and bounded Retry-After. Preserve signed bytes, never retry validation/auth/fence rejections, and clip heartbeat attempts to the last confirmed lease expiry. Keep existing workflow gates and ordering without redispatching GitHub actions for receipt retries.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed September 2, 2026, 11:40 PM ET / September 3, 2026, 03:40 UTC. ClawSweeper reviewWhat this changesThis PR adds bounded retries for batch-publication heartbeats and lifecycle post-effects, plus durable replay handling for lifecycle receipts and terminal dispositions. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain Keep open: a retried router receipt can still overwrite a newer requeue when its first request failed before persisting any receipt; required real behavior proof is also still mock-only. Priority: P1 Review scores
Verification
How this fits togetherThe batch publisher reports completed review work back to the exact-review queue after its GitHub and record effects finish. The queue persists lifecycle facts, schedules any required acknowledgement driver, and exposes terminal state to downstream status telemetry. flowchart LR
A[Batch publication workflow] --> B[Signed queue client]
B --> C[Lifecycle receipt endpoint]
C --> D[Durable lifecycle transaction]
D --> E{Terminal state}
E -->|completed| F[Acknowledgement driver]
E -->|requeue| G[Fresh publication work]
D --> H[Status telemetry]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain bounded retries, but make any router-receipt delivery preserve an already-authoritative requeue even when no earlier receipt was committed, then prove the repaired retry path through the required container-backed production boundary. Do we have a high-confidence way to reproduce the issue? Yes—source inspection gives a high-confidence ordering reproduction: fail the first router-receipt before persistence, record requeue, then deliver the retry and observe it replace requeue. Is this the best way to solve the issue? No—the retry is useful, but the router-receipt guard must also cover a retry whose first delivery never committed before this is a safe solution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9c5763013261. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What 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 (4 earlier review cycles)
|
|
Worker-side evidence for the transient class (production
Pre-deploy baseline (2026-09-02 22:00Z to 2026-09-03 01:29Z): 17 of 73 claimed batch runs failed, all in the two classes this PR retries (heartbeat 500 during prepare/finalize; finalize |
- Make complete lifecycle operations idempotent with durable operation IDs, atomic terminal/driver effects, and replay regression coverage. - Restore CHANGELOG.md from origin/main for release-owned changelog updates. - Preserve validated server error codes from bounded queue response bodies. - Remove the unused batch retry script and its documentation/PR references.
|
Merged #1368 as Live verification: 2026-09-03T03:43:57Z through 2026-09-03T04:23:58.107322+00:00 (40.02 minutes), with an initial post-deployment queue sample and five-minute checkpoints. Before snapshot: 2026-09-03T03:42:00.193Z; final server snapshot: 2026-09-03T04:23:55.826Z.
The final live health check still reported deployment Handoff health: before Publication completions increased by 229. Criterion (a), healthy/idle in most samples plus increasing completions: met. Matched pre-deploy cohort: 2026-09-03T03:02:00.193000+00:00–2026-09-03T03:42:00.193000+00:00 (40 minutes). Queue transport failures among claimed, completed batches: 2/18 (11.1%) before, 3/12 (25.0%) after. The earlier operator-supplied incident window was 4/10 (40%). A claim is evidenced by reaching the claim-gated target-token step. Runs that found no work do not enter this denominator. Durations below are creation-to-completion seconds; unfinished runs have no final duration. Post-deploy cohort: 20 runs; 14 completed, 12 claimed and completed, 6 unfinished. Completed logs contain 6
Queue samples:
OpenClaw Bay needs no frontend or public-schema change: the public projection is unchanged, and retry/idempotency bookkeeping remains inside the existing Worker and workflow paths. Completions also increased by 203 within the post-deploy samples themselves. Criterion (b), below the specified earlier 40% failure share with retry engagement when transients occurred: met. Criterion (c), no new failure class: met. All three stated criteria: met against the supplied incident benchmark. The matched 40-minute comparison did not improve: 3/12 after versus 2/18 before. The initial pre-merge run statuses were refreshed as those runs completed; 0 baseline run(s) remained unfinished at the final refresh. This short, observational cohort does not establish a causal reduction in queue failures. Unfinished post-deploy runs are excluded, so the final cohort rate may change. Observed failures and retry evidence:
Representative retry messages (route redacted): Successful completed batches with retry messages: 0. The three observed failures clustered around 04:00:45 UTC: each logged attempts 2/3 and 3/3, then exhausted the retry limit on HTTP 500 Final handoff reason: Rollback: none. All 9 post-deploy queue API requests returned HTTP 200; no pair of consecutive 5xx responses occurred. No new-class batch failure was observed. The higher failure share relative to the matched baseline is reported here and is not a rollback trigger under this work order. Open follow-up: assess the queue-unavailable burst and whether the bounded retry timing is sufficient; 6 post-deploy runs were still unfinished at the cutoff. This task made no additional source changes or production mutations beyond the authorized merge and deployment. |
What Problem This Solves
Batch publication could stop on a transient queue failure after its GitHub or canonical-record effects succeeded. Heartbeats and post-effect POSTs now retry bounded transient failures with unchanged signed bytes and the last confirmed lease expiry.
Lifecycle retries also need to distinguish a completed operation from a partially written legacy receipt. A lost response must not restore an old terminal state over a newer requeue, and reusing an operation ID for a different terminal kind must fail explicitly.
What Changed
operationComplete: trueonly through the atomic handler path. Completed replays are durable no-ops. Legacy receipts without the marker repair missing terminal/driver effects; if a different terminal disposition is at least as recent as the receipt, the handler marks completion without overwriting that disposition or changing the queue.{ operationId, kind }. Same-ID/same-kind replay is a no-op; a different kind returns HTTP 409conflicting_lifecycle_terminal_operation, and the store rejects it too. Existing string IDs migrate on read to{ operationId, kind: null }, deliberately retaining wildcard dedupe compatibility for that unreleased field.Retry-After, and no heartbeat past its last confirmed lease. HTTP 4xx failures remain non-retryable.errorcode from at most 512 response bytes. Raw bodies, URLs, and payloads are not included.OpenClaw Bay needs no frontend or public-schema change. It consumes the same terminal projection, preserving the authoritative requeue; completion markers and terminal operation history remain internal. Release-note context is maintained here; this fix round changes only the two lifecycle source files and their existing publication-lifecycle test file.
Validation and finding disposition
All three accepted second-round findings are addressed: recovery of legacy partial receipts, operation-kind conflict rejection, and bounded operation retention. Eight regression scenarios failed before their respective fixes across the baseline and timestamp-boundary runs. They cover legacy receipts with no terminal fact, legacy receipts with a terminal fact but no driver, legacy receipts followed by requeue (including equal timestamps), handler/store conflict rejection, 40-operation retention, and legacy string-ID migration. Existing plain replay, queue reconstruction, and driver-write rollback cases remain covered.
pr-behavior-proof
Claim: legacy partial receipt replay repairs missing lifecycle effects once while preserving newer terminal state; completed replay is a durable no-op. Terminal operation replay is bound to kind, with a bounded FIFO history and explicit legacy migration.
Surface and fixture: signed Worker lifecycle POST routes through the repository queue harness with real SQLite transactions and synthetic command revisions, plus direct lifecycle store calls. Reconstruct the queue, replay identical signed bytes, check HTTP status and durable projection/queue state, inject a driver-write failure, and persist a legacy string-ID row for migration.
Environment: local macOS, Node 26.8.1. Provider: local host; image and lease: not applicable. This is controlled regression evidence using storage and namespace adapters. It does not claim a production Worker deployment, real network transport, or a live workflow run.
Commands:
pnpm run format pnpm run build:all pnpm run lint git diff --check node --test test/dashboard-worker-publication-lifecycle.test.ts test/exact-review-lifecycle-bay.test.ts test/exact-review-publication-batches.test.ts test/dashboard-worker-queue-runtime.test.ts pnpm run build:repair && node scripts/run-node-tests.mjs repair pnpm run checkLocal artifacts:
.artifacts/batch-publication-retries/fix-round-2/, including the proof contract, pre-fix failures, post-fix replay results, full gate logs, and exact-head CI result. Validated source head:29f171d3fbc35899fd7632bae811ac0f3d598059. Formatting, all builds, lint, and whitespace checks passed. The requested four-file selection passed 317/317. The repair gate passed 1,378 tests with seven skipped and zero failures/cancellations.pnpm run checkpassed: 4,621 total tests, 4,612 passed, nine skipped, zero failures/cancellations; its separate 13-test coverage gate passed too.The fresh independent pre-commit review through P2 is scoped-clean. Its first pass identified two additional legacy timestamp boundaries: a later routed fact can still lack its driver, and a later requeue can share the receipt timestamp. Both were reproduced with failing regressions and corrected before the clean review. The stricter dashboard check also caught an optional-property typing issue, fixed before the final gate run.
Exact-head CI: https://github.com/openclaw/clawsweeper/actions/runs/33711394444 (tracked by this PR's checks). No merge, deployment, or manual live workflow dispatch was performed.