From e32274caf45b10d47164002b5d49c5a46969e404 Mon Sep 17 00:00:00 2001 From: garrytan Date: Mon, 26 Oct 2026 04:19:19 +0000 Subject: [PATCH] test(preload): strip the Capy launch markers so a direct bun test matches the shard sandbox Red Team finding: the launch-marker scrub lived only in createShardSandbox, so a direct `bun test ` run under an unattended Capy session inherited GSTACK_SESSION_KIND, GSTACK_CAPY, GSTACK_EPHEMERAL and GSTACK_INSTALL_VERDICT (GSTA-99's symptom). The preload now deletes the same four names, and test/shard-engine.test.ts imports CAPY_LAUNCH_MARKERS instead of re-typing them. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- test-setup.ts | 5 +++++ test/shard-engine.test.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test-setup.ts b/test-setup.ts index 1f95ab067..1cd3470f9 100644 --- a/test-setup.ts +++ b/test-setup.ts @@ -33,6 +33,11 @@ for (const name of ['GSTACK_STATE_ROOT', 'GSTACK_STATE_DIR']) { delete process.env[name]; process.stderr.write(`test-setup: stripped inherited ${name}; tests isolate state via GSTACK_HOME\n`); } +// The Capy installer's launch markers (GSTA-99, GSTA-104): a focused `bun test` +// run from a shell that sourced the launch file would hand every product child +// an unattended Capy session it never set up. The shard engine strips the same +// list for the lanes; this reaches direct runs too. +for (const name of ['GSTACK_SESSION_KIND', 'GSTACK_CAPY', 'GSTACK_EPHEMERAL', 'GSTACK_INSTALL_VERDICT']) delete process.env[name]; process.env.GSTACK_TEST_LEGACY_ROOT = path.join(os.tmpdir(), `gstack-test-legacy-root-${process.pid}-${Date.now()}-unused`); // Workflow leases (bin/gstack-lease) default to the installation's git dir; // for the dev checkout under test that is this repo's .git, and a live test diff --git a/test/shard-engine.test.ts b/test/shard-engine.test.ts index 36395f891..272d5d740 100644 --- a/test/shard-engine.test.ts +++ b/test/shard-engine.test.ts @@ -24,6 +24,7 @@ import { strictShardStatus, writeDurationSeed, zeroExecutionVerdict, + CAPY_LAUNCH_MARKERS, } from '../scripts/lib/shard-engine'; import { FREE_LANE_POLICY, exitCodeFor, runFreeShard } from '../scripts/test-free-shards'; import { @@ -252,7 +253,7 @@ describe('shard engine: capture and isolation', () => { for (const box of [a, b]) { expect(box.env.KEEP).toBe('1'); expect(box.env.GSTACK_HOME).toBeUndefined(); - for (const key of ['GSTACK_SESSION_KIND', 'GSTACK_CAPY', 'GSTACK_EPHEMERAL', 'GSTACK_INSTALL_VERDICT']) expect(box.env[key]).toBeUndefined(); + for (const key of CAPY_LAUNCH_MARKERS) expect(box.env[key]).toBeUndefined(); expect(box.env.GSTACK_STATE_ROOT).toBe('/kept-root'); for (const key of ['TMPDIR', 'TEMP', 'TMP']) expect(box.env[key]).toBe(box.tmp); expect(box.env.CHROMIUM_PROFILE).toBe(path.join(box.stateDir, 'chromium-profile'));