Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/lineage-reconcile-boot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -235,6 +235,12 @@ async function setupForkOnDisk(resumeInheritance?: boolean): Promise<ForkSetup>
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,
Expand Down Expand Up @@ -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);
Expand Down
Loading