Bare npx vitest run writes test fixtures into the real ~/.codeman #640
Description
Bug
A bare npx vitest run writes test fixtures into the developer's real ~/.codeman.
On a machine that runs Codeman this left a clis.json with a test entry, a fixture users.json, webhook.json, intents.json, .env, settings.json values and a .secret-fixture file. The running instance loads them on its next restart, which looks exactly like "my settings were reset".
Steps to reproduce
- On a machine with a real
~/.codeman, runnpx vitest runfrom the repo root (instead ofnpm test). - Inspect
~/.codeman: fixture files and values have been written there.
Cause
There is no root vitest config: the configs live in config/ and npm test passes --config. A bare invocation has no setupFiles, so test/setup.ts never runs and HOME is not redirected.
Related: on a machine with a real agent CLI installed, the temp-HOME teardown can fail a passing file with ENOTEMPTY (about 1 run in 3 for session-routes-claude-model), because claude keeps flushing ~/.claude.json and ~/.claude/backups/ into the temp HOME after the test ends.
Status
Fixed, with tests, on branch fix/test-home-isolation in my fork. Not submitted as a PR yet: I'm at the open-PR limit and the fix is queued behind my current open PRs (#567, #592, #616, #617, #618). I'll open the PR as soon as a slot frees, or sooner if you'd like to lift the limit or take it directly from the branch.
Activity
Ark0N commentedon Oct 18, 2026
Thanks @opticon454, this is a real bug and a nasty one, since it looks exactly like "my settings were reset".
npm testpasses--config config/vitest.ci.config.ts, so itssetupFilesredirect HOME, but a barenpx vitest runfinds no config at all and runs against the real~/.codeman. CLAUDE.md warns about it, which does not help anyone who has not read that line.I had a look at
fix/test-home-isolationand the shape is right, so yes, please open it as a PR. Two things the review will look at, so you can get ahead of them:vitest.config.ts. The repo root is kept short on purpose (CLAUDE.md, the note at the top) and config lives inconfig/, but the rule allows files a tool only looks for at the root, and a barevitestonly looks there, so I think it qualifies. Please add it to that list of root-only files in CLAUDE.md in the same PR, with the reason, so nobody "tidies" it back intoconfig/.ENOTEMPTYfrom a realclaudeflushing into the temp HOME after a test ends is a good catch. The retry has to stay bounded, and it must never retry or delete outside the temp HOME;safeRmHomeTree()is the guard the tests use for that, andtest/test-env-isolation.test.tspins the setup side.About the open-PR limit: drafts do not count toward it, so you can open this as a draft now and mark it ready once a slot frees. Several of your open PRs are reviewed and should go in with the next release, which frees slots too.
Ark0N commentedon Oct 18, 2026
@opticon454 quick follow-up: I added you to the repository's exemption from the open-PR limit, so you can open #640's and #641's fixes as normal PRs now, no draft needed. It exempts you from the cap only. Thanks for queueing them so patiently.
docs(test): a bare vitest is isolated now, and the guards need the sa…