Skip to content

Test runs whose workers start in their own session are no longer killed as stalled (GST-3213) - #4533

Merged
capy-ai[bot] merged 1 commit into
mainfrom
stall-check-counts-own-session-workers
Nov 19, 2026
Merged

capy-ai[bot] merged 1 commit into
mainfrom
stall-check-counts-own-session-workers

Conversation

@garrytan

@garrytan garrytan commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

/ship's test check no longer kills a quiet, working test run as stalled when the test command starts its workers in their own session, as pnpm 11's pnpm exec does for Vitest.
Why: the stall check read CPU time from the command's process group only, where just the idle launcher was left; it now counts every process descended from the command.
Nothing to do: a truly hung run is still killed at the same stall timeout, and every threshold is unchanged.

What changed
  • Stall check counts the whole process tree (the test supervisor): CPU is summed over the command's process group plus every descendant reached by parent links, whatever session or group it moved to. The busy share (a tenth of one CPU), the 1 s sample, the stall timeout and the deadline are unchanged. A descendant reparented away from the tree (a double-forked daemon) no longer counts.
  • Stall and timeout kills reach those workers: SIGTERM, then SIGKILL after the grace period, goes to the group of every tree member, so a worker in its own session is no longer left running after the kill. On main it kept running (and a busy one kept burning CPU) after its runner was killed. After a normal exit only the command's own group is cleaned up, as before. The kill never signals pid 1's group, gstack's own process or its own group.
  • Wording: the PREGATE_STALLED detail, the guard line, the result-code summary, docs/pregate.md and docs/troubleshooting.md say "process tree" where they described this check; a changelog fragment.
Proof

On main at 9610ba4, a throwaway repo whose test command starts one worker in a new session, run through /ship's local test check with a 3 s stall timeout:

worker main this branch
busy and silent for 8 s incomplete in 3.4 s, PREGATE_STALLED, worker still running afterwards pass in 8.4 s, exit 0
idle forever (a real hang) incomplete in 3.4 s, PREGATE_STALLED, worker still running afterwards incomplete in 3.2 s, PREGATE_STALLED, worker gone

New tests in the supervisor's test file (three of them fail on main and pass here): a busy own-session worker runs to the end; a worker that never stops is killed at the deadline with its runner; an idle tree is killed as stalled at the stall timeout, worker included; and a pure test of which processes make up the tree.

Security notes

This changes which processes gstack signals. The added targets are only process groups of descendants of the test command gstack itself launched, found through /proc (Linux) or ps -A -S -o pid=,ppid=,pgid=,time= (macOS and other BSDs; the same ps call as before with three more columns). No network, secrets, workflows, install scripts or dependencies are touched. Windows is unchanged (taskkill /T /F).

Why

