Skip to content

ferrovec 0.4.0 — crash-safe storage: checksummed snapshots, write-ahead log, published kill-the-tab test

Choose a tag to compare

@singhpratech singhpratech released this 11 Oct 01:10
· 19 commits to main since this release

Crash-safe storage (M7). The index on disk is now two alternating, CRC-32-checksummed snapshot slots plus a write-ahead log. Every insert/remove is a checksummed log record flushed to OPFS before its promise resolves; checkpoints are written before the log is reset, so open always takes the newest valid snapshot and replays the log on top. A torn or bit-flipped file is detected and skipped, never decoded into a wrong index. If nothing trustworthy is left, open refuses with a typed error instead of starting empty over your data.

Tested like a database. npm run test:chaos kills the tab at a random moment (including mid-insert), reopens, and checks every acknowledged id. Published results: 1,000 cycles each in Chromium 149 and Firefox 151, 5,518 + 5,445 acknowledged writes, 0 lost. A negative control (log write deferred by 30 ms) loses everything, so the harness detects loss. https://singhpratech.github.io/ferrovec/chaos.html

Also new

  • Ferrovec.list({ offset, limit }) enumerates stored documents.
  • durability: 'strict' | 'relaxed' and db.flush().
  • Ferrovec.destroy(name), db.storagePersisted, requestPersistentStorage option.
  • The log header carries the embedding model id, so a store is refused under a different model before any download, even before its first checkpoint.
  • Typed errors cross the worker boundary: StoreCorruptError, EmbeddingSpaceMismatchError, WalCorruptError, SnapshotCorruptError, EmptyOverwriteRefusedError.
  • Live demo with two tabs: semantic search, and a notebook you can kill mid-save. https://singhpratech.github.io/ferrovec/demo.html

Upgrading from 0.3.x. Existing single-file stores are migrated to the slot format on the first commit. Close every tab of your app before upgrading.

Not promised. Power-loss durability (OPFS flush() is not fsync) and cross-device sync.

crates.io: https://crates.io/crates/ferrovec/0.4.0 · npm: https://www.npmjs.com/package/ferrovec/v/0.4.0