diff --git a/tests/lineage-reconcile-boot.test.ts b/tests/lineage-reconcile-boot.test.ts index ad33f5db4e..6262f58107 100644 --- a/tests/lineage-reconcile-boot.test.ts +++ b/tests/lineage-reconcile-boot.test.ts @@ -7,7 +7,7 @@ import os from "node:os"; import path from "node:path"; import { defaultConfig } from "acp-kernel"; import { startServer } from "../src/server.ts"; -import { SessionStore, _setStoreForTest } from "../src/persist.ts"; +import { SessionStore, _setStoreForTest, getStore } from "../src/persist.ts"; import { listSessions } from "../src/session.ts"; import type { ProxyOptions } from "../src/config.ts"; import { _setForTest as setRegistryForTest } from "../src/registry.ts"; @@ -235,6 +235,12 @@ async function setupForkOnDisk(resumeInheritance?: boolean): Promise for (const b of child.state.blocks) child.blockContents.delete(b.blockId); child.state.blocks.length = 0; delete child.metadata.derivedBlocksAdopted; + // Pin the post-strip shape synchronously (#3336): an armed debounce + // timer from the request above would otherwise fire later and persist + // whichever in-memory snapshot it finds at fire time, leaking pre-strip + // state into the simulated restart below. Same for the parent's ledger. + assert.ok(getStore().flushSync(child), "post-strip persist of the fork child must land"); + assert.ok(getStore().flushSync(parent), "parent's folded ledger must be on disk before the restart"); return { run, @@ -446,6 +452,11 @@ test("AC12: a multi-hop grandchild stays eligible when its intermediate parent h for (const b of s.state.blocks) s.blockContents.delete(b.blockId); s.state.blocks.length = 0; delete s.metadata.derivedBlocksAdopted; + // Same #3336 pin as in setupForkOnDisk: the boot reconcile above + // adopted the child from the root and armed its debounce; without a + // sync flush here the final boot below could load the child WITH + // blocks and legally adopt the grandchild, closing its gate. + assert.ok(getStore().flushSync(s), `post-strip persist of ${id} must land`); } } finally { await close(proxy);