From 51b71c098b730d59afd8fbed0d0183b732d6db4e Mon Sep 17 00:00:00 2001 From: can1357 Date: Sun, 2 Aug 2026 20:47:42 +0200 Subject: [PATCH] test(mnemopi): exercise locked shared-bank flush --- packages/coding-agent/test/memory-tools.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/coding-agent/test/memory-tools.test.ts b/packages/coding-agent/test/memory-tools.test.ts index f0f39d096..b162f82ea 100644 --- a/packages/coding-agent/test/memory-tools.test.ts +++ b/packages/coding-agent/test/memory-tools.test.ts @@ -729,6 +729,14 @@ describe("Mnemopi backend lifecycle", () => { expect(sharedDbPath).toBeDefined(); const lock = new Database(sharedDbPath!); lock.exec("BEGIN IMMEDIATE"); + const sharedMemory = state.globalMemory; + expect(sharedMemory).toBeDefined(); + const sharedFlushSpy = vi.spyOn(sharedMemory!, "flushExtractions").mockImplementation(async () => { + // Model a pending extraction/embedding commit. An idle shared bank performs + // no SQLite work during flush, so merely locking it would not exercise its + // connection's busy timeout. + sharedMemory!.beam.db.exec("PRAGMA user_version=7351"); + }); const started = performance.now(); try { @@ -740,6 +748,7 @@ describe("Mnemopi backend lifecycle", () => { } expect(performance.now() - started).toBeLessThan(500); + expect(sharedFlushSpy).toHaveBeenCalledTimes(1); }); it("dispose with no timeoutMs retains, flushes, and closes without sleeping (#3641)", async () => {