Skip to main content

SochDB Documentation

Welcome to the official SochDB documentation. SochDB is The LLM-Native Database β€” a high-performance database designed specifically for AI applications, usable embedded or as a server.

Current Version: v2.0.3 (Core engine) | Python SDK v0.5.9 | Node.js SDK v0.5.3 | Go SDK v0.4.5

License

SochDB ships under a split license. The core engine (the Rust workspace β€” the sochdb crate, server, and MCP) is AGPL-3.0-or-later, with commercial licensing available. The language SDKs (Python, Node.js, Go) are Apache-2.0.


What is SochDB?​

SochDB is a single database that replaces your vector DB + relational DB + prompt packer stack. Store structured data, embeddings, and conversation history togetherβ€”then ask SochDB to assemble token-optimized context for your LLM.

Comparison​

Database + retrieval layer​

FeatureSochDBSQLite + vecPostgres + pgvectorChromaLanceDB
Embeddedβœ…βœ…βŒβœ…βœ…
Vector searchβœ… HNSW⚠️ (via extension)βœ… (HNSW / IVFFlat)βœ…βœ…
SQL (user-facing)βœ… joins, aggregates, GROUP BYβœ…βœ…βŒβœ…
Hybrid search (vector + keyword)βœ…βš οΈ (DIY)⚠️ (DIY)⚠️ (limited)βœ…
Context builderβœ…βŒβŒβŒβŒ
Token budgetingβœ…βŒβŒβŒβŒ
Graph overlayβœ…βŒβŒβŒβŒ
ACID transactionsβœ…βœ…βœ…βš οΈ (limited)❌
Columnar storageβœ…βŒβŒβŒβœ…

Memory / agent-memory layer​

FeatureSochDBMem0LettaGraphiti
Primary focusDB + retrieval + contextMemory layerAgent framework + memoryTemporal knowledge-graph memory
Long-term memory primitivesβœ…βœ…βœ…βœ…
Token-aware context budgetingβœ…βŒβŒβŒ
Graph-based memoryβœ…βŒβŒβœ…
Built-in vector storeβœ…βŒ (BYO)❌ (BYO)❌ (BYO)
Built-in agent runtimeβŒβŒβœ…βŒ
Drop-in β€œmemory add-on” to existing appsβœ…βœ…βš οΈβœ…

Quick links: πŸ“š Documentation β€’ Quick Start β€’ Architecture β€’ TOON Format β€’ Performance β€’ RFD


Why SochDB?​

❌ The Typical AI Agent Stack​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ YOUR APPLICATION β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚ β”‚ β”‚
β–Ό β–Ό β–Ό β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Postgres β”‚ β”‚ Pinecone β”‚ β”‚ Redis β”‚ β”‚ Custom Code β”‚
β”‚ (metadata) β”‚ β”‚ (vectors) β”‚ β”‚ (sessions) β”‚ β”‚ (context assembly) β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β€’ User data β”‚ β”‚ β€’ Embeddings β”‚ β”‚ β€’ Chat state β”‚ β”‚ β€’ Token counting β”‚
β”‚ β€’ Settings β”‚ β”‚ β€’ Similarity β”‚ β”‚ β€’ Cache β”‚ β”‚ β€’ Truncation logic β”‚
β”‚ β€’ History β”‚ β”‚ search β”‚ β”‚ β€’ Temp data β”‚ β”‚ β€’ Prompt packing β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β€’ Multi-source fusion β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚ β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 😰 You manage all of this: β”‚
β”‚ β€’ 4 different query languages β”‚
β”‚ β€’ 4 sets of credentials β”‚
β”‚ β€’ 4 failure modes β”‚
β”‚ β€’ No cross-system transactionsβ”‚
β”‚ β€’ Weeks of glue code β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βœ… With SochDB​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ YOUR APPLICATION β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SochDB β”‚
β”‚ β”‚
β”‚ SQL + Vectors + Context Builder β”‚
β”‚ β”‚
β”‚ β€’ One query language β”‚
β”‚ β€’ One connection β”‚
β”‚ β€’ ACID transactions β”‚
β”‚ β€’ Token budgeting built-in β”‚
β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 😎 What you actually ship: β”‚
β”‚ β€’ Single ~700KB embedded DB β”‚
β”‚ β€’ Zero external dependencies β”‚
β”‚ β€’ Works offline β”‚
β”‚ β€’ Deploys anywhere β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The Problem β†’ Solution​

