Repository navigation
fix(launcher): write the codex overlay back into the real home on clean exit (#1965) - #1974
Conversation
7496a5e to
e1850bc
Compare
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1996-pr.1974.0e8ed02This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1974.tgz
npm install -g packageInstall instructions are refreshed on each push. |
PR review complete — I rebased the branch onto current master and it is now mergeable; CI is re-running on the new head What I did this round
结构化七问
判定代码与测试质量达标,方向正确,根因修复(补退出路径)而非堵症状。CI 在 |
…an exit (#1965) bili codex ran its client against <CODEX_HOME>-bili but only the NEXT bili start attempted to fold the overlay back, so a native codex launched right after bili could not see this run's committed SQLite records. Add finalizeCodexHome(): on normal launcher exit (after the client has left and while this launch still holds the overlay) it merges each SQLite set (main+WAL/SHM/journal as one generation, via the existing mergeSqliteSet stale-check/conflict/rollback machinery) and every other private top-level entry (mtime-adjudicated, conflict-preserving mergeOverlayEntry) back into the real home, excluding generated files (.env / MCP config.toml), bili metadata and drafts. Shared entries are skipped (already in the real home). Failures keep the data in the overlay for the next launch's startup merge and are reported loudly.
…al home (#1965) Labeled follow-up found while working #1965, same mechanism family (overlay generated-file protection). prepareCodexHome only refresh-protected config.toml on launches that regenerate it, so an MCP launch's owned config.toml survived into a later non-MCP launch (BILI_LAUNCHER_PLUGIN=0 or local/private upstream), where refresh treated it as user data and merged it — MCP block and all — into the user's real config.toml. Protect config.toml on every launch (symmetric to .env) and make non-MCP launches restore the shared link exactly like the .env path does.
…ession resume Gated by ACP_TEST_E2E_FAKE=1 (deterministic fake upstream, zero tokens; runs per-PR via ci-e2e-fake.yml with codex pinned 0.147.0). One real turn through dist/index.js codex, then: the real home immediately carries state_5.sqlite (quick_check ok, >=1 thread row), no .bili-* metadata, config.toml byte-identical; then a NATIVE codex exec resume --last (no bili) recovers the session — the original turn's prompt is replayed from the recovered thread, asserted against the fake's request oracle.
…o the real codex home (#1965) finalizeCodexHome excluded the legacy pid marker but not the lease DIRECTORY from #1969. The normal path deletes it in releaseOverlayLease before finalize runs, but a failed release (Windows EBUSY-class) leaves the dir behind and finalize would merge it — and its owner.json — into the REAL home, violating #1965's acceptance that lock metadata never writes back. Exclude it like the other launcher metadata; regression test plants a stale lease dir and asserts the db still merges back.
e1850bc to
3afda32
Compare
第二轮 review 完成——作者在我上一轮之后把分支重新 rebase 到了最新 master(此时 master 已并入 #1969 codex overlay 租约锁、#1981 logger drain、#1963),并追加了一个针对跨 PR 交互的修复提交 新提交审查(
|
Closes #1965
What changed
1. Exit-time merge-back (
finalizeCodexHome, new).bili codexruns the client against<CODEX_HOME>-bili, but nothing folded the overlay back until the NEXT bili start — so a nativecodexlaunched right after bili could not see this run's committed SQLite records. On normal launcher exit (after the client has left, while this launch still holds the overlay) the overlay now merges back into the real home:mergeSqliteSetmachinery: winner by main-db mtime only, loser stale-checked against the copy-time origin snapshot (sqlite overlay (#1918): steady-state false-positive divergence — spurious warning + unbounded .bili-conflict accumulation every launch #1919) — silent drop when byte-identical to the copied source,.bili-conflictpreservation + loud warning on true divergence (Windows bili codex:SQLite 覆盖层拆分主库与 WAL,导致数据库损坏及已提交写入丢失 #1917), full rollback when any rename fails (real db open/locked);mergeOverlayEntryrules as the startup path;.env, MCPconfig.toml), bili metadata (.bili-sqlite-origin.json,.bili-launch.pid) and drafts never leave the overlay.Failures keep the data recoverable in the overlay, are reported loudly, and the next launch's startup merge retries — no silent overwrite of either side's committed data.
2. Labeled follow-up found while working this issue (same mechanism family: overlay↔home sync safety).
prepareCodexHomeonly refresh-protectedconfig.tomlon launches that regenerate it, so an MCP launch's ownedconfig.tomlcould survive into a later non-MCP launch (MCP disabled / local or private upstream) and be merged — MCP block and all — into the user's REALconfig.toml. It is now protected on every launch (symmetric to.env) and non-MCP launches restore the shared link, mirroring the.envhandling exactly. Own commit + regression test.Behavior changes (old → new)
bilistart; now a clean exit writes the run's records straight into the real home (native Codex can read them immediately). Guarantee boundary: NORMAL client exit only — a killed/crashed launcher skipsfinally; its data stays recoverable in the overlay and is folded by the next start. Concurrent native writes: Windows open-file lock → rename fails → rollback + retry-next-start; POSIX rename-under-open-handle → the Windows bili codex:SQLite 覆盖层拆分主库与 WAL,导致数据库损坏及已提交写入丢失 #1917 divergence contract applies (both generations survive, loser as.bili-conflict).config.tomlbake into the user's real config; it re-shares the real file instead. Previously reachable with default settings: any MCP launch followed by any launch with MCP off.Verification
tests/launcher-sqlite-overlay.test.ts(23 tests incl. 6 new finalize tests: fresh home, existing db, concurrent-native divergence with both generations preserved, blocked-slot failure + retry, crashed-client WAL unit move, missing/untouched no-op) andtests/codex-overlay-env.test.ts(7 incl. the config.toml regression test). Full matrix left to CI per local-testing discipline.ACP_TEST_E2E_FAKE=1, deterministic fake upstream, zero tokens; runs per-PR via ci-e2e-fake.yml with codex pinned 0.147.0): one real turn throughdist/index.js codex→ the real home immediately carriesstate_5.sqlite(quick_check ok, ≥1 thread row), no.bili-*metadata,config.tomlbyte-identical → then NATIVEcodex exec resume --lastwith NO bili recovers the session (the original turn's prompt is replayed from the recovered thread, asserted against the fake's request oracle). Verified locally against the same codex pin; the rest of the e2e-codex-fake suite (incl. the bili codex 报错 MCP client for codex_apps failed to start 仍然存在 #1802 launcher test) passes alongside it.Out of scope (flagged): the DSH lane has no known top-level SQLite sets and is unchanged; Windows-specific open-file-lock behavior is exercised via the blocked-slot simulation (directory stand-in, same technique as the existing startup-path test) plus CI.