Skip to content

v1.93.35.0 fix: pregate no longer kills a quiet test suite that is busy working (GST-1095) - #3899

Merged
capy-ai[bot] merged 5 commits into
mainfrom
gst-1095-pregate-cpu-liveness
Nov 3, 2026
Merged

capy-ai[bot] merged 5 commits into
mainfrom
gst-1095-pregate-cpu-liveness

Conversation

@garrytan

@garrytan garrytan commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3899,
  "head": "f79edd28f53f226e08c9eb4cdce7aab46a9c16fb",
  "version": "1.93.24.0",
  "base": "main",
  "gate": {
    "supervise": {
      "pass": 18,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "head_tree": "5de5d18f7426d1928d008df759b30b5d53280ff9",
  "product_patch_id": "832ddd575b9567977ab20b9ec44342c953e587e7",
  "gstack_version": "1.93.24.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 85,
    "rules": "b2272efd321ce7cb",
    "base": "f1cbdbb48313957613bafb2d05346afc876fed89",
    "registry": "f1cbdbb48313957613bafb2d05346afc876fed89",
    "gate_scan": {
      "tagged": 0,
      "head": "f79edd28f53f226e08c9eb4cdce7aab46a9c16fb"
    },
    "reasons": [
      "gate-class",
      "runtime=85"
    ],
    "risk": []
  },
  "pregate": "requires-remote cleared @5de5d18f7426 (1 checks, current for f79edd28f53f)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/41553194530/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/41553194530/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/41553194332/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=5de5d18f7426 tests=16511"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, CONTRIBUTING.md, AGENTS.md (read-only audit of the pregate stall change)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 4,
    "deferred": 0,
    "noted": 2,
    "fixed": 5,
    "scope": "frozen",
    "fix_checks": 2,
    "rounds": 3,
    "unrecorded": 4,
    "ledgers_read": 3,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  }
}

What changed

Before (origin/main): a silent CPU-busy run ends stalled and a busy lane test ends PREGATE_STALLED. After: both pass, and the idle-hang, deadline and SIGTERM controls still pass.

Before (origin/main): a silent CPU-busy run ends stalled and a busy lane test ends PREGATE_STALLED. After: both pass, and the idle-hang, deadline and SIGTERM controls still pass.

Before/after as text: Before (origin/main): a silent CPU-busy run ends stalled and a busy lane test ends PREGATE_STALLED. After: both pass, and the idle-hang, deadline and SIGTERM controls still pass.
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+$ git checkout gst-1095-pregate-cpu-liveness
+$ bun test test/pregate-supervise.test.ts
+(pass) a backgrounded child holding stdout does not keep the run waiting, and is killed with the group after the exit
+(pass) a command that prints nothing for the stall timeout is killed as stalled; a long command that keeps printing is not
+(pass) a silent command that keeps using CPU is not stalled; a busy run that never ends still times out at the deadline
+(pass) a group that ignores SIGTERM is SIGKILLed after the grace period
+(pass) the deadline kills the group as timeout; a launch that cannot start is spawn-failed, never a pass
+(pass) heartbeats arrive after each quiet interval without progress lines
+(pass) with lastLine, a heartbeat names the command's last output line
+(pass) with lastLine, a log removed mid-run still ends in a normal outcome
+(pass) bun test has an adapter: start and pass|fail per file from its headers; a runner without one reports nothing per file
+(pass) a one-file run reports its file from the launch for any runner; a bun test that blocks forever stalls naming that file
+(pass) a rejected check promise is incomplete, never pass
+(pass) a test that blocks forever is killed at the stall timeout, named, and recorded incomplete; --json stdout stays one JSON document
+(pass) the base branch stall_timeout_s applies without the flag
+(pass) a test that is silent past the stall timeout but busy runs to a pass
+(pass) a test whose child backgrounds and holds stdout passes promptly instead of waiting out --timeout
+(pass) --timeout bounds each runner process: serial files that each fit run to a pass even when their total exceeds it; one that overruns is incomplet
+(pass) a late tree mutation by a test's child is caught while the check runs, and a leftover child cannot mutate the tree after it
+(pass) SIGTERM to pregate kills the running test process group, exits 143 and writes no pregate.json
+ 18 pass
+ 0 fail
-$ git checkout f1cbdbb   # origin/main
-$ bun test test/pregate-supervise.test.ts -t "keeps using CPU|silent past the stall timeout but busy"
-Expected: "exited"
-Received: "stalled"
-(fail) supervise: process group, log file, stall and deadline > a silent command that keeps using CPU is not stalled; a busy run that never ends still times out at the deadline [1526.31ms]
-"code": "PREGATE_STALLED",
-"detail": "no test output for 2 s; process group killed; last file started: test/busy.test.js",
-(fail) gstack-pregate: the test stage never hangs silently > a test that is silent past the stall timeout but busy runs to a pass [3421.27ms]
- 0 pass
- 2 fail
 

