v0.9.4 is out Release notes

Vector, graph and document. One embedded engine.

TriviumDB is SQLite for AI applications: a Rust engine that keeps embeddings, JSON payloads and graph edges under one node ID, on one machine, in one transaction.

Get started
pip install triviumdb
One embedded engine, taken apart into its five layers. your app disk PY JS RS 01Interfaces Python · Node.js · Rust TQL PLAN 02Query TQL · Cascades · Pipeline node_id 42 03node_id Vector · Payload · Edges 04Indexes .idx · QuIVer · BM25 WAL .tdb .vec 05Storage WAL · .tdb · .vec

One embedded engine, taken apart into its five layers.

node ID for vector, JSON payload and graph edges
1
native bindings: Python, Node.js and Rust
3
graph algorithms callable inside TQL queries
15+
servers to deploy. It runs in your process.
0

Source, benchmarks and API reference on GitHub

01The problem

Three databases. One fragile memory.

Agent memory usually lives in three places: a vector index for recall, a document store for state, a graph for relations. Each is correct on its own. Keeping them consistent is left to your code.

Before Three ID spaces, held together by sync code.

With TriviumDB One node, one ID, one transaction.

02The model

One ID binds three kinds of data.

Every node holds a dense vector, a JSON document and its graph edges under one u64 ID. They share one write-ahead log and one lifecycle, so there is nothing to keep in sync.

node_id 42 u64
Vectorf32 · f16 · u64

Dense embedding for similarity search: cosine for f32 and f16, Hamming for u64.

PayloadJSON

Any JSON document, filterable with Hash, ordered ART, composite and bitmap indexes.

Edgesdirected · weighted

Typed relations for traversal, spreading activation and graph algorithms.

  • Atomic by construction

    A node and its vector, payload and edges commit together or not at all. Deletes remove all three.

  • Typed on disk

    Since 0.9 the file header records dtype and element width, so a vector of the wrong type is rejected before it is written.

  • Text on the same ID

    Optional BM25 and Aho-Corasick text indexes attach to the same node, ready for hybrid recall.

03Query

Store once. Query it any way.

Call search() for the default path, or write TQL to chain vector recall, document filters, graph patterns, graph algorithms and paths in one query.

  • Cascades optimizer with EXPLAIN ANALYZE
  • Prepared queries with strict parameters
  • 15+ graph algorithms inside queries
  • Same TQL in Rust, Python, Node.js and the CLI

04QuIVer index

Exact while small. Fast as it grows.

QuIVer is the default ANN for semantic embeddings. It navigates a compact graph and reranks candidates. Use exact search for synthetic vectors and handcrafted features.

query BQ encode 101101 0110… SM-L2 navigation candidates cosine rerank id:42 0.985 id:88 0.972 id:10 0.968 id:55 0.954 id:99 0.949

When does QuIVer switch on?

QuIVer takes over at 834 nodes.

Threshold = ceil(666,667 ÷ dimension), clamped to 209–834 nodes.

Hot and cold memory

hot Signatures + graph

Anonymous heap memory, used on every query.

cold Reranking

Rerank with original vectors or centered INT8 / INT4 codes in hot memory or on SSD.

Read the QuIVer preprint ↗

For fixed-curvature Poincaré ball embeddings, select Pelorus explicitly to rank by geodesic distance.

Pelorus · arXiv ↗

Vectors and payloads are memory-mapped from sidecar files, so large databases open without loading into RAM.

  • memory.tdb Header with dtype and CRC, node slots, edges, BQ metadata
  • memory.tdb.vec Memory-mapped vectors
  • memory.tdb.pld.<gen> Published JSON payloads, one file per generation
  • memory.tdb.flush_ok Checkpoint marker with generation, sizes and integrity digests
  • memory.tdb.wal Write-ahead log
  • memory.tdb.idx Indexes, registered text and index definitions

05Storage and recovery

Files you can reason about.

Both layouts publish a database file group. Use create_snapshot to copy it, verify_snapshot to check it and restore_snapshot to restore it.

What a commit does

  1. 01 Validate

    Dry-run IDs, dimensions, payload size and edge targets. A rejected transaction leaves no trace.

  2. 02 Log

    Append TxBegin, records and TxCommit to the WAL. Every frame carries a CRC32.

  3. 03 Apply

    Update memory and indexes. If the log write failed, the writer is isolated instead.

  4. 04 Checkpoint

    Write temporary files, fsync, then publish with an atomic rename.

  5. 05 Recover

    On open, replay complete transactions. An unfinished tail is dropped; a corrupted frame fails closed and keeps the log.

Durability follows the sync mode: full, normal (default) or off.

06Build

Runs inside your process.

No server, no port, no config file. Install a package, open a path, and your agent has memory. Prebuilt binaries mean there is nothing to compile.

triviumdb v0.9.4
import triviumdb

with triviumdb.TriviumDB("agent-memory.tdb", dim=3) as db:
    alice = db.insert([0.12, -0.45, 0.78], {"type": "memory", "text": "Alice works on databases"})
    cafe = db.insert([0.08, -0.52, 0.81], {"type": "place", "name": "Blue Bottle"})

    db.link(alice, cafe, label="visited", weight=0.8)

    for hit in db.search([0.10, -0.48, 0.80], top_k=5, expand_depth=2, min_score=0.1):
        print(hit.id, hit.score, hit.payload)
  • Linux x64 · ARM64
  • macOS Intel · Apple Silicon
  • Windows x64
  • Python 3.9–3.12
  • Node.js
  • Rust stable
  • tdb CLI

    Run TQL, import and export, repair and compact. Includes a REPL and a terminal UI with a graph view.

  • Embedded Console

    New in 0.9

    Drive an open database with JSON requests from Rust, Python or Node.js. Sessions are read-only by default.

  • HTTP server

    Preview

    An optional Axum server with a writer actor, group commit and optimistic concurrency.

  • Hooks

    Load C, C++ or Rust plugins at six points of the search pipeline.

Full API reference on GitHub ↗

07Start building

Give your agent one memory.

Open source under Apache-2.0. One package for Python, Node.js and Rust.

  • pip install triviumdb
  • npm install triviumdb
  • cargo add triviumdb