LatticeDB v0.7.0 — Vector Lifecycle Correctness
What's New
HNSW Vector Deletion & Replacement
This release fixes a critical correctness bug where deleted nodes could still appear in vector search results. Vectors were never cleaned up on node deletion, and setNodeVector double-stored vectors (once in a separate table, once in HNSW), leading to stale data on reopen.
Core Changes
- HnswIndex.remove() — Properly removes vectors from the in-memory index, updates the entry point and max layer, updates neighbor connections, decrements the vector count, and marks the index dirty for persistence.
- insert() auto-replace — Inserting a vector for an existing ID now replaces the old entry instead of leaking it.
- saveToTree() stale key pruning — The persistence layer now scans the B+Tree for vector keys belonging to deleted nodes and removes them, so deleted vectors do not resurrect on reopen.
Database Integration
- applyTxnOverlay() — Transaction overlay
.absentvector states now callhnsw.remove(). Uncommitted vector deletes are visible in their transaction. - deleteNode() — Removes the vector from HNSW in the direct (non-transactional) path.
- removeNodeLabel — When removing the last label from a node (making it unlabeled), the vector is marked absent in the transaction overlay so it gets cleaned up.
- vectorSearch / vectorSearchInTxn — Results are now filtered to skip vectors for nodes that have been deleted or no longer exist.
- setNodeVector — Removed the
vs.store()call that caused double-storing. HNSW now handles vector storage internally during indexing.
Tests
Six new integration tests cover vector delete/replace behavior:
database: vector delete removes from search resultsdatabase: vector replace updates search resultsdatabase: vector delete in transaction removes from searchdatabase: vector replace in transaction updates searchdatabase: vector delete survives reopendatabase: vector replace survives reopen
Zig Compatibility
- Added
src/compat.zig— a compatibility shim that wraps Zig 0.16.0's newstd.IoAPI, allowing the project to build and run on Zig 0.16.0 while maintaining familiar patterns. - Fixes across the entire codebase for API changes in
std.fs.*,std.posix.*,std.Thread.Mutex,std.time.timestamp(), andstd.heap.GeneralPurposeAllocator.
Files Changed
53 files | +1,346 insertions, −741 deletions