From c4e303c8b7319d3c5942e1825e0ed5786db3c570 Mon Sep 17 00:00:00 2001 From: Lucas Winther Date: Thu, 17 Sep 2026 10:26:54 +0200 Subject: [PATCH] docs: fix unreachable shared-prefix test cases in plan Task 2 The guard tests used 3-char query tokens whose field tokens were literal continuations ('car'/'carpet'), so the startsWith rule returned 0.9 before the shared-prefix rule was reached. With MIN_SHARED_PREFIX=4 the rule is unreachable for any 3-char token, making the assertion impossible to satisfy. Swapped in cases where neither token is a true prefix of the other, which actually exercise the guard. Co-Authored-By: Claude Opus 5 (1M context) --- docs/plans/2026-09-17-fuzzy-search-plan.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/plans/2026-09-17-fuzzy-search-plan.md b/docs/plans/2026-09-17-fuzzy-search-plan.md index fe0a85e..f235eb9 100644 --- a/docs/plans/2026-09-17-fuzzy-search-plan.md +++ b/docs/plans/2026-09-17-fuzzy-search-plan.md @@ -342,13 +342,17 @@ describe("scoreToken", () => { }); test("matches morphological variants via a shared prefix", () => { + // Neither token is a true prefix of the other, so these exercise the + // shared-prefix rule rather than being intercepted by the startsWith rule. expect(scoreToken("decide", "decision")).toBeGreaterThan(0.5); - expect(scoreToken("deploy", "deployment")).toBeGreaterThan(0.5); + expect(scoreToken("deployed", "deployment")).toBeGreaterThan(0.5); }); test("does not shared-prefix-match on fewer than 4 common characters", () => { - expect(scoreToken("car", "carpet")).toBeLessThan(0.9); - expect(scoreToken("bee", "beetle")).toBeLessThan(0.9); + // "cars"/"carton" share only "car" (3 < MIN_SHARED_PREFIX) and neither is + // a true prefix of the other, so every rule falls through to zero. + expect(scoreToken("cars", "carton")).toBe(0); + expect(scoreToken("bees", "beetle")).toBe(0); }); test("ranks a shared-prefix match below a true prefix match", () => {