Skip to content

fix(ci): auto-remediate demonstrably stuck queued runs - #1131

Merged
steipete merged 4 commits into
mainfrom
steipete/stuck-run-remediation
Aug 12, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/stuck-run-remediation

Conversation

@steipete

@steipete steipete commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replace the broad hourly 24-hour queued-run janitor with guarded remediation in the existing five-minute exact-review dead-letter reconcile cadence.

The selector cancels a run only when all of these are true:

  • GitHub still reports it as queued.
  • Its age is strictly greater than 90 minutes.
  • At least three later runs for the same workflow reached in_progress or completed.
  • Its workflow is not an expected long-queue workflow; the serialized repair-cluster-worker.yml lane is excluded.
  • It is not in the rolling permanent-zombie set.

Each pass cancels at most ten candidates. Regular cancellation is tried first; force-cancel is attempted only after HTTP 500. A second HTTP 500 persists the run in the rolling artifact so later passes do not retry it. The old .github/workflows/queued-run-janitor.yml is removed so cancellation has one owner.

Bounded discovery and deadline

Workflow-history discovery now has two independent bounds:

  • inspect at most eight distinct stale workflows per pass, oldest queued run first;
  • stop remediation at min(step start + 120,000 ms, EXACT_REVIEW_RECONCILE_DEADLINE_MS - 480,000 ms).

The eight-minute reservation leaves budget for live-guard verification and both dead-letter reconciliation stages. Inventory pagination, history pagination, queued-state revalidation, regular cancellation, and force-cancellation all use the remaining total deadline rather than starting a fresh 20-second request budget. Deadline exhaustion produces a successful partial artifact and step summary with deadline_reached plus distinct, inspected, and skipped workflow counts, including bound-versus-deadline attribution.

The timeout regression runs the production script against 20 distinct stale workflows whose history provider takes 20 seconds per request. It stops after one attempted request in about 1.5 seconds, reports one inspected and 19 skipped workflows (12 by the eight-workflow bound and seven by deadline), and preserves the full 480,000 ms dead-letter reserve.

Production-script behavior proof

Current pushed head: 5ea082af48af27e9e3d6c807d77567b7226f8a7e.

Docker-backed Crabbox local-container proof used a fresh checkout of this PR, asserted the exact head, and ran the production script through a loopback GitHub API using GITHUB_API_URL.

  • Recovery scenario: one two-hour-old queued run had three later same-workflow starts; one ten-minute-old queued run remained below threshold. The script selected and revalidated only the stranded run, posted exactly one regular cancellation, recorded HTTP 202 cancel_requested, and never addressed the young run.
  • Zombie scenario: regular and force cancellation returned HTTP 500. The script persisted the old run, then a second production-script pass restored the state, classified it as permanent_zombie, made no cancellation request, and left the young run untouched.

Final current-head confirmation: provider local-container, lease cbx_8d58967d196f, slug pearl-hermit-2887, Docker image node:24-bookworm, exit 0, lease stopped. It passed 71/71 focused tests, all three loopback assertions, static policy/documentation/format checks, all TypeScript builds, and every lint lane.

The committed receipt and redacted request trace are in docs/proof/stuck-queued-run-remediation/container-receipt.json and docs/proof/stuck-queued-run-remediation/loopback-proof-receipt.json. The receipt-producing run tested code head b46b579b6d12d940cb068b32da20a23e8c39b000; the docs-only receipt commit advanced the PR to the current head above, which the final lease then re-proved without further branch changes.

The broad host gate also passed on Node 24: 3,345 tests, 3,336 passed, nine platform-skipped, zero failed, with coverage and all static/build/lint gates green.

Limits: the after-fix mutation transport is a loopback fixture, not a production cancellation. The earlier live read-only inventory remains committed and selected no production run.

Production evidence and safety

Two incidents establish the failure mode and remediation:

  • On August 7, 14 runs became permanent GitHub backend zombies. Both cancel and force-cancel returned HTTP 500; fix: exclude zombie runs from operational health #1101 keeps these visible without pinning operational health.
  • On August 12 UTC, six runs queued for roughly three hours while later dispatches ran. Regular cancellation succeeded for all six and their items re-dispatched cleanly through the existing workflow_cancelled retry path.

OpenClaw Bay

Not affected. This changes a GitHub Actions maintenance lane and its private summary artifact only. It does not change Bay's observer-only contract, dashboard data, or expose queue/workflow actions on Bay.

@steipete
steipete requested a review from a team as a code owner August 12, 2026 04:13
@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 12:42 AM ET / 04:42 UTC.

ClawSweeper review

What this changes

The PR replaces the hourly queued-run janitor with guarded remediation in the five-minute dead-letter reconciliation workflow, including bounded discovery, cancellation revalidation, and persistent zombie-run state.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review: the patch has sufficient bounded real-behavior proof and no actionable correctness finding from this review.

