Skip to content

Commit d24a0dc

Browse files
committed
test(client): keep the embedding model loaded while another instance is live
close() releases the process-wide pipeline only with the last Turso lease, so a closing session cannot drop the model for sibling plugin instances (tickernelz#443).
1 parent eb571d3 commit d24a0dc

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎tests/fixtures/memory-injection-eligibility.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mock.module(moduleUrl("config"), () => ({
3737
}));
3838
mock.module(moduleUrl("services/embedding"), () => ({
3939
EmbeddingService: class {},
40-
embeddingService: { isWarmedUp: true, warmup: async () => {} },
40+
embeddingService: { isWarmedUp: true, warmup: async () => {}, dispose: async () => {} },
4141
}));
4242
mock.module(moduleUrl("services/turso/ready"), () => ({
4343
ensureTursoReady: async () => {},

‎tests/plugin-turso-refcount.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,22 @@ describe("plugin Turso refcount (#443)", () => {
7878

7979
const id = await userPromptManager.savePrompt("sess-b", "msg-b", "/tmp/p", "world");
8080

81+
// Fake a warmed local model so the close path has something to release.
82+
const { embeddingService } = await import("../src/services/embedding.js");
83+
const released: string[] = [];
84+
Object.assign(embeddingService, {
85+
pipe: { dispose: async () => released.push("dispose") },
86+
isWarmedUp: true,
87+
});
88+
8189
await memoryClient.close();
8290
expect(pluginTursoRefCount()).toBe(1);
8391
expect((await userPromptManager.getPromptById(id))?.content).toBe("world");
92+
// Sibling instance still live: the process-wide model must stay loaded.
93+
expect(released).toEqual([]);
8494

8595
await memoryClient.close();
8696
expect(pluginTursoRefCount()).toBe(0);
97+
expect(released).toEqual(["dispose"]);
8798
});
8899
});

0 commit comments

Comments
 (0)