fix(search): re-embed lexical vectors after IDF changes - #27
Merged
JohnXu22786 merged 4 commits intoSep 12, 2026
Merged
Conversation
Incremental corpus changes update the IDF weights used for queries. Recompute every lexical document vector after those changes so unchanged chunks use the same weights as the query while remote providers retain targeted re-embedding.
The previous format can contain lexical document vectors built with stale corpus IDF weights. Bump the persisted index version so those files are rebuilt before they can be searched.
When a targeted remote embedding fails, replace every stored vector with IDF-aware fallback vectors so provider and dimension state cannot mix. Persist empty indexes after removing the final file so autosaved deletions survive reload.
JohnXu22786
force-pushed
the
bug/search-reembed-after-incremental-idf-change
branch
from
September 12, 2026 14:51
897b428 to
a90827a
Compare
Reindexing removes the old file before reading its replacement. Refresh the corpus IDF and surviving lexical vectors when that read fails so autosaved indexes remain consistent.
JohnXu22786
marked this pull request as ready for review
September 12, 2026 15:13
JohnXu22786
deleted the
bug/search-reembed-after-incremental-idf-change
branch
September 12, 2026 15:13
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 this PR does
Before this PR:
Incremental corpus changes could leave unchanged lexical vectors on stale IDF weights. Persisted pre-fix indexes could reload those vectors. If a remote provider failed during targeted re-embedding, only changed chunks switched to lexical fallback, leaving mixed provider and dimension vectors. Removing the final file with autosave enabled left stale persisted index files. Reindexing a file removed the old record before reading its replacement; when the path disappeared or became unreadable, the failure path persisted stale surviving lexical vectors.
After this PR:
Re-embed all lexical document vectors after corpus changes and invalidate pre-fix persisted indexes with format v2. If targeted remote embedding falls back, re-embed the entire corpus with the IDF-aware lexical provider. Persist an empty index when the final file is removed. When reindexing fails after removing an existing file, refresh IDF and re-embed surviving lexical vectors before autosave. Add focused regression coverage for all affected paths.
Type of change
Bug fix
Breaking changes (if any)
Existing persisted indexes are intentionally rebuilt once after upgrade.