Skip to content

test: temp-path guard cannot match on Windows - 3 deterministic cross-process test deaths - #88

Merged
abogartz merged 3 commits into
abogartz:mainfrom
WhollyMindless:fix/temp-root-windows
Oct 25, 2026
Merged

abogartz merged 3 commits into
abogartz:mainfrom
WhollyMindless:fix/temp-root-windows

Conversation

@WhollyMindless

Copy link
Copy Markdown
Contributor

The bug #86 shipped

test/helpers/temp-root.ts decides "is this path inside the temp dir?" with

realpathSync(p).startsWith(realpathSync(tmpdir()) + "/")

realpathSync returns backslash paths on Windows, so + "/" never matches and no temp path on Windows can pass the guard. Every guarded child (writer.ts, lock-holder.ts) exits 2 against its own perfectly temporary store:

writer: refusing to run against a non-temporary store path: C:\Users\...\Temp\osi-race-w0JLZL\memory

Three cross-process tests therefore die deterministically on Windows on any tree containing #86, on both Bun lines:

  • two processes sharing one store > four writers: nothing is lost, every supersede lands, no lock is stranded
  • two processes sharing one store > a reader process always parses a complete file
  • withStoreLock > a second process waits for the first to finish publishing

(Verified by running current main on Windows ×2 Buns — and it's the guard's stderr in the failure output, not a filesystem race. On Linux sep is /, so CI saw none of this.)

The fix

One token: + sep. Bit-identical POSIX behavior.

Plus test/temp-root.test.ts, pinning the guard in both directions — the accept-path test is loud on the shipped bug all by itself, because a wrong comparison means process.exit(2) inside the test process (measured: the whole test file dies with raw exit 2). The refuse-path test spawns writer.ts against homedir() — deliberately not the repo path, because checkouts themselves can live under the temp dir (they do on the reference machine) and a repo probe there would pass the guard and let the writer write.

Verification (Windows ×2 Bun + Linux logic-unchanged)

shipped helper + this PR
guard test kills the test runner (exit 2) 2 pass
the 3 tests above 3/3 fail, every run pass
tsc --noEmit / lint clean clean

Independent of #80/#81/#85/#87. Any Windows test leg — a job like the one in the forthcoming Windows-semantics PR, or anyone's local bun test — cannot go green on current main until this lands.

assisted by Qwen3-flash-next

requireTempPath compared realpathSync(path) against
realpathSync(tmpdir()) + "/". On Windows realpathSync yields BACKSLASH
paths, so the comparison can never match: every guarded child
(writer.ts, lock-holder.ts) exited 2 against its own perfectly
temporary store path, and the cross-process tests that spawn them die
deterministically on Windows: "four writers: nothing is lost...",
"a reader process always parses a complete file" and "a second
process waits for the first to finish publishing" fail on any tree
containing abogartz#86 (measured: child stderr "writer: refusing to run
against a non-temporary store path: C:\...\osi-race-XXXX\memory").
On POSIX sep is "/" and behavior is bit-identical.

Adds a guard test in both directions: a fresh mkdtemp path must pass
in-process (the shipped bug's shape is loud there - process.exit(2)
takes the test runner down, verified against the pre-fix helper),
and writer.ts must refuse a non-temp path with exit 2. The refuse
probe uses homedir rather than the repo because checkouts can
themselves live under the temp dir - where they do on the reference
machine - and a repo-root probe there would pass the guard and let
the writer actually write.
@WhollyMindless

Copy link
Copy Markdown
Contributor Author

Bummer, on it.

@abogartz
abogartz merged commit 2fef172 into abogartz:main Oct 25, 2026
3 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.9.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@WhollyMindless
WhollyMindless deleted the fix/temp-root-windows branch October 26, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants