diff --git a/tests/stale_index_query.test.ts b/tests/stale_index_query.test.ts index 6a4668e0..1a0c780c 100644 --- a/tests/stale_index_query.test.ts +++ b/tests/stale_index_query.test.ts @@ -19,29 +19,9 @@ type Fixture = { match: string; expected_ids: string[]; }; - sample_text: { - text: string; - baseline_embedding: number[]; - min_cosine_similarity: number; - }; chunks: FixtureChunk[]; }; -function cosineSimilarity(a: number[], b: number[]): number { - if (a.length !== b.length) { - throw new Error(`Embedding length mismatch: ${a.length} vs ${b.length}`); - } - let dot = 0; - let normA = 0; - let normB = 0; - for (let i = 0; i < a.length; i++) { - dot += a[i] * b[i]; - normA += a[i] * a[i]; - normB += b[i] * b[i]; - } - return dot / (Math.sqrt(normA) * Math.sqrt(normB)); -} - function runCommand(cmd: string[], cwd: string): string { const proc = Bun.spawnSync(cmd, { cwd, @@ -57,7 +37,7 @@ function runCommand(cmd: string[], cwd: string): string { return proc.stdout.toString(); } -test("stale index fixture preserves FTS order and embedding baseline", () => { +test("stale index fixture preserves FTS order", () => { const repoRoot = process.cwd(); const fixturePath = join(repoRoot, "tests", "fixtures", "stale_index_query.json"); const fixture = JSON.parse(readFileSync(fixturePath, "utf8")) as Fixture; @@ -109,24 +89,6 @@ test("stale index fixture preserves FTS order and embedding baseline", () => { ); const rankedRows = JSON.parse(queryJson) as Array<{ chunk_id: string }>; expect(rankedRows.map((row) => row.chunk_id)).toEqual(fixture.query.expected_ids); - - const liveEmbeddingJson = runCommand( - [ - "uv", - "run", - "python3", - "-c", - [ - "import json", - "from brainlayer.embeddings import get_embedding_model", - `print(json.dumps(get_embedding_model().embed_query(${JSON.stringify(fixture.sample_text.text)})))`, - ].join("; "), - ], - repoRoot, - ); - const liveEmbedding = JSON.parse(liveEmbeddingJson) as number[]; - const cosine = cosineSimilarity(liveEmbedding, fixture.sample_text.baseline_embedding); - expect(cosine).toBeGreaterThan(fixture.sample_text.min_cosine_similarity); } finally { db.close(); rmSync(tmpRoot, { force: true, recursive: true });