Files
Garry TanandClaude Fable 5 3cfd0c4b42 fix(search): keep semantic cache alive for the query op (expandFn folded into knobs hash, not unsafe)
isSemanticCacheRequestSafe listed expandFn as cache-unsafe, but
operations.ts passes expandFn on every default `query` op call
(expand = p.expand !== false), so the semantic cache was silently
disabled for the flagship op (permanent 'disabled' status, 0% hit
rate).

expandFn's result-shaping effect is exactly the expansion arm, so fold
EFFECTIVE expansion into the cache-key resolver instead:
hybridSearchCached now threads `expandFn ? expansion : false` into
resolvedForCache.perCall (the inner search can only expand when
expansionAllowed AND expandFn is wired), and expandFn leaves the
unsafe list. No-expandFn callers under an expansion-on bundle key as
expansion=false, matching what actually ran — the cross-serve gap the
unsafe listing was defending against stays closed.

Pinned by a query-op-shaped miss→hit roundtrip in
test/search/hybrid-reranker-integration.serial.test.ts (verified
failing with 'disabled' before this commit) and a unit case in
test/cache-scope-key.test.ts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 11:32:50 -07:00
..