Repository navigation
fix: exclude zombie runs from operational health - #1101
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 12:34 PM ET / 16:34 UTC. ClawSweeper reviewWhat this changesThe 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 readinessKeep 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 Review scores
Verification
How this fits togetherThe 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]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…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.
Summary
queued_runs, reportzombie_queued_runsandoldest_zombie_queued_minutes, but exclude them fromqueued_over_threshold,oldest_queued_minutes, and degraded/stalled computation.waitingruns were already outside degraded computation and remain unchanged.GITHUB_API_URLWorker binding across every dashboard GitHub REST and GraphQL fetch site. Production behavior is unchanged by default and still uses the byte-identical originhttps://api.github.comwhen unset.Security repair
The accepted P1 review finding is fixed at
fe4b9e226a021b06dcf25917a62c4b0d876b48b1. A configuredGITHUB_API_URLmay now be only the exact production originhttps://api.github.comor an explicit-port loopback HTTP origin on127.0.0.1/localhost. Arbitrary HTTPS origins, alternate ports onapi.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 bothPOST .../runs/{id}/cancelandPOST .../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 (/graphqlremains 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>, orhttp://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/statusHTTP 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_URLunset. 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 headfe4b9e226a021b06dcf25917a62c4b0d876b48b1; source-tree SHA-256c4a8005d8ad7b65d8c10947ff2caaf66434a6a2c2c8524402d0310d0661157f2.Observable result: Local
PROOF_RC=0, 21 assertions. Zombie-only returnedhealthy,queued_runs: 1,zombie_queued_runs: 1,queued_over_threshold: 0,oldest_queued_minutes: 0,oldest_zombie_queued_minutes: 1500, and noworkflow_execution_degradedreason. Adding the 31-minute run returneddegraded,queued_runs: 2,zombie_queued_runs: 1,queued_over_threshold: 1,oldest_queued_minutes: 31, and addedworkflow_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/statuspayloads, 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— passpnpm run test:no-build— pass (3275tests,3266passed,9skipped,0failed/cancelled)pnpm run lint— passpnpm run format:check— passpnpm run check:dashboard-queue-boundary— passOpenClaw 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_degradedreason.Container proof
The unchanged proof passed from a clean GitHub PR checkout through Docker-backed Crabbox after the security fix was pushed:
--provider local-container,--fresh-pr openclaw/clawsweeper#1101,--no-hydrate, imagenode:24-bookworm, and Crabbox--scripttransport. Corepack was enabled into$HOME/.local/binfor the unprivileged lease user.local-container, Docker-backed Node 24 Bookworm.cbx_285108492329(crimson-barnacle), stopped automatically after the run.fe4b9e226a021b06dcf25917a62c4b0d876b48b1.PROOF_RC=0; CrabboxexitCode: 0,runStatus: succeeded; 21 proof assertions.