pnpm 11 starts Vitest's workers in their own session, so the old check saw only an idle launcher and killed a run that was still working, which made /ship's local test check unusable on such projects (reported in #4477). A run that really hangs still fails at the same stall timeout.

Blast radius

Only /ship's local test check and its housekeeping checks run through this supervisor (lib/pregate/supervise.ts, called from lib/pregate/checks/lanes.ts and guards.ts); CI's shard runner does not. The new kill targets are limited to process groups of descendants of the command gstack itself started, and never pid 1's group or gstack's own (read at killTree, exercised by the new tests).

Test Coverage

Four new tests in test/pregate-supervise.test.ts were written before /ship ran; the coverage audit added none. Coverage: 75% of changed code paths (9 of 12). The three uncovered paths are the macOS ps fallback (needs real macOS output), the pid-1 and own-group guard in killTree (testing it would signal real groups inside the test runner) and SIGKILL escalation to an own-session worker that ignores SIGTERM.

Pre-Landing Review

No blocking issues found. Five readers ran on the whole diff: a combined testing, security and state-machine reader, an attack-focused reader, a Claude adversarial reader and a second-model review (GPT-6.1 Sol), which returned clean. The Claude adversarial reader raised five low-severity notes, listed below; none is fixed in this PR.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL lib/pregate/supervise.ts:243 Stale group ids from the SIGTERM snapshot get the SIGKILL 5 s later; a reused pid could be a new unrelated group of the same user
  • INFORMATIONAL lib/pregate/supervise.ts:250 After a normal exit only the runner's group is killed, so an own-session worker can outlive the check (same as main; documented)
  • INFORMATIONAL lib/pregate/supervise.ts:265 A busy own-session helper parented to a hung test keeps the run alive until --timeout instead of the stall timeout (documented trade-off)
  • INFORMATIONAL lib/pregate/supervise.ts:242 A worker that starts a new session after the SIGTERM snapshot and whose parent dies before the SIGKILL snapshot escapes the kill
  • INFORMATIONAL lib/pregate/supervise.ts:82 cancelActive runs killTree per active run in the signal handler; on macOS each runs ps synchronously with a 15 s timeout
Exploratory QA

No separate probe ran. The smoke evidence is bun test test/pregate-supervise.test.ts at the reviewed tree (22 pass, 0 fail, run by the coverage and adversarial readers), which covers one success (a busy own-session worker runs to the end) and the riskiest edges (an idle tree killed as stalled with its worker; a runaway worker killed at the deadline). The before/after repro is in Proof above.

Eval Results

No prompt-related files changed, so evals were skipped.

TODOS

No TODO items completed in this PR.

Documentation

Scope: the stall-check change (process tree instead of process group) on branch stall-check-counts-own-session-workers, base 9610ba4 to head a9e4718. Result: docs/pregate.md and docs/troubleshooting.md and the PREGATE_STALLED summary already describe the process-tree behavior, including the kill semantics, and a changelog fragment exists. A grep of README.md, CLAUDE.md, docs/ship-policy.md, docs/unattended.md and docs/TESTING_INTERNALS.md found no stale mention. No edits made. Debt: none found.

Tests
  • bun test test/pregate-supervise.test.ts test/spawnsync-timeout-tripwire.test.ts test/ship-publication-gates.test.ts: 33 pass
  • bun run typecheck: clean
  • CI free suite at this tree (run 44565670131): 1712 files, green; macOS and Windows jobs green (runs 44565670131, 44565670154)
Agent notes

Bug fix (no plan review), rewritten on current main from the stall fix in #4477 by @dtoelke (credited with a Co-authored-by trailer); nothing else from #4477 is included. The brief pointed at scripts/lib/shard-engine.ts, which has only a wall-clock timeout; the stall check is lib/pregate/supervise.ts (gstack-pregate's lanes and guards), with its tests in test/pregate-supervise.test.ts. Decision trail: reports/GSTA-658-decisions.tsv in the controller drive.

Approvals

No approvals recorded for branch stall-check-counts-own-session-workers.
Plan: exempt: bug fix (no plan review; repro on main and failing-first tests in the PR)
Plan check: exempt bug fix

REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=5 fixed=0 scope=frozen dispatches=4
Gate edits: none detected (3 listed, 1 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

{
  "schema_version": 1,
  "pr": 4533,
  "head": "a9e471811246ed0e3f0cbaceade376475c9ebb4b",
  "version": "1.101.0.0",
  "base": "main",
  "gate": {
    "free": {
      "pass": 1712,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "free",
      "run": 44565670131,
      "attempt": 1,
      "tree": "4b3f4a4b34ffd122f9ca3cda1156f7e83244241a"
    }
  ],
  "calls": 18,
  "session_kind": "unattended",
  "run": "ship-4533",
  "head_tree": "4b3f4a4b34ffd122f9ca3cda1156f7e83244241a",
  "product_patch_id": "fc739063e434e4c620bab013623dbbda93d80320",
  "gstack_version": "1.101.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 112,
    "rules": "1afa38a4be3b5eef",
    "base": "9610ba43db3b9c9992eec69e555d94a99d9c807d",
    "registry": "9610ba43db3b9c9992eec69e555d94a99d9c807d",
    "gate_scan": {
      "tagged": 0,
      "head": "a9e471811246ed0e3f0cbaceade376475c9ebb4b"
    },
    "reasons": [
      "gate-class",
      "runtime=112"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @4b3f4a4b34ff (8 checks, current for a9e471811246)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/44565670131/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44565670131/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44565670154/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=4b3f4a4b34ff tests=38342 skipped=90 runs=44565670131/1 profiles=ci-reuse/free-tests heads=a9e471811246 verified=2026-11-19T16:46:27.721Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "README.md, AGENTS.md, CLAUDE.md, CONTRIBUTING.md and docs/ (pregate and troubleshooting pages read for the stall-check change)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 5,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  },
  "gate_dispositions": []
}

Open in Capy

…ed as stalled

The stall check read CPU time from the test command's process group only.
A launcher that starts its workers in a new session (pnpm 11's pnpm exec
running Vitest) left only an idle wrapper in that group, so a quiet suite
that was working got killed as PREGATE_STALLED. The check now counts every
process descended from the command, and a stall or timeout kill reaches
those workers too. A truly hung run is still killed at the same stall
timeout, and the thresholds are unchanged.

Co-authored-by: dtoelke <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai
capy-ai Bot merged commit 50cc282 into main Nov 19, 2026
59 checks passed
@garrytan garrytan mentioned this pull request Nov 19, 2026
capy-ai Bot added a commit that referenced this pull request Nov 19, 2026
- `gstack-artifact validate` no longer passes a run.json that gstack-autoplan never wrote. (#4494)
- /ship's changed-number check no longer stops on tests that only share a word with the change (#4478). (#4496)
- On Capy, /ship no longer edits or comments on pull requests as you. (#4518)
- The destructive-command check stops asking about scratch deletes and catches the real damage it used to miss. (#4513)
- The destructive-command check reads commands more carefully, closing gaps found after the last release. (#4525)
- The Codex readiness check and the second-model review now pick the same model for a custom Codex provider (GST-3089). (#4491)
- gstack's Codex hooks work when your Codex folder's path has a `(`, `&` or other shell character in it. (#4528)
- Uninstalling gstack keeps your own Codex hooks trusted. (#4528)
- Codex hook setup matches Codex more closely. (#4528)
- On Windows, setup copies the Claude Code hook code that gstack's Codex hooks import (#4528)
- /review's checklist on Codex reads shell commands more carefully. (#4528)
- On Codex, gstack now suggests the right skill for a prompt and stops destructive commands before they run. (#4512)
- On Codex, /review is now held once when it tries to finish without its adversarial pass or its report, as it already is on Claude Code. (#4522)
- On Codex, gstack's skill suggestion now names the skill the way Codex lists it. (#4523)
- On Codex, gstack's suggested prompts and docs now name skills the way Codex lists them. (#4524)
- /review on Codex with gpt-6.1-sol is no longer held back for a second-model pass it already ran. (#4526)
- On Codex, office-hours, plan-design-review and gstack-upgrade work again when you name them. (#4510)
- gstack knows when Codex is running unattended. (#4510)
- Codex reviewers start with a clean context. (#4510)
- Docs no longer say Codex has no hook support. (#4510)
- A command whose output was cut off no longer counts as a finished read. (#4492)
- A folder marked as published data can no longer hide source code or agent files from /ship's review. (#4516)
- Correction to the on-by-default helper hooks entry: the hook still routes only to /review, /qa and /verify, so skills you've installed yourself aren't suggested yet. With gstack's skills it routes 14 of 60 real bug reports (was 17), and long prompts are no longer skipped. (#4505)
- /sync-gbrain's read check now works when the first page in your code source is over 64 KB. (#4497)
- Free-suite CI no longer fails before any test runs when Ubuntu's package mirror is slow. (#4530)
- Syncing a second repo no longer makes the first one ask for /sync-gbrain again. (#4532)
- gstack's helper hooks are now on by default in Claude Code, OpenClaw and Hermes, and the prompt-routing hook fires on real bug reports. (#4503)
- `gstack-pregate clear --receipt` accepts a remote gate run from before a merged release when the release only regenerated a declared release output. (#4483)
- The second-model review now keeps the reviewer's own result, and reports a used-up budget as a budget stop. (#4515)
- When the reviewer wrote its review to the result file it was asked for, Codex then replaced that file with its short closing message ("Done, I wrote the review"), so the review was thrown away and reported as missing its markers. (#4515)
- When the provider refuses the call with HTTP 402 Payment Required (usually a metering proxy that hit its allowance, or an account out of credits or quota), gstack used to record only "exit 1". (#4515)
- The pre-commit /verify check now fails a check that times out, and its checks share one time budget (GST-3201). (#4527)
- /ship's review collector no longer reads a reviewer's own scope list or list of passed checks as findings (GST-3201). (#4527)
- Merge-queue stack tests fail when git cannot list a PR's added test files (GST-3201). (#4527)
- /ship can now review results PRs that publish raw session data. (#4511)
- /ship's review pass works when the checkout you ship isn't the project's default checkout. (#4507)
- A second review round no longer reports done when nothing was reviewed. (#4520)
- The prompt-routing hook now suggests skills you install yourself, and no longer sends ordinary bug reports to /qa (GST-3123). (#4506)
- gstack's script runner and merge-queue checks now also refuse cut-off output. (#4502)
- A failed second-model review reports the cause that actually stopped it, and the runner never deletes its own prompt. (#4519)
- `gstack-ship-queue ready` now fills in the trial merges and the second-model trail read instead of printing lines to fill. (#4529)
- Five small ship-tool fixes. (#4529)
- A ruling the owner gives while a `/ship` run is open can be relayed. (#4529)
- /ship no longer kills a working test run as stalled when the test command starts its workers in their own session. (#4533)
- /ship no longer stops a review because the state-machine reader started its reply the way its instructions say. (#4504)
- When Claude Code runs /verify right before a commit, it now gets a quick check instead of the full fix loop (GST-3150). (#4508)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant