Repository navigation
fix(core): key the embedding cache by the embedder's identity, not its name (#1536) - #1544
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The persistent embedding cache (
embed_cache.db) was keyed byinner.name(), a constant per backend (openai,ollama,embeddinggemma-q4).Embeddergains a provided methodidentity()(defaultname:dims);openaiandollamareturn backend, model, dimensions and a short hash of the endpoint (the API key is not part of it); the cache is keyed by it. A cached vector whose length is not the embedder's dimensions is ignored and an empty vector is not stored. Inensure_embedderthe cache now wraps the primary and the fallback wraps the cached primary, so vectors the cloud produced never enter the cache. Rows written under the old key are deleted once, when the cache is first opened (PRAGMA user_version0 to 1);invalidate_modelremoves every identity of a model.Why
Switching
[embedding] model,dimsor the endpoint served the vector of the previous configuration for any text already cached, silently, and a cloud vector produced through a fallback was cached under the primary's name (#1536, owner decision: purge the old rows). With a fallback configured, a repeated text whose primary embedding keeps failing now calls the cloud each time; that is the price of not caching a wrong-model vector. Refs #1536, part of #1543.Testing
-D warnings, fmt,cargo test --workspacepass;cargo run -p docgenchanges nothingtest_invalidate_modelran raw SQL with the old key instead of callinginvalidate_modelopenai) is purged and replaced byopenai:model-a:768:<hash>withuser_version=1; the ONNX path gives identical recall results and caches underembeddinggemma-q4:768guard.take().unwrap()calls became explicit errors, and the fallback trade-off above is recorded