fix: provider-cli pick spawns anchor at the sandbox project (real-repo config corruption) - #138
Merged
Merged
Conversation
…al-repo tripwire
akPick() destructured { cwd, ... } but pickSandbox() returns { project, ... },
so every call site spawned `ak x host pick --yes` with cwd undefined —
inherited from the test process: the real repository root. HOME/XDG/APPDATA
were correctly sandboxed, but pick's PROJECT-scoped writes anchor at
repoRoot(cwd), so each full test run rewrote the developer's real
.claude/settings.local.json (ENABLE_CODEX=false) and
.agentic-qe/llm-config.json (fixture openai chain, empty overrides).
Idempotent rewrites kept the corruption invisible on an already-hit repo,
and CI's throwaway checkout never surfaced it.
The spawn now anchors at cwd ?? project, and an after() tripwire records
the real cwd's two project files at module load and asserts them
byte-identical when the suite ends — a future harness regression fails
loudly instead of corrupting machines silently. Verified: from a healthy
repo state the tripwire fired before the anchor fix, and a full
pnpm run check now leaves both files hash-identical.
Fixes #137
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.
Fixes #137.
The leak
akPick()destructures{ cwd, home, binDir, catalog }butpickSandbox()returns{ home, project, binDir, catalog }— all 20 call sites pass the sandbox object wholesale, socwdwas alwaysundefinedandspawnSyncinherited the test process's cwd: the real repository root. HOME/XDG/APPDATA were correctly sandboxed (kit.json and ~/.claude were safe), butak x host pick --yesalso performs PROJECT-scoped writes anchored atrepoRoot(cwd):.claude/settings.local.json→ENABLE_CODEX: "false"from claude-only fixtures.agentic-qe/llm-config.json→ fixtureclaude-code→openaichain, emptyagentOverridesEvery
pnpm test/pnpm run checkon a developer machine silently regressed that machine's real provider/routing state. Two properties kept it invisible: rewrites are idempotent (an already-corrupted repo shows no mtime-content change on reruns), and CI runs in a throwaway checkout. This retroactively explains recurring "mysterious" post-test-run drift on a dev machine thatak synckept re-healing.The fix
akPickanchors the spawn at the sandbox project:cwd: cwd ?? project(heals all 20 call sites).after()hook records the real cwd's two project files at module load and asserts them byte-identical when the suite ends — any future harness regression of this class fails the suite loudly instead of corrupting machines silently.Verification
settings.local.jsonbefore the anchor fix (the corrupted state had masked it — idempotent rewrites — so the repo was healed first to expose true RED).pnpm run check(1469 tests, 0 fail) leaves both real files hash-identical (md5 before/after).🤖 Generated with Claude Code