A run's state is worked out from what it did (#8707)
One function: runState (src/runs/state.ts) names a run waiting, working, needs input, failed, done or silent from its row, its last sign of life and its plan — never from anything the run says about itself. The runs API rows carry it as shown; the runs tab and home badges read it.
Silent: a running agent run with no log line and no plan update for 10 minutes. One silent flow alarm names the one silent longest (home, /boards, the notifier). Signs of life are kept in memory (runs/activity.ts); a run started before this process booted is measured from its start. Because the signs are in this process's memory only, during a roll a run that is logging to the other process, or one logging from before a restart, can read silent falsely; the alarm is then a prompt to look, not a verdict.
Stopped by a person (#13457): a run someone cancels from its page reads Stopped by alice, 2 minutes ago — one sentence (stoppedWords, src/runs/cancelled.ts) on the run page, its feed row (kept a post, never folded as a quiet run) and the terminal's run log — in the quiet colour, never red. A run that ended on its own first keeps its real end.
Repeat stop: more than 3 agent runs on one issue in 10 minutes, whatever each said (crew/repeat.ts), parks the issue with one note and raises one repeat alarm; nothing starts until a person who directs the crew speaks.
Plan: a run keeps up to 12 checklist items on its issue, replaced whole each time: PUT /api/v1/repos/:owner/:name/issues/:number/plan{ items: [{ text, done? }], ask? }, the MCP tool keep_plan, shown on the issue page and in GET …/issues/:number as plan. ask marks the run needs input until the next update. Only the agent with a run going on that issue may set its plan (a writer's or another run's call is refused, forbidden). Not an event: it is progress, like a log.
Runs tab count is runningCount: running agent runs and checks, the sum of the pipeline's building, review and checking stages.
GET …/runs?state=queued|running|ok|failed|cancelled filters; an unknown state is a 422.
In the terminal: the issue screen (src/tui/screens/issue.ts, rows from src/tui/screens/runplan.ts) shows a Plan card above the thread — [x]/[ ] items and the question as needs input: … — read through the same readPlan (so gated as the page is), and its title says silent or needs input when the issue's runs read that way, from shownStates.
The runs API works out shown for a page of runs with one plan read (shownStates), not one per row.
Stopping: a cancel marks the row at once, but the run's page says stopping (a moving word, filed under working) until its worker here has ended every process the run started — SIGTERM to the group, SIGKILL once the grace runs out, an agent's orphans reaped — and only then cancelled; the cancel's one run.finished is announced at that moment, not before (src/runs/ending.ts, #13291; test/run-cancel-stopping.test.ts cancels a check whose stand-in step holds on after the abort, and finds the word stopping and no run.finished until the step lets go, then cancelled and the one run.finished after). That none of the processes is left is test/run-cancel-tree.test.ts's: a cancelled check's command, the child it forked and that child's child are all gone within 2 s, and a step and the sleeper it forked that both ignore SIGTERM are killed once the grace runs out. That the whole process group is empty, asked of the kernel and not pid by pid, is test/run-cancel.test.ts's (#14119): a cancelled step whose child forked a sleeper leaves no member of its group within 2 s, a sleeper deaf to SIGTERM included, and where the sandbox cannot signal a group the suite is skipped under a name that says why. A worker that never lets go is announced at the 30 s deadline (ENDING_DEADLINE_MS) while the page still says stopping; when it lets go later, a run.stopped wake-up (not a second run.finished) turns the live head to cancelled.