From 9db275dac3e7b5a9fa53338d923bdd496d68a7f1 Mon Sep 17 00:00:00 2001 From: Frank O'Hara Date: Thu, 27 Aug 2026 07:40:10 -0600 Subject: [PATCH] feat(fuzzy): boost shared-prefix candidates in ranking --- crates/lash-core/src/fuzzy.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/lash-core/src/fuzzy.rs b/crates/lash-core/src/fuzzy.rs index 1d9a6ba..0d83023 100644 --- a/crates/lash-core/src/fuzzy.rs +++ b/crates/lash-core/src/fuzzy.rs @@ -114,7 +114,16 @@ impl FuzzyMatcher { let mut scored: Vec = candidates .iter() .map(|candidate| { - let score = self.compute_similarity(query, candidate); + let mut score = self.compute_similarity(query, candidate); + // Boost candidates that share the query's leading characters: + // typos cluster at the end of IDs, so a shared prefix is a + // stronger signal than the raw edit distance alone. + let prefix_len = query.len().min(3); + if let Some(prefix) = query.get(..prefix_len) { + if !prefix.is_empty() && candidate.starts_with(prefix) { + score = (score + 0.02).min(1.0); + } + } FuzzyCandidate { task_id: candidate.clone(), score,