Repository navigation
fix(sweep): bound failed shard recovery - #518
Conversation
a748ada to
9455fc0
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs real behavior proof before merge. Reviewed July 13, 2026, 6:07 PM ET / 22:07 UTC. Summary Reproducibility: yes. Multiple linked production runs show the pre-fix failed-shard fan-out, and the isolated Docker comparison reproduces the old direct workflow-dispatch call while the fixed path performs signed durable enqueue without direct fan-out. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Use the durable queue as the single recovery authority, preserve all live ordinary work, publish recovery reviews without actionable markers, and require a monitored rollback-safe deployment that proves exactly-once acknowledgement, bounded completion, and no direct or deferred fan-out. Do we have a high-confidence way to reproduce the issue? Yes. Multiple linked production runs show the pre-fix failed-shard fan-out, and the isolated Docker comparison reproduces the old direct workflow-dispatch call while the fixed path performs signed durable enqueue without direct fan-out. Is this the best way to solve the issue? Yes technically: routing recovery through the existing durable queue, preserving live ownership, making recovery one-shot, and suppressing actionable markers is the narrowest coherent fix. Whether its present proof is enough for rollout remains a maintainer decision. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3b4a1894fc85. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (8 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper review |
a5c4111 to
f4c2bb3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4c2bb345a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const oneShotRecovery = | ||
| item.leaseDecision?.sourceAction === FAILED_REVIEW_SHARD_RECOVERY_SOURCE_ACTION; | ||
| const requeued = (!oneShotRecovery && retryingFailure) || hasNewerRevision || requeueLatest; |
There was a problem hiding this comment.
Stop retrying recovery dispatch failures
This one-shot gate only covers failures reported through /complete; if a failed_review_shard_recovery item is accepted by the queue but dispatchClawsweeperItem throws before a workflow run is created (for example workflow dispatch is disabled, credentials are bad, or GitHub returns a persistent API error), the alarm dispatch-failure path still clears the lease and puts the same item back to pending with backoff. That leaves recovery retrying indefinitely despite the new bounded enqueue attempts, so the dispatch-failure handler needs the same recovery check and should terminally drop these items unless a newer revision superseded them.
Useful? React with 👍 / 👎.
* fix(sweep): bound failed shard recovery * chore: retrigger validation * test(sweep): cover recovery branch transport * fix(sweep): complete review-only recoveries * fix(queue): keep failed-shard recoveries one-shot * fix(sweep): require recovery queue acknowledgement * test(sweep): cover split recovery router guards * fix(sweep): clear failed recovery reactions * fix(sweep): keep recovery comments non-actionable --------- Co-authored-by: Peter Steinberger <[email protected]>
Summary
Makes failed review-shard recovery durable, one-shot, and non-actionable. A recovery now waits for an acknowledged exact-review queue write instead of treating a GitHub event delivery as proof that a replacement review run exists.
Problem
The failed-shard recovery job could send a
repository_dispatchevent and accept GitHub's HTTP acknowledgement as success. The later legacy router could then create repeated replacementworkflow_dispatchruns for stale open items after the originating worker had finished. That bypassed the durable queue/lease decision at the point where failure was detected.This was not author activity. For example, a scheduled sweep selected a large ClawHub set and its recovery fanned out directly:
#2411,#2460,#2487,#2489,#2490,#2873,#2898,#2947,#2948,#2949,#2950,#2951,#2953,#2957,#2958,#2959,#2963,#2964,#2969,#2986,#3005,#3006,#3023,#3036,#3037,#3038,#3050,#3055, and#3056.The same mechanism explains the observed stale OpenClaw direct-review churn, including openclaw/openclaw#67967, #92328, and #84975. These are recovery fan-outs, not fresh review requests.
Separately, a live exact-review action-ledger publish on this PR's review run failed after eight non-fast-forward retries: run #29262649242 / job #86859694467. That shared-state write contention is a distinct control-plane issue and is being investigated separately; this PR does not claim to solve it.
Implementation
repository_dispatchhop with a signed POST directly to the existing durable/internal/exact-review/enqueueendpoint.actions: readandcontents: read.clawsweeper-verdictorclawsweeper-actionmarkers. This preserves the review record/version marker but prevents the scheduled comment router from later interpreting a recovery result as a close, repair, or merge instruction.Separate operational tracks
openclaw-clawsweeperGitHub App installation permissions foropenclaw/openclaw(Issues: Read and write and Pull requests: Read and write). Permission 403s for comments, labels, or closes must not be used to judge this queue-recovery canary.clawsweeper-stateconcurrent-write / non-fast-forward serialization. State publication contention must likewise be reported separately from whether this recovery enqueues once and avoids direct fan-out.Validation
git diff --check origin/main...HEAD— passed.pnpm exec oxfmt --check src/clawsweeper.ts src/repair/publish-event-result.ts test/clawsweeper.test.ts test/sweep-workflow.test.ts— passed.pnpm run build— passed.node --test test/clawsweeper.test.ts— 75 passed.node --test --test-name-pattern="failed review recovery waits" test/sweep-workflow.test.ts— 1 passed.cbx_764df5e94382(node:24-bookworm) rancorepack pnpm run build && node --test test/clawsweeper.test.ts && node --test --test-name-pattern 'failed review recovery waits' test/sweep-workflow.test.ts— exit 0; 75 + 1 tests passed.cbx_4d4775cfb925(node:24-bookworm) rancorepack pnpm run buildplus six focused tests — four realExactReviewQueuehandler cases for recovery completion and preserved pending/leased ownership, one marker-suppression case, and the durable-ack/no-fan-out/bounded-attempt workflow assertion. All passed; exit 0.Local Docker before/after recovery proof (not staging or production)
On 2026-07-13 UTC, two isolated
node:24-bookwormDocker containers ran the real dashboard Worker withwrangler dev --local, including real local MiniflareExactReviewQueueDurable Objects. The pre-fix container used base7cc5ef46d1b280410a97a82f6b9f53aea824f582; the fixed container used this PR headf4c2bb345a5d8b2b02d8c9d59f08320cf417159b. Both had only a test-only HMAC secret; neither had a GitHub App private key or GitHub token./internal/exact-review/enqueueendpoint returned202 { ok: true, queued: true }; repeating the same delivery returned202 { ok: true, deduped: true }. The local queue then reported one pending item and one delivery receipt.recover-review-failuresshell block was extracted from each revision and executed in a third disposable Docker container with the same failed-shard fixture (910002,910003). The base block made onegh workflow run sweep.yml … -f item_numbers=910002,910003call, captured by a harmless local fakegh. The fixed block made zeroghcalls and printedQueued failed review shards 1 through the exact-review control plane: 910002,910003after its signed requests reached the fixed local Worker.pending=0anddelivery_receipts=0; the fixed Worker hadpending=3anddelivery_receipts=3(the deduplicated direct probe plus two recovery items), withdispatching=0andleased=0. The fixed dispatcher was intentionallyblockedbecause no GitHub App credentials were present, so the local proof could not create an Action or external request.pnpm run buildand six focused tests passed: four actual queue handler cases for pending/active lease preservation and terminal failed-recovery completion, the marker-suppression case, and the durable-ack/no-direct-workflow run/three-attempt workflow guard.This is a redacted, isolated local integration comparison: it shows the actual recovery shell changes and the real signed Worker/DO boundary without GitHub mutation. It does not execute a deployed GitHub Actions job, obtain a real queue lease, publish a target comment, or observe the router at runtime. It therefore strengthens deterministic evidence but is not represented as staging/live proof or as a proof override.
The full workflow-helper suite has native-Windows baseline failures because this host's
docker-desktopWSL distribution has no/bin/bash; that is a Linux-hosted helper surface, not a product-platform regression. The changed workflow assertion was validated in the Linux container above.Codex review closeout
codex review --uncommitted— clean; no actionable findings.codex review --base origin/main— clean against current main; no actionable regressions.Maintainer proof decision and monitored canary
Current status: implementation and automated proof are ready; no after-fix production failed-shard event exists yet. Creating one artificially would create control-plane load and require prohibited manual workflow dispatch, rerun, cancellation, or an induced worker failure. The supplemental local-container proof above exercises the real queue handler and workflow sources deterministically, but not a deployed queue, a GitHub Actions job, or live runner step state; it cannot substitute for the requested staging/production observation.
Maintainer decision required before taking this PR out of draft:
If option 1 is approved, the first naturally occurring failed shard is the only canary trigger. Do not manually dispatch, rerun, cancel, or manufacture a failure. Capture a redacted linked run/log showing all of these invariants:
queued,deduped, or explicitlyaccepted=false);workflow_dispatchrun titledReview event items …and no recovery fan-out;clawsweeper-verdict:norclawsweeper-action:markers, so the scheduled router cannot close, repair, or merge from it;Immediate rollback criterion: if any invariant fails, revert the #518 merge commit immediately and preserve the redacted run/queue evidence for follow-up. Do not use App-permission changes or state-branch retry changes as a rollback substitute for this code path.
Rollout and risk
This changes failed-shard recovery scheduling and publication only; fresh review requests retain normal queue/retry behavior. The workflow uses the existing
CLAWSWEEPER_WEBHOOK_SECRET, and touching.github/workflows/sweep.ymlcarries the normal GitHub OAuth/workflow scope risk. The PR remains a draft solely pending the maintainer proof/canary decision above.