Skip to content

Run large unit suites on Linux instead of failing with argument list too long (#4424) - #4426

Merged
capy-ai[bot] merged 3 commits into
mainfrom
capy/run-large-unit-suites
Nov 17, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
capy/run-large-unit-suites

Conversation

@garrytan

@garrytan garrytan commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

/ship's test step now runs a unit suite with thousands of files on Linux instead of stopping with E2BIG: argument list too long before any test runs. It keeps gstack's merge checks working on large repositories such as gbrain, which has 5,567 unit files.

What changed

Before: a lane over Linux's 128 KiB per-argument limit stopped with the runner could not be launched (700 files): E2BIG: argument list too long, posix_spawn 'bash', and the fix text said to install a missing tool. After: the same lane passes with 700 tests ran in 700 file(s), exit 0, and a launch that still hits the limit is reported as arg-limit, not as a missing tool.

Why

gbrain's merge check stopped with PREGATE: incomplete and E2BIG on its 5,567 unit files (#4424). gstack put every unit file of a lane into one command argument, and Linux caps one argument at 128 KiB. A big file list now runs as several runner processes of about 96 KB each (24 KB on Windows), read back as one run, so any failing chunk still fails the lane.

Blast radius

Only a unit group whose quoted file list passes the limit changes; a group that fits in one process runs the identical command, because runOnce returns its single part unchanged (read at lib/pregate/checks/lanes.ts:414). CI's free suite passed at 7eeef79 (run 44026832699, 1,672 test files), and the remote-gate path is untouched.

Summary, tests and review

Summary

A team running /ship on gbrain hit E2BIG before a single test started, with advice to install a tool that was already installed. Lanes now split a large file list into byte-bounded chunks run one after another under the group's one deadline, add up their counts, and let the first unfinished or failing chunk decide the result. An E2BIG launch failure gets its own environment kind, arg-limit, whose fix says to report it as a gstack bug. The review round made the new test put its failing file in the last chunk, and the docs audit noted the Windows chunk size.

Test Coverage

Tests: 1791 → 1791 (+0 new; the PR adds test/pregate-lanes-arg-limit.test.ts, counted before the audit)
Coverage: 67% value-weighted (67% including 0 weakly covered paths), 4 gaps. 0 tests added.
Test value: 0 tests written, 0 rejected by the authoring gate, 0 existing tests extended, 0 paths weakly covered.
Coverage gate: 67%, between the minimum 60% and the target 80%; the audit ran audit-only (no generation in this run), so the gaps below are proposed tests.

lib/pregate/checks/lanes.ts
  argBudget()      [★★★] linux cap and env shrink; [★★] win32 cap
  argChunks()      [★★★] order, budget, oversized argument, empty list, one chunk
  runOnce() chunks [★★] single chunk unchanged; [★★★] 700 files over 128 KiB pass; [★★★] failing last chunk fails the lane
                   [GAP] a chunk that stalls or times out ends the group
                   [GAP] noBrowsers kept only when every chunk has it
                   [GAP] ran/failed become null when any chunk's summary is unparsed
lib/pregate/environment.ts
  [★★] E2BIG and "Argument list too long" classify as arg-limit
  [GAP] the launch path shows the arg-limit fix text
lib/pregate/types.ts  type only
COVERAGE: 8/12 paths (67%)

Tests ran: free 1672

Pre-Landing Review

Pre-Landing Review: 8 issues — 1 auto-fixed, 0 asked (0 fixed, 0 skipped), 0 deferred, 7 noted.

  • [AUTO-FIXED] test/pregate-lanes-arg-limit.test.ts:56: the test was named for a failure in the last chunk, but sorting put the failing file first; the failing file now sorts last (3c1a808), and the fix-check read it clean.
  • Second-model review (GPT-6.1 Sol): completed with one finding, that adding counts across chunks hides a chunk that ran zero tests. Ruled below the blocking floor and kept as a note: the zero-run check is per runner process and a unit group was one process before this change, so a whole-group zero is still caught and no lane that failed before now passes.

Review notes

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

  • INFORMATIONAL lib/pregate/checks/lanes.ts:468 The PREGATE_INCOMPLETE timeout detail says --timeout applies to each runner process, but chunks of a split unit group now share one deadline, as docs/pregate.md says; the message names the wrong scope for a chunked group.
  • INFORMATIONAL lib/pregate/checks/lanes.ts:502 The undeclared remote fallback (ubi-runner.sh run -- '') still inlines the whole file list into one bash -c argument, so a huge selection routed remotely on a <8-core machine can still hit E2BIG; pre-existing, and the new arg-limit fix text suggests the remote route.
  • INFORMATIONAL lib/pregate/checks/lanes.ts:417 Outside voice (stated High, Blocks: yes): summing ran across chunks lets a zero-test chunk pass beside a chunk that ran tests, so the ZERO-RUN guard does not see it. Lead judgment, below the floor: the guard is per runner process and a unit group was one process before this change, so an unsplit group whose files partly ran zero tests already summed to a positive count and passed; a whole-group zero still sums to 0 and is still caught. No test fails and no lane that failed before now passes; failing a zero-test chunk would make a split group stricter than the same files in one process (for example a chunk of win32-skipped files). Named for the owner in Review notes.
  • INFORMATIONAL lib/pregate/checks/lanes.ts:468 Native voice 1 (Low): the timeout detail says --timeout applies to each runner process, but a split group's chunks share one deadline; macOS is also capped at 96 KiB though it has only the 1 MiB total limit, so a large macOS group now runs as several processes under one deadline. Same location as p1/specialist-batched#2.
  • INFORMATIONAL lib/pregate/checks/lanes.ts:415 Native voice 2 (Low): bad prefers the first unfinished chunk, so a later chunk that fails to launch reports PREGATE_ENVIRONMENT even when an earlier chunk had counted test failures; the lane still fails (misattribution only).
  • INFORMATIONAL lib/pregate/checks/lanes.ts:416 Native voice 3 (Low): noBrowsers survives aggregation only when every chunk has it, so a split Playwright group where one chunk shows no browser error reports PREGATE_LANE_FAILED instead of the missing-binary environment cause; the lane still fails.
  • INFORMATIONAL lib/pregate/environment.ts:26 Native voice 4 (Low): the arg-limit rule also matches runner output printed before the first counted test (proof output), the same risk every output rule carries; investigate only if it shows up.

Exploratory QA

Functional surface, smoke budget (5 minutes): 2 probes on fixture repositories, both pass. Probe 1: a 700-file unit group whose quoted list is over 128 KiB passes with 700 tests in 700 files. Probe 2: the failing file sorts last, so only the final chunk fails; the lane fails with PREGATE_LANE_FAILED, 1 failed of 700 ran. A first probe set was blocked by the probe's own inherited install-verdict environment and was rerun with it unset. Not probed: stall, timeout, Playwright and unparsed-count chunks, and the remote route.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed — evals skipped.

Review bot comments

No review bot comments.

Scope Drift

Scope Check: CLEAN

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Fix: add "Plan: " to the PR body, or run /autoplan.

Issues

Fixes #4424
Refs p1/specialist-batched#1

Verification Results

No plan obligations (bug fix, no plan bound). Exploratory QA: 2 PASS, 0 FAIL, 0 BLOCKED on current inputs.

TODOS

No TODO items completed in this PR.

Documentation

Status: updated. One factual correction in docs/pregate.md; no blockers.

Scope: committed diff 5dcd76b..3c1a808 (6 files: lib/pregate/checks/lanes.ts, lib/pregate/environment.ts, lib/pregate/types.ts, test/pregate-lanes-arg-limit.test.ts, docs/pregate.md, changelog.d/lanes-large-file-lists-on-linux.md); no staged, unstaged or new files.

Documentation health

  • docs/pregate.md: Updated. The lanes section already described chunked unit runs and the environment-kinds table already listed arg-limit; added the 24 KB Windows chunk budget next to the 96 KB figure.
  • changelog.d/lanes-large-file-lists-on-linux.md: Current (not edited in ship-owned mode).
  • README.md, AGENTS.md, CONTRIBUTING.md: Current (no pregate lane surface).

Coverage debt: the arg-limit environment kind and file-list chunking have reference coverage in docs/pregate.md only, with no how-to; acceptable for an internal runner detail. argBudget and argChunks are exported for tests and are not public surface.

Diagram drift: none.

Test plan

  • bun run test: CI free-tests run 44026832699 at 7eeef79, 1,672 test files, exit 0 (carried)
  • bun test --timeout=30000 test/pregate-lanes-arg-limit.test.ts at 3c1a808: 3 pass, 0 fail

Known gap: the PREGATE_ENVIRONMENT entry in docs/troubleshooting.md does not list arg-limit yet (found by the first docs audit; not edited in this PR).

Agent notes

REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=7 fixed=1 scope=frozen ledgers_read=5 fix_checks=1 dispatches=3 est_input_tokens=13241
Gate edits: none detected (1 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Outside review: completed (host-subagent, openai/gpt-6.1-sol); 1 finding, noted below the floor.

Approvals

No approvals recorded for branch capy/run-large-unit-suites.
Plan: exempt: bug fix
Plan check: exempt bug fix

{
  "schema_version": 1,
  "pr": 4426,
  "head": "7eeef79ec77d1d5e2490557aa14a71e17ab1529c",
  "version": "1.99.5.0",
  "base": "main",
  "gate": {
    "free": {
      "pass": 1672,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "free",
      "run": 44026832699,
      "attempt": 1,
      "tree": "1de586763c9da6725d77359552445e2dd57afab6"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "1de586763c9da6725d77359552445e2dd57afab6",
  "product_patch_id": "146bdcf97033ac0f5b6dd75331a65808cb05a81d",
  "gstack_version": "1.99.5.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 67,
    "rules": "66e5174161eecc2c",
    "base": "5dcd76b4eae6bb06f73460d3ab29cef8e33e8537",
    "registry": "5dcd76b4eae6bb06f73460d3ab29cef8e33e8537",
    "gate_scan": {
      "tagged": 0,
      "head": "7eeef79ec77d1d5e2490557aa14a71e17ab1529c"
    },
    "reasons": [
      "gate-class",
      "runtime=67"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @1de586763c9d (8 checks, current for 7eeef79ec77d)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44026832699/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44026832930/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=1de586763c9d tests=37337 skipped=73 runs=44026832699/1 profiles=ci-reuse/free-tests heads=7eeef79ec77d verified=2026-11-17T05:58:26.890Z"
  ],
  "issues": {
    "fixes": [
      4424
    ],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/, README.md, CLAUDE.md, AGENTS.md, CONTRIBUTING.md against 5dcd76b (pregate lane chunking and the arg-limit kind)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 7,
    "fixed": 1,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 2,
    "est_input_tokens": 13241,
    "ledgers_read": 5,
    "dispatches": {
      "specialist-batched": 1,
      "red-team": 1,
      "fix-check": 1
    }
  },
  "gate_dispositions": []
}

…too long

A lane passed every unit file in one bash -c argument; Linux caps one
argument at 128 KiB, so thousands of files failed with E2BIG. Split the
file list into byte-bounded chunks run in sequence and read back as one
run, and classify E2BIG as its own arg-limit cause.

Fixes #4424

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

trunk-io Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 2 commits November 17, 2026 05:36
Put the failing fixture file last after sorting so the arg-limit test really checks a failure in the final chunk.

Review-Finding: p1/specialist-batched#1 reader=testing
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 5b4fa9e into main Nov 17, 2026
54 checks passed
@garrytan garrytan mentioned this pull request Nov 17, 2026
capy-ai Bot added a commit that referenced this pull request Nov 17, 2026
- /autoplan's approval page no longer hides a reviewer's product objection behind "keep your direction". (#4431)
- Every skill that loads the shared preamble, on every host, now says to ask a question once and to check a file before handing it over. (#4383)
- The Captain manuals now name the `Failed or skipped:` and `Also changed:` lines that READY and lane reports carry. (#4432)
- gstack's shell locks hold again on Ubuntu 26.04, where `mkdir` reports success when another process won the race (GST-2247). (#4262)
- `test/gstack-lock-race.test.ts` runs the old pattern and the helper against a PATH shim that behaves like uutils 0.8.0 `mkdir`, so it runs on any runner image: the old pattern lets two of four racers win, the helper admits exactly one in each of 60 races and never overlaps across take, hold and release loops, and parallel `gstack-config` writers keep every key. (#4262)
- Windows Setup E2E now runs when `bin/gstack-lock.sh` changes. (#4433)
- Claude Code's skill list now says when to use each gstack skill, so Opus loads /review and /plan-eng-review when a request fits. (#4387)
- A pull request's merge head can no longer keep its `/ship` receipt without a full review. (#4365)
- `/ship` now counts review rounds per pull request, and the head that merges always gets a full review. (#4360)
- /ship's documentation audit no longer accepts a passing result when an earlier line from the same audit said "blocked". (#4434)
- /ship's documentation audit no longer spends an attempt when the audit child writes text after its result. (#4285)
- The README lists the two new guides, and the install doc counts its hooks right. (#4403)
- docs/releases.md now says the stable release cut treats a failed commit status as red and a pending one as still going, as it has since #4257. (#4436)
- /ship's `finish --docs-requested` now accepts a docs fix when the audit named the file with a line number. (#4437)
- Document the `.gstack/approval-classes.json` schema, `gstack-approval-classes` CLI commands, and owner approval citation format in `docs/ship-policy.md#approval-classes`. (#4355)
- `/eval-plan` now runs four result checks instead of leaving them to judgment. (#4384)
- The /review coverage-audit eval no longer fails a run that really read the source file when zsh stops a command line at an `echo ====` separator. (#4364)
- Sixteen in-repo documentation links reach their section again. (#4394)
- gstack agents now open every status report with what failed, what they didn't verify and what else they changed. (#4273)
- Two new short guides. (#4380)
- A skill you wrote whose contract still lists `check_after_last_edit` keeps the rest of its contract. (#4439)
- The ship policy guide now explains how to merge any pull request with `gstack-ship-queue land`, even in a repository with one maintainer. (#4377)
- /ship's test step runs a large unit suite on Linux. (#4426)
- Every skill that loads the shared preamble, on every host, now says never to print a whole environment, git config or process table. (#4382)
- Pull requests from /ship now open with at most three plain lines, and every merge lands as one commit titled with the PR title. (#4438)
- `gstack-pr-wait`, `gstack-ci-gate` and the release cut no longer call a commit green while a check on it failed. (#4257)
- `gstack-runaway` now says what a thread's cold and empty wakes cost, not just how many there were (GST-2770). (#4385)
- The optional Stop hook no longer checks for a test run after the last edit, and /verify asks for it in plain words instead. (#4428)
- /ship's test step says when it ran out of time, and you can set its budget. (#4429)
- The remote test command no longer puts every file on one command line. (#4429)
- The stable release no longer waits on the nightly Windows tests (GST-2815). (#4400)
- Ubicloud fan-outs can no longer overshoot the vCPU limit, and owners no longer delete each other's VMs. (#4430)
- hono is pinned to 4.13.16, which fixes five advisories the weekly OSV scan found in 4.13.13 (gstack#4406). (#4408)
- `package.json` overrides (#4408)
- `test/dependency-security.test.ts`: the lockfile floor check now covers `hono >= 4.13.16`. (#4408)
- The nightly Windows test run finishes again. (#4409)
- A short write-up checklist in ETHOS.md. (#4381)

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.

/ship test step fails on Linux when the unit suite has thousands of files (argument list too long)

1 participant