Skip to content

fix: prevent guarded dead-letter reconciliation starvation - #1013

Merged
steipete merged 1 commit into
mainfrom
codex/clawsweeper-dead-letter-starvation
Aug 2, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/clawsweeper-dead-letter-starvation

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Aggregate every atomically rejected guarded cleanup from one inventory scan, refresh authoritative inventory once, then fence still-open blocked rows and every transferred/canonical alias instead of repeatedly spending the retry budget on unchanged targets.
  • Preserve recovery for any number of targetless legacy rows, multiple independently blocked groups, and recovery candidates staged at the original target cap; keep distinct canonical inspections/skipped counts stable across refreshes and reject malformed guarded cleanup responses.
  • Preserve atomic guarded cleanup, active-review/publication fences, source-head validation, conservative capacity checks, and create-only OpenClaw PR behavior.

Direct production failure

The first production run after landing the bounded-refresh fix succeeded as a workflow but recovered no work because it kept inspecting the same unchanged blocked target:

https://github.com/openclaw/clawsweeper/actions/runs/30757712437

{"action":"reconcile","dry_run":false,"inventory_complete":true,"queue_pressure":"idle","inspected_targets":3,"recovered_targets":0,"resolved_rows":0,"invalid_rows":0,"closed_rows":0,"duplicate_rows":0,"active_review_rows":0,"skipped_targets":3,"inventory_changed":true,"skipped_rows":1}

Its sanitized production artifact contained 1,387 open dead letters and 1,384 fresh-recovery-eligible rows, so zero recoveries reflected starvation rather than lack of recoverable work.

After-fix real operator subprocess

This executes the actual production operator as a separate Node process against real signed local HTTP endpoints. A closed target rejects guarded cleanup without changing inventory; after one authoritative refresh, its aliases remain fenced and an independent open target is recovered:

$ node /tmp/clawsweeper-starvation-proof.mjs
{
  "exit_code": 0,
  "summary": {
    "action": "reconcile",
    "dry_run": false,
    "inventory_complete": true,
    "queue_pressure": "idle",
    "inspected_targets": 2,
    "recovered_targets": 1,
    "resolved_rows": 1,
    "invalid_rows": 0,
    "closed_rows": 0,
    "duplicate_rows": 0,
    "active_review_rows": 0,
    "skipped_targets": 1
  },
  "inventory_requests": 2,
  "guarded_cleanup_calls": [["blocked"]],
  "fresh_recovery_calls": [["recoverable"]]
}
$ node /tmp/clawsweeper-starvation-edge-proofs.mjs
{"proof":"targetless_guard","exit_code":0,"inspected_targets":1,"recovered_targets":1,"skipped_targets":0,"inventory_requests":2,"guarded_cleanup_calls":[["legacy-blocked"]],"fresh_recovery_calls":[["recoverable"]]}
{"proof":"sixty_blocked_legacy_rows","exit_code":0,"inspected_targets":1,"recovered_targets":1,"skipped_targets":0,"inventory_requests":2,"guarded_cleanup_calls":[["legacy-0","legacy-1","legacy-2","legacy-3","legacy-4","legacy-5","legacy-6","legacy-7","legacy-8","legacy-9","legacy-10","legacy-11","legacy-12","legacy-13","legacy-14","legacy-15","legacy-16","legacy-17","legacy-18","legacy-19"]],"fresh_recovery_calls":[["recoverable"]]}
{"proof":"three_blocked_targets","exit_code":0,"inspected_targets":4,"recovered_targets":1,"skipped_targets":3,"inventory_requests":2,"guarded_cleanup_calls":[["blocked-1"],["blocked-2"],["blocked-3"]],"fresh_recovery_calls":[["recoverable"]]}
{"proof":"mixed_blocked_and_disappeared_groups","exit_code":0,"inspected_targets":3,"recovered_targets":2,"skipped_targets":1,"inventory_requests":2,"guarded_cleanup_calls":[["blocked"],["duplicate"]],"fresh_recovery_calls":[["primary","recoverable"]]}
$ node --test test/exact-review-dead-letter-operator.test.ts
✔ an unchanged blocked cleanup cannot starve independent fresh recovery
✔ a blocked targetless legacy row cannot starve independent fresh recovery
✔ many blocked targetless legacy rows cannot exhaust the inventory refresh budget
✔ multiple independently blocked groups share one authoritative refresh
✔ blocked canonical targets are counted only once across inventory refreshes
✔ active and capped targets are counted only once across blocked inventory refreshes
✔ staged recovery retains its original target budget across a blocked refresh
✔ blocked duplicate cleanup fences its primary without starving another target
✔ only unchanged blocked groups fence aliases after an aggregated refresh
✔ a blocked transferred alias fences its whole target without starving another
✔ reconciliation rejects a malformed zero-mutation guarded cleanup response
ℹ tests 50
ℹ pass 50
ℹ fail 0
$ node --test --test-name-pattern='guarded dead-letter (recovery|resolution)' test/dashboard-worker.test.ts
ℹ tests 8
ℹ pass 8
ℹ fail 0

The existing independent counter-regression reproduction still reports resolved_rows=2, closed_rows=1, invalid_rows=1, and both original target/recovery caps remain unchanged. Non-atomic cleanup responses still fail closed, stale transferred/active aliases remain fenced, and fresh recovery is never sent before the authoritative inventory refresh.

@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 1:27 PM ET / 17:27 UTC.

ClawSweeper review

What this changes

The branch updates dead-letter reconciliation so unchanged guarded-cleanup conflicts are aggregated into one inventory refresh, fenced by canonical target, and no longer starve unrelated eligible recovery work.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This PR addresses a demonstrated production reconciliation starvation path and the submitted branch adds a focused aggregate-refresh and fencing fix with strong operator-level proof. It is still necessary because commit 458a60e9f5654e2daf486f78c566ed57863aa127 is not on current main or the v0.3.0 release; no discrete correctness or security defect was found in the patch.

Priority: P1
Reviewed head: 458a60e9f5654e2daf486f78c566ed57863aa127

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong real operator proof and focused coverage support a clean, bounded fix; the remaining merge consideration is normal current-head automation verification.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body includes after-fix terminal output from the actual operator running as a separate Node process against signed local HTTP endpoints, with observable blocked-cleanup, refresh, fencing, and independent-recovery results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body includes after-fix terminal output from the actual operator running as a separate Node process against signed local HTTP endpoints, with observable blocked-cleanup, refresh, fencing, and independent-recovery results.
Evidence reviewed 6 items Focused operator change: The PR aggregates atomic guarded-cleanup conflicts, refreshes the inventory once, records unchanged blocked rows and aliases, and skips only those fenced canonical targets before considering independent recovery work.
Safety invariants remain explicit: The branch rejects non-atomic guarded-cleanup responses, preserves target inspection accounting across refreshes, revalidates recovery targets, source heads, and queue pressure before issuing fresh recovery.
Regression coverage: The added focused tests cover unchanged blocked cleanup, targetless legacy rows, many blocked rows, multiple blocked targets, alias transfer, target-cap accounting, malformed cleanup responses, and independent recovery.
Findings None None.
Security None None.

How this fits together

The dead-letter reconciliation operator inventories failed review-publication rows, identifies their live GitHub targets, resolves terminal or duplicate rows, and submits safe fresh recovery work. The changed path handles an atomic cleanup race: it refreshes authoritative inventory once, fences unchanged blocked aliases, and continues recovering independent work within the original limits.

flowchart TD
  Inventory[Dead-letter inventory] --> Group[Canonical target groups]
  Group --> Cleanup[Guarded cleanup]
  Cleanup --> Refresh[One authoritative refresh]
  Refresh --> Fence[Unchanged alias fencing]
  Fence --> Select[Eligible recovery selection]
  Select --> Validate[Live target validation]
  Validate --> Queue[Fresh repair work]
Loading

Before merge

  • Resolve merge risk (P1) - Merging changes automated reconciliation scheduling and alias fencing; an unforeseen inventory-race variant could defer or skip recovery work, so the current focused checks should finish against this exact head before landing.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch scope 2 files affected; 636 additions, 28 deletions The implementation is confined to the dead-letter operator and its narrowest matching regression test file.
New regression scenarios 11 focused scenarios added The tests cover blocked cleanup aggregation, alias fencing, limits, and malformed atomic responses rather than only the original single-target case.

Merge-risk options

