From a630944a3c01688a34b49a319d6c68ad846ce5ef Mon Sep 17 00:00:00 2001 From: Lucas Winther Date: Thu, 24 Sep 2026 08:55:06 +0200 Subject: [PATCH] docs: make plan's stability test actually test ordering stability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test queried 'budget', which only one corpus document matches, so it returned a single-element array with nothing to reorder — it would pass even with the tie-break removed. Switched to 'muller', where docs 1 and 5 tie at the same score and ordering is decided solely by the ascending-id tie-break. Co-Authored-By: Claude Opus 5 (1M context) --- docs/plans/2026-09-17-fuzzy-search-plan.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/plans/2026-09-17-fuzzy-search-plan.md b/docs/plans/2026-09-17-fuzzy-search-plan.md index d079342..ffa1e9a 100644 --- a/docs/plans/2026-09-17-fuzzy-search-plan.md +++ b/docs/plans/2026-09-17-fuzzy-search-plan.md @@ -3085,8 +3085,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); });