Skip to content

gstack's script runner and merge-queue checks now refuse cut-off command output (GST-3104) - #4502

Merged
capy-ai[bot] merged 3 commits into
mainfrom
script-runner-and-merge-queue-refuse-cut-off-output
Nov 18, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
script-runner-and-merge-queue-refuse-cut-off-output

Conversation

@garrytan

@garrytan garrytan commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

The helper that runs gstack's own scripts and bash -c commands, and the merge queue's branch-ownership, stacked-test, release-version and merge-group record checks, now fail with SPAWN_OUTPUT_INCOMPLETE when Bun cuts a command's output off, instead of treating part of it as the whole answer.
Why: #4492 added this for the scanners and gates but left these on Node's spawnSync, and its release note claimed wider coverage than it shipped.
Nothing to do: a new test stops any new gstack command from calling Node's spawnSync directly.

What changed

runBashSync on 200 KB of output under a 1 KiB limit that exits 0: main reports status 0 on cut-off output; this branch reports status null with SPAWN_OUTPUT_INCOMPLETE

On main, runBashSync returns status 0 when the child's output overflows the read limit and the child still exits 0, so a caller reads cut-off output as a finished answer. On this branch it returns status null with SPAWN_OUTPUT_INCOMPLETE.

Testing
  • Failing first: two cases in test/script-invocation.test.ts run a bun-shebang script and a bash -c string that print 200 KB under a 1 KiB maxBuffer, ignore SIGTERM and exit 0. On main both return status 0; on this branch both return status null with ENOBUFS and SPAWN_OUTPUT_INCOMPLETE on stderr. The bash -c case skips on Windows.
  • The two tests Commands that read cut-off output now fail instead of judging part of it (GST-3086) #4492's review left out, in test/spawn-sync.test.ts: the pre-push stub now execs the git binary from git --exec-path instead of Bun.which('git'), with a case showing a PATH-resolving wrapper first on PATH is what Bun.which returns and is not what the stub uses; and listRepoFiles throws both when git cannot start and when a stub git ls-files prints past 64 MiB and exits 0.
  • Fixture copy lists that include lib/script-invocation.ts now also include lib/spawn-sync.ts (doctor fixture, PlanTune cathedral, timeline stop-hook slug).
  • Passed locally: bun run typecheck, bun run typecheck:test (no new diagnostics), and the focused files above plus pr-dependencies (paid-runner closure), module-size ratchet, sync-spawn timeout tripwire, Bun entry isolation, docs-only and test-of-test ratchets. bun run test:quick failed only in browse tests that need a Playwright browser this machine does not have, and two test/cso-witness.test.ts cases that need the built CSO launcher; neither touches a changed file. CI is the full run.
Before/after as text
--- Before (main at 36b349d)
+++ After (this branch at e67b269)
-{"status":0,"stdoutBytes":20480,"error":"ENOBUFS","stderrTail":""}
+{"status":null,"stdoutBytes":16384,"error":"ENOBUFS","stderrTail":"bash: the output may be cut off (ENOBUFS, exit 0), so it was not used; see docs/troubleshooting.md#spawn-output-incomplete (SPAWN_OUTPUT_INCOMPLETE)"}
  • lib/script-invocation.ts (runScriptSync, runBashSync, used by the pre-merge checks' test-selection manifest read, /ship's review-log read and many bins) now imports spawnSync from lib/spawn-sync.ts.
  • Five merge-queue modules in crew/lib/ that read git or test output with a 64 MiB or 256 MiB limit do the same: lane-ownership.ts, ship-queue-gate.ts, ship-queue-stack-tests.ts, version-gate-train.ts and ship-queue-train-record.ts (the last already checked r.error; it moves so the list below shrinks).
  • Import check in test/spawn-sync.test.ts: no product file (code files and bin/ scripts, tests excluded) may import spawnSync from node:child_process unless it is in test/fixtures/spawn-sync-raw-importers.json. That list has 68 files and may only shrink.
  • Changelog: a new fragment says what is covered now and that the earlier entry's claim was too broad.
