github jeffhajewski/latticedb v0.7.0
LatticeDB v0.7.0 — Vector Lifecycle Correctness

latest releases: v0.15.0, v0.14.0, v0.13.0...
5 months ago

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 .absent vector states now call hnsw.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:

  1. database: vector delete removes from search results
  2. database: vector replace updates search results
  3. database: vector delete in transaction removes from search
  4. database: vector replace in transaction updates search
  5. database: vector delete survives reopen
  6. database: vector replace survives reopen

Zig Compatibility

  • Added src/compat.zig — a compatibility shim that wraps Zig 0.16.0's new std.Io API, 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(), and std.heap.GeneralPurposeAllocator.

Files Changed

53 files | +1,346 insertions, −741 deletions

Don't miss a new latticedb release

NewReleases is sending notifications on new releases.