From 2b82800c238364539aa246e5eb918b70d5554497 Mon Sep 17 00:00:00 2001 From: Lucas Winther Date: Thu, 24 Sep 2026 08:55:59 +0200 Subject: [PATCH] test(search): strengthen stability test to detect broken tie-break The "results are stable" test queried "budget", a single-match query, so the sort had nothing to reorder and would pass even with a broken or removed ascending-id tie-break. Switch to "muller", where docs 1 and 5 tie on score, so the assertion actually exercises the tie-break. Co-Authored-By: Claude Opus 5 (1M context) --- tests/search/recall.test.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/search/recall.test.ts b/tests/search/recall.test.ts index c5940c2..d48adf6 100644 --- a/tests/search/recall.test.ts +++ b/tests/search/recall.test.ts @@ -77,8 +77,15 @@ describe("Search recall", () => { }); test("results are stable across repeated identical searches", () => { - const first = rankRecords(CORPUS, "budget", FIELDS).map((r) => r.record.id); - const second = rankRecords(CORPUS, "budget", FIELDS).map((r) => r.record.id); + // Uses "muller" deliberately: docs 1 and 5 share the identical person + // string, so both score exactly 0.33 and the ORDER is decided purely by + // the ascending-id tie-break. A single-result query (e.g. "budget") would + // pass this assertion even if the tie-break were removed entirely, since + // a one-element array cannot be reordered. + const first = rankRecords(CORPUS, "muller", FIELDS).map((r) => r.record.id); + const second = rankRecords(CORPUS, "muller", FIELDS).map((r) => r.record.id); + expect(first).toHaveLength(2); + expect(first).toEqual([1, 5]); expect(first).toEqual(second); });