Repository navigation
Conversation
Running npm test from a shell inside a live Claude Code session fails 4 tests at HEAD and silently pollutes the user's real plugin data: ~150 fake 'codex-plugin-test-*' workspaces and ~420 job records per two runs land in $CLAUDE_PLUGIN_DATA/state, because: - CLAUDE_PLUGIN_DATA is inherited by in-process state writes and by spawned companions (buildEnv spreads process.env), so fixture state goes to the real data dir instead of the temp fallback, and 'resolveStateDir uses a temp-backed per-workspace directory' fails; - CODEX_COMPANION_SESSION_ID (set by the plugin's own session hook) makes status/result session-filter fixture-seeded jobs that carry no sessionId, failing the status/result tests. Fix: helpers.mjs pins CLAUDE_PLUGIN_DATA to a fresh temp root per test process and clears CODEX_COMPANION_SESSION_ID (session-scoped tests set it explicitly); the fallback-path state test now manages the variable locally like its CLAUDE_PLUGIN_DATA sibling already does. Validated: suite run from inside a live Claude Code session (14 CLAUDE*/CODEX* vars present) goes 87/91 -> 91/91 with zero new entries in the real plugin state dir. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Independent reproduction on a different machine, in case a second data point helps. Environment: Windows 11, Node 22, plugin 1.0.6, run from inside a live Claude Code session (
The failing one is Worth noting for anyone triaging: this is not Windows-specific and CI cannot catch it, because GitHub Actions never sets I also see the fixture leak this PR describes: |
Fixes #455.
Problem
npm testrun from inside a live Claude Code session fails 4 tests at HEAD and leaks fixture state into the user's real plugin data dir (~150 fakecodex-plugin-test-*workspaces / ~420 job records per two runs). Two inherited variables cause it:CLAUDE_PLUGIN_DATA→ in-process state writes and spawned companions (buildEnvspreadsprocess.env) resolve state into the real data dir instead of the temp fallback; theresolveStateDirfallback test also fails.CODEX_COMPANION_SESSION_ID(set by the plugin's own session hook) →status/resultsession-filter fixture-seeded jobs that carry nosessionId, so those tests render empty output.Full evidence trail in #455.
Fix (2 files, tests only)
tests/helpers.mjs: pinCLAUDE_PLUGIN_DATAto a freshmkdtemproot for the test process (in-process writers and spawned companions then agree on a temp-backed root, so state handling is still exercised end-to-end), and clearCODEX_COMPANION_SESSION_ID— every session-scoped test already sets it explicitly in the env it composes (sess-current/sess-other).tests/state.test.mjs: the fallback-path test now saves/deletes/restoresCLAUDE_PLUGIN_DATAlocally, exactly like itsuses CLAUDE_PLUGIN_DATA when providedsibling already does.Deliberately did NOT strip
CLAUDE*wholesale inbuildEnv: broker-mode tests rely onCLAUDE_ENV_FILE, and blanket stripping breaks 4 other tests (verified) while still missing the in-process leak path.Testing
CLAUDE*/CODEX*vars in the env): 87/91 → 91/91, and the real plugin state dir gains zero new entries across the run (was ~75 fake workspaces per run before).env -i PATH HOME): 91/91 before and after — no behavior change for CI.🤖 Generated with Claude Code