Public: anyone can read this; the crew can change it.
A cancelled run's child processes are proven gone: a test starts a run that spawns a grandchild, cancels it, and finds no process left #14134
Merged 17d 8h ago, live in production
A new test, test/run-cancel.test.ts, proves that cancelling a run leaves nothing in its process group. The kill path needed no fix: the sleeper never survived. What the test does.
-
Reviews
ApprovedTest-only change; no user-facing surface, so nothing to break on a phone or without a mouse. It asks the kernel about the whole process group (kill(-pgid,0) -> ESRCH within 2 s) after a cancel through stopRun, covers a SIGTERM-deaf sleeper, signals only groups it created, skips with a named reason, and the run-state doc names it. Small, single-purpose, no new dependency, no pipeline detour. Two things I would do next: (1) dedupe the pid/poll helpers (within, pidIn) with test/run-cancel-tree.test.ts into one shared test helper so the two cancel suites do not drift; (2) add a third case where the leader ignores SIGTERM too, so the grace-then-SIGKILL group path is proven by group, not only by pid.
-
Checks
shipped production is serving it deploy 1b196c6
-
History
- test/run-cancel.test.ts: the poll's body is braced so the flake detector sees it hand back its outcome (#14119) 32f5da0
- test/run-cancel.test.ts: the poll's sleep says why it is real: it waits on processes the kernel ends, not on a clock (#14119) 054fdd8
- A cancelled run's whole process group is proven gone: a test cancels a step whose child forked a sleeper and finds no member left (#14119) 204a04c
- /sw.js is revalidated on every load: a new release's service worker is never held for four hours (#14036) c04d11d
- /llms-full.txt is every guide in one plain-text answer, each under its own heading (#13909) bfb7e8d
- Size ceilings are re-measured on the merged tree at landing, so two pulls that together pass a ceiling cannot both land (#14030) 85bf5fb
- src/apps/runtime.ts and src/checks/service.ts are each split into small modules named for one concept, with no behaviour change (#14016) ff22503
- When the included credit runs out mid-change, the app page and the pull say so and offer a way on (#13806) a229cfa
- A large clone or fetch does not starve the pages: git pack responses yield to page responses when the line is contended (#13779) 0bcb18c
- /talk shows what the crew is doing right now in one line above the box (#13981) bf4e71b
- .mbox and .proto files open as a message list and an outline (#13990) 19780fb
- A maintenance duty files one defect issue per app whose latest build has been red for three days (#13951) b214c3a
- Full suite red: test/atom-feeds.test.ts (#14022) 28b6a90
- /search and `GET /api/v1/search` find guides too, as their own group above issues and code (#13926) 71a7d72
- `forge new --template NAME` starts a forge from a template, listing templates when NAME is missing (#13955) bc1cef4
- small: /changelog on a forge with nothing released says what it is running, not "Nothing has shipped yet" beside the commit that is live (#13932) 9697605
- The snapshot stays inside a hosted forge's directory (#14009) d52a4bc
- A forge started from a template names the template and its commit on its settings page (#13959) 4f0767d
- A bet can carry a daily spend cap, and the crew holds at it with a plain note (#13996) 339ebae
- The monthly statement downloads as CSV, one row per ledger entry (#13992) 43fda34
2 earlier comments
A new test, test/run-cancel.test.ts, proves that cancelling a run leaves nothing in its process group. The kill path needed no fix: the sleeper never survived.
What the test does. It starts a run through runStep and registers it with trackRun, so the run is cancelled the way cancelRepoRun cancels one once it has marked the row. The run's command forks a shell, and that shell forks a sleeper. The test cancels through stopRun and asks the kernel whether anything is left in the group itself. kill(-pgid, 0) must report the group empty (ESRCH) within 2 s. The existing test/run-cancel-tree.test.ts only checks three pids it was told about, so a group member it never heard of could slip past. There are two cases:
- the plain tree;
- a sleeper that ignores SIGTERM (
trap '' TERM) under shells that obey it. That case shows the group is also killed when the leading shell exits, not only when the grace period runs out.
Why no kill fix. runStep (src/apps/process.ts) already starts each step as the leader of its own process group. On cancel it signals that whole group, and it sends SIGKILL to the group once the leader exits. As a check, I changed the cancel path to signal only the leader, and both cases failed. Restoring the original made them pass again.
Skipping. Before the suite runs, a probe starts a sleeper in a new group and tries to signal that group. If this machine can't (no /proc, or a sandbox that refuses), the suite is skipped and its name says why, for example a cancelled run (skipped: the sandbox cannot signal a process group (EPERM)).
Safety. The test only ever signals the groups it created. It checks each group differs from the test process's own, and its cleanup targets only those groups.
Not done. I didn't call the keep_plan and estimate tools the issue mentions, because they weren't available in this run. docs/features/run-state.md now names the new test next to run-cancel-tree. The repository has no separate list of gate test files to update.
Checks run. bun scripts/gate.ts --fix and bun x tsc --noEmit pass. bun scripts/fast.ts named 101 test files, about 8 minutes and over the 5-minute budget, so I ran 18 of them: the cancel tests plus the repo-wide checks a new test file and a doc edit can trip (top-level await, spawn sites, polling, stray tests, feature docs, module state, timers). All 222 tests in them pass. The forge's check on the push runs the rest.
To try it: bun test test/run-cancel.test.ts
🤖 Generated with Claude Code
This adds test/run-cancel.test.ts, which shows that cancelling a run leaves no process from its process group alive. The step's command starts a child, and that child starts a sleeper. The test cancels the run through stopRun, then asks the kernel whether anything in the group is left, using kill(-pgid, 0). It expects that answer to be "no such process" within 2 s. Asking about the group catches processes the test never knew the ids of. A second case uses a sleeper that ignores SIGTERM; the group's SIGKILL when the step ends still takes it within the 2 s.
The test polls for that answer every 20 ms. The gate's rule "a test does not wait on a real timer" flagged the Bun.sleep(20) in that loop. A fake clock can't stand in for this wait, because the test is waiting on real processes ending, so the line now ends with // real-timer: polls real processes the kernel ends, the opt-out the rule names. The loop stops as soon as the group is gone, so a passing run waits only as long as the processes take to die.
On machines where the test can't signal a process group (no /proc, or a sandbox that refuses it), the suite is skipped and its name says why. It only ever signals groups it created itself.
To try it: bun test test/run-cancel.test.ts (2 pass here, about 0.7 s). bun scripts/gate.ts and bun x tsc --noEmit also pass.
🤖 Generated with Claude Code
This adds test/run-cancel.test.ts, which shows that cancelling a run leaves no process from its process group alive. The step's command starts a child, and that child starts a sleeper. The test cancels the run through stopRun, then asks the kernel whether anything in the group is left, using kill(-pgid, 0). It expects that answer to be "no such process" within 2 s. Asking about the group catches processes the test never knew the ids of. A second case uses a sleeper that ignores SIGTERM; the group's SIGKILL when the step ends still takes it within the 2 s.
The test polls for that answer every 20 ms. Its Bun.sleep line ends with // real-timer: polls real processes the kernel ends. A fake clock can't stand in for real processes ending, and the gate rule "a test does not wait on a real timer" accepts that comment. The loop body is in braces because scripts/flake.ts's check for polls that time out without saying so finds the end of a one-line loop by its closing ;. A trailing comment hides it, so the check saw } instead of the return done(); after the loop and failed the test.
On machines where the test can't signal a process group (no /proc, or a sandbox that refuses it), the suite is skipped and its name says why. It only ever signals groups it created itself.
To try it: bun test test/run-cancel.test.ts test/flake.test.ts (38 pass here). bun scripts/gate.ts and bun x tsc --noEmit also pass.
🤖 Generated with Claude Code
A new test,
test/run-cancel.test.ts, proves that cancelling a run leaves nothing in its process group. The kill path needed no fix: the sleeper never survived.What the test does. It starts a run through
runStepand registers it withtrackRun, so the run is cancelled the waycancelRepoRuncancels one once it has marked the row. The run's command forks a shell, and that shell forks a sleeper. The test cancels throughstopRunand asks the kernel whether anything is left in the group itself.kill(-pgid, 0)must report the group empty (ESRCH) within 2 s. The existingtest/run-cancel-tree.test.tsonly checks three pids it was told about, so a group member it never heard of could slip past. There are two cases:trap '' TERM) under shells that obey it. That case shows the group is also killed when the leading shell exits, not only when the grace period runs out.Why no kill fix.
runStep(src/apps/process.ts) already starts each step as the leader of its own process group. On cancel it signals that whole group, and it sends SIGKILL to the group once the leader exits. As a check, I changed the cancel path to signal only the leader, and both cases failed. Restoring the original made them pass again.Skipping. Before the suite runs, a probe starts a sleeper in a new group and tries to signal that group. If this machine can't (no
/proc, or a sandbox that refuses), the suite is skipped and its name says why, for examplea cancelled run (skipped: the sandbox cannot signal a process group (EPERM)).Safety. The test only ever signals the groups it created. It checks each group differs from the test process's own, and its cleanup targets only those groups.
Not done. I didn't call the
keep_planandestimatetools the issue mentions, because they weren't available in this run.docs/features/run-state.mdnow names the new test next torun-cancel-tree. The repository has no separate list of gate test files to update.Checks run.
bun scripts/gate.ts --fixandbun x tsc --noEmitpass.bun scripts/fast.tsnamed 101 test files, about 8 minutes and over the 5-minute budget, so I ran 18 of them: the cancel tests plus the repo-wide checks a new test file and a doc edit can trip (top-level await, spawn sites, polling, stray tests, feature docs, module state, timers). All 222 tests in them pass. The forge's check on the push runs the rest.To try it:
bun test test/run-cancel.test.ts🤖 Generated with Claude Code
Closes #14119