workflows: stuck-run-triage — read-only triage for a Cloud run that will not finish
Tonight seven Software Garden runs sat in RUNNING for four hours while a sibling failed relayfile ACL provisioning exceeded 45000ms. Answering "why" meant hand-gathering evidence from three places; this makes that repeatable.
flows run workflows/stuck-run-triage.flow.ts --local-agent --input '{"runIds":["c649fe14","8d864d39"],"listenerId":"28a6d9ec-…"}'
- Three deterministic, journaled steps collect the run records (Cloud API), the sandboxes (
daytona sandbox list/info) and the edge (wrangler deployments list,queues list,tail --search <runId>) intotriage/. - Two agents read that evidence in parallel — sandbox forensics (is anything still executing, what does the run's own journal say, is a mount daemon wedged) and edge forensics (what Cloud thinks, whether a lease or timeout will ever end the run) — and a third writes
triage/verdict.mdwith the root cause, whether the runs are immortal, and the defects worth a PR. - Read-only by construction: the shell steps only list/inspect/tail, the agents are told to change nothing, and the flow ends
needs_human. It never "fixes" production.
Local-only for now: wrangler and daytona must be authenticated as you, and Cloud does not bundle those credentials into a sandbox — noted in the README row.
🤖 Generated with Claude Code
[!NOTE]
Medium Risk
New operational workflow reads production Cloud credentials and APIs (mitigated by read-only steps, origin allowlist, and untrusted-evidence agent prompts); CI-only root symlink change.
Overview
Adds workflows/stuck-run-triage.flow.ts, a local flows v2 workflow for read-only incident triage when Cloud runs stay stuck: journaled shell steps pull run records (Cloud API with allowlisted apiUrl), Daytona sandbox context, and Cloudflare edge evidence (wrangler with explicit Worker names, concurrent tails, portable watchdog), then three read-only agents produce triage/verdict.md and the flow ends needs_human.
Input handling is fail-closed: full run ids only (no prefix lookup), whole-batch rejection on bad ids, caps on batch size and runIds × workers fan-out, duplicate detection, and safe curl writes via a temp file so 404s do not leave empty run JSON.
Adds packages/sdk/tests/stuck-run-triage.test.ts to drive the flow body through a recording context and pin validation, shell text, macOS timeout fallback, and agent prompts. CI symlinks @relayflows/surface at the repo root so root-level workflows/*.flow.ts imports resolve during SDK tests. workflows/README.md documents the new workflow.
Reviewed by Cursor Bugbot for commit 53b1bf3ff3853848ca1d7abcd4376263de10fe51. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Adds workflows/stuck-run-triage.flow.ts, a read-only local flow that answers why a Cloud run will not finish. It replaces manual evidence-gathering with a repeatable triage that never modifies production.
- Gathers run records,
daytonasandbox state, andwrangleredge logs intotriage/; two agents analyze them and a third writestriage/verdict.md. - Requires full Cloud run ids, at most eight per batch; malformed or duplicate ids or worker names fail the whole batch, as does any fan-out over 16 concurrent tails.
- Restricts
apiUrlto production Cloud or loopback, saves run records only after successful fetches, and treats evidence as untrusted before endingneeds_human. - Adds
packages/sdk/tests/stuck-run-triage.test.tsand links the local@relayflows/surfaceat the repo root in CI so that test can load the workflow. - Needs local
wrangler,daytona, and Cloud auth.