Skip to content

fix: exclude zombie runs from operational health - #1101

Merged
steipete merged 3 commits into
mainfrom
steipete/operational-health-zombie-runs
Aug 10, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/operational-health-zombie-runs

Conversation

@steipete

@steipete steipete commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Treat queued workflow runs older than 24 hours as surfaced zombies: keep them in queued_runs, report zombie_queued_runs and oldest_zombie_queued_minutes, but exclude them from queued_over_threshold, oldest_queued_minutes, and degraded/stalled computation.
  • Preserve the existing 30-minute queue and 150-minute running thresholds for non-zombie runs. Exactly 24 hours remains ordinary queue pressure; approval-gated waiting runs were already outside degraded computation and remain unchanged.
  • Add a validated GITHUB_API_URL Worker binding across every dashboard GitHub REST and GraphQL fetch site. Production behavior is unchanged by default and still uses the byte-identical origin https://api.github.com when unset.

Security repair

The accepted P1 review finding is fixed at fe4b9e226a021b06dcf25917a62c4b0d876b48b1. A configured GITHUB_API_URL may now be only the exact production origin https://api.github.com or an explicit-port loopback HTTP origin on 127.0.0.1 / localhost. Arbitrary HTTPS origins, alternate ports on api.github.com, loopback without an explicit port, credentials, paths, queries, fragments, and non-origin forms are rejected before any credentialed request can be constructed. This keeps local proof injection without allowing an environment misconfiguration to forward Bearer tokens or GitHub App JWTs to another origin.

Production evidence

Measured live payload before the change:

{"status":"degraded","queued_runs":17,"queued_over_threshold":16,"oldest_queued_minutes":41086} — 28.5 days.

The zombie population was verified with gh run list --status queued --limit 100: runs 29219675461, 29219804812 (Jul 13), 29591086714 (Jul 17), plus 14 runs created 2026-08-07T09:08-09:09. All 17 returned HTTP 500 from both POST .../runs/{id}/cancel and POST .../runs/{id}/force-cancel.

GitHub fetch coverage

All six hardcoded dashboard fetch sites now use the shared validated origin:

  • dashboard/worker.ts: webhook token REST helper, status REST helper, status GraphQL helper (/graphql remains correct), and GitHub App REST helper.
  • dashboard/exact-review-queue.ts: token REST helper and GitHub App REST helper.

Accepted configured origins are exactly https://api.github.com, http://127.0.0.1:<port>, or http://localhost:<port>.

pr-behavior-proof

Claim: The real dashboard Worker surfaces a queued run older than 24 hours without letting it degrade queue health, while an additional 31-minute queued run still degrades health exactly as before. The unset binding retains the production GitHub origin, and configured remote HTTPS overrides are rejected before credentials can be forwarded.

Exercised surface: Real wrangler dev --local, real /api/status HTTP requests, real loopback HTTP GitHub REST dependency, production operational-health summary, production dashboard-health reason derivation, and the shared GitHub API origin validator.

Scenario/fixture: Three fresh Worker boots with full process-group shutdown between boots: zombie-only, zombie plus a 31-minute queued run, and GITHUB_API_URL unset. Each boot uses disposable Wrangler persistence. The first two use a Node HTTP stub that implements the GitHub REST shapes consumed by /api/status; the third sends no GitHub credential. Focused unit coverage exercises the accepted production origin, rejected arbitrary HTTPS and alternate-port GitHub origins, accepted explicit-port loopback origins, rejected portless loopback origins, and the unset default.

Command/environment: Node 24, pinned Wrangler 4.107.0, docs/proof/operational-health-zombie-runs/run-proof.sh. Reviewed head fe4b9e226a021b06dcf25917a62c4b0d876b48b1; source-tree SHA-256 c4a8005d8ad7b65d8c10947ff2caaf66434a6a2c2c8524402d0310d0661157f2.

Observable result: Local PROOF_RC=0, 21 assertions. Zombie-only returned healthy, queued_runs: 1, zombie_queued_runs: 1, queued_over_threshold: 0, oldest_queued_minutes: 0, oldest_zombie_queued_minutes: 1500, and no workflow_execution_degraded reason. Adding the 31-minute run returned degraded, queued_runs: 2, zombie_queued_runs: 1, queued_over_threshold: 1, oldest_queued_minutes: 31, and added workflow_execution_degraded. With the override unset and no credentials, the retained payload carried unauthenticated public-GitHub HTTP 403 diagnostics.

Artifacts/trace: The proof writes proof-summary.json, all three /api/status payloads, GitHub request JSONL traces, and bounded Wrangler/stub logs under .artifacts/operational-health-zombie-runs/.

