Repository navigation
feat(atlas-search): query-embedding cache — memory LRU + shared Turso tier (#9941) - #10086
Conversation
… tier (#9941) Slice 1 of #5668, per design PR #5667 section 3.1: a query vector is a pure function of (normalized text, model id, model revision), so the cache has no TTL and no invalidation — a model change re-keys. - atlas-core::embed_cache: key = sha256 over length-prefixed model_id/model_rev + normalized text (trim + whitespace collapse; case preserved — the embedder is case-sensitive). Memory LRU (~10k) always on; shared Turso tier via ATLAS_EMBED_CACHE_TURSO_URL / _TOKEN env, spoken to over the libsql HTTPS pipeline. Tier writes are async/best-effort on a background writer thread and never sit in the request path; any tier failure degrades to a cache miss — a cache outage cannot fail a search. - The cached value is the raw full-dimension vector; finish_query_vector (truncate + renormalize) is applied after retrieval on hit and miss alike, so both paths return identical vectors for any per-request trunc. - AtlasEmbedder::embed_raw exposes the prompt+embed step; CachingEmbedder decorates it; CliEmbedder wires it in front of the production embedder, so CLI one-shot and serve mode share the cache. The FixedEmbedder test-hook path is untouched. Tests (atlas-core, all green): provider-call-count oracle stays 1 across repeats incl. whitespace variants; shared tier serves a fresh-memory cache without a provider call; unreachable tier never fails a search; LRU eviction order; proptest PBT over key construction — whitespace invariance, case/model/re-keying sensitivity, field-boundary unambiguity. Golden CLI parity suite unchanged and green.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 11 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Implements #9941 — slice 1 of #5668, per design PR #5667 §3.1.
What
A query-embedding cache in
atlas-core(embed_cache.rs), wired in front of the production embedder at theCliEmbeddercall site so CLI one-shot and serve mode share it:sha256(model_id ‖ model_rev ‖ normalized_text)— the two identity fields are length-prefixed so field boundaries are unambiguous. No TTL, no invalidation: a model change re-keys. Normalization = trim + collapse whitespace runs to one ASCII space; case is preserved (the embedder is case-sensitive, so case variants must re-key). The embedder is always fed the normalized text, so the cache is a pure function of its key by construction.ATLAS_EMBED_CACHE_TURSO_URL/ATLAS_EMBED_CACHE_TURSO_TOKEN(memory-only when unset). Reads happen on memory miss (2s timeout, failure = miss); writes are async/best-effort on a bounded background writer queue and never sit in the request path. Any tier failure degrades to a normal embed — a cache outage cannot fail a search.finish_query_vector(truncate + renormalize) is applied after retrieval on hit and miss alike, so per-requesttruncbehaves identically on both paths.AtlasEmbedder::embed_rawexposes the prompt+embed step for this; theFixedEmbeddertest-hook path is untouched.Tests (oracles named per the testing doctrine)
cargo test -p atlas-core— all green (55 unit + integration suites), including the new cache tests:trunc;cargo test -p atlas-search— green, including the golden CLI parity suite (cli_text_goldens_match_python,cli_search_envelopes_match_python, …): parity unchanged, cold or warm (the golden path runs the untouched FixedEmbedder hook; ranking code is not modified).cargo fmtapplied. (Localcargo clippyis broken on this laptop — E0514 rustc/clippy mismatch on untouched crates from a cold target dir; CI's gates are the lint authority.)Notes for follow-up
Queue task 16725 (lane any-c, fallback coordination — the queue backend failed mid-shift; see the notes on #9941).
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.