Reproduced independently in two separate worktrees during a full-suite run, with different leftover directory names each time.
Measured
FAIL test/demo.test.ts > commitlore demo > temporary directory does not exist after successful completion
expected [ 'commitlore-demo-WZjX8a' ] to deeply equal []
FAIL test/demo.test.ts > commitlore demo > temporary directory is gone after a simulated crash (safety property)
Both pass in isolation (7/7). Both fail under npx vitest run when another worker happens to hold a demo directory during the assertion window.
Cause
test/demo.test.ts:53-60 and :62-73 both read the process-wide tmpdir():
const leftover = readdirSync(tmpRoot).filter((d) => d.startsWith('commitlore-demo'));
expect(leftover).toEqual([]);
The first takes a before/after delta, which narrows the window but does not close it — a directory created by another worker after the before snapshot and still alive at the after snapshot counts as leftover. The second takes no delta at all and fails if any commitlore-demo* directory exists anywhere in the shared tmpdir, whoever made it.
Why it is worth fixing rather than tolerating
The property under test is real and worth keeping: runDemo must not leave its temp directory behind, including after a crash. The defect is that the test asserts it against a namespace it does not own. A test that goes red for a reason unrelated to the code under test is the most expensive kind of failure this repository can carry — it trains a reader to discount red, which is the one signal the commit gate depends on.
Shape of the fix
runDemo should create its directory under a root the test controls, and the test should assert emptiness of that root. Whether that means a tmpRoot option on runDemo or an env override is a design call — the current signature is runDemo({ cwd, crashTest }).
Reproduced independently in two separate worktrees during a full-suite run, with different leftover directory names each time.
Measured
Both pass in isolation (7/7). Both fail under
npx vitest runwhen another worker happens to hold a demo directory during the assertion window.Cause
test/demo.test.ts:53-60and:62-73both read the process-widetmpdir():The first takes a before/after delta, which narrows the window but does not close it — a directory created by another worker after the
beforesnapshot and still alive at theaftersnapshot counts as leftover. The second takes no delta at all and fails if anycommitlore-demo*directory exists anywhere in the shared tmpdir, whoever made it.Why it is worth fixing rather than tolerating
The property under test is real and worth keeping:
runDemomust not leave its temp directory behind, including after a crash. The defect is that the test asserts it against a namespace it does not own. A test that goes red for a reason unrelated to the code under test is the most expensive kind of failure this repository can carry — it trains a reader to discount red, which is the one signal the commit gate depends on.Shape of the fix
runDemoshould create its directory under a root the test controls, and the test should assert emptiness of that root. Whether that means atmpRootoption onrunDemoor an env override is a design call — the current signature isrunDemo({ cwd, crashTest }).