mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-29 19:01:39 +00:00
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>