Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/gstack-pregate
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const HELP = `gstack-pregate — cheap checks before anything paid or remote (do
--timeout <s> timeout for each runner process (default timeout_s from the base .gstack/pregate.json, else 600):
the unit-file group, each serial file, each guard without timeout_s, the remote gate; the stall
timeout catches a silent one sooner
--stall-timeout <s> kill a test command's process group after this long with no output and record the check
--stall-timeout <s> kill a test command's process tree after this long with no output and record the check
incomplete (PREGATE_STALLED); default stall_timeout_s from the base .gstack/pregate.json,
else ${DEFAULT_STALL_TIMEOUT_S}; 0 disables; the --remote gate is exempt (only --timeout bounds it)
--remote run the base branch's remote_gate now instead of local tests (needs --allow-repo-commands;
Expand Down Expand Up @@ -202,7 +202,7 @@ async function cmdRun(root: string, rest: string[], json: boolean): Promise<numb
for (const signal of ['SIGINT', 'SIGTERM'] as const) {
process.once(signal, () => {
const killed = cancelActive();
process.stderr.write(`gstack-pregate: cancelled by ${signal}; killed ${killed} test process group(s); no pregate.json written\n`);
process.stderr.write(`gstack-pregate: cancelled by ${signal}; killed ${killed} test process tree(s); no pregate.json written\n`);
process.exit(signal === 'SIGINT' ? 130 : 143);
});
}
Expand Down
1 change: 1 addition & 0 deletions changelog.d/stall-guard-counts-worker-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **/ship no longer kills a working test run as stalled when the test command starts its workers in their own session.** The stall check measured CPU in the test command's process group only, so under pnpm 11, where `pnpm exec` starts Vitest in a new session, a quiet suite that was busy read as idle and ended `PREGATE_STALLED` after the stall timeout. The check now counts the whole process tree: the command's group plus every descendant reached by parent links. A stall or timeout kill reaches those descendants too, so no worker is left running.
26 changes: 17 additions & 9 deletions docs/pregate.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ the byte-pinned `/ship` renders in `test/fixtures/golden/`).
| `serial_patterns` | test-file globs the `lanes` check runs one process per file, apart from the unit files (default `**/*.serial.test.*`) |
| `sealed` | sealed or eval output that must never reach a public destination; read by the pre-push hook and `gstack-pregate sealed` (see [sealed output](#sealed)) |
| `price_file` | repo-relative path of the paid gate's call-plan data file (`GSTACK_EVAL_CALLS v1`); `gstack-eval-plan price-gate` prices from it and never executes anything ([docs/eval-calls.md](eval-calls.md)) |
| `stall_timeout_s` | seconds a test command may print nothing while using under a tenth of one CPU before its process group is killed and the check is `incomplete` (`PREGATE_STALLED`); default 300, `0` disables; `--stall-timeout` overrides; the `--remote` gate is exempt (see [supervision](#supervision)) |
| `stall_timeout_s` | seconds a test command may print nothing while its process tree uses under a tenth of one CPU before the tree is killed and the check is `incomplete` (`PREGATE_STALLED`); default 300, `0` disables; `--stall-timeout` overrides; the `--remote` gate is exempt (see [supervision](#supervision)) |
| `timeout_s` | seconds each runner process may take (the unit-file group, each serial file, each guard without its own `timeout_s`, and the remote gate's deadline) when `--timeout` is not passed; 1 to 3600, default 600. `gstack-ship-preflight` forwards its own `--timeout`; without it, and in the `finish` fallback, this is how a repo with long lanes sets theirs. The whole pregate under `gstack-ship-preflight` has a separate budget, `--step-timeout <s>` (1 to 86400, default 3600): a pregate stopped there prints `PREGATE: time limit hit` and a STOP naming the way out, push and let CI's full run at the tree carry the tests ([CI carry](#ci-carry)), or a larger `--step-timeout` |
| `remote_gate` | the repo's remote test gate command; under 8 cores the local test tier becomes a `requires-remote` obligation naming it, and `--remote` runs it (see [remote gate](#remote-gate)) |
| `run_profiles` | a map from each profile name to `{ workflow, events, jobs, artifact, max_age_hours?, os?, skippable? }`: the GitHub Actions runs `clear --run` verifies as evidence on the identical tree; a profile named after a lane (`free-tests.yml/macos-named-regressions`) clears that lane (see [run evidence](#run-evidence)). `--from-run` and the reuse job verify runs against them too ([from-run](#from-run), [CI reuse](#ci-reuse)) |
Expand Down Expand Up @@ -539,14 +539,18 @@ test-tier command:
a one-file run (each serial file) reports its file from the launch for any
runner. Other runners (node --test, vitest, jest, pytest, playwright test, flutter test, dart test, cargo test) get heartbeats
only. A heartbeat follows each 60 s with no progress line;
- is killed as **stalled** when its log does not grow and its process group
- is killed as **stalled** when its log does not grow and its process tree
stays under a tenth of one CPU for the stall timeout (`--stall-timeout <s>`, else
`stall_timeout_s`, else 300; `0` disables): the check is `incomplete` with
`PREGATE_STALLED` and names the last file started; the next serial file
still runs. The group counts as busy when its CPU time, sampled each second,
grew by at least a tenth of the wall time, so a quiet suite that is working
(FOUN-63: a parallel `check.sh` silent for 9 minutes) is not killed, while
a hang that waits on nothing is. A hang that keeps burning CPU is left to
still runs. The process tree is the command's process group plus every
descendant reached by parent links, whatever session or group it started,
so a worker a launcher starts in its own session (`pnpm exec` running
Vitest) counts. The tree counts as busy when its CPU time, sampled each
second, grew by at least a tenth of the wall time, so a quiet suite that is
working (FOUN-63: a parallel `check.sh` silent for 9 minutes) is not killed,
while a hang that waits on nothing is. A descendant reparented away from the
tree (a double-forked daemon) no longer counts. A hang that keeps burning CPU is left to
the timeout. Linux reads `/proc` (exited children's time included once
reaped); macOS and other BSDs read `ps -S`; a failed read skips that
sample. Windows reads no CPU time here and uses log growth alone. The `--remote` gate is exempt: a
Expand All @@ -557,9 +561,13 @@ test-tier command:
serial files that each fit still pass): the check is `incomplete`, its detail
names which of the three set the timeout, and the next serial file still runs.

A kill is SIGTERM to the group, then SIGKILL after 5 s (a group that ignores
SIGTERM still dies). SIGINT or SIGTERM to `gstack-pregate` itself SIGKILLs every
running group, writes no `pregate.json` and exits 130 or 143. Windows has no
A stall or timeout kill is SIGTERM to the process group and to the group of
each descendant that left it, then SIGKILL to the same groups after 5 s (a
group that ignores SIGTERM still dies, and a worker in its own session is not
orphaned). After a normal exit only the command's own group is killed: a
descendant that started its own session is reparented once the command exits
and is left alone. SIGINT or SIGTERM to `gstack-pregate` itself SIGKILLs every
running tree, writes no `pregate.json` and exits 130 or 143. Windows has no
process groups here: the kill is `taskkill /T /F` on the shell's tree, which
misses a descendant that was reparented or started detached.

Expand Down
4 changes: 2 additions & 2 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -4677,9 +4677,9 @@ missing checks needs a full `gstack-pregate --allow-repo-commands` (neither
<a id="pregate-stalled"></a>
### `PREGATE_STALLED`

**Meaning.** A test command the lanes check (or a guard) launched wrote nothing to its log, and its process group used under a tenth of one CPU (Windows: log growth alone), for the stall timeout (default 300 s,
**Meaning.** A test command the lanes check (or a guard) launched wrote nothing to its log, and its process tree (its process group plus every descendant, whatever session it started) used under a tenth of one CPU (Windows: log growth alone), for the stall timeout (default 300 s,
`stall_timeout_s` in the base branch's `.gstack/pregate.json` or the user-owned file, or
`--stall-timeout`). pregate killed its process group and names the last test
`--stall-timeout`). pregate killed its process tree and names the last test
file started. The check is incomplete, never pass.

**Fix.** Open the printed log, find the hang in the named file (a blocked
Expand Down
2 changes: 1 addition & 1 deletion lib/pregate/checks/guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async function run(ctx: PregateContext): Promise<CheckResult> {
for (const r of runs) {
if (r.carryNone) lines.push(`CI_CARRY: none guard=${r.guard.id} (${r.carryNone})`);
if (r.prior) { lines.push(`GUARD: ${r.guard.id} ${r.prior}`); continue; }
lines.push(r.stalled ? `GUARD: ${r.guard.id} stalled: no output for ${ctx.stallTimeoutMs / 1000} s${STALL_IDLE}; process group killed (log ${r.log})` : r.timedOut ? `GUARD: ${r.guard.id} timed out after ${r.guard.timeout_s ?? ctx.timeoutMs / 1000} s (log ${r.log})` : `GUARD: ${r.guard.id} exit=${r.exit} (log ${r.log})`);
lines.push(r.stalled ? `GUARD: ${r.guard.id} stalled: no output for ${ctx.stallTimeoutMs / 1000} s${STALL_IDLE}; process tree killed (log ${r.log})` : r.timedOut ? `GUARD: ${r.guard.id} timed out after ${r.guard.timeout_s ?? ctx.timeoutMs / 1000} s (log ${r.log})` : `GUARD: ${r.guard.id} exit=${r.exit} (log ${r.log})`);
if (r.exit !== 0) lines.push(...r.tail.map(l => ` ${l}`));
if (r.environment) lines.push(` ${r.guard.id} ${environmentLine(r.environment)}`);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/pregate/checks/lanes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ function unfinished(ctx: PregateContext, r: Awaited<ReturnType<typeof runLocal>>
const timedOut = r.runs.filter(x => x.outcome === 'timeout');
const rest = r.failed ? `; ${r.failed} failed` : '';
if (stalled.length) {
return { code: 'PREGATE_STALLED', detail: `no test output for ${ctx.stallTimeoutMs / 1000} s${STALL_IDLE}; process group killed; last file started: ${stalled.map(x => x.lastFile ?? `(none reported; ${x.files.length} file(s))`).join(', ')}${rest}`, fix: `read ${r.log} for the stalled file; fix the hang, or raise --stall-timeout (stall_timeout_s in ${ctx.configFile}; 0 disables) for a test that waits quietly for longer` };
return { code: 'PREGATE_STALLED', detail: `no test output for ${ctx.stallTimeoutMs / 1000} s${STALL_IDLE}; process tree killed; last file started: ${stalled.map(x => x.lastFile ?? `(none reported; ${x.files.length} file(s))`).join(', ')}${rest}`, fix: `read ${r.log} for the stalled file; fix the hang, or raise --stall-timeout (stall_timeout_s in ${ctx.configFile}; 0 disables) for a test that waits quietly for longer` };
}
const launch = r.runs.find(x => x.outcome === 'spawn-failed');
if (launch) {
Expand Down
4 changes: 2 additions & 2 deletions lib/pregate/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* price_file the call-plan data file `gstack-eval-plan price-gate` prices
* a paid gate from (GSTACK_EVAL_CALLS v1; never executed)
* stall_timeout_s seconds without test output or CPU activity before the
* lanes check kills the runner's process group (default 300;
* lanes check kills the runner's process tree (default 300;
* 0 disables)
* timeout_s seconds each runner process may take (the unit-file group,
* each serial file, each guard without its own timeout_s, the
Expand Down Expand Up @@ -383,7 +383,7 @@ export function explainConfig(): string {
`serial_patterns: test-file globs the lanes check runs one process per file, apart from the unit files (default ${DEFAULT_SERIAL_PATTERNS.join(', ')})`,
'sealed: { paths, transcripts, answer_markers, seed_patterns, local_paths, allow_paths, case_insensitive, label_keys, identifier_keys, visibility }: sealed or eval output the pre-push hook and `gstack-pregate sealed` refuse to publish to a public destination; allow_paths (base branch only) exempt publishable files from the path globs; label_keys turns on sealed.label_join, which refuses a published record that puts one of those fields next to an identifier (identifier_keys globs, or a hex value) (docs/pregate.md#sealed)',
'price_file: repo-relative path of the GSTACK_EVAL_CALLS v1 call-plan file `gstack-eval-plan price-gate` prices a paid gate from; never executed (docs/eval-calls.md)',
'stall_timeout_s: seconds without test output or CPU activity before the lanes check kills the runner\'s process group and records it incomplete (default 300; 0 disables; --stall-timeout overrides)',
'stall_timeout_s: seconds without test output or CPU activity before the lanes check kills the runner\'s process tree and records it incomplete (default 300; 0 disables; --stall-timeout overrides)',
'timeout_s: seconds each runner process may take (the unit-file group, each serial file, each guard without its own timeout_s, and the remote gate\'s deadline) when --timeout is not passed; 1 to 3600, default 600',
'remote_gate: the repo\'s remote test gate command; under 8 cores the test tier becomes a requires-remote obligation naming it, and gstack-pregate --remote runs it (it must print PREGATE_REMOTE: tree=<tree> tests=<n> failed=<n>) (docs/pregate.md#remote-gate)',
'run_profiles: name → { workflow, events, jobs, artifact, max_age_hours?, os? }; the GitHub Actions runs gstack-pregate clear --run verifies as evidence on the identical tree (docs/pregate.md#run-evidence)',
Expand Down
Loading