Repository navigation
test(scenarios): acceptance suites — ordered-event harness + cross-process red/green - #86
Merged
Merged
Conversation
…ent harness plus cross-process red/green Two determinism layers: - scenarios-scripted.test.ts + helpers/scripted.ts: fresh store, fake host, aliased tool calls; the event order IS the schedule. Asserts the exact active-row table plus conservation (nothing promised lands nowhere). - scenarios-consistency.test.ts: cross-process window races over the whole-file-rewrite seams (restore, supersede, prune, viewer edit/delete, merge), red 10/10 on the pre-lock commit, green 5/5 on main. - helpers/temp-root.ts: spawned test processes refuse non-temporary store paths; wired into the two shared helper scripts.
This was referenced Oct 24, 2026
Merged
|
🎉 This PR is included in version 0.8.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
abogartz
pushed a commit
that referenced
this pull request
Oct 25, 2026
A full-suite run leaks every temp directory it creates: 250 osi-*
dirs measured under the system temp dir from one run at 0.8.9. The
repo already has the child-side half of this discipline
(test/helpers/temp-root.ts: "Guards, not care" — a spawned writer
refuses non-temp paths); this is the parent side.
Pattern, one shape everywhere: the file's temp root gets
`rmSync(root, { recursive: true, force: true, maxRetries: 5,
retryDelay: 20 })` in the afterEach that restores the env —
maxRetries because an AV-scanning handle can briefly outlive a
viewer's stop, and afterEach rather than afterAll so a crashed run
costs one dir, not its whole batch (lock.test.ts's afterAll drain
converted to match). Four files hoist a beforeEach-local `const root`
to a module `let` so the hook can see it; the scripted helper's
cleanup() and the consistency suite's root (both from #86) gain the
same, removing the osi-script-/osi-cons- leak those suites add.
Pass/fail is unchanged by construction — no assertion or hook-order
edits — and verified: the same failure set (the Bun 1.3.x resolver
trio plus load-sensitive cross-process races) before and after on
both Bun versions, and 0 leaked dirs after versus 250 before.
abogartz
pushed a commit
that referenced
this pull request
Oct 25, 2026
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 #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.
This was referenced Oct 25, 2026
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 #69.
Two determinism layers, one promise: a row a session was told it remembered is in the store or in a snapshot — never nowhere.
1. Ordered-event harness (the new shape)
test/helpers/scripted.ts+test/scenarios-scripted.test.ts— the scenario runner as specified: fresh store with no entries → the plugin loaded on the fake host with a fake LLM → a set number of memory actions (every action is one awaited tool call, aliased so the expected table can name rows) → compare against the expected result.The event order is the schedule: no timing windows anywhere, so a regression only needs the events in the wrong order to fire, and every scenario replays identically. Five scenarios ship: add→update→forget exact-table lifecycle; duplicate collapse; two sessions interleaved step-by-step (targeted update supersedes exactly its own row); remember→snapshot→remember→force restore (store reverts, rolled-back row stays recoverable — the #60 promise at tool level); forgotten-value-via-import re-ingestion (pins current policy: the value returns — that table flipping blocked is the acceptance diff for the tombstone ticket).
2. Cross-process window scenarios (the red/green proof)
test/scenarios-consistency.test.ts— ordering alone cannot open a window inside one operation, so these replay real OS processes against the whole-file-rewrite seams. Extends the two measured scenarios (restore, supersede) with: prune sweep vs appenders, viewer delete/edit vs a second session, check-mode (refuses, never mutates) and merge-mode (union claim) under contention, and import landing while sessions write. Appends have been O_APPEND-safe since before the lock fix, so the import and check scenarios are honest green-on-both pins (documented as such in the file), not fake reds.Measurements (PR-body evidence, rule: red-then-green is the definition of done)
Pre-fix =
357ecaf^(pre-store-lock), detached worktree, file runs unmodified:tsc --noEmitclean,biome lintclean, e2e 9/9, both published benches byte-identicalAn escape observed in one early run (before this push) was closed structurally, not by hoping: restore windows 6→8, prune scopes 6→8, viewer mutations 6→10, merge windows 4→6 — then re-measured 10/10 red pre-fix, 5/5 green on main.
Harness safety rule, enforced
test/helpers/temp-root.ts: spawned test processes refuse any store path outside the OS temp dir (the scenario file already guarded its own children after 140 rows once landed in the developer's real store — inheriting env). Now wired into both shared helper scripts (helpers/writer.ts,helpers/lock-holder.ts), so no test in the repo can write outside a temp root — by guard, not care.Deliberately not here
markManySupersededdoes not exist yet (Supersede in batch: decay rewrites and snapshots the store file once per row #61); when it lands, the scenario comes with it.