Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/regression-guard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,35 @@ jobs:
- name: cargo check ruvector-core with simd-avx512 (default)
run: cargo check -p ruvector-core

# Issues #1310 / #1313: filtered top-k is full at 1% and 10% selectivity
# (10k vectors), duplicate-id inserts are upserts with no ghost nodes, and
# NaN/Inf vectors are rejected before storage.
ruvector-core-retrieval-correctness:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4
with:
toolchain: '1.89.0'
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32
- name: retrieval correctness contract
run: cargo test -p ruvector-core --release --test retrieval_correctness --test filtered_search

# Issue #1239: ruvector-delta-core must build without std (no parking_lot,
# bincode or other std-only dependencies on the no_std path).
ruvector-delta-core-no-std:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4
with:
toolchain: '1.89.0'
targets: thumbv7em-none-eabihf
- name: cargo build ruvector-delta-core for a bare-metal target
run: |
cargo build -p ruvector-delta-core --no-default-features --target thumbv7em-none-eabihf
cargo build -p ruvector-delta-core --no-default-features --features serde --target thumbv7em-none-eabihf

# Issue #430: HNSW recall@1 must stay above 95% on the regression test that
# historically exposed the result-heap inversion.
hnsw-recall-at-1:
Expand Down
72 changes: 34 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/ruvector-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ruvector-core"
version = "2.5.0"
version = "2.5.1"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
Expand Down
17 changes: 12 additions & 5 deletions crates/ruvector-core/src/index/hnsw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,13 @@ impl HnswIndex {

let neighbors = inner.hnsw.search(query, wanted, effective_ef);

// Only an id's live node answers for it (snapshots from older versions can still map superseded nodes).
let mut results: Vec<SearchResult> = neighbors
.into_iter()
.filter_map(|(idx, distance)| {
inner.idx_to_id.get(&idx).map(|id| SearchResult {
let id = inner.idx_to_id.get(&idx)?;
let live = inner.id_to_idx.get(id.as_str()).is_some_and(|i| *i == idx);
live.then(|| SearchResult {
id: id.clone(),
score: distance,
vector: None,
Expand Down Expand Up @@ -334,9 +337,11 @@ impl VectorIndex for HnswIndex {

inner.hnsw.insert(&vector, idx);

// Store mappings
// Store mappings. Re-adding an id is an upsert: the old graph node becomes a tombstone.
inner.vectors.insert(id.clone(), vector);
inner.id_to_idx.insert(id.clone(), idx);
if let Some(old) = inner.id_to_idx.insert(id.clone(), idx) {
inner.idx_to_id.remove(&old);
}
inner.idx_to_id.insert(idx, id);

Ok(())
Expand Down Expand Up @@ -368,10 +373,12 @@ impl VectorIndex for HnswIndex {
.collect();
inner.hnsw.insert_batch(&items);

// Store mappings
// Store mappings; an id seen earlier (in the index or this batch) keeps only its newest node.
for (id, idx, vector) in data_with_ids {
inner.vectors.insert(id.clone(), vector);
inner.id_to_idx.insert(id.clone(), idx);
if let Some(old) = inner.id_to_idx.insert(id.clone(), idx) {
inner.idx_to_id.remove(&old);
}
inner.idx_to_id.insert(idx, id);
}

Expand Down
Loading
Loading