Repository navigation
test: keep update-channel tests off the real state root, and guard it (GST-1659) - #4094
Merged
Merged
Conversation
…T-1659) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
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.
What changed
An exported
GSTACK_STATE_ROOTno longer receives the update-channel test'sgstack-configwrites: on main the sentinel'sconfig.yamlgainsupdate_channel: stable, and on this branch it stays unchanged.Before/after as text: An exported GSTACK_STATE_ROOT no longer receives the test's gstack-config writes
Why
GST-1659: running
test/update-channel.test.tswithout this repository'sbunfig.tomlpreload (from another directory, or withbun --config=/dev/null test) wroteupdate_channelinto whateverGSTACK_STATE_ROOTthe shell exported, which can flip a developer's or crew machine's update channel. Those tests now keep every write in their own temp roots, and a guard test fails if any exported state root or HOME changes. The install fixture also accepts a worktree whosenode_modulesis a symlink, which brokeupdate-channel-setup.test.ts4 of 4 in a worktree.Evidence
GSTACK_STATE_ROOT=<sentinel> … bun --config=/dev/null test test/update-channel.test.tsran 15 pass and 1 fail, and the sentinel'sconfig.yamlgainedupdate_channel: stable.state-root/config.yamlchanged. With the fix it runs 3 pass in about 43 s.node_modules -> /workspace/gstack/node_modules,update-channel-setup.test.tsfailed 0/4 before the fix and passes 4/4 after it.gstackHomeran 1211 pass and 8 fail. The 8 failures are all ingbrain-sync-skip.test.tsand fail the same way without this change, because the machine-local bun shim does not find bun on that test's scrubbed PATH.bun run typecheckandtypecheck:testreport no new diagnostics. The state-root ratchet, bun-entry isolation, spawnSync tripwire, module-size ratchet and install-fixture tests all pass.Blast radius
Test code only, with no product change.
runBin'sgstackHomeoption now setsGSTACK_STATE_ROOTtoo, which reaches its 59 callers; under the normal preloadGSTACK_STATE_ROOTis absent, so they resolve the same directory as before, and CI's free suite passed at this head (run 42282505151, 36060 tests carried). The guard adds about 43 s to the free suite, seeded inscripts/free-test-durations.json.Approvals
No approvals recorded for branch capy/gst-1659-state-root-isolation.
Summary
The
runBinhelper setGSTACK_HOMEandGSTACK_STATE_DIRbut notGSTACK_STATE_ROOT, which outranks both, andtest-setup.tsstrips that variable only when Bun loads this repository'sbunfig.toml. NowgstackHomesets all three state-root variables, every spawn inupdate-channel.test.tsstarts fromisolatedEnv()(the state-root chain removed and HOME in a temp dir), andtest/state-root-isolation.test.tsruns both update-channel test files with the whole chain and HOME pointed at sentinel directories. A planted test that callsgstack-config seton the inherited environment is the negative control, and the guard catches it writingstate-root/config.yaml.Test Coverage
All new code paths have test coverage: the change is test code, and the new guard carries its own negative control.
Tests ran: focused 23 (
bun test --timeout=30000 test/update-channel.test.ts test/state-root-isolation.test.ts test/update-channel-setup.test.ts, Capy git guard directory removed from PATH; see Review notes)Pre-Landing Review
No blocking issues found. Readers: batched specialist (testing, security, state-machines), red team, native adversarial (Opus 5.5) and outside voice (GPT-6.1 Sol, medium). Specialists, red team and outside voice reported no findings; the adversarial reader and the lead review raised 5 low-severity notes, listed under Review notes, none fixed (below the crew blocking floor).
REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=1 fixed=0 scope=frozen ledgers_read=1 dispatches=4
Gate edits: none detected (19 listed, 16 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Outside review: completed, GPT-6.1 Sol via a host subagent, recommendation approve, no findings.
Review notes
test/state-root-isolation.test.ts:44(lead review): the guard's childbun testruns with Bun's default 5 s per-test timeout, while the free suite uses 30 s. The slowest guarded test took 1.8 to 2.8 s on a 2-core machine, so only a heavily loaded runner could fail the guard while the file passes. Passing--timeout=30000to the child would match the suite..capy(tree()ininstall-fixture.tsskips them), so a leak that only creates a directory or writes underHOME/.capywould pass the guard.runBin'sgstackHomenow overrides a caller's explicitenv.GSTACK_STATE_ROOT. The one caller passing both (test/gate-diff-cli.test.ts:41, which unsets it) still passes.BUN_RUNTIME_TRANSPILER_CACHE_PATHis a fixed shared path under the temp dir and is never cleaned; a per-run path under the sentinel base would avoid sharing.update-channel.test.tsstarts from the isolated environment, but therunBincall still inheritsCLAUDE_PLUGIN_DATA; it is safe becauseGSTACK_STATE_ROOToutranks it.giton PATH is a PATH-searching wrapper (Capy's shared-tree git guard), thegstack-update-checktest's git shim and the wrapper exec each other until the 30 s timeout. It fails identically on main a7585d0, and CI does not have the wrapper.Exploratory QA
Smoke: the focused lane (23 pass),
update-channel.test.tsunder--config=/dev/null(16 pass, slowest 1.8 s), the guard's planted-leak negative control (passes inside the guard), and the before/after repro above (main writesupdate_channel: stableto the exported sentinel; this head writes nothing). QA method files were not read for this test-only diff.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). This is a bug fix with a repro on main, so it skips plan review.
Verification Results
No Step 8.1 obligations (no plan bound).
TODOS
No TODO items completed in this PR.
Documentation
Status: current. This was a read-only audit, and no documentation changes are needed.
Audited scope: 7 committed files from a7585d0 to ffa7d2e, with no staged, unstaged or new files. The branch changes only test infrastructure:
runBin'sgstackHomeoption now sets all three state-root variables, update-channel tests spawn from an isolated environment, the new guardtest/state-root-isolation.test.tsand its helpertest/helpers/state-root-isolation.tswere added, the install fixture no longer treats anode_modulessymlink as source, there is a new test-durations entry, and there is a changelog.d fragment. I checked these against the state-root, testing, contributor and entry-point docs.Coverage: All shipped features have adequate documentation. No public surface changed, so there are no critical or common gaps and no diagram drift.
Low-priority debt (optional): The new state-root isolation guard (
test/state-root-isolation.test.ts) and itsisolatedEnvhelper are explained only in source comments. A one-line how-to pointer in the docs/TESTING_INTERNALS.md fixtures section would make them easier to find.Test plan
bun test --timeout=30000 test/update-channel.test.ts test/state-root-isolation.test.ts test/update-channel-setup.test.ts(Capy git guard directory removed from PATH): 23 pass, 0 fail🤖 Generated with Claude Code