Priority: P1
Reviewed head: 5ea082af48af27e9e3d6c807d77567b7226f8a7e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong production-script proof and focused coverage support a mergeable operational patch, with the normal caution appropriate for scheduled cancellation behavior.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body and committed receipts provide Docker-backed local-container evidence that the production script performed the intended loopback cancellation and zombie-replay behavior at the current head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body and committed receipts provide Docker-backed local-container evidence that the production script performed the intended loopback cancellation and zombie-replay behavior at the current head.
Evidence reviewed 6 items Guarded remediation implementation: The production script requires a queued run older than the threshold, excludes known zombies and serialized lanes, and selects only runs with later same-workflow progress evidence.
Bounded workflow behavior: The script caps history inspection, shares the reconciliation deadline while reserving dead-letter time, and records deadline and skipped-workflow attribution.
Current-head behavior proof: The committed loopback receipt records the production script selecting only the stranded run, receiving HTTP 202 for cancellation, and persisting a double-500 run so replay makes no POST request.
Findings None None.
Security None None.

How this fits together

The dead-letter reconciliation workflow maintains exact-review queue health. It reads GitHub Actions run state, identifies demonstrably stranded queued runs, requests bounded cancellation, and records results for later passes.

flowchart LR
  A[Queued workflow runs] --> B[Dead-letter reconcile workflow]
  B --> C[Eligibility and deadline checks]
  C --> D[Revalidate queued state]
  D --> E[Cancel or force-cancel]
  E --> F[Zombie state artifact]
  F --> G[Next reconciliation pass]
Loading

Before merge

  • Resolve merge risk (P1) - Scheduled runs gain permission to cancel up to ten qualifying GitHub Actions runs per pass; a selector defect could interrupt review throughput despite the age, progress, revalidation, deadline, and artifact safeguards.
  • Complete next step (P2) - No narrow repair is indicated: the patch has no actionable review finding and already includes sufficient real-behavior proof.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Operational change surface 12 files; +1,850 / -84 lines The patch consolidates one scheduled workflow and adds a bounded remediation implementation with its operational artifacts.
Production versus test delta operational code/config +759 / -66; tests +341 / -18 The production change is accompanied by focused selector, retry, and deadline coverage.

Merge-risk options

Maintainer options:

  1. Proceed with the bounded remediation design (recommended)
    Accept the intentionally narrow scheduled cancellation capability while retaining the documented thresholds, live revalidation, ten-run cap, and artifact trail.

Technical review

Best possible solution:

Land the consolidated remediation path with its existing eligibility guards, cancellation cap, deadline reserve, and persistent audit artifacts so stranded runs recover without broad janitor behavior.

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

Yes. The current-head proof runs the production remediation script against a loopback GitHub API and demonstrates both successful recovery of one stranded run and safe permanent-zombie handling after two HTTP 500 responses.

Is this the best way to solve the issue?

Yes. Consolidating guarded remediation into the existing serialized reconciliation cadence removes the broad janitor while preserving explicit eligibility, bounded work, and audit state.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body and committed receipts provide Docker-backed local-container evidence that the production script performed the intended loopback cancellation and zombie-replay behavior at the current head.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: The patch changes automatic recovery of stuck review workflows, where failures can delay real review and repair work.
  • merge-risk: 🚨 automation: It changes scheduled GitHub Actions execution, artifact restoration, and cancellation behavior.
  • merge-risk: 🚨 availability: A faulty cancellation decision could interrupt queued workflow execution until the retry path recovers it.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Sufficient (linked_artifact): The PR body and committed receipts provide Docker-backed local-container evidence that the production script performed the intended loopback cancellation and zombie-replay behavior at the current head.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and committed receipts provide Docker-backed local-container evidence that the production script performed the intended loopback cancellation and zombie-replay behavior at the current head.

Evidence

What I checked:

Likely related people:

  • steipete: The feature-history commit that introduced the reconciliation workflow and the adjacent queued-run reliability work are attributed to this contributor. (role: feature owner and recent area contributor; confidence: high; commits: 765644804756, 5091608743e1; files: .github/workflows/exact-review-dead-letter-reconcile.yml, scripts/stuck-queued-run-remediation.mjs)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-12T04:16:18.173Z sha d02b005 :: needs real behavior proof before merge. :: [P1] Bound workflow-history discovery before remediation | [P1] Re-run proof in local-container at the current head

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 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 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(ci): auto-remediate demonstrably stuck queued runs This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit 408c283 into main Aug 12, 2026
12 checks passed
@steipete
steipete deleted the steipete/stuck-run-remediation branch August 12, 2026 04:45
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. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant