VSDB is a high-performance embedded key-value database for Rust that provides:
- Persistent collections with Rust std-like API (Mapx, MapxOrd, Orphan)
- Git-model versioning (VerMap) — branches, commits, three-way merge, rollback, GC
- Merkle tries (MPT + SMT) for stateless cryptographic commitments
- Slot-based indexing (SlotDex) for timestamp-paged queries
- DAG-based collections (DagMap) for graph-like data
- Vector index (VecDex) — pure-Rust HNSW for approximate nearest-neighbor search
Built exclusively on mmdb (pure-Rust LSM-Tree engine) with 16-shard prefix-based routing.
vsdb/
├── core/ # vsdb_core — engine integration, MapxRaw, prefix allocation
└── strata/ # vsdb — typed collections, versioning, tries, slotdex, dagmap, vecdex
make all # fmt + lint + test
make test # cargo test --workspace (release + debug, single-threaded)
make lint # cargo clippy --workspace + check tests/benches
make bench # criterion benches (core basic, strata basic, versioned, slotdex)Important: Tests MUST run single-threaded (--test-threads=1) due to global MMDB state.
| Subsystem | Key files | Purpose |
|---|---|---|
| Engine | core/src/common/engine/mod.rs, mmdb.rs |
Mapx, batch ops, prefix alloc, 16-shard routing |
| MapxRaw | core/src/basic/mapx_raw/ |
Untyped raw KV, prefix isolation |
| Typed Collections | strata/src/basic/mapx/, mapx_ord/, mapx_ord_rawkey/, orphan/ |
Mapx<K,V>, MapxOrd<K,V>, MapxOrdRawKey, Orphan |
| Persistent B+ Tree | strata/src/basic/persistent_btree/ |
COW B+ tree, structural sharing |
| Versioning | strata/src/versioned/ |
VerMap, Branch/BranchMut handles, commit DAG, merge |
| Error types | strata/src/common/error.rs |
VsdbError enum (thiserror-based) |
| Merkle Tries | strata/src/trie/ |
MPT (16-ary) + SMT (binary 256-bit) |
| Slot Index | strata/src/slotdex/ |
Time-slot tier-based indexing |
| DAG Collections | strata/src/dagmap/ |
DAG-based data structures |
| Vector Index | strata/src/vecdex/ |
VecDex, HNSW ANN search, distance metrics |
| Encoding | strata/src/common/ende.rs |
postcard-based KeyEnDe/ValueEnDe |
/x-review— deep regression analysis (supports: N commits,all, hash, range)/x-fix— fix audit backlog: resolvedocs/audit.md→ self-review → commit/x-commit— self-reviewing commit: review uncommitted changes → fix → commit/x-overhaul— full codebase overhaul: review all → fix → commit
Supporting documentation in .claude/docs/:
technical-patterns.md— cataloged bug patterns for vsdb + mmdb layersreview-core.md— systematic review methodologyfalse-positive-guide.md— rules for filtering spurious findingspatterns/— per-subsystem review guides (btree, versioning, trie, slotdex, dagmap, engine, vecdex)
Additional documentation in docs/:
audit.md— audit findings registry (tracked by /x-review and /x-fix)
- All clippy warnings are errors (
#![deny(warnings)]in lib.rs) - No
#[allow(...)]— fix warnings at the source, never suppress them - Prefer imports over inline paths — avoid
std::foo::Bar::new()inline in function bodies when the same path appears 3+ times in a file; adduse std::foo;at file top (oruse std::foo::Bar;) instead. Function-bodyusestatements (scoped imports) are fine and don't count as inline paths. 1-2 inline uses of commonstd::items are acceptable. - Grouped imports — merge common prefixes:
use std::sync::{Arc, Mutex}; - Doc-code alignment — public API changes must update corresponding docs
parking_lotfor Mutex (prefix allocator, VSDB_BASE_DIR global, DagMap ID allocation)VsdbError(thiserror) for public API errors;rucfor internal error chainingpostcardfor serialization (replaced serde_cbor_2 in v12)- Tests run single-threaded; use
tempdiror/tmp/vsdb_testingfor isolation - ~22 unsafe blocks — all require
// SAFETY:commentsshadow(): SWMR contract — caller serializes writesfrom_bytes(): caller provides valid serialized bytes- Pointer casts in entry API macros
env::set_varinvsdb_set_base_dir: caller must invoke before spawning threads