harden vector operations — bug fixes, tests, docs - #96
Merged
Conversation
- reject NaN/infinity in add() and search() (NonFinite error variant)
- always set expansion_search explicitly in search() to prevent state
pollution between calls (default ef=64)
- use wrapping_add for next_key to prevent overflow
- add try_clone() for fallible index cloning, graceful Clone fallback
- replace expect("just inserted") in vadd with proper error return
- AOF round-trip: vadd (3d and 1536d), vrem serialization - snapshot round-trip: vector entries, empty vector set with TTL - recovery: snapshot load, AOF replay with add+remove, auto-delete on last element removal
kacy
added a commit
that referenced
this pull request
Feb 19, 2026
* fix: harden vector operations — NaN validation, ef leak, panic paths
- reject NaN/infinity in add() and search() (NonFinite error variant)
- always set expansion_search explicitly in search() to prevent state
pollution between calls (default ef=64)
- use wrapping_add for next_key to prevent overflow
- add try_clone() for fallible index cloning, graceful Clone fallback
- replace expect("just inserted") in vadd with proper error return
* test: add vector persistence integration tests
- AOF round-trip: vadd (3d and 1536d), vrem serialization
- snapshot round-trip: vector entries, empty vector set with TTL
- recovery: snapshot load, AOF replay with add+remove, auto-delete
on last element removal
* docs: add vector similarity search to readme
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.
summary
what was tested
--features vectorcargo fmt --all -- --checkcleancargo clippy --workspace --features vector -- -D warningscleandesign considerations
NaN/infinity rejection: usearch behavior with non-finite floats is undefined. vectors are now validated before reaching the HNSW index — both in
add()andsearch().expansion_search state pollution:
change_expansion_search()mutates the index's internal state. previously, callingVSIMwith a custom EF value would affect subsequent searches that used the default. now we explicitly set ef on every search call (default: 64).fallible clone: the
Cloneimpl previously usedexpect()which would crash the server if usearch couldn't allocate. now usestry_clone()with a graceful fallback to an empty set — data loss is preferable to a server crash.