diff --git a/packages/plugins/semantic-search/src/sdk/tool-search-index.test.ts b/packages/plugins/semantic-search/src/sdk/tool-search-index.test.ts index 111b1a147..6efa0797f 100644 --- a/packages/plugins/semantic-search/src/sdk/tool-search-index.test.ts +++ b/packages/plugins/semantic-search/src/sdk/tool-search-index.test.ts @@ -1032,6 +1032,45 @@ describe("ToolSearchIndex manifest snapshot", () => { }), ); + it.effect("scans the create-time manifest snapshot when the live manifest changes", () => + Effect.gen(function* () { + const [tool] = makeTools(1); + expect(tool).toBeDefined(); + if (tool === undefined) return; + let liveManifests = [manifestForTool(tool, "fp-at-create", "source-at-create")]; + const counters = { manifest: 0 }; + const executor: Pick = { + tools: { + list: () => Effect.succeed([tool]), + manifest: () => { + counters.manifest++; + return Effect.succeed(liveManifests); + }, + schema: () => Effect.succeed(null), + }, + cache: makeMemoryCache(), + }; + const base = makeBase(executor as Executor); + + yield* create({ ...base, runId: "run-snapshot-stability", partitionCount: 1 }); + liveManifests = [manifestForTool(tool, "fp-after-create", "source-after-create")]; + + const scanned = yield* scan({ + ...base, + runId: "run-snapshot-stability", + partition: 0, + limit: 10, + }); + + expect(scanned).toMatchObject({ processed: 1, changed: 1, skipped: 0 }); + expect(counters.manifest).toBe(1); + expect([...base.jobs.data.values()][0]).toMatchObject({ + fingerprint: "fp-at-create", + sourceRevision: "source-at-create", + }); + }), + ); + it.effect("fails the scan when the run snapshot is missing (no D1 fallback)", () => Effect.gen(function* () { const { executor, counters } = makeCountingExecutor(makeTools(2));