From 9a7999d61668c486154fe3c00618857da6ca1d43 Mon Sep 17 00:00:00 2001 From: alpurkan17 Date: Tue, 19 May 2026 21:33:38 +0000 Subject: [PATCH] fix: track backend label separately in JSONL search handler (#14) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _h_search used Python to chain FTS5 and substring backends, then inferred the backend label from truthiness. When FTS5 returns empty results, evaluates substring but is truthy, so backend is mislabeled as 'fts5'. Fix: separate FTS5 call, check result, fall through to substring if empty — matching the correct pattern in server.py. Closes #14 --- src/vouch/jsonl_server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vouch/jsonl_server.py b/src/vouch/jsonl_server.py index 5c169ec9..c9cfcbfd 100644 --- a/src/vouch/jsonl_server.py +++ b/src/vouch/jsonl_server.py @@ -77,8 +77,11 @@ def _h_search(p: dict) -> list[dict]: q = p["query"] limit = int(p.get("limit", 10)) try: - hits = index_db.search(s.kb_dir, q, limit=limit) or s.search_substring(q, limit=limit) - backend = "fts5" if hits and hits is not None else "substring" + hits = index_db.search(s.kb_dir, q, limit=limit) + backend = "fts5" + if not hits: + hits = s.search_substring(q, limit=limit) + backend = "substring" except Exception: hits = s.search_substring(q, limit=limit) backend = "substring"