Problem
tests/contracts/tool-hardening.test.ts ("find passes --no-require-git only outside a git repo") fails intermittently under npm run test and passes in isolation. The cause is a stray empty /tmp/.git directory that appears during a full suite run. isInsideGitRepo in src/tools/ignore-policy.ts:45 walks up from the scratch directory and, once it reaches /tmp, finds that .git and drops --no-require-git.
Expected: no test creates a .git at the system temp root, and the suite is order-independent.
Reproduce
Observed on 2026-08-24 on WSL2 with fd 10.3.0:
rmdir /tmp/.git (it was an empty directory owned by the test user, mtime 11:49, then again 12:06, both during suite runs).
node --import tsx --import ./tests/harness/tmp-root.ts --test tests/contracts/tool-hardening.test.ts passes 51/51 and does not recreate it.
- Running each
describe block of that file separately never recreates it.
- A concurrent full
npm run test in a sibling worktree recreated it at 12:06.
So the creator is a test elsewhere in the suite, likely one that spawns a child with a scrubbed environment (no CLIO_CODER_TEST_TMP_ROOT / TMPDIR) and then creates join(tmpdir(), ".git"), or a product path exercised by a test that writes .git at os.tmpdir().
Evidence
src/tools/ignore-policy.ts:45 (isInsideGitRepo walks to the filesystem root).
tests/contracts/tool-hardening.test.ts:356.
tests/harness/tmp-root.ts repoints TMPDIR for the runner and its children, but only when the child inherits the environment.
Acceptance criteria
Links
Noticed while integrating v0.3.7 wave 1; unrelated to the /btw and dispatch-intent briefs.
Problem
tests/contracts/tool-hardening.test.ts("find passes --no-require-git only outside a git repo") fails intermittently undernpm run testand passes in isolation. The cause is a stray empty/tmp/.gitdirectory that appears during a full suite run.isInsideGitRepoinsrc/tools/ignore-policy.ts:45walks up from the scratch directory and, once it reaches/tmp, finds that.gitand drops--no-require-git.Expected: no test creates a
.gitat the system temp root, and the suite is order-independent.Reproduce
Observed on 2026-08-24 on WSL2 with
fd 10.3.0:rmdir /tmp/.git(it was an empty directory owned by the test user, mtime 11:49, then again 12:06, both during suite runs).node --import tsx --import ./tests/harness/tmp-root.ts --test tests/contracts/tool-hardening.test.tspasses 51/51 and does not recreate it.describeblock of that file separately never recreates it.npm run testin a sibling worktree recreated it at 12:06.So the creator is a test elsewhere in the suite, likely one that spawns a child with a scrubbed environment (no
CLIO_CODER_TEST_TMP_ROOT/TMPDIR) and then createsjoin(tmpdir(), ".git"), or a product path exercised by a test that writes.gitatos.tmpdir().Evidence
src/tools/ignore-policy.ts:45(isInsideGitRepowalks to the filesystem root).tests/contracts/tool-hardening.test.ts:356.tests/harness/tmp-root.tsrepointsTMPDIRfor the runner and its children, but only when the child inherits the environment.Acceptance criteria
.gitat the system temp root and names the test that made it.npm run testpasses with no/tmp/.gitpresent before or after the run, twice in a row.tool-hardening"find passes --no-require-git only outside a git repo" is order-independent.Links
Noticed while integrating v0.3.7 wave 1; unrelated to the
/btwand dispatch-intent briefs.