Commit f4b37e2
fix: pin prefetch search_type=text to avoid async-vector race
BM 0.20.x defaults search_type to "hybrid" when semantic_search is
enabled (default), which mixes FTS with vector search. Vector
indexing is scheduled asynchronously (knowledge_router.py:272-278 +
search_service._schedule_vector_sync_if_enabled), so hybrid search
can miss notes that were just written — the FTS row exists but the
vector row hasn't been added yet.
On a Mac dev box, vector indexing finishes before the test's poll
loop ends. On the GitHub CI runner (cold onnxruntime, shared CPU),
the vector index lags long enough that a 30s budget with 111
prefetch attempts all return zero results. Confirmed via integration
log diagnostics from run 25760814491.
prefetch is a 3s-budget recall hot path with keyword-shaped queries;
FTS is both faster and the semantically correct lookup for it.
queue_prefetch mirrors the change. Agent-facing bm_search is
unchanged — natural-language queries still benefit from hybrid when
the index has caught up.
Also revises the integration test:
- budget back down to 10s (was 30s in the previous flake-mitigation
attempt; with search_type=text we don't need that margin)
- keeps the improved diagnostic that surfaces failure_count and
circuit state — the previous run's 111-attempts diagnostic is what
led us to the right cause
Unit test test_prefetch_calls_search_when_cache_empty pins
search_type="text" so future refactors can't silently regress.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0d8f1e0 commit f4b37e2
3 files changed
Lines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
975 | 975 | | |
976 | 976 | | |
977 | 977 | | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
978 | 985 | | |
979 | 986 | | |
980 | 987 | | |
981 | 988 | | |
982 | 989 | | |
983 | 990 | | |
| 991 | + | |
984 | 992 | | |
985 | 993 | | |
986 | 994 | | |
| |||
998 | 1006 | | |
999 | 1007 | | |
1000 | 1008 | | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
1001 | 1012 | | |
1002 | 1013 | | |
1003 | 1014 | | |
1004 | 1015 | | |
1005 | 1016 | | |
1006 | 1017 | | |
| 1018 | + | |
1007 | 1019 | | |
1008 | 1020 | | |
1009 | 1021 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
333 | 335 | | |
334 | 336 | | |
335 | 337 | | |
| |||
341 | 343 | | |
342 | 344 | | |
343 | 345 | | |
344 | | - | |
| 346 | + | |
345 | 347 | | |
346 | 348 | | |
347 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
0 commit comments