Why

Founderstar's review audit for FOUN-63 says it plainly: "the second ended PREGATE_STALLED because check.sh is silent for >300 s". A parallel suite that prints nothing for nine minutes while working was killed as hung. Now pregate counts CPU activity as a sign of life, so a busy quiet suite runs to the end, and an idle hang is still killed at the stall timeout.

Blast radius

The change lives in lib/pregate/supervise.ts, which runs the pregate lanes check, the guards and gstack-checks. The remote gate passes stallMs: 0 and is untouched. A run is now killed as stalled only when both signals are quiet, so the change can only keep alive a run main would have killed. A hang that keeps burning CPU now ends at --timeout instead, and that is still incomplete, never a pass (walked failure path, plus the new deadline test). No threshold or config key changed, and bin/gstack-pregate and lib/pregate/context.ts (open #3852) are not touched.

Approvals

Date Asked Exact words Outcome Covers Still pending
2026-11-02 Fix GST-1095 (pregate stall timeout kills quiet suites) and ship it “GST-1095 assigned: bug fix, no autoplan, cap $25” (GStack Minder (Captain)) approved bug fix for GST-1095 only; no autoplan (fix-lane exemption); spend cap $25 none

Source: gstack-approvals record for gst-1095-pregate-cpu-liveness (display only; not an approval citation).

Summary

"pregate's 300 s stall timeout kills quiet long suites" (GST-1095, from FOUN-63). The stall timer looked only at log growth. supervise now also samples the process group's CPU time each second (/proc on Linux, ps -S on macOS and BSDs). A group whose CPU time grew by at least a tenth of wall time counts as alive. Windows reads no CPU time and keeps log growth alone. The PREGATE_STALLED detail, the guard line, the result-code summary and the docs now say what was measured.

Red proof on main (f1cbdbb), before the fix: both new tests fail there. supervise returns stalled for a silent CPU-bound command, and gstack-pregate --stall-timeout 2 records {"code":"PREGATE_STALLED","detail":"no test output for 2 s; process group killed; last file started: test/busy.test.js"} for a busy node:test file. Logs: handoffs/GST-1095/red-on-main-unit.txt and red-on-main-e2e.txt in the GStack Minder drive.

Negative controls kept: an idle hang (sleep 1000, a bun test blocked in Atomics.wait, a node test blocked forever) still ends stalled / PREGATE_STALLED. A busy run that never ends ends timeout at the deadline. A group that ignores SIGTERM is still SIGKILLed.

Security read: no network calls, environment reads, permission changes, workflow, setup or install edits, and no new dependencies. The one new subprocess is ps -A -S -o pgid=,time= on non-Linux POSIX, with a 15 s timeout, and it only reads process CPU times.

Refs: GST-1095, FOUN-63 (Founderstar review audit 2026-11-02).

Test Coverage

lib/pregate/supervise.ts
  groupCpuMs /proc branch            [★★ TESTED] by the busy and idle tests
  groupCpuMs ps fallback (macOS/BSD) [GAP] needs a platform seam; runs on macOS CI lanes only
  stall loop: silent + busy          [★★★ TESTED] new unit test
  stall loop: silent + idle          [★★★ TESTED] existing tests
  stall loop: busy forever           [★★ TESTED] new unit test (deadline)
  stallMs = 0 disables               [★★ TESTED] existing
gstack-pregate tests stage
  quiet + busy lane passes           [★★ TESTED] new e2e test
  idle hang -> PREGATE_STALLED       [★★★ TESTED] existing e2e tests

Tests: 16 → 18 (+2 new) in test/pregate-supervise.test.ts
Coverage: 70% value-weighted (70% including 0 weakly covered paths)
Test value: 2 tests written, 0 rejected by the authoring gate, 0 existing tests extended, 0 paths weakly covered.
Regression proof: fails at main f1cbdbb · passes after fix (both new tests).
Tests ran: supervise 18

Pre-Landing Review

Gate-class review at full depth (gstack-review-plan REVIEW_CLASS: gate). Pass 1 ran specialists (testing, security, state-machines) plus a red team and found 3 informational items, all fixed. The fix-check (round 2) found 3 informational items: 2 fixed, 1 noted. Step 11 ran a native adversarial voice (4 informational) and a GPT-6.1 Sol outside voice (2 items it marked blocking). Both of those only fall back to the behavior main already has, so they are below the blocking floor and recorded as notes. A last fix-check on the frozen tree rebound the review records and found 1 informational item (noted).
REVIEW_LOOP: passes=1 blocking_found=4 deferred=0 noted=2 fixed=5 scope=frozen unrecorded=4 ledgers_read=3 fix_checks=2 dispatches=4

The 4 counted as blocking are Step 11 voice findings that the collector labeled CRITICAL: the two the GPT-6.1 Sol outside voice marked "Blocks: yes", plus two from the native voice. My lead judgment is that all 4 sit below the blocking floor, because none fails a test, breaks production or loses data, and each one falls back to the behavior main already has. They are listed under Review notes below, and the judge tool keeps their original label.
Gate edits: none detected (GATE_SCAN tagged=0 at every pass)
Outside review: GPT-6.1 Sol (certified configuration), completed, 2 findings, both judged below the floor.

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:222 a silent hang that keeps using CPU (or keeps an idle helper awake) now runs to --timeout instead of the stall timeout; still incomplete, never pass
  • INFORMATIONAL lib/pregate/supervise.ts:224 after a failed CPU read (BSD only) the next sample compares about 2 s of CPU against a 1 s threshold
  • INFORMATIONAL lib/checks.ts:269 gstack-checks stalled detail and bin/gstack-pregate --stall-timeout help still say 'no output' only
  • INFORMATIONAL lib/pregate/supervise.ts:100 CPU outside the process group (setsid children, daemons) is not seen; same as before the change
  • INFORMATIONAL lib/pregate/supervise.ts:221 a fractional --stall-timeout under 1 s fires before the first CPU sample; falls back to pre-change log-growth behavior
  • INFORMATIONAL lib/pregate/supervise.ts:95 short-lived double-forked workers reaped by init lose their CPU before a sample; such launchers still stall on log growth, as before
  • INFORMATIONAL bin/gstack-pregate:82 the --stall-timeout help text still says "no output". It is not edited here because open v1.93.33.0 wave(review): #3705 #3744 #3745 #3764 #3765 #3795 #3852 owns that file.

Eval Results

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

Verification Results

Remote pregate (Ubicloud us-east-a2, owner gsta212) on tree 5de5d18f7426: 16511 tests, 0 failed, $0.10. The VM was destroyed afterward (UBICLOUD: left=0). The macOS and Windows lanes are cleared from this PR's CI runs.

TODOS

No TODO items completed in this PR.

Documentation

Scope: Audit of the gst-1095 change (pregate stall detection now needs both no log output and low process-group CPU use). I read the committed diff against main, the working tree, docs/pregate.md, docs/troubleshooting.md, the PREGATE_STALLED entry in lib/result-codes.ts, the config help text and the changelog fragment. I grepped every other doc and template for stall wording; hits were unrelated (codex, captain, TODOS).

Result: Current. The branch already updates the stall_timeout_s row, the supervision section and the PREGATE_STALLED troubleshooting entry. These match the code: the one-tenth-CPU threshold, the 1 s sampling, /proc on Linux, ps -S on macOS and BSDs, Windows using log growth alone, and a CPU-bound hang left to --timeout. The result-code summary and the config help text match too. No README, CONTRIBUTING or TESTING_INTERNALS page describes the stall behavior, so none is stale.

Debt: None found.

Test plan

  • bun test test/pregate-supervise.test.ts: 18 pass, 0 fail (lane receipt FRESH, tests_ran=18)
  • bun run typecheck: clean
  • Remote pregate gstack-pregate --stage tests --remote: 16511 tests, 0 failed on tree 5de5d18f7426

🤖 Generated with Claude Code

garrytan and others added 4 commits November 2, 2026 23:28
…095)

The stall timer looked only at log growth, so a parallel check.sh that
prints nothing for 9 minutes while working ended PREGATE_STALLED (FOUN-63).
supervise now samples the process group's CPU time each second and treats
growth of at least a tenth of wall time as liveness. An idle hang still
stalls; a hang that burns CPU is left to --timeout.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… skips one sample; ps -S on BSDs (review pass 1)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ng (fix-check)

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

trunk-io Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@github-actions github-actions Bot changed the title fix: pregate no longer kills a quiet test suite that is busy working (GST-1095) v1.93.35.0 fix: pregate no longer kills a quiet test suite that is busy working (GST-1095) Nov 3, 2026
@capy-ai
capy-ai Bot merged commit f47d19d into main Nov 3, 2026
46 checks passed
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