Maintainer options:

  1. Land after current automation checks (recommended)
    Keep the targeted refresh-and-fence design and merge once the required checks complete for the current head, since the real operator proof and focused regression coverage already exercise the claimed failure mode.
  2. Pause for broader live telemetry
    If maintainers want more operational confidence, wait for one additional production reconciliation observation before merging, accepting continued starvation risk in the meantime.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Require current-head checks to complete successfully; preserve the aggregate guarded-cleanup refresh and alias-fencing coverage.

Technical review

Best possible solution:

Keep the aggregate single-refresh design, preserve the existing atomic cleanup and live-target validation fences, and merge this focused fix after the current review and required checks apply to the submitted head.

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

Yes. The PR documents a production reconciliation run that inspected unchanged blocked targets and recovered none, then provides an after-fix subprocess run against signed local HTTP endpoints that fences the blocked target and recovers an independent target.

Is this the best way to solve the issue?

Yes. Aggregating atomic conflicts into one authoritative refresh and fencing only unchanged blocked aliases is a narrow solution that retains the existing safety checks, caps, target validation, and recovery behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The reported production behavior can prevent otherwise eligible repair work from being recovered by the review automation.
  • add merge-risk: 🚨 automation: The patch changes the operator that selects and creates automated fresh-recovery work after inventory races.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from the actual operator running as a separate Node process against signed local HTTP endpoints, with observable blocked-cleanup, refresh, fencing, and independent-recovery results.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal output from the actual operator running as a separate Node process against signed local HTTP endpoints, with observable blocked-cleanup, refresh, fencing, and independent-recovery results.

Label justifications:

  • P1: The reported production behavior can prevent otherwise eligible repair work from being recovered by the review automation.
  • merge-risk: 🚨 automation: The patch changes the operator that selects and creates automated fresh-recovery work after inventory races.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal output from the actual operator running as a separate Node process against signed local HTTP endpoints, with observable blocked-cleanup, refresh, fencing, and independent-recovery results.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from the actual operator running as a separate Node process against signed local HTTP endpoints, with observable blocked-cleanup, refresh, fencing, and independent-recovery results.

Evidence

What I checked:

  • Focused operator change: The PR aggregates atomic guarded-cleanup conflicts, refreshes the inventory once, records unchanged blocked rows and aliases, and skips only those fenced canonical targets before considering independent recovery work. (scripts/exact-review-dead-letter-operator.mjs:74, 458a60e9f565)
  • Safety invariants remain explicit: The branch rejects non-atomic guarded-cleanup responses, preserves target inspection accounting across refreshes, revalidates recovery targets, source heads, and queue pressure before issuing fresh recovery. (scripts/exact-review-dead-letter-operator.mjs:303, 458a60e9f565)
  • Regression coverage: The added focused tests cover unchanged blocked cleanup, targetless legacy rows, many blocked rows, multiple blocked targets, alias transfer, target-cap accounting, malformed cleanup responses, and independent recovery. (test/exact-review-dead-letter-operator.test.ts:431, 458a60e9f565)
  • Current-main ownership history: Current main introduced the nearby bounded-refresh reconciliation behavior in the recent publication-backlog refactor; this PR is a targeted follow-up to that code path. (scripts/exact-review-dead-letter-operator.mjs:270, 4a39cfcf6a96)
  • Release and main inclusion check: The proposed commit is not an ancestor of current main, and no tag contains it; the fix is therefore not shipped in v0.3.0 or current main yet. (458a60e9f565)
  • Real operator proof in PR body: The PR body includes a production failure observation plus after-fix subprocess results showing one blocked target remains fenced while an independent target is recovered after two inventory requests. (458a60e9f565)

Likely related people:

  • steipete: Peter Steinberger authored the current-main dead-letter recovery/refactor commits and the proposed focused follow-up; the history is concentrated in this operator path. (role: recent area contributor; confidence: high; commits: 4a39cfcf6a96, 60ad8788f545, 458a60e9f565; files: scripts/exact-review-dead-letter-operator.mjs, test/exact-review-dead-letter-operator.test.ts)

Rank-up moves

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

  • Let the in-progress required checks complete for commit 458a60e9f5654e2daf486f78c566ed57863aa127.

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 5f8543d into main Aug 2, 2026
19 checks passed
@steipete
steipete deleted the codex/clawsweeper-dead-letter-starvation branch August 2, 2026 17:30
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
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. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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