Repository navigation
Description
Two tests in test/repokey-path.test.ts (the #92 suite) went red on the ubuntu test job for a tree that is byte-identical, apart from a package.json version string, to trees where the same job passed. The failure signature is cross-file state contamination, and the channel is identifiable in source.
The failure (run 40716641566, head da64f63 of #135 — a maintainer "update branch" merge whose content equals the approved 152d613):
(fail) non-git repo keys are bare tokens (#92) > a session dir containing a space stamps repo= as an unquoted hash, repoPath stays raw
Expected to contain: "repo=39fb4455edb0"
Received: "... content=\"the build runs from a folder with a space\" repo=7f336c009f10 repoPath=/tmp/osi-upd-H5OLSA/repo"
(fail) non-git repo keys are bare tokens (#92) > rows written before the hash (repo= was the path) stay visible through repoPath
Expected to contain: "legacy note about the old pipeline" Received: ""
repoPath=/tmp/osi-upd-* is test/update-targeting.test.ts's fixture directory (mkdtempSync("osi-upd-"), liveRoot = join(root, "repo") — line 34/41 there). A row written by a repokey-path test got stamped with a DIFFERENT FILE's repo scope; the second test then finds nothing because the reads filter through the same hijacked scope.
Why the tree is innocent: the same job passed on 152d613 (run 40574894053, identical suite content) and on main 8ad23d2 two minutes after #133 merged (run 40716278212, same code). git range-diff between the branch tips proves the merge changed nothing but the merge commit itself.
The channel (all verified in source):
src/memory.ts:273: the write choke point stamps frominput.sessionID ?? getCurrent().sid— session identity beats the module ambient scope (by design, capture: sid is bound via setCurrent then awaited — write-time identity races the live session #116).test/update-targeting.test.ts:62doessetCurrent({ sessionID: "upd", ... }); itsafterEach(line 46) tears down dirs and env but not state/session scope —resetState()runs only in itsbeforeEach, socurrent = "upd"plus the instance's binding of"upd"to itsliveRootsurvive the file boundary in the shared test process.test/repokey-path.test.ts'sbeforeEachclears only the ambient (setRepoScope(null)), neverresetState()/resetSessionScopes().- Whether the leak bites therefore depends on a continuation landing between
repokey-path's setup and its stamped write — the same turn-end capture continuations that fix(capture): fire on turn-end events; session.idle is never emitted (#136) #142 put on the event path (and which capture: sid is bound via setCurrent then awaited — write-time identity races the live session #116's comment atmemory.ts:269-271describes exactly: "the last setCurrent before persistence may belong to another session entirely"). CI timing produces the window;bun test test/update-targeting.test.ts test/repokey-path.test.tsin either order is green locally, which is why this is a lottery rather than a deterministic break.
Suggested fix — the #146 prescription, which fixed precisely this class (capture-sid-race leaking session→repo scope into the next file): teardown parity at the file that creates the state.
update-targeting.test.tsafterEach: addresetState(); resetSessionScopes();(and optionallysetRepoScope(null)).- Belt-and-suspenders for the victim file:
repokey-path.test.tsbeforeEach: addresetState(); resetSessionScopes();alongside itssetRepoScope(null).
Test-only change; no product code involved. Suite-hygiene issue in the family of #146 (fixed), #144, and #141 — worth sweeping once: a grep of setCurrent(/rememberSessionDir( call sites in test/ against files lacking a matching reset would find any remaining pairs.
Activity
WhollyMindless commentedon Oct 28, 2026
Closing as a duplicate of #149, which abogartz diagnosed more precisely and fixed via #151 (shared preload isolation + per-file resets). My 'timing lottery' framing was wrong: the leak is deterministic under file ordering via bindSessionProvisional registering bySession for the tool-dispatching session — reproduced on plain 0.14.12 with a two-file invocation and on macOS/Bun 1.4.3. My local pair-runs on Windows/Bun 1.4.4 were green, which misled the diagnosis into a race narrative. Kept this issue as a cross-reference for the run evidence (run 40716641566).