Repository navigation
test: release session identity between tests (#149) - #151
Merged
Merged
Conversation
Dispatching a tool binds the calling session to the plugin instance's workspace at flow entry (#127), and that session -> repository map is module-global. A file that binds a session and never releases it silently changes the NEXT file's write stamp and read scope, so the outcome depends purely on runner file order. - update-targeting: release the ambient session and its binding in afterEach (it is the leaker: setCurrent("upd") + a tool dispatch against liveRoot). - repokey-path: own the ambient scope it asserts on, in beforeEach — both appendMemory's stamp and the ambient reader resolve the calling session first, so a leftover sid outranks its setRepoScope(). - bunfig preload: clear both identity registries after every test so file order cannot change the outcome; this is the third instance of the leak (injection-framing, negative-eval, update-targeting) and per-file patches keep depending on someone remembering. Repro before: `bun test ./test/update-targeting.test.ts ./test/repokey-path.test.ts` -> 19 pass / 2 fail on main 9caed07; after: 21/0, and green in the reverse order too. Full suite 578 pass / 12 skip / 0 fail forward and in reverse file order (3 consecutive runs); e2e 11/0; tsc and biome clean.
appendMemory stamps `ts` from the wall clock at millisecond resolution and only bumps it when that ts is already present in the day file. The re-ingested-row test deletes the store between its two writes, so nothing forces the second stamp forward and both rows can share a millisecond — `expect(fresh.ts).not.toBe(original.ts)` becomes a coin flip on how fast the prune runs. Observed twice while working on this branch (once inside the pre-push gate). The race is pre-existing and independent of #149, but it makes the gate untrustworthy for everyone. Cross the millisecond boundary before the second write; the assertion itself is unchanged. hits.test.ts 0 failures in 20 consecutive runs; full suite clean forward x3 and in reverse file order x2.
This was referenced Oct 28, 2026
|
🎉 This PR is included in version 0.14.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #149. Unblocks #135, whose required
testcheck went red the momentgh pr update-branchreordered its files onto post-#133main.Root cause
#127's entry binding made session identity sticky: dispatching a tool runs
bindSessionProvisional(sid, instanceDir)at flow entry (src/index.ts:361-363), registering that sid → the instance's workspace inbySession. That map is a module global, so it outlives a test file.test/update-targeting.test.tssets an ambient session (setCurrent({sessionID:"upd"}), line 62) and dispatches tools against its ownliveRoot, but itsafterEachreleased neither the ambient state nor the binding. The next file to rely on the ambient module scope then breaks in both directions:appendMemoryresolvesrepoScopeFor(input.sessionID ?? getCurrent().sid)(src/memory.ts:273), so the stale"upd"entry outranks a freshly calledsetRepoScope();readerForAmbient()resolves the same stale scope and filters the rows back out.That is why
test/repokey-path.test.ts(#92) failed withrepo=7f336c009f10 repoPath=/tmp/osi-upd-H5OLSA/repo— a stamp from a temp directory that had already been deleted.Changes
test/update-targeting.test.ts— release the identity the file takes (resetState()+resetSessionScopes()inafterEach). It is the leaker.test/repokey-path.test.ts— own the ambient scope it asserts on (resetState()+resetSessionScopes()inbeforeEach). It depends on module scope for both its stamp and its read, so it must not inherit it.bunfig.toml+test/preload-isolation.ts— the durable net: clear both identity registries after every test, so runner file order cannot change an outcome. This is the third instance of the same leak (injection-framing,negative-eval,update-targeting); per-file patches keep depending on someone remembering to add one.Evidence
bun test ./test/update-targeting.test.ts ./test/repokey-path.test.tsbeforemain9caed07)cf9b73c, same pair & orderbun test ./test/bun test ./e2e/bun run gate(tsc → biome → unit → real-host BDD)Second commit: a latent race I hit twice
While iterating I hit
hits.test.ts › a re-ingested row cannot inherit the reinforcement…fail twice (once inside the pre-push gate). Root cause is pre-existing and independent of #149:appendMemorystampstsfrom the wall clock at millisecond resolution and only bumps it when that ts is already in the day file — and this test deletes the store between its two writes, so nothing forces the stamp forward and both rows share a millisecond whenever the prune is fast enough.expect(fresh.ts).not.toBe(original.ts)was a coin flip.It never reproduced in 20 solo runs or 6 full-suite runs on pristine
main, so I am not claiming this branch caused it — but a gate that fails at random is worse than a gate with a known gap, so the second commit crosses the millisecond boundary before the second write. The assertion itself is unchanged;hits.test.tsis now 0 failures in 20 consecutive runs.Notes
src/changes — this is test infrastructure only, andtest:commits do not trigger semantic-release.