Skip to content

fix: discard stale raw vectors when overwriting snapshots - #87

Open
N7766 wants to merge 1 commit into
MinishLab:mainfrom
N7766:codex/fix-overwrite-vector-store
Open

N7766 wants to merge 1 commit into
MinishLab:mainfrom
N7766:codex/fix-overwrite-vector-store

Conversation

@N7766

@N7766 N7766 commented Nov 13, 2026

Copy link
Copy Markdown

Fixes #86.

When a saved index with raw vectors is replaced by an index created with store_vectors=False, load() currently reattaches the previous snapshot's store/vectors.npy to the new items. A vector lookup can therefore return the old document's embedding even though nearest-neighbor queries use the new index.

This removes the obsolete library-owned raw-vector file during overwrite, removes its directory only when empty, and checks for the actual vector file when loading. Unrelated files in the snapshot and store/ directory are preserved. Existing snapshots containing raw vectors retain the same format and load behavior. A store/ directory without vectors.npy now loads without optional raw-vector access, so unrelated sidecar files can remain.

Validation on Python 3.11.13 / NumPy 2.0.2:

  • 14 persistence regression/control cases pass, covering all four raw-vector storage transitions for cosine and Euclidean, dimensionality changes, fresh snapshots, refusal to overwrite, and preservation of unrelated files.
  • Against unmodified main, the same cases produce 5 failures and 9 passes; the failures demonstrate stale raw-vector attachment.
  • All 3 existing utility tests pass alongside the 14 new cases (17 passed).
  • git diff --check and the repository-pinned Ruff 0.4.10 lint/format checks pass.
  • The existing tests/test_vicinity.py suite could not be collected in this minimal environment because it imports the optional faiss dependency at module level. The full multi-backend suite and upstream CI were not run locally.

The public-API reproduction uses synthetic NumPy arrays only; no model or embedding services were called. Prepared with Codex assistance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overwriting a snapshot without raw vectors reloads the previous snapshot's vectors

1 participant