fix(test-runner): cap bun heap with --smol, env-gate scope:all, process-group kill on timeout#962
Merged
Merged
Conversation
…ss-group kill on timeout - Add `--smol` to both bun command builders (dispatch default path in `src/lang/default-backend.ts` and legacy path in `src/tools/test-runner.ts`) to cap heap growth and prevent OOM-driven session crashes. - Remove agent-settable `allow_full_suite` arg from `TestRunnerArgs` and Zod schema; gate `scope:'all'` behind `SWARM_ALLOW_FULL_SUITE` env var (CI/maintainer only, not accessible via LLM tool call). Error message deliberately omits the env var name. - Add opt-in `killProcessTree: true` to `BunCompatSpawnOptions`; test-runner spawn sets this flag. Node path spawns `detached: true` and kills via `process.kill(-pid)` (POSIX) or `taskkill /T` (Windows). Default behaviour of all other ~30 `bunSpawn` callers is unchanged. - Update `AGENTS.md` §6, `docs/engineering-invariants.md`, and all agent-facing skill files to reflect the new gate. Agent-facing docs do not reveal the env var name. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…leanup, windowsHide) - Add stdin: 'ignore' to bunSpawn call in runTests() to prevent Windows stdin-pipe block on child exit (AGENTS.md invariant 3, v7.3.3 regression) - Capture and clear setTimeout handle in timeoutPromise so the timer is cancelled when the process exits normally, matching the bun-compat.ts pattern (lines 546-548) - Add windowsHide: true to bunSpawn Node spawn path for consistency with bunSpawnSync and to prevent console flash on Windows with detached: true - Add negative assertion: blocked-scope error must not contain 'SWARM_ALLOW_FULL_SUITE' env var name, hardening the security guard against future accidental leakage - Fix dispatch-parity test expectation for vitest command (rebase artifact: main added --reporter=json --outputFile args; test now matches actual code) - Fix parsed.error type safety in MAX_SAFE_SOURCE_FILES test (use ?? '')
7a255f7 to
40f1b72
Compare
zaxbysauce
added a commit
that referenced
this pull request
May 22, 2026
…te refs, add subprocess patterns - swarm-pr-review: add STALE BRANCH CHECK block before explorer dispatch. A branch behind main makes origin/main..HEAD show all of main's changes, inflating apparent scope (22 files appeared as 152 in PR #962). Documents git cat-file parent-SHA comparison and the correct git diff <parent>..<head> command for true PR scope. - running-tests: fix duplicate 'all' scope row; update gate from removed allow_full_suite: true to SWARM_ALLOW_FULL_SUITE=1 env var (PR #962) - engineering-conventions: update scope:'all' gate description from allow_full_suite arg to SWARM_ALLOW_FULL_SUITE env var; add windowsHide and clearTimeout patterns to the subprocess invariant description
Owner
Author
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: zaxbysauce <10211642+zaxbysauce@users.noreply.github.com>
Contributor
Resolved and pushed in commit Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
�un --smol on every test run: both the dispatch path (src/lang/default-backend.ts) and legacy path (src/tools/test-runner.ts) now emit ['bun', '--smol', 'test', ...]. This caps bun's heap growth and eliminates OOM-driven OpenCode session crashes during broad test runs, matching the per-file CI pattern already used throughout the repo.
scope: 'all' is now environment-gated: the agent-settable �llow_full_suite argument has been removed from TestRunnerArgs and the Zod schema. The only unlock is SWARM_ALLOW_FULL_SUITE=1 in the environment (CI/maintainer sessions only — not accessible via LLM tool call). The blocked-response message deliberately omits the env var name to prevent prompt-engineering.
Process-group kill on timeout: �unSpawn gains an opt-in killProcessTree: true flag. When set (only by the test-runner), the Node spawn path uses detached: true and kills via process.kill(-pid) on POSIX or askkill /PID /T /F on Windows, reaping jest/vitest worker-pool descendants. The ~30 other �unSpawn callers are unaffected (opt-in only).
Prose docs aligned: AGENTS.md §6, docs/engineering-invariants.md, and all agent-facing skill files updated to reflect the new gate. Agent-facing docs do not reveal the env var name.
Root cause
The tool crashed OpenCode sessions via OOM because (a) bun ran without --smol so heap grew unbounded across a 50-file batch, (b) �llow_full_suite: true was documented directly in the schema, teaching LLMs how to bypass the scope block, and (c) the schema alone enforced nothing — prose warnings in AGENTS.md failed repeatedly because nothing in the tool itself enforced safety.
Invariant audit
ode --input-type=module import OK; �undle-portability.test.ts / �undle-plugin-shape.test.ts unaffected
ode scripts/repro-704.mjs passed all 3 timing assertions. dist import OK verified.
Test plan
ode scripts/repro-704.mjs — T1/T2/T3 all OK
Pre-existing failures (not regressions)
All confirmed on origin/main baseline:
egistration-smoke,
epo-graph-codex-adversarial,
epo-graph.adversarial: all in untouched files, all matching baseline.