Limits: The stub does not emulate authentication, GraphQL, rate limiting, cancellation, or the production scheduler. Unit tests cover URL validation and the exact 24-hour boundary. External HTTPS overrides are rejected by design; only the production GitHub origin and explicit-port HTTP loopback proof origins are supported. The production population and cancel/force-cancel failures above are coordinator measurements, not repeated by this proof.

Validation

  • pnpm run build:all — pass
  • pnpm run test:no-build — pass (3275 tests, 3266 passed, 9 skipped, 0 failed/cancelled)
  • pnpm run lint — pass
  • pnpm run format:check — pass
  • pnpm run check:dashboard-queue-boundary — pass
  • Pre-commit and final committed-branch Codex autoreview — clean, no accepted/actionable findings

OpenClaw Bay impact

No Bay contract or implementation change is needed. Bay remains a public, indexable, observer-only projection and gains no queue, workflow, GitHub, DLQ, recovery, deploy, or rollback action. The security repair changes only outbound dashboard GitHub origin validation; the zombie-run change affects only the dashboard status payload and the existing derived workflow_execution_degraded reason.

Container proof

The unchanged proof passed from a clean GitHub PR checkout through Docker-backed Crabbox after the security fix was pushed:

  • Invocation: explicit --provider local-container, --fresh-pr openclaw/clawsweeper#1101, --no-hydrate, image node:24-bookworm, and Crabbox --script transport. Corepack was enabled into $HOME/.local/bin for the unprivileged lease user.
  • Actual provider/runtime: local-container, Docker-backed Node 24 Bookworm.
  • Lease: cbx_285108492329 (crimson-barnacle), stopped automatically after the run.
  • Reviewed head: fe4b9e226a021b06dcf25917a62c4b0d876b48b1.
  • Verbatim result: PROOF_RC=0; Crabbox exitCode: 0, runStatus: succeeded; 21 proof assertions.
  • Timing: sync 9.982s, command 16.780s, total 26.762s.

@clawsweeper

clawsweeper Bot commented Aug 10, 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: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 12:34 PM ET / 16:34 UTC.

ClawSweeper review

What this changes

The PR separates queued workflow runs older than 24 hours from active queue-pressure health while reporting them as zombies, and routes dashboard GitHub requests through a validated origin helper.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal landing review: current main still lacks this behavior, and the prior credential-forwarding finding is resolved by the strict origin allowlist.

Priority: P1
Reviewed head: fe4b9e226a021b06dcf25917a62c4b0d876b48b1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong current-head behavior proof and a focused security repair support normal merge review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides current-head Docker-backed Worker proof with real HTTP requests, observed after-fix status payloads, and an explicit 21-assertion result.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides current-head Docker-backed Worker proof with real HTTP requests, observed after-fix status payloads, and an explicit 21-assertion result.
Evidence reviewed 6 items Current main still needs the change: Current main counts every valid queued age toward queue-pressure metrics and has no zombie-run fields, so it does not yet solve the reported health signal.
Health classification is bounded and tested: The PR classifies only runs older than 24 hours as zombies, retains the exact 24-hour boundary as live pressure, and reports separate zombie counters.
Credentialed origin override is restricted: The shared helper accepts only the exact production GitHub origin or explicit-port localhost/127.0.0.1 HTTP origins, rejecting credentials, paths, queries, fragments, alternate ports, and arbitrary hosts before requests are built.
Findings None None.
Security None None.

How this fits together

The dashboard Worker reads GitHub workflow runs, summarizes operational health, and exposes that status through its API and dashboard. The change alters queue-age classification and the origin used for authenticated GitHub REST and GraphQL requests.

flowchart LR
  A[GitHub workflow runs] --> B[Dashboard Worker]
  B --> C[Operational health summary]
  C --> D[Zombie run classification]
  D --> E[Status API payload]
  E --> F[Dashboard health reason]
  B --> G[Validated GitHub API origin]
Loading

Before merge

  • Resolve merge risk (P1) - This cross-cutting helper governs authenticated GitHub App and bearer-token requests, so its strict production-or-loopback allowlist must remain intact when the PR lands.
  • Complete next step (P2) - No repair lane is needed: the current branch already contains the resolved security fix and no actionable review finding remains.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Change size 11 files; production +194/-48, tests +86/-3, proof/docs +396 The production change is cross-cutting because one validator is threaded through all dashboard GitHub request paths, with focused regression and real-behavior proof.

Merge-risk options

Maintainer options:

  1. Retain the strict origin boundary (recommended)
    Land only with the exact production-origin and explicit-port loopback allowlist so credentialed requests cannot be redirected to arbitrary hosts.
  2. Pause if broader override support is needed
    Treat any request to allow additional remote origins as a separate security design decision with credential-forwarding proof.

Technical review

Best possible solution:

Land the focused health correction while preserving the strict origin validator and its boundary coverage.

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

Yes. The PR documents the observed production stale-queue payload, and current main source still counts every queued age toward degradation; the controlled Worker proof then verifies the corrected cases.

Is this the best way to solve the issue?

Yes. Separating unremediable runs from active queue pressure while keeping them visible is the narrowest repair, and the validated helper preserves the default GitHub origin without opening credentialed redirects.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Operational-health classification affects the live workflow signal used to detect degraded execution.
  • merge-risk: 🚨 security-boundary: The patch changes the origin used by requests carrying GitHub App JWTs and bearer tokens, albeit behind a strict allowlist.
  • 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 (live_output): The PR body provides current-head Docker-backed Worker proof with real HTTP requests, observed after-fix status payloads, and an explicit 21-assertion result.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides current-head Docker-backed Worker proof with real HTTP requests, observed after-fix status payloads, and an explicit 21-assertion result.

Evidence

What I checked:

  • Current main still needs the change: Current main counts every valid queued age toward queue-pressure metrics and has no zombie-run fields, so it does not yet solve the reported health signal. (dashboard/operational-health.ts:94, cd4892391195)
  • Health classification is bounded and tested: The PR classifies only runs older than 24 hours as zombies, retains the exact 24-hour boundary as live pressure, and reports separate zombie counters. (dashboard/operational-health.ts:97, fe4b9e226a02)
  • Credentialed origin override is restricted: The shared helper accepts only the exact production GitHub origin or explicit-port localhost/127.0.0.1 HTTP origins, rejecting credentials, paths, queries, fragments, alternate ports, and arbitrary hosts before requests are built. (dashboard/github-api.ts:6, fe4b9e226a02)
  • Prior finding repair provenance: The prior reviewed head was followed by a focused security commit; its diff changes only the origin helper, its tests, and proof documentation. (dashboard/github-api.ts:1, fe4b9e226a02)
  • Real behavior proof: The PR body records a Docker-backed Crabbox local-container run at the reviewed head with 21 passing assertions across zombie-only, fresh-backlog, and unset-origin scenarios. (docs/proof/operational-health-zombie-runs/run-proof.mjs:25, fe4b9e226a02)
  • Feature history: History shows Peter Steinberger as the primary recent contributor across the health, Worker, and exact-review queue surfaces; Martin Cleary most recently changed the queue on current main. (dashboard/exact-review-queue.ts:1, cd4892391195)

Likely related people:

  • steipete: Peter Steinberger authored this PR and has the strongest recent history across the operational-health, Worker, and exact-review queue paths. (role: feature introducer and recent area contributor; confidence: high; commits: 561b37833eb5, 80847d16452c, dc6fc0b4a479; files: dashboard/operational-health.ts, dashboard/worker.ts, dashboard/exact-review-queue.ts)
  • Martin Cleary: Current main’s latest queue change substantially updates the exact-review queue adjacent to this PR’s shared request helper. (role: recent area contributor; confidence: medium; commits: cd4892391195, 50f90eac14f7; files: dashboard/exact-review-queue.ts)

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-10T16:15:43.174Z sha 3ae6634 :: needs changes before merge. :: [P1] Restrict API override origins before forwarding credentials

@clawsweeper clawsweeper Bot added 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. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 10, 2026
@steipete
steipete merged commit 35b5f62 into main Aug 10, 2026
19 checks passed
@steipete
steipete deleted the steipete/operational-health-zombie-runs branch August 10, 2026 16:45
steipete added a commit that referenced this pull request Aug 12, 2026
…ns (#1131)

GitHub-side stuck-queued workflow runs have now caused two production
incidents: fourteen runs from one Aug-7 window became permanent backend
zombies (both cancel APIs return HTTP 500; excluded from health by #1101's
ceiling), and six runs from one window tonight sat queued for three hours
while their items cycled as oldest-dispatching -- degrading operational
health and flapping handoff until manual cancellation cleared everything
within minutes.

That proven manual playbook is now a bounded remediation stage in the
scheduled reconcile lane, replacing the old hourly 24-hour janitor. Selection
is strict: queued over 90 minutes AND at least three later runs of the same
workflow already started (capacity provably existed -- a global crunch can
never trigger it), oldest-first, max 8 workflows inspected and 10
cancellations per pass. Per review, discovery is deadline-bounded at
min(start+120s, shared deadline minus 480s), reserving eight minutes so the
dead-letter reconciliation stages can never be starved; a stubbed
20-second-per-call provider across 20 workflows stops after one request with
full headroom retained. Regular cancel first, force-cancel on 500, 500-500
persists the run as a permanent zombie that is never retried. Cancelled runs
re-dispatch through the queue's existing retry machinery -- the mechanism
tonight's recovery proved.

Proof: the production script driven against a loopback GitHub API cancels
exactly the demonstrably-stranded run, leaves the young run untouched, and
persists the double-500 zombie with idempotent replay; verified in a
Docker-backed Crabbox local-container on the final head with committed
receipt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. 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