Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA
TypeScript
Commands that read cut-off output now fail instead of judging part of it (GST-3086) (#4492)
Garry Tan36b349d66017
diff --git a/bin/gstack-archive-check b/bin/gstack-archive-checkindex 6c340346a..daff84fc3 100755--- a/bin/gstack-archive-check+++ b/bin/gstack-archive-check@@ -7,7 +7,7 @@* gstack-archive-check thread --thread <code> --reads <file.json> [--stub-out <file>] [--json]* gstack-archive-check landed --pr <n> [--repo <owner/repo>] [--json]*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import { checkThread, landedIssues, MAX_READ_AGE_MS } from '../lib/archive-check';import { flagValue } from '../lib/bin-context';diff --git a/bin/gstack-banned-terms b/bin/gstack-banned-termsindex f67d51e9f..94c5bdefd 100755--- a/bin/gstack-banned-terms+++ b/bin/gstack-banned-terms@@ -12,7 +12,7 @@* last line is `BANNED_TERMS: ok | found=<n> | none`. Exit 0 ok or none, 1 found,* 3 when the file is invalid. Logic: lib/banned-terms.ts. Called from /review and /document-release.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { BANNED_TERMS_PATH, addedLines, exampleBannedTermsJson, loadBannedTerms, renderBannedTerms, scanBannedTerms, validateBannedTerms, wholeFiles } from '../lib/banned-terms';diff --git a/bin/gstack-ci-carry b/bin/gstack-ci-carryindex c777cbc21..554ac3a9c 100755--- a/bin/gstack-ci-carry+++ b/bin/gstack-ci-carry@@ -16,7 +16,7 @@* prints CI_WAIT: green|red|running|none, and on green runs find. Exit 0 green and carried, 1 red or not* carried, 3 still running or no run. Logic: lib/ci-carry.ts; the run checks are lib/run-evidence.ts.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { carriedFromLine, findCarry, laneMapping, mappingCoverage, treeTwins, waitForRun } from '../lib/ci-carry';import { isConfigUnavailable, loadConfigFromBase, loadConfigFromHead } from '../lib/pregate/config';import { buildRunCheck } from '../lib/pregate/run-check';diff --git a/bin/gstack-design-detect.ts b/bin/gstack-design-detect.tsindex addb543fe..c0f83e61b 100755--- a/bin/gstack-design-detect.ts+++ b/bin/gstack-design-detect.ts@@ -86,7 +86,7 @@ import * as fs from 'fs';import * as os from 'os';import * as path from 'path';import { createHash } from 'crypto';-import { spawnSync } from 'child_process';+import { spawnSync } from '../lib/spawn-sync';import {SENTINEL, TESTED_ENGINE_VERSIONS, ADVISORY_RULE_IDS, DETECT_LIMITS,UNTRUSTED_BEGIN, UNTRUSTED_END, neutralizeSentinels,@@ -879,7 +879,7 @@ function runEngine(p: Probe, engine: string, batch: string[], cwd: string, timeotimeout: timeoutMs, killSignal: 'SIGKILL', maxBuffer: DETECT_LIMITS.stdoutBytes + 1024,});const out = r.stdout ?? new Uint8Array();- const tooLarge = out.byteLength > DETECT_LIMITS.stdoutBytes;+ const tooLarge = r.exitedDueToMaxBuffer === true || out.byteLength > DETECT_LIMITS.stdoutBytes;return {exit: r.exitCode ?? 1,stdout: tooLarge ? '' : Buffer.from(out).toString('utf-8'),diff --git a/bin/gstack-docs-candidate b/bin/gstack-docs-candidateindex b354b33a1..a1a605932 100755--- a/bin/gstack-docs-candidate+++ b/bin/gstack-docs-candidate@@ -61,7 +61,7 @@* checks the reply, refusing a second repair of the same audit and any change to a value the* first line gave correctly; after trailing text only a blocked status and its blockers carry over.*/-import { spawnSync } from 'child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'fs';import * as path from 'path';import { baseContainsHead } from '../lib/default-base';diff --git a/bin/gstack-doctor-components.sh b/bin/gstack-doctor-components.shindex 468ca5e49..f68a43fba 100644--- a/bin/gstack-doctor-components.sh+++ b/bin/gstack-doctor-components.sh@@ -380,6 +380,7 @@ gstack_result_anchor() {PUSH_REFUSED) printf '%s' 'push-refused' ;;PUSH_REJECTED) printf '%s' 'push-rejected' ;;PUSH_GIT_FAILED) printf '%s' 'push-git-failed' ;;+ SPAWN_OUTPUT_INCOMPLETE) printf '%s' 'spawn-output-incomplete' ;;APPROVAL_RECORD_INVALID) printf '%s' 'approval-record-invalid' ;;APPROVAL_RECORD_SECRET) printf '%s' 'approval-record-secret' ;;APPROVAL_RECORD_NO_BRANCH) printf '%s' 'approval-record-no-branch' ;;diff --git a/bin/gstack-evidence b/bin/gstack-evidenceindex 924f8cccd..02dcb3fa1 100755--- a/bin/gstack-evidence+++ b/bin/gstack-evidence@@ -91,7 +91,7 @@import { openSync, writeSync, closeSync, readdirSync, statSync, unlinkSync, chmodSync, readFileSync } from "fs";import { mkdirpSync } from "../lib/fs-utils";import { join, dirname } from "path";-import { spawnSync } from "child_process";+import { spawnSync } from "../lib/spawn-sync";import { appendJsonl, readJsonl } from "../lib/jsonl-store";import { resolveStateRoot } from "../lib/state-root";import { scan, applyRedactions } from "../lib/redact-engine";diff --git a/bin/gstack-gbrain-read-capability.ts b/bin/gstack-gbrain-read-capability.tsindex e28847113..8126b0827 100644--- a/bin/gstack-gbrain-read-capability.ts+++ b/bin/gstack-gbrain-read-capability.ts@@ -1,7 +1,7 @@#!/usr/bin/env -S bun --no-env-file --config=/dev/nullimport { readFileSync, realpathSync, statSync } from 'node:fs';import { join } from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { gbrainInvocation, buildGbrainEnv } from '../lib/gbrain-exec';import { parseSourcesList } from '../lib/gbrain-sources';import { resolveStateRoot } from '../lib/state-root';diff --git a/bin/gstack-greptile-early b/bin/gstack-greptile-earlyindex f2fb5fd6d..bed435f5d 100755--- a/bin/gstack-greptile-early+++ b/bin/gstack-greptile-early@@ -11,7 +11,7 @@* ship_greptile_early false` turns it off. Logic: lib/greptile-early.ts.*/import * as path from "path";-import { spawnSync } from "child_process";+import { spawnSync } from "../lib/spawn-sync";import { runGreptileEarly } from "../lib/greptile-early";process.exitCode = runGreptileEarly(process.argv.slice(2), {diff --git a/bin/gstack-issue-guard b/bin/gstack-issue-guardindex 610366e70..adb194bac 100755--- a/bin/gstack-issue-guard+++ b/bin/gstack-issue-guard@@ -19,7 +19,7 @@* issue number is validated before use.*/-import { spawnSync } from "child_process";+import { spawnSync } from "../lib/spawn-sync";import { wrapUntrustedTrackerContent } from "../lib/tracker-guard";import { flagValue } from "../lib/bin-context";diff --git a/bin/gstack-issue-links b/bin/gstack-issue-linksindex 764f45b97..f383a8a34 100755--- a/bin/gstack-issue-links+++ b/bin/gstack-issue-links@@ -21,7 +21,7 @@* missing any of its lines (ISSUE_LINKS_MISSING).* Logic: lib/issue-links.ts.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { EXIT, exitTableHelp } from '../lib/headless-artifacts';diff --git a/bin/gstack-memory-ingest.ts b/bin/gstack-memory-ingest.tsindex 924ccbb05..34f10d752 100644--- a/bin/gstack-memory-ingest.ts+++ b/bin/gstack-memory-ingest.ts@@ -57,7 +57,8 @@ import {realpathSync,} from "fs";import { join, basename, dirname, delimiter, relative } from "path";-import { execFileSync, spawnSync, spawn, type ChildProcess } from "child_process";+import { execFileSync, spawn, type ChildProcess } from "child_process";+import { spawnSync } from "../lib/spawn-sync";import { homedir } from "os";import { createHash } from "crypto";diff --git a/bin/gstack-motion-encode b/bin/gstack-motion-encodeindex 250efa323..08b734323 100755--- a/bin/gstack-motion-encode+++ b/bin/gstack-motion-encode@@ -26,7 +26,7 @@//// Adapted from Elaya's design-to-motion (MIT, (c) 2026 Elaya). See NOTICE.md.-import { spawnSync } from 'child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'fs';import * as path from 'path';import {diff --git a/bin/gstack-no-stop b/bin/gstack-no-stopindex 35491f2dc..c508cbb86 100755--- a/bin/gstack-no-stop+++ b/bin/gstack-no-stop@@ -12,7 +12,7 @@* the approval record and prints GRANT: <id> for `gstack-review-plan --grant`. Anything that does not* qualify prints `NO_STOP: refused` and exits 3: that stop still goes to the owner.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as path from 'node:path';import { appendRows, buildRow, locate, readRecord } from '../lib/approval-record';import { EXIT, exitTableHelp } from '../lib/headless-artifacts';diff --git a/bin/gstack-post b/bin/gstack-postindex d8cf6e7f7..47eaa7247 100755--- a/bin/gstack-post+++ b/bin/gstack-post@@ -14,7 +14,7 @@*/import * as fs from "fs";import * as path from "path";-import { spawnSync } from "child_process";+import { spawnSync } from "../lib/spawn-sync";import { runPost } from "../lib/gstack-post";const code = runPost(process.argv.slice(2), {diff --git a/bin/gstack-pregate b/bin/gstack-pregateindex 6c0b3c0ee..da435de9a 100755--- a/bin/gstack-pregate+++ b/bin/gstack-pregate@@ -24,7 +24,7 @@* origin/<base>; their commands and the test runner run only with* --allow-repo-commands (what /ship passes). Logic: lib/pregate/*.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { baseContainsHead } from '../lib/default-base';diff --git a/bin/gstack-redact-prepush b/bin/gstack-redact-prepushindex 7658a3c74..bdc3f7169 100755--- a/bin/gstack-redact-prepush+++ b/bin/gstack-redact-prepush@@ -42,7 +42,7 @@* Installed/uninstalled via `gstack-redact install-prepush-hook` (see the* gstack-redact CLI), which chains any pre-existing hook.*/-import { spawnSync } from "child_process";+import { spawnSync } from "../lib/spawn-sync";import * as fs from "fs";import * as path from "path";import { normalizeWithMap, scan, type Finding, type ScanOptions } from "../lib/redact-engine";@@ -76,7 +76,8 @@ function git(args: string[]): string {* (#1946). status !== 0 covers repo errors; status === null covers a killed* process AND maxBuffer overflow — the oversized-diff case is exactly where* a large secret-bearing blob is most likely, so "couldn't read the diff"- * must block, not silently allow.+ * must block, not silently allow. Bun can report an overflow as status 0 with+ * a cut-off diff; lib/spawn-sync.ts turns that into null (GST-3086).*/function gitStrict(args: string[]): string {const r = spawnSync("git", args, { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });@@ -84,7 +85,7 @@ function gitStrict(args: string[]): string {// signal or maxBuffer overflow — null !== 0 is true).if (r.status !== 0) {throw new Error(- `git ${args[0]} failed (status=${r.status ?? "killed/overflow"}): ${(r.stderr ?? "").slice(0, 300)}`,+ `git ${args[0]} failed (status=${r.status ?? "killed/overflow"}${r.error ? `, ${r.error.message}` : ""}): ${(r.stderr ?? "").slice(0, 300)}`,);}return r.stdout ?? "";diff --git a/bin/gstack-restamp b/bin/gstack-restampindex e33fa228a..0d1a2f857 100755--- a/bin/gstack-restamp+++ b/bin/gstack-restamp@@ -19,7 +19,7 @@* file changed since (RESTAMP_NOT_STAGED). Idempotent; --dry-run writes nothing. Workflow command: ends with the* GSTACK_RESULT line. Logic: lib/restamp.ts; policy: lib/ship-policy.ts.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { EXIT, exitTableHelp, formatResult } from '../lib/headless-artifacts';diff --git a/bin/gstack-review-bots b/bin/gstack-review-botsindex 3adc6178e..a3aa44ec5 100755--- a/bin/gstack-review-bots+++ b/bin/gstack-review-bots@@ -10,7 +10,7 @@*/import * as os from "os";import * as path from "path";-import { spawnSync } from "child_process";+import { spawnSync } from "../lib/spawn-sync";import { runReviewBots } from "../lib/review-bots";process.exitCode = runReviewBots(process.argv.slice(2), {diff --git a/bin/gstack-review-dispatch b/bin/gstack-review-dispatchindex 80cd9306a..9db36a121 100755--- a/bin/gstack-review-dispatch+++ b/bin/gstack-review-dispatch@@ -17,7 +17,7 @@* Logic: lib/review-brief.ts (rendering from the sections), lib/review-ledger.ts (ledger, collect, judge, verify),* lib/review-pass.ts (the staged manifest) and lib/capy-review-pass.js (the Capy program that runs it).*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/bin/gstack-review-plan b/bin/gstack-review-planindex 929edc693..2f57800e4 100755--- a/bin/gstack-review-plan+++ b/bin/gstack-review-plan@@ -22,7 +22,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { baseContainsHead } from '../lib/default-base';import { locate, readRecord } from '../lib/approval-record';import { reviewRoundGrants } from '../lib/review-round-grant';diff --git a/bin/gstack-review-scope b/bin/gstack-review-scopeindex 7279baf03..98d98d499 100755--- a/bin/gstack-review-scope+++ b/bin/gstack-review-scope@@ -16,7 +16,7 @@* passes and prints the REVIEW_LOOP line the ship receipt carries.* Logic: lib/review-scope.ts.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/bin/gstack-ship-receipt b/bin/gstack-ship-receiptindex c7f9f0adb..d3002f867 100755--- a/bin/gstack-ship-receipt+++ b/bin/gstack-ship-receipt@@ -34,7 +34,7 @@* RECEIPT_CARRY_PRODUCT_CHANGED and nothing is rewritten.* Query commands: no GSTACK_RESULT line. Logic: lib/ship-receipt.ts.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/bin/gstack-state-matrix b/bin/gstack-state-matrixindex f17ee2cd0..045985fcb 100755--- a/bin/gstack-state-matrix+++ b/bin/gstack-state-matrix@@ -20,7 +20,7 @@* (lib/review-scope.ts mapStateMatrixOutput) and `STATE_MATRIX_FINDINGS:` on* stderr. Logic: lib/state-matrix.ts.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { randomBytes } from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/bin/gstack-tasks b/bin/gstack-tasksindex cea8bbe8d..1c6d985bf 100755--- a/bin/gstack-tasks+++ b/bin/gstack-tasks@@ -9,7 +9,7 @@* --dir defaults to <state root>/projects/<gstack-slug SLUG>, --branch to the current git branch.* Logic: lib/tasks-prior.ts. Codes: lib/result-codes-plan.ts (TASKS_SUPERSEDE_REFUSED).*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { EXIT, exitTableHelp } from '../lib/headless-artifacts';diff --git a/changelog.d/cut-off-child-output-fails-closed.md b/changelog.d/cut-off-child-output-fails-closed.mdnew file mode 100644index 000000000..f6b7fb0ec--- /dev/null+++ b/changelog.d/cut-off-child-output-fails-closed.md@@ -0,0 +1 @@+- **A command whose output was cut off no longer counts as a finished read.** Bun can report exit status 0 for a `spawnSync` child whose output passed the read limit (ENOBUFS), handing back only part of the output. The credential pre-push hook, the pregate secret and literal scans, the sealed-output guard, the ship receipt, review scoping and the other gstack commands that read large git or gh output now treat that case as a failure, named `SPAWN_OUTPUT_INCOMPLETE`, instead of judging part of a diff or file list. Before this, a push whose diff passed 64 MiB could carry a credential past the pre-push hook.diff --git a/crew/scripts/gate-cost-replay.ts b/crew/scripts/gate-cost-replay.tsindex 0d03abdd9..08e989cbb 100644--- a/crew/scripts/gate-cost-replay.ts+++ b/crew/scripts/gate-cost-replay.ts@@ -25,7 +25,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../lib/spawn-sync';import {SCREEN_LABEL, TODAY_WEEKLY_USD, AFTER_GSTA48_WEEKLY_USD, caseCostTable, changedLinesByFile, fullGateUsd, isSkillMd,parseEvalReport, parseTrialOutcomes, prSelectionCost, screenSelection, simulateTrains, summarizeGates, summarizeSelector, todaySelection,diff --git a/crew/scripts/gate-reuse.ts b/crew/scripts/gate-reuse.tsindex 400242f4c..bf2f2fb34 100644--- a/crew/scripts/gate-reuse.ts+++ b/crew/scripts/gate-reuse.ts@@ -50,7 +50,7 @@* bind and are never listed, so they neither reuse nor are reused.*/import { createHash } from 'node:crypto';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../lib/spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/crew/scripts/recover-receipts.ts b/crew/scripts/recover-receipts.tsindex 264d1e38e..c4c68df1f 100644--- a/crew/scripts/recover-receipts.ts+++ b/crew/scripts/recover-receipts.ts@@ -26,7 +26,7 @@import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../lib/spawn-sync';import { mergeReceiptDirs, writeNegativeReceipt } from '../../scripts/e2e-shard-reuse';import { loadSliceArtifacts, panelReports, parseRunManifest, shardFile } from '../../scripts/test-paid-shards';diff --git a/crew/scripts/release-cut.ts b/crew/scripts/release-cut.tsindex f78c3b57c..b74e3f537 100755--- a/crew/scripts/release-cut.ts+++ b/crew/scripts/release-cut.ts@@ -67,7 +67,7 @@import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../lib/spawn-sync';import { FLOOR_HOURS, IMPORTANT_FLOOR_HOURS, SCHEDULED_GRACE_HOURS, decideDaily, importantChanges, type DailyDecision } from './release-cadence';import { KIND_LABEL, NOTES_CAP, changeSources, changelogEntries, compareVersions, releaseKind, releaseNotes } from './release-notes';import { bucketClass } from '../../lib/ci-gate';diff --git a/crew/scripts/replay-pr-selection.ts b/crew/scripts/replay-pr-selection.tsindex 4db7e0d94..6c0d538eb 100644--- a/crew/scripts/replay-pr-selection.ts+++ b/crew/scripts/replay-pr-selection.ts@@ -20,7 +20,7 @@import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../lib/spawn-sync';import { computePaidCaseSelection } from '../../scripts/test-paid-shards';import { packageChangeOnlyVersion } from '../../scripts/test-pr-profile';import { E2E_TIERS, E2E_TOUCHFILES, GLOBAL_TOUCHFILES } from '../../test/helpers/touchfiles-data';diff --git a/crew/scripts/review-dispatch-compare.ts b/crew/scripts/review-dispatch-compare.tsindex 40965806d..17abb7fc0 100755--- a/crew/scripts/review-dispatch-compare.ts+++ b/crew/scripts/review-dispatch-compare.ts@@ -12,7 +12,7 @@* effort ({ "specialist": { "full": n, "light": n }, ... }); without it the script uses the shipped* defaults below and says so. Counts are exact for the modelled scenarios; tokens are estimates.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../lib/spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/crew/scripts/train-gate.ts b/crew/scripts/train-gate.tsindex 51a024622..bd2693065 100644--- a/crew/scripts/train-gate.ts+++ b/crew/scripts/train-gate.ts@@ -20,7 +20,7 @@* screen-summary (plan-slices, PR runs under a train policy) the screening* selection and its estimated cost; no paid case runs.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../lib/spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/docs/troubleshooting.md b/docs/troubleshooting.mdindex ff1fe95c1..883af2f7a 100644--- a/docs/troubleshooting.md+++ b/docs/troubleshooting.md@@ -5338,6 +5338,22 @@ rename the file and its id, commit, then rerun`gstack-pregate regate --against <gated-head> --bundle <file>`. The renamedmigration is a code change, so the gate reruns.+<a id="spawn-output-incomplete"></a>+### `SPAWN_OUTPUT_INCOMPLETE`++**Meaning.** gstack ran a command (usually git or gh) and the command's+result carried an error, so its output could be incomplete. The usual cause+is ENOBUFS: the output was larger than the read limit (maxBuffer). Bun can+report that with exit status 0 and the output cut off part way, so gstack+treats the read as failed whatever the status says. A scanner, gate or git+read that sees this stops or reports a failure instead of judging part of+its input. The line names the command and the error.++**Fix.** Rerun once. If it repeats, the output really is that large: narrow+the commit range or paths the command reads, then rerun. Report a repeat on a+normal-sized repository to the gstack maintainers with the command the line+names.+<a id="sealed-output-refused"></a>### `SEALED_OUTPUT_REFUSED`diff --git a/lib/approval-citations.ts b/lib/approval-citations.tsindex 6ec869e39..c731619b9 100644--- a/lib/approval-citations.ts+++ b/lib/approval-citations.ts@@ -26,7 +26,7 @@* the current scope, so a later effect change invalidates it.* Caller: bin/gstack-ship-receipt write (APPROVAL_CITATION_MISSING).*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { runApprovalScan, type ApprovalHit, type ApprovalScope } from './approval-classes';diff --git a/lib/approval-classes.ts b/lib/approval-classes.tsindex 1a223fc2d..e40f826b4 100644--- a/lib/approval-classes.ts+++ b/lib/approval-classes.ts@@ -17,7 +17,7 @@* Callers: bin/gstack-approval-classes, bin/gstack-ship-receipt.*/import { createHash } from 'node:crypto';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { addedLines } from './banned-terms';diff --git a/lib/approval-record.ts b/lib/approval-record.tsindex 68b271dee..015dea559 100644--- a/lib/approval-record.ts+++ b/lib/approval-record.ts@@ -26,7 +26,7 @@* anything is written.*/import { createHash } from 'node:crypto';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/autoplan-lean.ts b/lib/autoplan-lean.tsindex f16c939b5..d3f915706 100644--- a/lib/autoplan-lean.ts+++ b/lib/autoplan-lean.ts@@ -10,7 +10,7 @@* check. `--full`, `--ceo-only` and every non-Capy or interactive session keep* today's run. The reviewer's receipt names the draft hash (`DRAFT:`), checked at submit.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as crypto from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/lib/banned-terms.ts b/lib/banned-terms.tsindex 07568e1aa..cb3a5f5b4 100644--- a/lib/banned-terms.ts+++ b/lib/banned-terms.ts@@ -11,7 +11,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import type { ResultCodeName } from './result-codes';import { assertInsideRoot, containedRelative, globToRegExp, matchesAny } from './ship-policy';diff --git a/lib/ceo-review-gate.ts b/lib/ceo-review-gate.tsindex 1e946f16d..dc4a78379 100644--- a/lib/ceo-review-gate.ts+++ b/lib/ceo-review-gate.ts@@ -14,7 +14,7 @@* else cwd) is never a candidate or the place the block names: the review's* own methodology sections are not its output.*/-import { spawnSync } from 'child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'fs';import * as path from 'path';import { isPlaceholder, sameSkill, skillLoads, type SkillLoad, type Transcript } from './skill-contract';diff --git a/lib/changelog-fragments.ts b/lib/changelog-fragments.tsindex a9dc83470..903cd4275 100644--- a/lib/changelog-fragments.ts+++ b/lib/changelog-fragments.ts@@ -7,7 +7,7 @@* (mode 100644) directly under `dir` count, so a symlink, gitlink or nested path cannot pull bytes* from outside the repository into a stamp.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { headingVersion, parseChangelog } from './changelog-check';import { readHistoryFile } from './history-read';import type { Bump } from './version-source';diff --git a/lib/ci-gate.ts b/lib/ci-gate.tsindex 62729c6bc..8e3e2ca16 100644--- a/lib/ci-gate.ts+++ b/lib/ci-gate.ts@@ -1,4 +1,4 @@-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { headCheckRows, type HeadCheckRow } from './ci-head-checks';import { MIN_POLL_MS, pollDelayMs, syncLimitEnv, withRateLimit } from './gh-poll';diff --git a/lib/code-intelligence/suggest.ts b/lib/code-intelligence/suggest.tsindex 283d5e076..6318444ef 100644--- a/lib/code-intelligence/suggest.ts+++ b/lib/code-intelligence/suggest.ts@@ -9,7 +9,7 @@* (`git ls-files` count); a non-repo directory never triggers the offer.*/-import { spawnSync } from "child_process";+import { spawnSync } from "../spawn-sync";import { resolve } from "path";import { readSelection } from "./selection";diff --git a/lib/contributor-mode.ts b/lib/contributor-mode.tsindex baad89084..eb5c4a522 100644--- a/lib/contributor-mode.ts+++ b/lib/contributor-mode.ts@@ -9,7 +9,7 @@* two lines, not a section: the table (evidence value, risk surfaces,* accept / supersede / decline) and the credit-line rule.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { sha256Hex, writeReceipt } from './egress-receipt';import type { ResultCodeName } from './result-codes';diff --git a/lib/default-base.ts b/lib/default-base.tsindex b1cf27a6d..abb48062e 100644--- a/lib/default-base.ts+++ b/lib/default-base.ts@@ -10,7 +10,7 @@* failure; gh names no base for a PR from another repository. bin/gstack-diff-scope reads* both through this file's command line.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { resultLine } from './result-codes';export interface DefaultBase {diff --git a/lib/doc-links.ts b/lib/doc-links.tsindex f6fc1d007..869d59ae5 100644--- a/lib/doc-links.ts+++ b/lib/doc-links.ts@@ -4,7 +4,7 @@* blocks and inline code are ignored. An anchor into a Markdown file must match a heading slug (GitHub style, with -1,* -2 suffixes for repeats) or an explicit <a id="..."> / <a name="..."> in that file.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/lib/docs-only.ts b/lib/docs-only.tsindex accaabedd..71956a74a 100644--- a/lib/docs-only.ts+++ b/lib/docs-only.ts@@ -15,7 +15,7 @@* path (a script, test, workflow or skill that reads it pins it). A rename needs both sides to pass and a deletion needs* the old path to pass. Unsure, an unreadable base policy, or any git failure, is never docs-only.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { classifyPath } from './review-depth';diff --git a/lib/eval-models.ts b/lib/eval-models.tsindex 878b8fecf..5f7d736d8 100644--- a/lib/eval-models.ts+++ b/lib/eval-models.ts@@ -20,7 +20,7 @@* stale map. The reviewed copy is read from origin/<base>; the working tree's* copy only with --models-from head. Doc: docs/eval-models.md.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { MODEL_CATALOG } from './model-catalog';diff --git a/lib/eval-plan.ts b/lib/eval-plan.tsindex 9b5580c1e..9d8d23223 100644--- a/lib/eval-plan.ts+++ b/lib/eval-plan.ts@@ -9,7 +9,7 @@* (lib/pricing.ts), so the spend table always shows `unknown` charges and the* worst-case overrun (one in-flight call per worker) beside `spent`.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/lib/evidence-bundle.ts b/lib/evidence-bundle.tsindex a7fa3e17b..1f517eed3 100644--- a/lib/evidence-bundle.ts+++ b/lib/evidence-bundle.ts@@ -11,7 +11,7 @@* count toward reuse. Also home of `gstack-evidence ancestor` (plan C7).*/import { createHash } from 'node:crypto';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/flaky-run.ts b/lib/flaky-run.tsindex a92ba91d8..f54db2255 100644--- a/lib/flaky-run.ts+++ b/lib/flaky-run.ts@@ -40,7 +40,8 @@*/import * as fs from 'fs';import * as path from 'path';-import { spawn as spawnChild, spawnSync } from 'child_process';+import { spawn as spawnChild } from 'child_process';+import { spawnSync } from './spawn-sync';import { finalAttempt, JunitError, parseTestId, readJunit, type Attempt, type JunitReport, type JunitRunner, type JunitTest } from './junit';import { redactFindingSpans } from './redact-engine';import { resolveStateRoot } from './state-root';diff --git a/lib/gate-diff/git.ts b/lib/gate-diff/git.tsindex daebe14d4..556ae819b 100644--- a/lib/gate-diff/git.ts+++ b/lib/gate-diff/git.ts@@ -10,7 +10,7 @@* `unsupported` files, not zero hunks. Every git call runs with* GIT_OPTIONAL_LOCKS=0, no pager, no prompt, a timeout, and `--` before paths.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { defaultBaseBranch, type DefaultBase } from '../default-base';diff --git a/lib/gate-dispositions.ts b/lib/gate-dispositions.tsindex 708ef64df..809e987d8 100644--- a/lib/gate-dispositions.ts+++ b/lib/gate-dispositions.ts@@ -13,7 +13,7 @@* the store at the pin, never from the receipt or the PR body (docs/ship-policy.md#gate-dispositions).*/import { createHash } from 'node:crypto';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { appendRows, locate, readRecord, type ApprovalRow, type Env, type RecordError, type StoreLocation } from './approval-record';diff --git a/lib/gbrain-exec.ts b/lib/gbrain-exec.tsindex c1171ef1e..aaec4a09d 100644--- a/lib/gbrain-exec.ts+++ b/lib/gbrain-exec.ts@@ -36,7 +36,8 @@import { existsSync, readFileSync } from "fs";import { isAbsolute, join } from "path";import { homedir, tmpdir } from "os";-import { spawnSync, spawn, execFileSync, type SpawnSyncReturns, type ChildProcess, type SpawnOptions } from "child_process";+import { spawn, execFileSync, type SpawnSyncReturns, type ChildProcess, type SpawnOptions } from "child_process";+import { spawnSync } from "./spawn-sync";import { resolveWindowsBash, type BashProbe } from "./script-invocation";interface GbrainConfig {diff --git a/lib/gbrain-repo-policy-client.ts b/lib/gbrain-repo-policy-client.tsindex 941a4c9d0..42d190c1c 100644--- a/lib/gbrain-repo-policy-client.ts+++ b/lib/gbrain-repo-policy-client.ts@@ -16,7 +16,7 @@* site keeps its own fail-open / fail-closed decision on `error`.*/-import { spawnSync } from "child_process";+import { spawnSync } from "./spawn-sync";import { lstatSync, statSync } from "fs";import { dirname, join } from "path";import { mergedStateRoots, resolveStateRoot } from "./state-root";diff --git a/lib/gh-poll.ts b/lib/gh-poll.tsindex 4a960b8e8..4d4c0f453 100644--- a/lib/gh-poll.ts+++ b/lib/gh-poll.ts@@ -21,7 +21,8 @@* on pollDelayMs. GSTACK_GH_POLL_FLOOR_MS is a test seam only (fixtures that* drive real binaries with millisecond polls); no shipped file may set it.*/-import { spawnSync, type SpawnSyncOptionsWithStringEncoding, type SpawnSyncReturns } from 'node:child_process';+import type { SpawnSyncOptionsWithStringEncoding, SpawnSyncReturns } from 'node:child_process';+import { spawnSync } from './spawn-sync';import type { GhResult, GhRunner } from './ci-gate';export const MIN_POLL_MS = 60_000;diff --git a/lib/harness-qm.ts b/lib/harness-qm.tsindex 01923d0f4..15b112c65 100644--- a/lib/harness-qm.ts+++ b/lib/harness-qm.ts@@ -14,7 +14,7 @@*/import { createHmac } from 'node:crypto';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { HarnessError, ledgerPath, readLedger, registrationId, writeLedger } from './harness-register';type Env = Record<string, string | undefined>;diff --git a/lib/harness-start-hook.ts b/lib/harness-start-hook.tsindex 7529d0fd2..f03368b60 100644--- a/lib/harness-start-hook.ts+++ b/lib/harness-start-hook.ts@@ -11,7 +11,7 @@* from off to on, so a plugin the user disabled in the harness is never turned back on. Turning it off and* unregistering run gstack_harness_hook_release in bin/gstack-harness-ledger.sh, the same code gstack-uninstall runs.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { readConfigKey } from './state-root';diff --git a/lib/history-read.ts b/lib/history-read.tsindex f1fb39f9f..f44546e91 100644--- a/lib/history-read.ts+++ b/lib/history-read.ts@@ -11,7 +11,7 @@* HISTORY_READ_FAILED instead of reading as absent* (docs/troubleshooting.md#history-read-failed).*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';export const HISTORY_READ_TRIES = 3;diff --git a/lib/inventory.ts b/lib/inventory.tsindex ef05c437f..67a45ed53 100644--- a/lib/inventory.ts+++ b/lib/inventory.ts@@ -7,7 +7,7 @@* buildBill (offline token estimates) and the dispatch counts ship and autoplan already document,* each found by its quoted line so a citation that drifts is named. Read-only except the CLI's write.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/land-merged-checks.ts b/lib/land-merged-checks.tsindex fdd731a95..cf18e83e0 100644--- a/lib/land-merged-checks.ts+++ b/lib/land-merged-checks.ts@@ -18,7 +18,7 @@* environment and has no per-process opt-out, so there the land process's environment stays readable to the checks.*/import { dlopen, FFIType } from 'bun:ffi';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/no-stop.ts b/lib/no-stop.tsindex 51d76cb47..3b6d55e5b 100644--- a/lib/no-stop.ts+++ b/lib/no-stop.ts@@ -14,7 +14,7 @@* The ledger is a JSON array of {class, reason, evidence} under the checkout's git dir, one file per* branch, so `gstack-ship-receipt write --no-stop @<ledger>` takes it as it stands.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { branchKey } from './approval-record';diff --git a/lib/office-hours-probe.ts b/lib/office-hours-probe.tsindex e35987aa5..1a665064a 100644--- a/lib/office-hours-probe.ts+++ b/lib/office-hours-probe.ts@@ -19,7 +19,7 @@* `-h` for a listed CLI whose output has no usage line, as with a* missing man page; never for a gstack bin), 10 s timeout, output capped*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/plan-reality-receipts.ts b/lib/plan-reality-receipts.tsindex f5d396a6b..9bc25d0a7 100644--- a/lib/plan-reality-receipts.ts+++ b/lib/plan-reality-receipts.ts@@ -18,7 +18,7 @@* Reads are bounded: only regular files whose real path stays inside the* root, at most `maxBytes`, and no file content ever appears in a result.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { RECEIPT_RE, type RealityLine } from './plan-reality';diff --git a/lib/plan-record.ts b/lib/plan-record.tsindex db95a7107..18d38e299 100644--- a/lib/plan-record.ts+++ b/lib/plan-record.ts@@ -19,7 +19,7 @@* store (gateState), so a revised gate must be imported again before it counts. Callers: gstack-ship-queue ready (writes the record into the READY note), land (checks* it), gstack-ship-release finish --plan (/ship) and gstack-approvals render --plan / plan-check.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/lib/pr-shots.ts b/lib/pr-shots.tsindex 0e8c4659a..2090edbfc 100644--- a/lib/pr-shots.ts+++ b/lib/pr-shots.ts@@ -14,7 +14,7 @@* once to pair.png through lib/aside-render.ts; with no browser the HTML and* the text fallback (text.md, a collapsed unified diff) are still written.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { resolveBase } from './gate-diff/git';diff --git a/lib/pregate/checks/literals.ts b/lib/pregate/checks/literals.tsindex a1db40bb7..46767f339 100644--- a/lib/pregate/checks/literals.ts+++ b/lib/pregate/checks/literals.ts@@ -6,7 +6,7 @@* nightly-only test still asserted the old number and went red a week after* the merge.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { baseInputs, sha256 } from '../context';diff --git a/lib/pregate/checks/secrets.ts b/lib/pregate/checks/secrets.tsindex c8dda8fe2..2ab833c88 100644--- a/lib/pregate/checks/secrets.ts+++ b/lib/pregate/checks/secrets.ts@@ -8,7 +8,7 @@* merge-base diff git did not finish. Files git calls binary are read too* (scannableReadings). Runs regardless of lint tools.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { runScriptSync } from '../../script-invocation';diff --git a/lib/pregate/checks/strays.ts b/lib/pregate/checks/strays.tsindex 6dc8e09ca..d45718c80 100644--- a/lib/pregate/checks/strays.ts+++ b/lib/pregate/checks/strays.ts@@ -6,7 +6,7 @@* `tmp-watch.js`; editor leftovers). Incident p0-4-scratch-script: a `zz-probe.sh` shipped in a* release PR because nothing looked at the file list.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../spawn-sync';import { matchesAny } from '../../ship-policy';import { baseInputs } from '../context';import type { CheckDef, CheckResult, PregateContext } from '../types';diff --git a/lib/pregate/checks/timing.ts b/lib/pregate/checks/timing.tsindex 15b4ef0f1..6bee001e4 100644--- a/lib/pregate/checks/timing.ts+++ b/lib/pregate/checks/timing.ts@@ -9,7 +9,7 @@* master went red on a 461 ms run against a 400 ms bound, and five such flakes* were fixed by hand in one week.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { baseInputs, sha256 } from '../context';diff --git a/lib/pregate/config.ts b/lib/pregate/config.tsindex 1797338a8..c03b7e260 100644--- a/lib/pregate/config.ts+++ b/lib/pregate/config.ts@@ -72,7 +72,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import { createHash } from 'node:crypto';import { shipLanesErrors, type ShipLaneMapping } from '../ci-carry';import type { ResultCodeName } from '../result-codes';diff --git a/lib/pregate/context.ts b/lib/pregate/context.tsindex 597211fab..09df33fdd 100644--- a/lib/pregate/context.ts+++ b/lib/pregate/context.ts@@ -7,7 +7,7 @@* (bin/gstack-wtree) before a check runs and again after; a tree that moved* during a check makes its result `incomplete`, never `pass`.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as os from 'node:os';diff --git a/lib/pregate/docs-only-lane.ts b/lib/pregate/docs-only-lane.tsindex cbb434837..1e7cbdd5d 100644--- a/lib/pregate/docs-only-lane.ts+++ b/lib/pregate/docs-only-lane.ts@@ -5,7 +5,7 @@* (DOCS_READER_TESTS, those present in this repository) run locally. It owes no remote gate, so no CI carry is needed;* pregate's regen (generated-page freshness) and secrets (credential scan) checks run as always.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { bunIsolationArgs } from '../bun-isolation';diff --git a/lib/pregate/flaky-exception.ts b/lib/pregate/flaky-exception.tsindex 107e4f125..4ba53f851 100644--- a/lib/pregate/flaky-exception.ts+++ b/lib/pregate/flaky-exception.ts@@ -18,7 +18,7 @@* base_red is not used: it proves a failure by reproducing it on the base, and a timing flake passes there.*/import { createHash } from 'node:crypto';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import * as path from 'node:path';import { locate, readRecord } from '../approval-record';import type { PregateException, PregateFile } from '../headless-artifacts';diff --git a/lib/pregate/head-policy.ts b/lib/pregate/head-policy.tsindex bb8d13e98..53c15f605 100644--- a/lib/pregate/head-policy.ts+++ b/lib/pregate/head-policy.ts@@ -12,7 +12,7 @@* at all, the head file is a bootstrap and runs as written. `sealed` is not* compared: its guard reads the base branch's copy itself.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { GENERATED_PATH } from '../regen';diff --git a/lib/pregate/import-graph.ts b/lib/pregate/import-graph.tsindex 5d08ef363..2e37b3fd3 100644--- a/lib/pregate/import-graph.ts+++ b/lib/pregate/import-graph.ts@@ -23,7 +23,7 @@* caller's `no lane` failure, not a pass. test/helpers/touchfile-closure.ts* (helpers and fixtures only, a lower bound by its own words) is the precedent.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { matchesAny } from '../ship-policy';@@ -170,6 +170,7 @@ export function blankDartComments(source: string): string {export function listRepoFiles(repoRoot: string): string[] {const r = spawnSync('git', ['ls-files', '-co', '--exclude-standard', '-z'], { cwd: repoRoot, encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 });+ if (r.error) throw new Error(`git ls-files did not finish: ${r.error.message}`);return (r.stdout ?? '').split('\0').filter(p => p && !p.startsWith('node_modules/'));}diff --git a/lib/pregate/index.ts b/lib/pregate/index.tsindex 152eca8c8..4f4e258bd 100644--- a/lib/pregate/index.ts+++ b/lib/pregate/index.ts@@ -10,7 +10,7 @@* land: `guards` (field wave CD1); ratchets, lint, links, hermetic, patches* and integrator later.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/lib/pregate/lane-selection.ts b/lib/pregate/lane-selection.tsindex cf07e3b5e..d8b712adc 100644--- a/lib/pregate/lane-selection.ts+++ b/lib/pregate/lane-selection.ts@@ -7,7 +7,7 @@* runner-owned selection manifest `.gstack/pregate.json` declares for a* planner-computed matrix. Every uncertainty widens the selection.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import { GENERATED_PATH } from '../regen';import { runBashSync } from '../script-invocation';import { matchesAny } from '../ship-policy';diff --git a/lib/pregate/regate.ts b/lib/pregate/regate.tsindex 83b160b63..b7f8c3b17 100644--- a/lib/pregate/regate.ts+++ b/lib/pregate/regate.ts@@ -7,7 +7,7 @@* numbers the branch adds are compared with the base branch and every open* PR; any lookup that cannot finish is `unknown`, which blocks `not-needed`.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import * as path from 'node:path';import type { ResultCodeName } from '../result-codes';import type { ShipPolicy } from '../ship-policy';diff --git a/lib/pregate/remote-receipt.ts b/lib/pregate/remote-receipt.tsindex 1d5fa7810..e866ac620 100644--- a/lib/pregate/remote-receipt.ts+++ b/lib/pregate/remote-receipt.ts@@ -29,7 +29,7 @@* working-tree fingerprint `bin/gstack-wtree` wrote). A tree that is not* here cannot be diffed and is refused, never trusted.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import type { PregateReceiptSubstitution } from '../headless-artifacts';import { parseUnifiedDiff, versionAtRef } from '../restamp';import { isUnavailable, loadPolicyFromBase, SHIP_POLICY_PATH } from '../ship-policy';diff --git a/lib/pregate/run-check.ts b/lib/pregate/run-check.tsindex 38466ec02..fd7d07265 100644--- a/lib/pregate/run-check.ts+++ b/lib/pregate/run-check.ts@@ -7,7 +7,7 @@* clear` and `gstack-pregate --from-run`, so both read profiles from the* base and nowhere else.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/pregate/workflows.ts b/lib/pregate/workflows.tsindex f6996bb60..453456474 100644--- a/lib/pregate/workflows.ts+++ b/lib/pregate/workflows.ts@@ -8,7 +8,7 @@* runner-owned selection manifest `.gstack/pregate.json` declares for it, or* it is reported as an unsupported expression and treated conservatively.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { laneOf, type Lane as Platform } from '../runtime-pins';diff --git a/lib/prose-lint.ts b/lib/prose-lint.tsindex 7eaf64131..6412a0df2 100644--- a/lib/prose-lint.ts+++ b/lib/prose-lint.ts@@ -12,7 +12,7 @@* (`--gate`), so templates and docs get a report and nothing more.*/import * as fs from 'node:fs';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { addedLines } from './banned-terms';import { parseChangelog } from './changelog-check';diff --git a/lib/quarantine.ts b/lib/quarantine.tsindex 2b4c619e9..d924faa17 100644--- a/lib/quarantine.ts+++ b/lib/quarantine.ts@@ -23,7 +23,7 @@*/import * as fs from 'fs';import * as path from 'path';-import { spawnSync } from 'child_process';+import { spawnSync } from './spawn-sync';import { parseTestId, readJunit, type JunitRunner } from './junit';import { safeText } from './flaky-run';diff --git a/lib/regen.ts b/lib/regen.tsindex 4760e5573..94a35f406 100644--- a/lib/regen.ts+++ b/lib/regen.ts@@ -15,7 +15,7 @@* globs (lib/ship-policy.ts rules), commands are single lines under 512* bytes, at most 64 entries. Docs: docs/pregate.md#generated.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as os from 'node:os';diff --git a/lib/release-stamp.ts b/lib/release-stamp.tsindex 7bff79055..011201ef0 100644--- a/lib/release-stamp.ts+++ b/lib/release-stamp.ts@@ -6,7 +6,7 @@* (bin/gstack-release-stamp); classifyRelease is the one test of "this head is the release stamp of its merge base"* that land --pin and the Version Gate both apply.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/restamp.ts b/lib/restamp.tsindex af712e23a..5e32b23df 100644--- a/lib/restamp.ts+++ b/lib/restamp.ts@@ -20,7 +20,7 @@* commands run only with allowRepoCommands (the /ship flag).*/import { createHash } from 'node:crypto';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/result-codes-release.ts b/lib/result-codes-release.tsindex 5834e5385..0c5a21893 100644--- a/lib/result-codes-release.ts+++ b/lib/result-codes-release.ts@@ -643,4 +643,9 @@ export const RELEASE_RESULT_CODES = {summary: 'git could not read the remote branch or git push failed for another reason (authentication, a pre-push hook or the network), so nothing was pushed',fix: 'repair the cause git printed in the STOP: line, repeat Step 16, then rerun push; never bypass a guard',},+ SPAWN_OUTPUT_INCOMPLETE: {+ anchor: 'spawn-output-incomplete',+ summary: 'a child process reported an error (ENOBUFS when its output passed maxBuffer) even though its exit status may be 0, so its output may be cut off and was not used',+ fix: 'rerun once; if the output really is that large (a huge diff or file list), narrow the range or paths, and report a repeat to the gstack maintainers with the command named here',+ },} as const satisfies Record<string, ResultCode>;diff --git a/lib/review-brief.ts b/lib/review-brief.tsindex eec05087e..5589261a0 100644--- a/lib/review-brief.ts+++ b/lib/review-brief.ts@@ -21,7 +21,7 @@* gstack-review-dispatch pass wrote for the kept files whose only reason is a secret line). Unset, every brief renders byte for byte as before. The base policy's readers.forbid_paths* (lib/review-fetch.ts) arrive the same way as policy_exclude items, without a disclosure.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash, randomUUID } from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/lib/review-collect.ts b/lib/review-collect.tsindex 63dd88cf8..a34c7b231 100644--- a/lib/review-collect.ts+++ b/lib/review-collect.ts@@ -7,7 +7,7 @@* line counts, the base commit's generated-output registry and collector errors;* the caller adds the gate-scan result.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { resolveBase, type ResolvedBase } from './gate-diff/git';diff --git a/lib/review-evidence.ts b/lib/review-evidence.tsindex b993ceb8b..60db6974c 100644--- a/lib/review-evidence.ts+++ b/lib/review-evidence.ts@@ -1,5 +1,5 @@import { createHash } from 'node:crypto';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';import { join } from 'node:path';import { deriveReviewStatus, isCriticalFinding, isOpenByAction, readJsonl } from './headless-artifacts';diff --git a/lib/review-exclude.ts b/lib/review-exclude.tsindex e2e469dfc..793e9fc40 100644--- a/lib/review-exclude.ts+++ b/lib/review-exclude.ts@@ -22,7 +22,7 @@* gstack-review-dispatch stops with REVIEW_DIFF_TOO_LARGE above REVIEW_DIFF_MAX_BYTES and* with REVIEW_DIFF_UNREADABLE when git fails, before it writes a manifest or a brief.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as os from 'node:os';diff --git a/lib/review-platform.ts b/lib/review-platform.tsindex b22c68ac0..880714c86 100644--- a/lib/review-platform.ts+++ b/lib/review-platform.ts@@ -5,7 +5,7 @@* review, a review at another commit, one that requested changes or was dismissed, gh unavailable) is no evidence, and the* single light reader runs.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';export const PLATFORM_REVIEWER = 'capy-ai[bot]';export interface PlatformReview { id: string; head: string; reviewer: string }diff --git a/lib/review-round-grant.ts b/lib/review-round-grant.tsindex afd052d0f..51485809a 100644--- a/lib/review-round-grant.ts+++ b/lib/review-round-grant.ts@@ -7,7 +7,7 @@* gstack-approvals round-grant, is never an owner ask and never a plan approval (lib/plan-record.ts NOT_PLAN_ROW).* --by is recorded, not enforced.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { locate, readRecord, type ApprovalRow, type Env } from './approval-record';import { GSTACK_ACTOR } from './ruled-notes';diff --git a/lib/review-targeted-delta.ts b/lib/review-targeted-delta.tsindex 81367bbec..ab2c686a6 100644--- a/lib/review-targeted-delta.ts+++ b/lib/review-targeted-delta.ts@@ -12,7 +12,7 @@* (`granted`, checked by the plan before it gets here), a code change since the read takes the same one reader (GST-1607, harness-evals #271: the* granted fix round moved the product patch the record names). Anything else keeps `done` with the reason.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { comparePath, touchedPaths } from './ship-patch';import { docsChangeSince } from './ship-receipt-depth';diff --git a/lib/review-targeted.ts b/lib/review-targeted.tsindex 5e7203e33..acd46efbc 100644--- a/lib/review-targeted.ts+++ b/lib/review-targeted.ts@@ -17,7 +17,7 @@* loosened check), not GATE_PATH: over the last 100 non-release commits on main, GATE_PATH* alone hit 43 (the precision gate allows 25), and those paths already get full depth.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/lib/run-evidence.ts b/lib/run-evidence.tsindex 1edf6a23f..308c65b8c 100644--- a/lib/run-evidence.ts+++ b/lib/run-evidence.ts@@ -35,7 +35,7 @@* once, online, at `gstack-pregate clear`; the receipt it writes carries the* evidence, and `gstack-pregate verify` checks that receipt offline.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/sealed-guard.ts b/lib/sealed-guard.tsindex 38ebcee6f..64149359d 100644--- a/lib/sealed-guard.ts+++ b/lib/sealed-guard.ts@@ -40,7 +40,7 @@* the whole file at the commit, which the base may never have held. No* combined-diff matching; any lookup failure scans everything.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as os from 'node:os';diff --git a/lib/sealed-join.ts b/lib/sealed-join.tsindex 3c048ddf4..9a1ca7cb4 100644--- a/lib/sealed-join.ts+++ b/lib/sealed-join.ts@@ -13,7 +13,7 @@* over 4 MiB, one that does not parse, nests deeper than 64 or cannot be read* is `sealed.label_join_unchecked`. Findings carry field names, never values.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash } from 'node:crypto';import type { SealedFinding } from './sealed-guard';diff --git a/lib/ship-bin-common.ts b/lib/ship-bin-common.tsindex 62968d798..59f68722a 100644--- a/lib/ship-bin-common.ts+++ b/lib/ship-bin-common.ts@@ -5,7 +5,8 @@* does next). The bins chain existing commands and never make a decision the /ship prose* assigns to the agent.*/-import { spawn, spawnSync } from 'node:child_process';+import { spawn } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/ship-handoff.ts b/lib/ship-handoff.tsindex cc0bf8af4..831ddff27 100644--- a/lib/ship-handoff.ts+++ b/lib/ship-handoff.ts@@ -20,7 +20,8 @@import * as crypto from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';-import { spawn, spawnSync } from 'node:child_process';+import { spawn } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { resolveClaudeCommand } from './claude-bin';import { readConfigKey } from './state-root';import { wtreeFingerprint } from './script-invocation';diff --git a/lib/ship-mechanical.ts b/lib/ship-mechanical.tsindex 73ecd7dd7..0a73a8d87 100644--- a/lib/ship-mechanical.ts+++ b/lib/ship-mechanical.ts@@ -11,7 +11,7 @@* - a golden: a base .gstack/generated.json entry the constant names regenerates it byte-identically (lib/regen.ts).* A declared path that fails its proof is refused with the reason and stays behavior; nothing is inferred.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/ship-patch.ts b/lib/ship-patch.tsindex 47f8d3830..c3b15f3ac 100644--- a/lib/ship-patch.ts+++ b/lib/ship-patch.ts@@ -22,7 +22,7 @@* Paths reach git as literal pathspecs from NUL-separated listings, so quoted names and glob* characters cannot widen or empty a comparison.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as os from 'node:os';diff --git a/lib/ship-policy-at.ts b/lib/ship-policy-at.tsindex e32b92197..87d7cc6ac 100644--- a/lib/ship-policy-at.ts+++ b/lib/ship-policy-at.ts@@ -5,7 +5,7 @@* default. Callers: lib/review-exclude.ts, lib/ship-receipt-depth.ts,* bin/gstack-review-plan.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { SHIP_POLICY_PATH, finish, type PolicyLoad, type PolicySource } from './ship-policy';function git(repoRoot: string, args: string[]): { ok: boolean; out: string; err: string } {diff --git a/lib/ship-policy.ts b/lib/ship-policy.tsindex b5731248e..203a227b8 100644--- a/lib/ship-policy.ts+++ b/lib/ship-policy.ts@@ -12,7 +12,7 @@* resolved against a tree. Docs: docs/ship-policy.md. Callers: bin/gstack-* ship-policy, lib/restamp.ts, lib/tree-receipt.ts, lib/ship-receipt.ts.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { defaultBaseBranch, noDefaultBaseLine } from './default-base';diff --git a/lib/ship-queue-land.ts b/lib/ship-queue-land.tsindex aa8f2d6f2..60e2b1532 100644--- a/lib/ship-queue-land.ts+++ b/lib/ship-queue-land.ts@@ -10,7 +10,7 @@* base branch's tree is the stamped tree. Every step is journaled under* .gstack/tmp/ship-queue/land/<pr>.json, so a rerun resumes.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/lib/ship-receipt-depth.ts b/lib/ship-receipt-depth.tsindex 58190ae69..e1eeffe2d 100644--- a/lib/ship-receipt-depth.ts+++ b/lib/ship-receipt-depth.ts@@ -17,7 +17,7 @@* a head whose required classes the pass did not cover (GST-966). Kept beside* lib/ship-receipt.ts so that module stays under the size ratchet.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash, randomBytes } from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/lib/ship-receipt.ts b/lib/ship-receipt.tsindex 5ee50595d..d2e2ae0d3 100644--- a/lib/ship-receipt.ts+++ b/lib/ship-receipt.ts@@ -6,7 +6,7 @@* computes the P7 adoption census over merged PRs (deduplicated by run and* thread id against an owner-maintained thread cohort).*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { ARTIFACT_SCHEMAS, checkSchema, type ShipReceipt, type ValidationError } from './headless-artifacts';import { agentNotesOrBody, splitAgentNotes, withAgentNotes } from './agent-notes';import { approvalSummary } from './approval-citations';diff --git a/lib/ship-sidecar.ts b/lib/ship-sidecar.tsindex 62748036a..bbd1e48a6 100644--- a/lib/ship-sidecar.ts+++ b/lib/ship-sidecar.ts@@ -16,7 +16,7 @@* saw is not reviewed).* Any other `.uid` is refused with the reason and stays behavior; a `.import` file is never a candidate.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { touchedPaths, type PatchSides } from './ship-patch';export interface SidecarInput {diff --git a/lib/skill-bill.ts b/lib/skill-bill.tsindex c2e72590d..1a445c6fa 100644--- a/lib/skill-bill.ts+++ b/lib/skill-bill.ts@@ -9,7 +9,7 @@import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";import { homedir } from "node:os";import { basename, dirname, join, relative, resolve } from "node:path";-import { spawnSync } from "node:child_process";+import { spawnSync } from "./spawn-sync";import { estimateTokens } from "./context-bill";import { skillEvidence } from "./inventory";diff --git a/lib/spawn-sync.ts b/lib/spawn-sync.tsnew file mode 100644index 000000000..04d9c883e--- /dev/null+++ b/lib/spawn-sync.ts@@ -0,0 +1,31 @@+/**+ * spawnSync that never hands back cut-off output as a finished read (GST-3086).+ *+ * Bun's node:child_process spawnSync can return status 0 together with error+ * ENOBUFS and stdout cut near maxBuffer: when the child exits before the+ * overflow kill lands (or ignores SIGTERM), the exit status is the child's own+ * clean exit (seen on Bun 1.4.2 and 1.4.4, GSTA-618, #4490). The default+ * maxBuffer is 1 MiB, so every buffered call has a limit. A caller that checks+ * only `status` then treats part of a diff, a file list or a scan input as the+ * whole answer. execFileSync and execSync throw in that case; spawnSync does not.+ *+ * This keeps Node's signature and result. When `error` is set and `status` is+ * not null, or the error is ENOBUFS, it returns `status: null` (so a+ * `status === 0` check fails closed), keeps `error.code`, and names+ * SPAWN_OUTPUT_INCOMPLETE in `error.message` and on the end of a captured stderr.+ * The code's row lives in lib/result-codes-release.ts; this file imports nothing+ * from lib/ because the paid test runner's global import closure includes it.+ */+import { spawnSync as nodeSpawnSync, type SpawnSyncReturns } from 'node:child_process';++export const spawnSync = ((...args: unknown[]) => {+ const r = (nodeSpawnSync as (...a: unknown[]) => SpawnSyncReturns<string | Buffer>)(...args);+ const code = (r.error as NodeJS.ErrnoException | undefined)?.code;+ if (!r.error || (r.status === null && code !== 'ENOBUFS')) return r;+ const line = `${String(args[0])}: the output may be cut off (${code ?? r.error.message}, exit ${r.status ?? r.signal ?? 'unknown'}), so it was not used; see docs/troubleshooting.md#spawn-output-incomplete (SPAWN_OUTPUT_INCOMPLETE)`;+ r.error.message = `${r.error.message} (SPAWN_OUTPUT_INCOMPLETE)`;+ const stderr = typeof r.stderr === 'string' ? `${r.stderr}${r.stderr && !r.stderr.endsWith('\n') ? '\n' : ''}${line}\n`+ : Buffer.isBuffer(r.stderr) ? Buffer.concat([r.stderr, Buffer.from(`${r.stderr.length && r.stderr[r.stderr.length - 1] !== 10 ? '\n' : ''}${line}\n`)])+ : r.stderr;+ return { ...r, status: null, stderr };+}) as typeof nodeSpawnSync;diff --git a/lib/squash-message.ts b/lib/squash-message.tsindex c577a680e..6202d96f6 100644--- a/lib/squash-message.ts+++ b/lib/squash-message.ts@@ -8,7 +8,7 @@* whole message passes the shared redaction scan before gh sees it. Every gstack merge (land --pin, the stamping* land --pr, train land) builds its message here and picks its method with landMethod.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import type { ShipPolicy } from './ship-policy';import { AGENT_NOTES_MARKER } from './agent-notes';import { foldSections, unfoldSections, visibleOpening, VISIBLE_CHARS, VISIBLE_LINES } from './pr-body-shape';diff --git a/lib/stable-release.ts b/lib/stable-release.tsindex 68a917b76..51916e640 100644--- a/lib/stable-release.ts+++ b/lib/stable-release.ts@@ -13,7 +13,7 @@* project's own release tags never stand in for gstack's.* bin/gstack-doctor-check.sh resolves it the same way in Bash for its floor row.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { cmpVersion, parseVersion } from './version-source';diff --git a/lib/test-impact/key.ts b/lib/test-impact/key.tsindex 76ec75196..6858bbae9 100644--- a/lib/test-impact/key.ts+++ b/lib/test-impact/key.ts@@ -21,7 +21,7 @@* scripts/test-impact.ts loads this module from the base ref, so a branch cannot change the* rules that decide what it skips.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../spawn-sync';import { createHash } from 'node:crypto';import * as fs from 'node:fs';import * as os from 'node:os';diff --git a/lib/transcript-consent.ts b/lib/transcript-consent.tsindex 8f39dd3c5..a40d5144a 100644--- a/lib/transcript-consent.ts+++ b/lib/transcript-consent.ts@@ -25,7 +25,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import { createHash } from 'node:crypto';import { canonicalizeRemote } from './gstack-memory-helpers';import { mergedStateRoots, readKeyFromRoot, resolveStateRoot } from './state-root';diff --git a/lib/tree-receipt.ts b/lib/tree-receipt.tsindex 1a6577e3f..831728dfb 100644--- a/lib/tree-receipt.ts+++ b/lib/tree-receipt.ts@@ -10,7 +10,7 @@* the receipt also compares the execution identity the gate ran under (from* a `gstack-evidence bundle`) with the current one.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from './spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';import { normalizeChangelog } from './changelog-check';diff --git a/lib/worktree.ts b/lib/worktree.tsindex 0a8e507ec..32d8e2ef5 100644--- a/lib/worktree.ts+++ b/lib/worktree.ts@@ -9,7 +9,7 @@* can import this directly.*/-import { spawnSync } from 'child_process';+import { spawnSync } from './spawn-sync';import * as crypto from 'crypto';import * as fs from 'fs';import * as path from 'path';diff --git a/scripts/check-conflict-markers.ts b/scripts/check-conflict-markers.tsindex 4389ef0e6..3f4ba801b 100755--- a/scripts/check-conflict-markers.ts+++ b/scripts/check-conflict-markers.ts@@ -17,7 +17,7 @@* skipped. Prints one CONFLICT_MARKER: <path>:<line> <marker> per hit and exits 1, or CONFLICT_MARKERS: none* and exits 0; a git failure exits 2.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/scripts/cso-requalification.ts b/scripts/cso-requalification.tsindex 32d061608..b98db0ced 100644--- a/scripts/cso-requalification.ts+++ b/scripts/cso-requalification.ts@@ -5,7 +5,7 @@* differ from the current source is older than its inputs and must be* requalified (or its runtimes withdrawn) before it ships.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/scripts/cso-verify-runtime-base.ts b/scripts/cso-verify-runtime-base.tsindex 9400a995d..19867e553 100644--- a/scripts/cso-verify-runtime-base.ts+++ b/scripts/cso-verify-runtime-base.ts@@ -1,6 +1,6 @@#!/usr/bin/env -S bun --no-env-file --config=/dev/null/** Native trusted-CI verification for reviewed OCI build inputs. */-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { committedImageBuildMatrix, type ImageBuildRow } from './cso-image-matrix';const MAX_OUTPUT = 1024 * 1024;diff --git a/scripts/e2e-shard-reuse.ts b/scripts/e2e-shard-reuse.tsindex 9beef61ee..9cc12312c 100644--- a/scripts/e2e-shard-reuse.ts+++ b/scripts/e2e-shard-reuse.ts@@ -25,7 +25,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { buildEvalInputIdentity, lookupEvalInputCache, sourceDependencyClosure, storeEvalInputCache,type EvalCacheValue, type EvalInputIdentity, type EvalPassingProof } from '../crew/scripts/eval-input-cache';import { matchGlob } from '../test/helpers/test-selection';diff --git a/scripts/eval-bg.ts b/scripts/eval-bg.tsindex ac265acbb..c519edf29 100644--- a/scripts/eval-bg.ts+++ b/scripts/eval-bg.ts@@ -27,7 +27,7 @@import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { pollDelayMs } from '../lib/gh-poll';import { detectBaseBranch } from '../test/helpers/touchfiles';import { DEFAULT_JOBS, ROOT, type PaidTier } from './lib/paid-types';diff --git a/scripts/eval-trial-series.ts b/scripts/eval-trial-series.tsindex 65a29ba0f..78c763c36 100644--- a/scripts/eval-trial-series.ts+++ b/scripts/eval-trial-series.ts@@ -20,7 +20,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { createHash } from 'node:crypto';import { LIVE_REGISTRY, readTrialOutcomeDir, type Registry } from './eval-flake-rank';import { formatTrialOutcomes, parseTrialOutcomes } from '../test/helpers/eval-store';diff --git a/scripts/lib/ci-history.ts b/scripts/lib/ci-history.tsindex 3ea51b75c..0d547c32a 100644--- a/scripts/lib/ci-history.ts+++ b/scripts/lib/ci-history.ts@@ -11,7 +11,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../lib/spawn-sync';import type { FlakeLedgerEntry } from '../test-free-shards';// --- Clients ---diff --git a/scripts/lib/eval-history.ts b/scripts/lib/eval-history.tsindex b73d84c51..ad1a13539 100644--- a/scripts/lib/eval-history.ts+++ b/scripts/lib/eval-history.ts@@ -19,7 +19,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../lib/spawn-sync';import { panelVerdict, type TrialOutcomeRecord } from '../../test/helpers/eval-store';import { HEADROOM_FAIL, HEADROOM_WARN } from '../../test/helpers/eval-budgets';import { sanitizeFixedFenceLine } from './published-text';diff --git a/scripts/lib/paid-select.ts b/scripts/lib/paid-select.tsindex 2b2f75bae..baed1e08c 100644--- a/scripts/lib/paid-select.ts+++ b/scripts/lib/paid-select.ts@@ -4,7 +4,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../../lib/spawn-sync';import { normalizeRelativePath } from './shard-engine';import { isPaidTestFile } from '../../test/helpers/paid-test-set';import { PERIODIC_CI_EXCLUDE } from '../../test/helpers/periodic-exclude-data';diff --git a/scripts/modules-install.ts b/scripts/modules-install.tsindex 122034409..aaa88c50c 100644--- a/scripts/modules-install.ts+++ b/scripts/modules-install.ts@@ -21,7 +21,7 @@* (name, digest and an install lock) beyond the newest KEEP by last use are* removed once unused for PRUNE_GRACE_MS.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { createHash, randomBytes } from 'node:crypto';import * as fs from 'node:fs';import * as os from 'node:os';diff --git a/scripts/pr-dependencies.ts b/scripts/pr-dependencies.tsindex 4959fe0a2..70e02b6ff 100644--- a/scripts/pr-dependencies.ts+++ b/scripts/pr-dependencies.ts@@ -26,7 +26,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { matchGlob } from '../test/helpers/test-selection';import { isPaidTestFile } from '../test/helpers/paid-test-set';diff --git a/scripts/ship-measure-sweep.ts b/scripts/ship-measure-sweep.tsindex d51aa21b8..7d8e8c159 100644--- a/scripts/ship-measure-sweep.ts+++ b/scripts/ship-measure-sweep.ts@@ -25,7 +25,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { CASE_QUARANTINE } from '../test/helpers/periodic-exclude-data';import { E2E_KINDS, E2E_TIERS, LLM_JUDGE_TOUCHFILES } from '../test/helpers/touchfiles-data';import { parseCliFlags } from './lib/shard-engine';diff --git a/scripts/ship-measure.ts b/scripts/ship-measure.tsindex 797dbc482..94aca53c9 100644--- a/scripts/ship-measure.ts+++ b/scripts/ship-measure.ts@@ -52,7 +52,8 @@import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';-import { spawn, spawnSync } from 'node:child_process';+import { spawn } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { EVAL_POLICY } from '../test/helpers/periodic-exclude-data';import { E2E_KINDS, E2E_TIERS, LLM_JUDGE_TOUCHFILES } from '../test/helpers/touchfiles-data';import { getClaudeCliVersion, getProjectEvalDir, isFinalizedEvalResultFile } from '../test/helpers/eval-store';diff --git a/scripts/skill-check.ts b/scripts/skill-check.tsindex 4c3cccf8f..5b146435c 100644--- a/scripts/skill-check.ts+++ b/scripts/skill-check.ts@@ -5,7 +5,7 @@import * as fs from 'fs';import * as os from 'os';import * as path from 'path';-import { spawnSync } from 'child_process';+import { spawnSync } from '../lib/spawn-sync';import { validateSkill, externalHostPathLeaks } from '../test/helpers/skill-parser';import { ALL_HOST_CONFIGS } from '../hosts/index';import {diff --git a/scripts/skill-gates-smoke.ts b/scripts/skill-gates-smoke.tsindex 8c41c24b8..efb782b8c 100644--- a/scripts/skill-gates-smoke.ts+++ b/scripts/skill-gates-smoke.ts@@ -19,7 +19,7 @@* 0 when every check passes, 1 when one fails, 2 on a setup error.* Docs: docs/skill-gates.md#headless-smoke.*/-import { spawnSync } from 'child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'fs';import * as os from 'os';import * as path from 'path';diff --git a/scripts/slop-diff.ts b/scripts/slop-diff.tsindex 5689f23de..89753e835 100644--- a/scripts/slop-diff.ts+++ b/scripts/slop-diff.ts@@ -11,7 +11,7 @@* bun run slop:diff origin/release # diff against another base*/-import { spawnSync } from "child_process";+import { spawnSync } from "../lib/spawn-sync";import * as fs from "fs";import * as os from "os";import * as path from "path";diff --git a/scripts/test-health-report.ts b/scripts/test-health-report.tsindex bbc48d17e..a8cb522e9 100644--- a/scripts/test-health-report.ts+++ b/scripts/test-health-report.ts@@ -18,7 +18,7 @@*/import * as fs from 'node:fs';import * as path from 'node:path';-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import { GH_CLIENT, downloadRunArtifacts, formatFlakeSummary, historyFetcher, listRunJobs, listWorkflowRuns, readCiFlakeLedgers,readFlakeLedgerDir, repoSlug, unavailableReason, type CiRun, type FlakeWindow, type GhClient } from './lib/ci-history';import { analyzePassRates, readTrialOutcomeDir, type TrialRecord } from './eval-flake-rank';diff --git a/scripts/test-impact.ts b/scripts/test-impact.tsindex d392e192b..8c3bf9066 100755--- a/scripts/test-impact.ts+++ b/scripts/test-impact.ts@@ -14,7 +14,7 @@** Nothing here changes what CI runs. Exit codes: 0 done, 1 a traced run or key failed, 2 usage or setup.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as os from 'node:os';import * as path from 'node:path';diff --git a/scripts/typecheck-test.ts b/scripts/typecheck-test.tsindex 3e0458ba5..c315820eb 100644--- a/scripts/typecheck-test.ts+++ b/scripts/typecheck-test.ts@@ -11,7 +11,7 @@* Fixing one error and adding an identical-message error in the same file is* the one substitution this cannot see.*/-import { spawnSync } from 'node:child_process';+import { spawnSync } from '../lib/spawn-sync';import * as fs from 'node:fs';import * as path from 'node:path';diff --git a/test/spawn-sync.test.ts b/test/spawn-sync.test.tsnew file mode 100644index 000000000..2df711430--- /dev/null+++ b/test/spawn-sync.test.ts@@ -0,0 +1,114 @@+/**+ * lib/spawn-sync.ts (GST-3086): a spawnSync whose output passed maxBuffer never+ * reads as a finished command. Bun can return status 0 together with error+ * ENOBUFS and cut-off stdout when the child exits before the overflow kill+ * lands (GSTA-618, seen on Bun 1.4.2 and 1.4.4). A child that ignores SIGTERM+ * reproduces that every time, so these tests do not depend on timing.+ */+import { describe, expect, test } from 'bun:test';+import { spawnSync as rawSpawnSync } from 'node:child_process';+import * as fs from 'node:fs';+import * as os from 'node:os';+import * as path from 'node:path';+import { RESULT_CODES } from '../lib/result-codes';+import { spawnSync } from '../lib/spawn-sync';+import { gitEnv } from './helpers/git-env';++const OVERFLOW = "process.on('SIGTERM', () => {}); process.stdout.write('x'.repeat(200000)); setTimeout(() => {}, 300);";+const overflowArgs = ['-e', OVERFLOW];++describe('spawnSync (lib/spawn-sync.ts)', () => {+ test.skipIf(process.platform === 'win32')('raw Bun spawnSync reports status 0 with ENOBUFS for a child that outlives the overflow kill', () => {+ const r = rawSpawnSync(process.execPath, overflowArgs, { encoding: 'utf8', maxBuffer: 1024, timeout: 20_000 });+ expect((r.error as NodeJS.ErrnoException | undefined)?.code).toBe('ENOBUFS');+ expect(r.status).toBe(0);+ });++ test('an overflowing read returns status null and names SPAWN_OUTPUT_INCOMPLETE', () => {+ const r = spawnSync(process.execPath, overflowArgs, { encoding: 'utf8', maxBuffer: 1024, timeout: 20_000 });+ expect(r.status).toBeNull();+ expect((r.error as NodeJS.ErrnoException | undefined)?.code).toBe('ENOBUFS');+ expect(r.error?.message).toEndWith('(SPAWN_OUTPUT_INCOMPLETE)');+ const line = r.stderr.trimEnd().split('\n').pop() ?? '';+ expect(line).toEndWith('(SPAWN_OUTPUT_INCOMPLETE)');+ expect(line).toContain(`docs/troubleshooting.md#${RESULT_CODES.SPAWN_OUTPUT_INCOMPLETE.anchor} `);+ });++ test('a Buffer-mode read gets the same line on its stderr Buffer', () => {+ const r = spawnSync(process.execPath, overflowArgs, { maxBuffer: 1024, timeout: 20_000 });+ expect(r.status).toBeNull();+ expect(Buffer.isBuffer(r.stderr)).toBe(true);+ expect(r.stderr.toString('utf8')).toContain('(SPAWN_OUTPUT_INCOMPLETE)');+ });++ test('a clean read and a plain non-zero exit pass through unchanged', () => {+ const ok = spawnSync(process.execPath, ['-e', "process.stdout.write('hi')"], { encoding: 'utf8', timeout: 20_000 });+ expect(ok.status).toBe(0);+ expect(ok.stdout).toBe('hi');+ expect(ok.error).toBeUndefined();+ const bad = spawnSync(process.execPath, ['-e', "process.stderr.write('no'); process.exit(3)"], { encoding: 'utf8', timeout: 20_000 });+ expect(bad.status).toBe(3);+ expect(bad.stderr).toBe('no');+ });+});++describe('the pre-push credential scan with a cut-off diff', () => {+ const PREPUSH = path.resolve(import.meta.dir, '..', 'bin', 'gstack-redact-prepush');+ const FAKE_AWS_KEY = ['AKIA', '1234567890ABCDEF'].join('');++ // POSIX only: the stub is a #!/bin/sh file named git, which Windows does not run.+ test.skipIf(process.platform === 'win32')('a diff git finishes with status 0 after passing the 64 MiB buffer BLOCKS the push', () => {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'spawn-sync-prepush-'));+ const repo = path.join(root, 'repo');+ const stubDir = path.join(root, 'stub');+ const git = (args: string[]) => {+ const r = rawSpawnSync('git', args, { cwd: repo, encoding: 'utf8', timeout: 30_000, env: gitEnv() });+ if (r.status !== 0 || r.error) throw new Error(`git ${args.join(' ')} failed: ${r.stderr}`);+ return r.stdout.trim();+ };+ try {+ fs.mkdirSync(repo);+ fs.mkdirSync(stubDir);+ git(['init', '-q', '-b', 'main']);+ git(['config', 'user.email', '[email protected]']);+ git(['config', 'user.name', 'T']);+ fs.writeFileSync(path.join(repo, 'README.md'), 'base\n');+ git(['add', 'README.md']);+ git(['commit', '-q', '-m', 'base']);+ const base = git(['rev-parse', 'HEAD']);+ fs.writeFileSync(path.join(repo, 'config.txt'), `aws_access_key_id = ${FAKE_AWS_KEY}\n`);+ git(['add', 'config.txt']);+ git(['commit', '-q', '-m', 'add config']);+ const head = git(['rev-parse', 'HEAD']);+ // The diff call prints about 90 MB of context lines first, so the real diff (and its key) lands past the+ // hook's 64 MiB maxBuffer; it ignores SIGTERM and exits 0, which is what Bun then reports as the status.+ const realGit = Bun.which('git') || '/usr/bin/git';+ const stub = [+ '#!/bin/sh',+ 'if [ "$1" = "diff" ]; then',+ " trap '' TERM",+ " printf 'diff --git a/pad.txt b/pad.txt\\n--- a/pad.txt\\n+++ b/pad.txt\\n@@ -1,2000000 +1,2000000 @@\\n'",+ " yes ' padding line that only fills the read buffer of the scanner' | head -n 2000000",+ ` "${realGit}" "$@"`,+ ' exit 0',+ 'fi',+ `exec "${realGit}" "$@"`,+ '',+ ].join('\n');+ fs.writeFileSync(path.join(stubDir, 'git'), stub, { mode: 0o755 });+ const pathKey = Object.keys(process.env).find(k => k.toLowerCase() === 'path') || 'PATH';+ const r = rawSpawnSync('bun', [PREPUSH], {+ cwd: repo,+ input: `refs/heads/main ${head} refs/heads/main ${base}\n`,+ encoding: 'utf8',+ env: gitEnv({ [pathKey]: `${stubDir}${path.delimiter}${process.env[pathKey] || ''}` }),+ timeout: 60_000,+ });+ expect(r.status).toBe(1);+ expect(r.stderr).toContain('could not compute the pushed diff');+ expect(r.stderr).toContain('SPAWN_OUTPUT_INCOMPLETE');+ } finally {+ fs.rmSync(root, { recursive: true, force: true });+ }+ }, 90_000);+});