Skip to content

test(codex): give each active-writer server its own runtime.db - #884

Merged
RonenMars merged 1 commit into
mainfrom
test/codex-writer-runtime-db-isolation
Sep 12, 2026
Merged

test(codex): give each active-writer server its own runtime.db#884
RonenMars merged 1 commit into
mainfrom
test/codex-writer-runtime-db-isolation

Conversation

@RonenMars

Copy link
Copy Markdown
Owner

startServer in __tests__/codex-active-writer.test.ts builds a per-server cacheDir but lets runtime.db fall through to the shared default.

The adopt cases register a managed session, and runtime.db is the authoritative store that deliberately outlives server.close().
So a later server's boot reconcile picks that row up through reconcilePreviousSessions and probes the previous case's pid with isPidAlive, which is process.kill(pid, 0).
That sends no signal, but the two cases asserting "and kills nothing" spy on process.kill broadly enough to record it, and they fail.

Why this is worth fixing rather than tolerating

It passes on main today only because the reconcile is fire-and-forget and usually lands outside the spy's window.
Running just the takeover case and one refusal together already fails on main: npx vitest run __tests__/codex-active-writer.test.ts -t "take".
Anything that shifts startup timing turns a latent ordering dependency into a red suite, and the failure points at the scanner rather than at test isolation, which costs the next reader real time.

The change

Hoist the temp dir into a local and pass runtimeDbPath: join(dir, "runtime.db") alongside the existing cacheDir, matching how access-probe.test.ts and auto-resume-on-boot.test.ts already isolate it.

Verification

The file passes 12/12 on main with this fix.
It also passes 12/12 with the #876 scanner change applied on top, which is the state that surfaced the problem.
Full suite on this branch: 283 files, 3062 passed, 0 failed, lint clean across 517 files.

Unblocks #879.

@RonenMars
RonenMars force-pushed the test/codex-writer-runtime-db-isolation branch 2 times, most recently from b04fb97 to e052e36 Compare September 12, 2026 07:16
startServer built a per-server cacheDir but let runtime.db fall through to the shared default.
The adopt cases register a managed session there, and runtime.db deliberately outlives server.close(), so a later server's boot reconcile probed the previous case's pid through isPidAlive.
That probe is process.kill(pid, 0), which sends no signal but is still recorded by the kill spy in the two cases asserting that nothing was killed.
Those cases pass today only because the fire-and-forget reconcile usually lands outside the spy's window; running just the takeover case and one refusal together already fails on main.
@RonenMars
RonenMars force-pushed the test/codex-writer-runtime-db-isolation branch from e052e36 to ed5fae8 Compare September 12, 2026 07:32
@RonenMars
RonenMars enabled auto-merge (squash) September 12, 2026 07:32
@RonenMars
RonenMars merged commit 7c0828b into main Sep 12, 2026
10 checks passed
@RonenMars
RonenMars deleted the test/codex-writer-runtime-db-isolation branch September 12, 2026 07:42
@RonenMars

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 1.90.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

1 participant