fix(store): preserve embedding on metadata-only updates#25
Merged
Conversation
update() passed vector=None for metadata-only changes (state, tags, supersede-state). memory_to_batch then wrote a zero vector which merge_insert.when_matched_update_all() committed, silently wiping the row's embedding and making refined memories invisible to vector search. Reuse the stored vector via get_vector_by_id when no new embedding is supplied. Adds a regression test (test_metadata_only_update_preserves_vector). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
CI here is red only because of pre-existing |
Contributor
|
Merged and deployed — great catch! This was a serious silent data corruption bug introduced by the merge_insert migration. Metadata-only updates were quietly wiping embeddings. Now fixed. 🎉 |
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.
Problem
LanceStore::updatebuilds its row viamemory_to_batch(memory, vector), andmemory_to_batchwrites a zero vector whenvectorisNone:The update handler passes
vector = Nonefor any edit that does not change content (tags, state, supersede, …). Combined withmerge_insert(...).when_matched_update_all(None), this silently overwrites the row's real embedding with zeros. The memory still exists and reads back fine over the API, but its vector is gone — so it is invisible to vector search, with no error and an HTTP 200.In practice this wipes embeddings on exactly the memories edited most often (tag/state churn), and the degradation is invisible until you notice recall has quietly rotted.
Fix
When
vectorisNone, reuse the row's existing embedding viaget_vector_by_idinstead of lettingmemory_to_batchzero it.Test
test_metadata_only_update_preserves_vector: create with a vector → metadata-only update (vector = None) → assert the stored vector is unchanged (and non-zero).