ChallengeTraditional StackSochDB
Token wasteJSON/SQL bloat in promptsTOON format for dense output
RAG plumbingSeparate vector DB + glue codeBuilt-in HNSW with hybrid search
Context assemblyCustom packer per use caseOne query with token budget
I/O overheadMultiple DB round-tripsSingle columnar read
ConsistencyDistributed transaction headachesLocal ACID guarantees
DeploymentManage 4 servicesSingle binary, embed anywhere

Key Features​

🧠 Context Query Builder β€” Assemble system + user + history + retrieval under a token budget
πŸ” Hybrid Search β€” HNSW vectors + BM25 keywords with reciprocal rank fusion
πŸ•ΈοΈ Graph Overlay β€” Lightweight relationship tracking for agent memory
⚑ Embedded-First β€” ~700KB binary, no runtime dependencies, SQLite-style simplicity
πŸ”’ Full ACID β€” MVCC + WAL + Serializable Snapshot Isolation
πŸ“Š Columnar Storage β€” Read only the columns you need


Why SochDB exists​

Most "agent stacks" still glue together:

  • a KV store (sessions / state)
  • a vector DB (retrieval)
  • a prompt packer (context budgeting, truncation)
  • a relational DB (metadata)

…and then spend weeks maintaining brittle context assembly and token budgeting.

SochDB collapses that stack into one LLM‑native substrate: you store structured data + embeddings + history and ask the DB to produce a token‑efficient context payload.


What you can rely on today​

βœ… LLM + agent primitives​

  • TOON: compact, model-friendly output for context windows
  • Graph Overlay: lightweight agent-memory graph with BFS/DFS traversal and relationship tracking
  • ContextQuery builder: token budgets, deduplication, and multi-source fusion
  • Policy hooks: safety controls with pre-built policy templates and audit trails
  • Tool routing: multi-agent coordination with dynamic discovery and load balancing
  • Hybrid retrieval: vector + BM25 keyword (+ a grep lane) with Reciprocal Rank Fusion (RRF)
  • Multi-vector documents: chunk-level aggregation (max / mean / first)
  • Vector search (HNSW): integrated into retrieval workflows
Where these live by language

The context builder, policy hooks, tool routing, and graph overlay are real importable modules in the Rust and Node.js SDKs. In the Python SDK they are example patterns (shipped in sochdb-python-examples, not importable SDK classes) β€” Python's first-class agent surface is the AgentMemory API. See Agent Memory and the per-language SDK guides.

βœ… Database fundamentals​

  • SQL: SELECT / INSERT / UPDATE / DELETE plus DDL (CREATE/DROP TABLE, CREATE/DROP INDEX, ALTER TABLE)
    • Joins: INNER, LEFT, RIGHT, FULL, and CROSS
    • Aggregates & GROUP BY: COUNT, SUM, AVG, MIN, MAX (plus MEDIAN and STDDEV via the SQL aggregate path), with HAVING
    • EXPLAIN: textual query-plan output via the Volcano executor
    • VECTOR_SEARCH(...): vector similarity directly in SQL
    • AST-based query executor: unified Volcano operator engine with dialect normalization
    • Multi-dialect compatibility: MySQL, PostgreSQL, SQLite
    • Idempotent DDL: CREATE TABLE IF NOT EXISTS, DROP TABLE IF EXISTS
  • ACID transactions with MVCC
  • WAL durability + group commit
  • Serializable Snapshot Isolation (SSI)
  • Columnar storage with projection pushdown (read only the columns you need)
  • Sync-first architecture: async runtime (tokio) is optional
    • ~500KB smaller binaries for embedded use cases
    • Follows SQLite-style design for maximum compatibility

βœ… Server (v2.0)​

Run SochDB as a service with the sochdb-grpc-server binary and connect over multiple protocols.

  • Authentication & RBAC: API keys (SHA-256, or HMAC-SHA256 with a pepper), JWT validation (HS256, validation-only), TLS/mTLS, and Owner / Editor / Viewer roles with per-namespace scoping
  • CDC & subscriptions: WAL-derived change-data-capture stream with gRPC Subscribe / WatchKey and table/operation filtering
  • Observability: Prometheus metrics endpoint (/metrics) and a health endpoint
  • WebSocket gateway: JSON protocol for SQL, KV, and subscribe messages
  • Postgres wire protocol: connect with psql and standard Postgres drivers (simple-query mode)
  • At-rest encryption: AES-256-GCM-SIV engine for data blocks, WAL, and checkpoints (library API)
  • Agent memory: episodic write/search with bi-temporal point-in-time queries and token-budgeted context

Upgrading from v0.4.x? See the v2.0 migration guide.

βœ… Developer experience​

  • Rust client: sochdb
  • Python & Nodejs & Golang SDK with:
    • Embedded mode (FFI) for lowest latency
    • IPC mode (Unix sockets) for multi-process / service deployments
    • Namespace isolation for multi-tenant apps
    • Typed error taxonomy with remediation hints
  • Bulk vector operations for high-throughput ingestion

Known limits​

  • Single-node today (no built-in replication or clustering). A server node can fan out to clients over gRPC, WebSocket, and Postgres wire, and the CDC subscription stream is the building block for downstream replication, but the engine itself does not yet replicate or shard across nodes.
At-rest encryption is library-only

The AES-256-GCM-SIV encryption engine is a shipped, unit-tested library API, but it is not yet wired to a server CLI flag β€” sochdb-grpc-server does not construct an encryption engine on its main path. Treat it as an available API / planned wiring, not a runtime toggle. See Encryption.

Postgres wire is unauthenticated by default

The Postgres-wire endpoint supports simple-query only, has no auth (trust), and is cleartext (no TLS). Keep it loopback-only unless you accept the risk, and pass --pg-data-dir to back it with real persistent SQL. See Postgres Wire.


SochDB in one picture​

ProblemTypical approachSochDB approach
Token wasteJSON/SQL payload bloatTOON: dense, table-like output
RAG plumbingExternal vector DB + glueBuilt-in HNSW + quantization
Context assemblymultiple reads + custom packerOne context query with a budget
I/O amplificationrow store reads all columnscolumnar + projection pushdown

Quick Install​

cargo add sochdb
use sochdb::Database;

fn main() -> anyhow::Result<()> {
let db = Database::open("./my_app_db")?;

db.put(b"users/alice", br#"{"name": "Alice", "role": "admin"}"#)?;

if let Some(user) = db.get(b"users/alice")? {
println!("{}", String::from_utf8_lossy(&user));
}

Ok(())
}

β†’ Full Quick Start Guide


Documentation Sections​

πŸš€ Getting Started​

Step-by-step guides to get you up and running quickly.

πŸ“– Guides​

Task-oriented guides for specific use cases.

Language SDKs:

  • Rust SDK β€” Native Rust guide (crate sochdb v2.0.3)
  • Python SDK β€” Complete Python guide (v0.5.9)
  • Node.js SDK β€” TypeScript/JavaScript guide (v0.5.3)
  • Go SDK β€” Go client guide (v0.4.5)

Features:

AI Agent Safety & Memory:

Server & Operations:

πŸ’‘ Concepts​

Deep dives into SochDB's architecture and design.

πŸ“‹ API Reference​

Complete technical specifications.

πŸ› οΈ Server Reference​

Deep technical documentation for SochDB servers and tools.

🍳 Cookbook​

Recipes for common tasks.


I want to...Go to...
Get started in 5 minutesQuick Start
Use Namespace & CollectionsPython SDK
Use Priority QueuesPython SDK
Use Memory SystemNode.js SDK
Use SQL queriesSQL Guide
Use the Rust SDKRust Guide
Use the Python SDKPython Guide
Use the Node.js SDKNode.js Guide
Use the Go SDKGo Guide
Add vector searchVector Search
Integrate with Claude (MCP)MCP Integration
Enforce agent safety policiesPolicy Hooks
Route tools across agentsTool Routing
Model agent memory relationshipsGraph Overlay
Build token-aware contextContext Query
Use agent memoryAgent Memory
Secure the server (auth/RBAC)Security
Stream changes (CDC)CDC & Subscriptions
Scrape Prometheus metricsObservability
Connect with psqlPostgres Wire
Upgrade from v0.4.xMigration to v2.0
Use the Node.js APINode.js API
Use the Go APIGo API
Understand the architectureArchitecture
See the SQL API referenceSQL API