Why

The follow-up to #4492 (GST-3086) found that "every other gstack command that reads large git or gh output" was not covered: the script runner and five merge-queue modules still called Node's spawnSync, which reports status 0 on cut-off output when the child exits 0. These now fail closed like the pre-push hook and the pre-merge scans.

Blast radius

Every caller of runScriptSync and runBashSync and the five merge-queue modules now gets status null instead of 0 only when output overflowed; normal output passes through unchanged (wrapper tests in test/spawn-sync.test.ts, a probe of diffLane on this branch's own diff returned all 14 files, and the full free suite passed in CI run 44362338523).

Test Coverage

All new code paths have test coverage: 7 of 7 paths (two runner paths tested end to end with a real overflowing child, the five module imports held by the import check and the wrapper's own tests). Tests: 1819 → 1819 test files (+0 written in this step; the failing-first cases came with the change).

Pre-Landing Review

No blocking issues. Five notes below the blocking floor, left for a follow-up:

  • The import check misses the combined form import cp, { spawnSync } from 'child_process'; no file in the repo uses it.
  • lane-ownership.ts drops git's stderr, so a cut-off read reports "git diff failed" without the reason; it still marks the branch unresolved.
  • wtreeFingerprint labels a cut-off read as "could not start"; it still refuses.
  • The cut-off notice is printed twice by lib/ship-bin-common.ts; the verdict is unaffected.
  • A caller that branches on a specific exit code sees null in the overflow case; no caller can reach it today.

A second-model review (openai/gpt-6.1-sol) found nothing.

Exploratory QA

Pass, 3 probes on this branch: runBashSync returns status 0 with full output on a small command; it returns status null, ENOBUFS and SPAWN_OUTPUT_INCOMPLETE when 200 KB overflows a 1 KiB limit and the child exits 0; diffLane reads this branch's diff normally (14 files).

Scope Drift

Scope Check: CLEAN. Intent: send the script runner and the merge-queue modules through the cut-off-output wrapper and stop new raw imports. Delivered: exactly that, plus the fixture copy lists and the changelog fragment.

Documentation

Status: current. The documentation already matches this branch, so no edits were made.

Scope: base 36b349d to head e67b269, branch script-runner-and-merge-queue-refuse-cut-off-output, with no staged, unstaged or new files. The change sends the script runner (lib/script-invocation.ts) and five merge-queue modules in crew/lib through lib/spawn-sync.ts, so cut-off output fails with SPAWN_OUTPUT_INCOMPLETE. It also adds a guard test and a list of 68 files that still import spawnSync raw.

Documentation health:

  • docs/troubleshooting.md: current. The SPAWN_OUTPUT_INCOMPLETE entry is generic and covers the new callers.
  • changelog.d/script-runner-and-merge-queue-refuse-cut-off-output.md: current. It matches the code, and its count of 68 matches the fixture.
  • README.md, AGENTS.md and docs/TESTING_INTERNALS.md: not affected. These modules are internal and no doc describes them.

Debt: none in coverage and no diagram drift. The browser's process-list read is still not protected; the changelog fragment says so.

Tests
  • Failing first: two cases in test/script-invocation.test.ts (a bun-shebang script and a bash -c string that print 200 KB under a 1 KiB limit, ignore SIGTERM and exit 0) return status 0 on main and status null with SPAWN_OUTPUT_INCOMPLETE here; the bash -c case skips on Windows.
  • Focused local run at e67b269: test/spawn-sync.test.ts, test/script-invocation.test.ts, test/free-fixtures.test.ts, test/plan-tune-cathedral.test.ts, test/timeline-stop-hook-slug.test.ts, test/gstack-doctor.test.ts, test/spawnsync-timeout-tripwire.test.ts, test/module-size-ratchet.test.ts, crew/test/ship-queue-train-logic.test.ts, crew/test/train-backstop.test.ts: 127 pass, 0 fail.
  • Typecheck, module-size and conflict-marker checks before push: pass.
  • Full free suite in CI on this exact tree: run 44362338523, green; macOS jobs green in the same run; Windows smoke green in run 44357891103.
Agent notes

Follow-up to #4492 (GST-3086), GST-3104.

Approvals

No approvals recorded for branch script-runner-and-merge-queue-refuse-cut-off-output.
Plan: exempt: bug fix (--kind fix, R65; failing-first tests in test/script-invocation.test.ts)
Plan check: exempt bug fix

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

Open in Capy

{
  "schema_version": 1,
  "pr": 4502,
  "head": "4667b995d584093d0725933b33d07da1ab221acb",
  "version": "1.101.0.0",
  "base": "main",
  "gate": {
    "targeted": {
      "pass": 127,
      "fail": 0,
      "skip": 0
    }
  },
  "calls": 27,
  "session_kind": "unattended",
  "run": "ship-4502-e67b269",
  "head_tree": "fa82433df57a66850c48740f6efebabf5996ba04",
  "product_patch_id": "f585e83302a3d0385e8422002281173bcea12730",
  "gstack_version": "1.101.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 13,
    "rules": "1afa38a4be3b5eef",
    "base": "36b349d66017758af838910dde344cda6c7339bc",
    "registry": "36b349d66017758af838910dde344cda6c7339bc",
    "gate_scan": {
      "tagged": 0,
      "head": "4667b995d584093d0725933b33d07da1ab221acb"
    },
    "reasons": [
      "gate-class",
      "risk:security",
      "runtime=13"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @fa82433df57a (8 checks, current for 4667b995d584)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/44369695132/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44369695132/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44367744731/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=fa82433df57a tests=37865 skipped=73 runs=44369695132/1 profiles=ci-reuse/free-tests heads=4667b995d584 verified=2026-11-18T18:36:13.395Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, CONTRIBUTING.md, AGENTS.md, CLAUDE.md and changelog.d fragments vs 36b349d6..e67b2692"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 4,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 3,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  },
  "gate_dispositions": [],
  "carry": {
    "from": "e67b2692096b94a84b5359152dd7331433e87182",
    "reason": "release metadata",
    "product_patch_id": "f585e83302a3d0385e8422002281173bcea12730",
    "changed_paths": [
      "metadata:changelog.d/script-runner-and-merge-queue-refuse-cut-off-output.md"
    ],
    "merge_commits": 0,
    "range_diff": "1:  bdb64804 = 1:  bdb64804 gstack's script runner and merge-queue checks refuse cut-off output (GST-3104)\n2:  e67b2692 = 2:  e67b2692 Register the raw spawnSync importer list as a free test fixture (GST-3104)\n-:  -------- > 3:  4667b995 Say which leftover raw spawnSync readers are not short reads in the changelog entry (GST-3104)",
    "covers": [
      "pre-landing review",
      "adversarial review",
      "gate integrity",
      "documentation audit"
    ],
    "reruns": [
      "CI at head (gstack-ship-queue ready requires it); test and helper code changed since the reviewed head runs there unreviewed"
    ],
    "ancestry": "linear",
    "trees": [
      "820a0c8be5b2da8024cfbec45f6cfed1cc4a349e"
    ]
  }
}
{"head":"e67b2692096b94a84b5359152dd7331433e87182","version":"1.101.0.0","gstack_version":"1.101.0.0","run":"ship-4502-e67b269","review_loop":{"passes":1,"blocking_found":0,"deferred":0,"noted":4,"fixed":0,"scope":"frozen","rounds":1,"ledgers_read":3,"dispatches":{"specialist":3,"red-team":1}},"depth":"full"}

…GST-3104)

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

trunk-io Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 2 commits November 18, 2026 17:21
…3104)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…hangelog entry (GST-3104)

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant