Repository navigation
Description
Problem
The test suite is not hermetic against the environment sequant's own phases run under. phase-executor.ts:1458 injects SEQUANT_ORCHESTRATOR, SEQUANT_WORKTREE (and SEQUANT_PHASE/SEQUANT_ISSUE) into every phase, for every driver. An exec phase that runs npm test inherits them, and two tests change outcome:
| Env var | Test | Result |
|---|---|---|
SEQUANT_ORCHESTRATOR=sequant-run |
src/commands/__tests__/prompt-wait.test.ts › returns 0 and prints the reply when one arrives within the window |
expected 1 to be +0 |
SEQUANT_WORKTREE=<path> |
src/lib/workflow/batch-executor.test.ts › returns the input config unchanged when onProgress is undefined |
config gains 2 keys (13 vs 11) |
SEQUANT_PHASE and SEQUANT_ISSUE alone do not reproduce.
Why it matters
An exec phase that sees red tests in files its diff never touched cannot tell pre-existing breakage from its own, and the exec skill's pre-PR gate correctly refuses to open a PR. That is what stopped #1060's gate run 3: exec (Codex driver) reported 7 failures in unchanged files and opened no PR, so QA returned AC_NOT_MET on a correct implementation. Driver-agnostic — a Claude Code phase gets the same env.
Reproduce ($0)
SEQUANT_ORCHESTRATOR=sequant-run npx vitest run src/commands/__tests__/prompt-wait.test.ts
SEQUANT_WORKTREE=$PWD npx vitest run src/lib/workflow/batch-executor.test.ts -t "onProgress is undefined"
Both pass with the vars unset.
Not attributed
Run 3's other 5 failures (2 cli-ui.test.ts minimal-mode cases, 3 batch-executor.test.ts cases at 7–10s) did not reproduce in isolation, including under codex sandbox with the driver's exact workspace-write config. Exec had several vitest runs and lint in flight at once; contention fits the timeouts. Out of scope unless they reproduce.
Acceptance criteria
- AC-1:
SEQUANT_ORCHESTRATOR=sequant-run SEQUANT_WORKTREE=$PWD SEQUANT_PHASE=exec SEQUANT_ISSUE=1 SEQUANT_RELAY=true SEQUANT_RELAY_FRAME=1 npx vitest run src/commands/__tests__/prompt-wait.test.ts src/lib/workflow/batch-executor.test.ts __tests__/integration/relay-hook.integration.test.tspasses - AC-2: the fix scrubs every variable matching
^SEQUANT_by prefix at the suite level (vitest configenvor a setup file that runs in every worker), not from a list and not per test, so a new phase var or a new test cannot reintroduce the leak — Verify:grep -n 'SEQUANT_' vitest.config.ts vitest.global-setup.ts vitest.setup.ts 2>/dev/nullshows one prefix match, no per-name list - AC-3: a test that deliberately reads one of the scrubbed vars still controls it explicitly (
vi.stubEnv) and passes - AC-4: gate test — mutation-verified per CLAUDE.md §Testing: remove the scrub, confirm the AC-1 command fails, restore, record the marker in the PR body
- AC-5: the PR body records whether
SEQUANT_ORCHESTRATOR=sequant-runalone andSEQUANT_WORKTREE=$PWDalone reproduce under the AC-1 test files in the worktree (Phase 0 on 09-18 and 09-20 got 1 passed for each; onlySEQUANT_RELAY=truereproduced alone — PLAN OQ-1)
Release-graph plan — guard-2026-09 (2026-09-20)
Graph: guard-2026-09 Tier: mechanical Wave: 1
May touch: vitest.config.ts, vitest.global-setup.ts or a new vitest.setup.ts, and the three AC-1 test files only if AC-3 needs an explicit vi.stubEnv example
The npm run build && npm test AC is verified by the runner from a clean shell after the PR opens (PLAN I-1); the agent runs only the test files its ACs name. Mutation markers use failedTest starting with the test file path (I-4). Root node: until this merges the runner's suite shows these failures under the orchestrator, so its PR is merged first when the owner consents.
Activity
admarble commentedon Sep 19, 2026
Third leaked var, verified 2026-09-18:
SEQUANT_RELAY=true(set atphase-executor.ts:1516when relay is on) breaks__tests__/integration/relay-hook.integration.test.ts› AC-7 "does NOT render when SEQUANT_RELAY is unset".Worth adding
SEQUANT_RELAY(andSEQUANT_RELAY_FRAME,:1521) to the AC-2 scrub list. With it, the fix covers all three of the failures that PRs #1036, #1042 and #1048 (2026-09-10/11) each reported as "3 pre-existing failures inbatch-executor.test.ts,prompt-wait.test.ts,relay-hook.integration.test.ts, unrelated to this diff" — those three were this bug, a week before it was filed.Null result, for the record: in a clean interactive shell here,
SEQUANT_ORCHESTRATOR=sequant-runalone did not failprompt-wait.test.ts(3 passed) andSEQUANT_WORKTREE=$PWDalone did not fail the batch-executoronProgress is undefinedcase (1 passed). Not disputing the repro above; those two may need the combined env or relay state under.sequant/.chore(hooks): allow anchored env|grep in the env-dump guard; red test…
admarble commentedon Sep 20, 2026
Runner context — guard-2026-09 launch, 2026-09-20. Base:
origin/mainatda9ed6e8(2.16.0 plus the plan docs). These rules override the exec skill's defaults for this run:npm testin the worktree. Run only the test files this issue's ACs name. The runner runs the full suite once per PR from a clean shell. Undersequant runthe suite is not hermetic againstSEQUANT_*(bug(test): suite isn't hermetic against the SEQUANT_* env phases inject — exec sees red tests it didn't cause and opens no PR #1086), so a full run shows red files you did not cause.env -u SEQUANT_ORCHESTRATOR -u SEQUANT_WORKTREE -u SEQUANT_PHASE -u SEQUANT_ISSUE -u SEQUANT_RELAY -u SEQUANT_RELAY_FRAME npx vitest run <file>. If it is still red, the PR body names the issue number and the base-vs-head result for that test.<!-- SEQUANT_MUTATION: {"ac":"AC-N","mutation":"<what you deleted>","failedTest":"<test file path> > <describe> > <case>"} -->in the PR body.failedTestMUST start with the test file path, or the qa classifier reports it Failed. Commit before mutating.timeout.git commit -m "...", noCo-Authored-By. Never rebase or force-push after pushing. One AC per line in the PR body, idsAC-Nonly.Issue-specific: Root node for suite hygiene. AC-5 is a PR-body record: run the AC-1 files with
SEQUANT_ORCHESTRATOR=sequant-runalone andSEQUANT_WORKTREE=$PWDalone and write both results. Do not edit any test file beyond the three AC-1 names, and only if AC-3 needs avi.stubEnvexample.admarble commentedon Sep 20, 2026
Complexity: Standard (5 ACs, 1 directory)
AC Quality Check
SEQUANT_TEMPLATES_DIR/SEQUANT_LOCKS_DIR-style vars the suite deliberately sets are also caught by a prefix scrub.SEQUANT_WORKTREE, butwithActivityHook(src/lib/workflow/batch-executor.ts:150-151) branches onSEQUANT_ORCHESTRATORonly;SEQUANT_WORKTREEis not read there. That fits both null results in the comments (each var alone passes). AC-5 records this, so the PR should report it as measured, not asserted.Scope Assessment
Non-Goals:⚠️ No Non-Goals section, but "Not attributed" (cli-ui and batch-executor timeouts) and the runner's "may touch" list bound scope:
vitest.config.ts,vitest.global-setup.ts/ newvitest.setup.ts, and the three AC-1 files only for anvi.stubEnvexample.Verdict: ✅ SCOPE_OK
Acceptance Criteria
AC-1: Combined-env run of the three named files passes
Verification: Integration Test (the command itself)
Scenario: Given all six
SEQUANT_*vars exported → When the AC-1npx vitest runcommand runs → Then exit 0, all three files green.Assumptions:
globalSetupenv mutations reach forked workers (existingGIT_CONFIG_GLOBALscrub relies on the same inheritance) — confirm with the AC-1 run itself, not by reading vitest docs.AC-2: Prefix scrub at suite level
Verification: Manual Test (grep) plus AC-1/AC-4 as behavioral proof
Scenario: Given
vitest.global-setup.ts→ Whengrep -n 'SEQUANT_' vitest.config.ts vitest.global-setup.ts vitest.setup.ts→ Then exactly one prefix match (^SEQUANT_/startsWith("SEQUANT_")), no per-name list.Assumptions: Comment lines also match the grep — keep the word
SEQUANT_out of explanatory comments (write "the SEQUANT_ prefix" once, in the code line only, or phrase the comment without it) so "one match" stays literal.AC-3: A test that reads a scrubbed var still controls it explicitly
Verification: Unit Test (existing)
Scenario: Given the scrub → When
templates.test.ts(setsSEQUANT_TEMPLATES_DIR) andbatch-executor.test.ts:1495-1516(sets/restoresSEQUANT_ORCHESTRATOR) run → Then they pass; saved-original is nowundefinedand is restored viadelete.Assumptions: Both already handle an unset original. Run them post-change. Only add a
vi.stubEnvexample to an AC-1 file if a reviewer wants it — the "may touch" list allows it but does not require it.AC-4: Gate test mutation-verified
Verification: Manual Test (procedure)
Scenario: Given the fix committed → When the scrub block is deleted and the AC-1 command is re-run → Then it fails; restore; record
<!-- SEQUANT_MUTATION: {"ac":"AC-4","mutation":"deleted the SEQUANT_ prefix scrub loop in vitest.global-setup.ts","failedTest":"src/commands/__tests__/prompt-wait.test.ts > ..."} -->in the PR body.Assumptions:
failedTestmust start with the test file path (#1104). Commit before mutating. Use the test name actually printed by the failing run, and check which of the three files fail (the marker names one).AC-5: PR body records single-var reproduction results
Verification: Manual Test
Scenario: Given the worktree → When the AC-1 files run with
SEQUANT_ORCHESTRATOR=sequant-runalone, thenSEQUANT_WORKTREE=$PWDalone, on the unfixed base (or with the scrub temporarily removed) → Then the PR body records pass/fail for each.Assumptions: Measure with the scrub removed — with it in place both trivially pass and the record is meaningless. Run these during the AC-4 mutation step to save a cycle.
Implementation Plan
Phase 1: Scrub
vitest.global-setup.ts, beforeexecSync("npm run build"), add a loop:for (const k of Object.keys(process.env)) if (k.startsWith("SEQUANT_")) delete process.env[k];with a comment stating intent (phases inject these; bug(test): suite isn't hermetic against the SEQUANT_* env phases inject — exec sees red tests it didn't cause and opens no PR #1086). Follows the existing hermetic-git block directly above it.vitest.setup.tslisted undersetupFilesin both projects (setupFilesis per-project inprojects: [...], not inherited from the roottest).Phase 2: Verify
templates.test.ts,batch-executor.test.ts,prompt-wait.test.tsand the relay-hook file with the vars unset (regression check on AC-3).AC-Nonly. Stop at the PR.Per the runner context: no full
npm testin the worktree; run only the named files.Design Review
vitest.global-setup.ts— it already owns the hermetic-git env scrub and runs for every project. A per-filebeforeEachwould be the per-test approach AC-2 forbids.test.env(can only set values;""leaves the var defined, andBoolean(process.env.X)sites differ from=== undefinedsites); an explicit name list (the reason for AC-2).GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEMblock in the same file, relying on fork inheritance. Tests that need a var already set it in-process (process.env.X = ...with save/restore), so a startup scrub does not disturb them.Feature Quality Planning
All standard checks pass. Notable items:
sequant runitself is unaffected (it is not run under vitest).SEQUANT_TEMPLATES_DIR(38 refs),SEQUANT_LOCKS_DIRandSEQUANT_SKILL_LOCK_TTL_MSare read by production code and could also leak from a developer shell; the prefix scrub covers them at no extra cost. Non-SEQUANT_leaks (e.g.CLAUDE_*) are out of scope — not proposed here.Derived ACs
None.
Open Questions
globalSetupmutation reach the forked workers under Vitest 4projects? — Recommendation: try it first (matches existing precedent); AC-1 is the arbiter; fallback in Plan step 2. Impact if wrong: AC-1 fails and we addvitest.setup.ts.SEQUANT_*var (e.g.SEQUANT_TEMPLATES_DIRused by CI smoke workflows)? — Recommendation: no. Only.github/workflows/opencode-smoke.ymlsets it, and that job does not invoke vitest (checked by grep, novitest/npm testthere). AC-2 requires pure prefix, no exceptions. Impact if wrong: a CI job that passed a var into vitest would silently lose it.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: Small mechanical
bugfix in one config file; testgen skipped (bug label, and AC-1's command is itself the test). No UI, no security surface.Label Review
Current: bug
Recommended: bug, planned
Reason: Plan posted; no additional labels warranted.
Quality Loop: Won't auto-enable (SCOPE_OK, single file).
admarble commentedon Sep 20, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/1 met
Gaps:
SEQUANT_*vars to leak — the only thing that catches the regression is someone manually re-running the AC-1 command under an orchestrator. AC-4 asked for a mutation record, which was delivered, so this is not an AC gap; it is the durability gap left behind.Suggestions:
vitest.global-setup.test.tsthat setsprocess.env.SEQUANT_FAKE, calls the exportedsetup(), and asserts the key is gone would convert this into a real gate. It would also have made §6i classify naturally (see below). TheexecSync("npm run build")line would need extracting or stubbing first.SEQUANT_prefix, or the scrub will silently disable it.docs(#1086): changelog entry for the SEQUANT_ prefix scrub
fix(#1086): scrub SEQUANT_* env by prefix in the vitest global setup (#…