Skip to content

test(scenarios): acceptance suites — ordered-event harness + cross-process red/green - #86

Merged
abogartz merged 2 commits into
mainfrom
test/acceptance-scenarios
Oct 24, 2026
Merged

abogartz merged 2 commits into
mainfrom
test/acceptance-scenarios

Conversation

@abogartz

Copy link
Copy Markdown
Owner

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:

run pre-fix 357ecaf^ main
consistency 5 fail / 2 pass — restore, supersede, prune, viewer edit/delete, merge all red; check-mode + import pins green. 10/10 consecutive runs, zero escapes (25 cumulative including pre-density runs) 7/7 pass
scripted 5/5 pass (functional composition was not the pre-fix bug; deterministic pins) 5/5 pass
full suite — 342 tests green, tsc --noEmit clean, biome lint clean, e2e 9/9, both published benches byte-identical

An 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

review and others added 2 commits October 24, 2026 13:01
…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.
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 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.
@abogartz
abogartz deleted the test/acceptance-scenarios branch November 19, 2026 05:53
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.

Testing-1: acceptance scenario suite for the destructive seams — red on the pre-fix commit, green on main

1 participant