Documentation
Storage features
Opt-in engine features. Encryption, commit timestamps
and graphs need v5 files; change feeds and sequence restore work on v4 and v5.
Older binaries refuse v5 files with flags they do not understand
(UnsupportedFeature). No operation modifies its source file: each writes a
new, fully revalidated file or reads a closed or copied one.
Shared-lock read-only snapshots
Database::open_read_only(path) and open_read_only_encrypted(path, &key)
take a shared OS lock, so several processes can read one file. A writer needs
exclusive ownership; conflicting opens return Error::Locked without waiting.
A handle sees the commits that existed when it opened. Mutations return
Error::ReadOnly without poisoning the handle, incomplete tails are rejected
rather than repaired, and is_read_only() reports the mode. In-memory ANN
builds still work.
Python: native.open(path, read_only=True). Node:
native.open(path, {readOnly: true}). C ABI Open: "read_only": true. The C
ABI serializes calls per process, so parallel Python reads need separate
processes. The server keeps its exclusive lock and serves concurrent reads
itself; see MCP read-only access.
Encryption at rest
let key = EncryptionKey::from_bytes([7; 32]); // or from_passphrase(..)
let db = Database::create_with_options(path, 384, CreateOptions {
encryption: Some(key), ..Default::default() })?;
let db = Database::open_encrypted(path, &key)?;
- Cipher. ChaCha20-Poly1305 (pure Rust) with a per-file key derived from
yours and a random salt. Passphrases use Argon2id (
KdfParams). The header stores the salt, cost parameters and a non-secret key ID. - Scope. Frame bodies (vectors, payloads, metadata) are sealed as
nonce || ciphertext || tag. Frame prefixes stay plaintext for recovery and reveal operation type, collection ID, record ID, sequence and sizes; file size and timing also leak. - Errors.
EncryptionKeyMismatch(wrong key; reports the file's key ID),EncryptionKeyRequired(missing key) andNotEncrypted(key for a plain file). A damaged frame fails authentication, so garbage is never returned. - Maintenance.
maintenance::reencrypt(src, dest, old_key, new_key)rotates keys into a validated copy with a new salt; retire the old file and its backups yourself.inspect_with_key,verify_with_key,backup_with_key,restore_with_keyandcompact_with_keyhandle encrypted files, and the keyless versions returnEncryptionKeyRequired. Backups stay encrypted. - Sidecars. ANN snapshots and disk-ANN files are refused
(
SidecarUnavailable) because they would hold plaintext vectors; rebuild HNSW in memory instead. - Not covered. Key storage and distribution, process memory, swap, core dumps and the server's own sidecar files. A lost key means lost data.
Point-in-time restore
Create the database with CreateOptions { commit_timestamps: true, .. } to
record a wall-clock time per commit, then:
maintenance::restore_to(Some(base_backup), log_copy, dest,
RestoreTarget::Sequence(42) /* or TimestampMs(ms) */, key)?;
- The log is a copy of the full committed log: a closed primary, a backup or a follower's file. An optional base must share its lineage and be an exact byte prefix of the log; both are verified.
- The output is a new, validated file with a new lineage. A target before
the base or past the log gives
InvalidRestoreTarget, and a timestamp target on a file without timestamps givesTimestampsUnavailable. compactdrops timestamps and assigns a new lineage, so keep pre-compaction backups to restore earlier history by time. Sequence restore needs no timestamps.
Change feed
let mut cursor = db.feed_cursor()?; // or FeedCursor::beginning(lineage)
let batch = db.changes_after(&cursor, 500)?; // ChangeBatch { changes, next, has_more, head }
cursor = batch.next;
cursor.save(path)?; // durable (tmp + fsync + rename)
- Events: put (with record and expiry), delete, metadata update, collection
created or dropped, settings updated and vectors updated. Batch commits are
never split, so a feed batch may exceed
max_events. Expiry is not an event; consumers readexpires_at_mson the put. - Cursors hold lineage, sequence and a CRC-checked token. Errors:
CursorCompacted(file compacted or restored; resync),CursorAhead(past the head) andInvalidCursor(damaged token). - Needs v4+ (
ChangeFeedRequiresUpgradeotherwise). Each call scans the log from the start, O(log size), so use large batches and poll sparingly. Encrypted files are read with the database key. changes::read_log_changes(path, key, cursor, max)reads a closed or copied log without opening a database.
Read replicas
let segment = primary.export_log(follower_sequence, 1 << 20)?; // LogSegment
let mut follower = ReplicaFollower::create(path, &segment, key)?; // first segment
follower.apply(&next_segment)?;
let lag = follower.status()?; // applied_sequence, primary_head, lag
follower.db().search(..)?; // read-only access
- Segments are whole commits authenticated by CRCs (and AEAD tags when
encrypted). Gaps, replays and foreign lineages fail with
ReplicaDivergedand leave the follower unchanged. - Writes on a follower return
ReadOnlyReplica;promote()closes it and returns a writableDatabase. - For file shipping, use
LogSegment::save/load,apply_file, orsync_from_log(path, max_bytes)on a closed or copied primary. A live primary on Windows holds an exclusive lock, so shipDatabase::export_logsegments instead. - Each apply replays the whole follower file (O(database size)) and drops its in-memory ANN, so batch applies. A crashed apply's tail is discarded on reopen. There is no network transport.
Disk-based ANN
let source = db.build_disk_ann("default", sidecar, HnswConfig::default(), DistanceMetric::SquaredL2)?;
let index = DiskAnnIndex::open(sidecar, DiskAnnOptions { cache_bytes: 64 << 20 })?;
let hits = db.search_disk_ann(&index, &query, 10, /*ef*/ 100)?;
- The index is a rebuildable sidecar holding the HNSW graph and f32 vectors in
CRC-checked node records. It is bound to the database's lineage and
sequence, so any later commit makes it
StaleIndex; rebuild it.verify()checks every node, and a damaged sidecar is never trusted. - Query memory is bounded. The header and upper layers stay resident;
nodes are read with
preadinto an LRU cache capped atcache_bytes.memory()reports resident bytes, cache use, hits and disk reads. - Build memory is not. A build needs as much memory as an in-memory HNSW build, so build larger-than-RAM collections on a bigger machine, or in pieces, and query them on a small one.
- Recall matches in-memory HNSW at the same
efbecause the same graph is walked. Tests assert recall@10 ≥ 0.9, within 0.05 of in-memory HNSW, and exact results at exhaustiveef. Records are indexed as stored (no metadata filters or expiry); squared L2 and cosine are supported. - Not available for encrypted databases. On Windows, drop an open
DiskAnnIndexbefore replacing its file.
GPU exact search
Enable the cargo feature gpu (wgpu compute shaders).
let gpu = GpuExactSearcher::new(); // None without an adapter
let hits = GpuExactSearcher::search_or_cpu(gpu.as_ref(), &db, &query, 10)?;
- Squared L2 over the default collection only; use the CPU path for filtered,
cosine or other-collection search. The GPU scores in f32 and the best
4k + 32candidates are re-scored in f64 on the CPU, so distances matchDatabase::search. Near-ties within f32 error may reorder at the top-k boundary. - With no adapter, or on GPU failure (
GpuUnavailable),search_or_cpuuses the CPU. Software adapters (WARP, llvmpipe) work but are slow.
WebAssembly
The engine builds for wasm32-unknown-unknown with --no-default-features.
Database::create_in_memory, open_from_bytes and to_bytes use a
byte-buffer backend without file locking. Encryption, change feeds and
timestamps work, and the host must persist the image for durability.
set_wasm_clock_ms supplies the time. Background HNSW rebuilds need threads
and return an error, and path-based APIs fail at runtime. bindings/wasm is a
wasm-bindgen package with a Node smoke test. The in-memory backend also works
natively.
Graph-enabled files
Every build since v0.5.1 can store named property graphs in the same log as
vectors; there is no graph Cargo feature. Every new file is
graph-enabled: Database::create writes a v5 file with header flag
FLAG_GRAPH = 4 (an explicit v3/v4 create stays plain);
maintenance::enable_graph writes a graph-enabled copy of a v4 or v5 file.
Graph commits are op-12 frames on the same commit path as vectors, so locking,
sequences, checksums, encryption and commit timestamps work as usual.
- Limits. Graph names follow the collection-name rule. At most 64 graphs exist at once, and a dropped graph's ID can be reused. A frame holds 1..=4,096 entries, plus entries that remove expired nodes and edges (one may open the body and one may follow each due expiry entry), and a body of at most 16 MiB. Names, keys, labels and properties live only in the body, which is encrypted in encrypted files.
- Open. Each graph frame is verified, decrypted, decoded, validated and
applied atomically. A malformed frame fails the open with
Corrupt; there is no partial graph state. - Writes.
create_graphanddrop_graph(empty graphs only) commit one frame each.graph_mut(name).write_batch(&[GraphOp])applies up to 4,096 node, edge, attachment and vector operations, in any collection, in order as one atomic frame; nothing is written on error. Attached records must be live and without expiry when the frame commits. While a record is attached, plain, conditional, batch and import deletes fail withGraphAttachedRecord, and setting an expiry fails withGraphAttachedRecordExpiry. Overwrites and metadata updates keep the attachment. Detach first to delete. - Expiry. Nodes and edges can carry deadlines (Rust API only). A due node
is hidden with all its edges, and a due edge on its own. Graph writes,
compaction and checkpoints remove what is due; a write also removes what
its own operations make due before its next operation. Only files that use
the expiry operations contain the new entries, so other files are written
as before; older builds refuse those files as
Corrupt. See Expiry. - Reads.
graph(name)offers node and edge gets, pagedfind_nodesandneighbors, breadth-firsttraverse, canonicalshortest_pathandexplain.ReadOptionsbounds work and output and supports cancellation; exceeding a hard ceiling is an error. Results reportview_sequence,complete, truncation reasons and work statistics, and a truncated shortest-path search returnsExhausted, never an unproven "no path". Paged cursors are bound to the query and graph sequence: graph writes and attached-record updates invalidate them, unrelated vector writes do not. - Maintenance.
inspect,inspect_detail,verify,backup,restore,compact*,reencrypt,restore_to,drill,upgrade, log export and read replicas handle graph files. Graph files are already the latest format, soupgrademakes a validated copy that keeps the graph flag and every graph frame.compact*keeps graph IDs and never reuses node or edge IDs; like vector compaction, it restarts sequences and drops commit timestamps.maintenance::inspect_graphandverify_graphreport graph, node, edge and attachment counts.maintenance::strip_graphcopies the vector data to a v5 file without graphs and needsconfirm_graph_data_loss = true.vlite-maintaingainsenable-graphandstrip-graph --confirm-graph-data-loss. - Change feed. Since v0.6.0
feed_cursor,changes_afterandread_log_changesreport graph commits asGraphCreated,GraphDroppedandGraphBatchevents, and/v1/changes, gRPCChanges/WatchChangesand webhooks serve them; see Change feed and webhooks. - Unsupported. Releases before v0.5.0, and v0.5.0 builds without
graph, reject graph files withUnsupportedFeature(4). The server maps graph errors to 409 (state conflicts) or 422 (invalid input). Schemas, hybrid retrieval, query text and the server, MCP and SDK surfaces are in the property graph guide. - CLI.
vlite-graph-cliruns these reads and write batches with JSON; see Graph operations.
Periodic (lazy) durability
Since v0.5.1 file handles default to Durability::Periodic with a 60 s
interval (1 ms–60 s allowed): commits reach the OS immediately and a background
flusher syncs them, for vector and graph writes alike. A process crash loses
nothing acknowledged; an OS crash or power loss can lose up to about the last
interval (~60 s by default). Durability::Full syncs every commit before
acknowledgement. Durability::None is the in-memory mode: nothing touches
disk and all data is lost on restart. Use sync() for an explicit durable
point; close() syncs and a failed sync poisons the handle. The mode is not
persisted. Server: --durability periodic|full|none [--flush-interval-ms N];
C ABI, Python and Node: durability and flush_interval_ms plus sync. See
periodic durability for reopen cases.
Key-value store
Database::kv_store(collection) (Rust, v4+) stores namespaced string keys
with byte values, no vector needed. It uses an ordinary one-dimension
collection, created on first use, so the file format is unchanged.
use vlite::{Expected, kv::KvPut};
let mut kv = db.kv_store("agent-memory")?;
let token = kv.put("pool", "claim/42", b"worker-a", KvPut {
expected: Expected::Absent, // create only
expires_at_ms: Some(deadline_ms), // v5 files only
})?;
kv.delete("pool", "claim/42", Expected::Revision(token))?;
use vlite::kv::{KvOp, KvOutcome};
let outcomes = kv.write_batch(&[
KvOp::Put {
namespace: "pool",
key: "claim/43",
value: b"worker-b",
options: KvPut { expected: Expected::Absent, expires_at_ms: None },
},
KvOp::Delete { namespace: "pool", key: "claim/41", expected: Expected::Any },
])?; // all or nothing; one KvOutcome each
assert!(matches!(outcomes[0], KvOutcome::Put { .. }));
let entries = kv.view().get_many(&[("pool", "claim/43"), ("pool", "claim/41")])?;
- Versions are commit sequences. Use them for compare-and-set
(
Expected::Revision). They are revisions within one file lineage, not durable lease-fencing tokens: they change after compaction, upgrade or restore, so re-read the entry after any of those. - Expiry hides an entry at its deadline.
Expected::Absentthen succeeds. Expiry on a v4 file returnsExpiryRequiresUpgrade. - Listing with
view().list(namespace, prefix, after, limit)returns keys in order, up to 10,000 per page. It scans the whole collection, so its cost grows with the number of entries, not withlimit: keep key-value data in its own collection and list by prefix. The scan keeps only thelimit + 1smallest candidate keys, so its working memory does not grow with the number of matching entries.listcopies every value it returns (10,000 values of just under 1 MiB are roughly 10 GB), so use a smallerlimitwhen values can be large, orview().visit_at(namespace, prefix, after, limit, now_ms, visitor): it lends each value to a callback as aKvRef(withhas_next, which says whether the listing continues) and stops when the callback returnsControlFlow::Break(()), so a caller can build a page of a fixed byte size without copying the entries it leaves out. - Batch.
kv.write_batch(&[KvOp])commits puts and deletes of any namespaces of the collection, all or nothing, as one frame: a crash leaves all of it or none of it, and a reader sees the state before or after. It behaves as if the operations ran one at a time, in order, on one clock, and returns oneKvOutcomefor each:Put { version }orDeleted(bool). All puts of a batch get the same version, and each is a validExpected::Revisionfor its key. Each(namespace, key)may appear once. The whole request is checked before any state is read, oncekv_storehas opened the collection (it creates a missing one, and refuses a collection of another kind or a handle that has failed). The first operation that cannot run fails the whole batch with the error of its single call (RevisionMismatch,KvSlotsExhausted,GraphAttachedRecord) and nothing is written. A batch that changes no record writes nothing, and an empty batch is a no-op. On a format 1 file a batch that changes a record fails withBatchRequiresUpgrade, although single puts work there. AfterCommitIndeterminatethe batch is written entirely or not at all, and which is unknown: read the keys back withget_manybefore you decide anything. - No deadline in a batch. A
KvOp::Putwhoseoptions.expires_at_msis set is refused withInvalidKvKey. Like a put without a deadline, a batch put clears the deadline of the entry it replaces. Useputfor an entry that needs a deadline. - Multi-get with
view().get_many(&[(namespace, key)])returns oneOption<KvEntry>for each key, in order:Nonefor a key that is absent or expired. One clock and one view of the store serve the call, so its keys agree with each other; nothing is consistent between two calls.view().visit_many_at(keys, now_ms, visitor)lends each entry to a callback as aKvRefinstead of copying it (has_nextsays that a later requested key follows) and stops when the callback returnsControlFlow::Break(()).write_batch_atandget_many_attake the clock likeput_at. - Limits: namespaces up to 255 bytes, keys up to 1,024 bytes, values just
under 1 MiB. A batch takes at most
MAX_KV_BATCH_OPERATIONS(1,000) operations andMAX_KV_BATCH_VALUE_BYTES(4,194,304) value bytes in all, andget_manyat mostMAX_KV_GET_MANY_KEYS(1,000) keys; over any of them isInvalidKvKey, and nothing is written or read.KvOpandKvOutcomeare#[non_exhaustive]. - Hash collisions: keys hash to 16 consecutive record IDs. If all 16 hold
other keys or other records,
KvSlotsExhaustedis returned (REST and gRPC: 409 /FAILED_PRECONDITIONkv_slots_exhausted, counted by thekv_slots_exhausted_totalmetric). A slot holding an expired entry of another key is reused; other records are never overwritten. Because anyone who can write the collection can place ordinary records at those IDs, give write access to a key-value collection only to principals you trust with its keys and keep it separate from other data (SECURITY). - REST and gRPC provide ordinary get, put/CAS, delete, prefix listing, an atomic
batch and a multi-get on existing one-dimension collections; see
REST KV for wire bounds and pagination. Unlike the
Rust handle, neither transport creates a collection. gRPC uses
vlite.v1.Kvand raw byte values with the same page boundary. The Python, JavaScript, .NET and Go clients call the REST routes; the shell and MCP tools work on local files only. Leases are not provided. - Ordinary KV follows configured durability:
fullsyncs,periodiccan lose a flush interval on OS crash/power loss, andnoneis memory-only. Entry revisions do not establish durable, never-reused lease fencing domains.
Directory store
Database::create_directory(path, dimensions, options) (Rust only, v5)
stores a database as a directory instead of one file. Every other API,
including Database::open, open_read_only, the server and the maintenance
tools, accepts the directory path unchanged.
store/
LOCK held while open (exclusive, or shared for read-only)
MANIFEST ordered list of the live files, replaced atomically
image-N.vlite checkpoint image, optional
wal-N.log write-ahead logs; only the last one is appended
- Checkpoints fold the logs into one image on a background thread, so
reopen loads the image plus a short log instead of the whole history.
One starts after a commit once the active log reaches 64 MiB. Change it with
set_checkpoint_threshold(Some(bytes)), turn it off withNone, or run one and wait withcheckpoint(), which returns the floor sequence. - Reopen maps the image and sealed logs read-only and loads the image's records and graphs in bulk, in parallel, instead of replaying them; only the active log is replayed. Earlier releases cannot open a directory path at all, even before its first checkpoint, nor a backup packed from a checkpointed one.
- Kept across checkpoints: the lineage, every record's revision (compare-and-set revisions still match), graphs and encryption.
- History below the floor is gone. Change-feed and log-segment requests
for an earlier cursor return
CursorBeforeHistory(REST 409cursor_before_history). Take a snapshot, then resume from the floor. A new replica of a checkpointed store starts from a backup. - Converters:
maintenance::convert_to_directory(file, dir)keeps the lineage, revisions and cursors.maintenance::backup(dir, file)packs a directory back into one file. - Not supported: commit timestamps and v3 or v4 formats. Crash recovery trims a torn tail of the active log only; damage elsewhere is reported as corruption.
Filter block summaries
A collection with declared metadata indexes (CollectionSettings::metadata_indexes)
also keeps in-memory summaries of each block of 1024 records over the declared
fields. Exact filtered search and the exact scan of search_auto skip blocks
whose summary proves that no record can match and recheck every other record,
so hits, distances and order are unchanged; only SearchStats::records_scanned
can be lower. Geo radius and undeclared fields never skip. Nothing is written
to disk: summaries are derived again on first use after open.
Choose the index kind by the filter. Eq and EqRange keep equality postings
for any value type, which narrow an equality filter to its matches wherever
they lie. Range and EqRange order integers and floats, which serves numeric
ranges. On any other type a Range index adds only these summaries: they help
when the matching records sit together in ID order, and a filter whose matches
are spread over every block runs at the speed of no index. Measured gains are
in the supplemental results.
Server file compaction
A single-file database keeps old pages after updates and deletes until it is
compacted to a new file. Offline, vlite-maintain compact writes that new
file. The managed vlite-server can also do it while it runs, from the
dashboard (Administration → Backup & recovery → File compaction) or the
admin API, now or on an opt-in daily UTC schedule.
The server makes a frozen copy of the database, builds and validates a compact
file from it, then restarts its whole storage generation on the new file
during a short pause. The live file is never changed in place, and the
original is kept as a recovery copy. Records, graphs, credentials, the
lineage, the global commit sequence and ID high-water marks are kept. Record
ETags and graph revisions can advance, so earlier If-Match and
expected_revision values fail instead of overwriting data. Change history
from before compaction is dropped, so the server requires explicit consent
first.
The feature is experimental and off unless started or enabled. It is qualified only for Linux with the database and admin directory on one local ext4 filesystem, for files up to 1 GiB. SMB/Azure Files, NFS, overlay and native Windows or macOS stay disabled with a reason. See API.md for routes and limits.