Skip to content

Test flake: isolate the lotor-mh- cleanup test from the shared temp dir - #96

Open
githubscum wants to merge 1 commit into
mainfrom
lotor-lane/mh-tmpdir-isolation
Open

githubscum wants to merge 1 commit into
mainfrom
lotor-lane/mh-tmpdir-isolation

Conversation

@githubscum

Copy link
Copy Markdown
Owner

WO: WO-MH-TMPDIR-01. Source: lane run 77 / main-session note 2026-10-26 ("known flake", candidate limit). Test reliability, not a v3 rung: a suite that fails at random teaches the reviewer to rerun instead of read.

What changed: one test in test/matcher-history.test.js ("temp dirs prefixed lotor-mh- are cleaned up"). It counted every lotor-mh-* entry in the system temp dir, so any concurrent test file, worktree, or process making lotor-mh- dirs moved the count (observed once: 39 vs 27). The test now points TMPDIR/TEMP/TMP at a private mhiso- dir for its duration, asserts the override took effect, and restores the env (delete-or-assign) and removes the dir in finally. No source file touched; no pin re-stamp needed.

Not a new limit: the defect was in the test, not in what Lotor witnesses, so nothing goes in KNOWN-LIMITS.

Tested:

  • npm test: 1379 tests, 1374 pass, 0 fail, 5 skipped (same as main).
  • Still has teeth: with the reader's cleanup mutated to leak (scratch edit, reverted), the test fails 9/1.
  • Flake reproduced and closed: with a noise process creating/removing lotor-mh-noise-* dirs in the system temp dir every 15 ms, the test as on main fails (9/1); this version passes (10/0).

Executor: glm-5.3-flash:cloud via dispatch-to-ollama. Lotor receipt session 33efeafa: model: glm-5.3-flash, touched only this test file. It could not run node under acceptEdits and said so. Verification above is mine.

Eval: none of E1-E6 (test hygiene).

Doubt:

  1. It works because the reader calls os.tmpdir() at call time (src/views/matcher-history.js:117). If someone hoists that to module load, the leak check would look in the real temp dir again and go quiet in the private one. A short comment pins the dependency; a tripwire would be stronger.
  2. Mutating process.env inside a test is process-global. Tests in this file run in sequence, so nothing else sees it, but a future { concurrency: true } on the describe would break that.

The count read the whole system temp dir, so parallel test files and
other worktrees making lotor-mh- dirs failed it at random. Point
TMPDIR/TEMP/TMP at a private dir for the test and restore in finally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant