Skip to content

contextdbThe epistemics layer for AI systems

Memory that knows what it knows, what it doesn't, and why it believes what it does.

4time dimensions
4score components
4namespace modes
4deployment modes

Five lines to a working database

Zero external dependencies. No Docker. No config files. One go get and you're running. Auto-embedding lets you skip the vector. Just send text.

go
db := client.MustOpen(client.Options{})
defer db.Close()

ns := db.Namespace("my-app", namespace.ModeGeneral)
ns.Write(ctx, client.WriteRequest{
    Content:  "Go 1.22 added routing patterns to net/http",
    SourceID: "docs-crawler",
})
results, _ := ns.Retrieve(ctx, client.RetrieveRequest{
    Text: "What changed in Go 1.22?", TopK: 5,
})
python
from contextdb import ContextDB

db = ContextDB("http://localhost:7701")
ns = db.namespace("my-app", mode="general")
ns.write(content="Go 1.22 added routing patterns", source_id="docs-crawler")
results = ns.retrieve(text="What changed in Go 1.22?", top_k=5)
typescript
import { ContextDB } from "contextdb";

const db = new ContextDB("http://localhost:7701");
const ns = db.namespace("my-app", "general");
await ns.write({ content: "Go 1.22 added routing patterns", sourceId: "docs-crawler" });
const results = await ns.retrieve({ text: "What changed in Go 1.22?", topK: 5 });
bash
# Write
curl -X POST http://localhost:7701/v1/namespaces/my-app/write \
  -H "Content-Type: application/json" \
  -d '{"content": "Go 1.22 added routing patterns", "source_id": "docs-crawler"}'

# Retrieve
curl -X POST http://localhost:7701/v1/namespaces/my-app/retrieve \
  -H "Content-Type: application/json" \
  -d '{"text": "What changed in Go 1.22?", "top_k": 5}'

Architecture at a glance

The scoring function

Every retrieval result is scored by a weighted combination of four dimensions:

score = w_sim  * cosine_similarity(candidate, query)
      + w_conf * confidence
      + w_rec  * exp(-alpha * age_hours)
      + w_util * utility_feedback

All weights are normalised at query time. You supply alpha (decay rate) and the four weights, or use namespace mode defaults.

Deployment modes

ModeBackendUse case
EmbeddedIn-memory or BadgerDBDevelopment, testing, sidecars, CLIs
StandardPostgres + pgvectorProduction single-node, teams
RemotegRPC to contextdb serverMicroservices, multi-language clients
ScaledQdrant + Redis + PostgresHigh-throughput production

Namespace modes

ModeBest forKey weight
belief_systemFact tracking, poisoning resistanceconfidence
agent_memoryAgentic workflows with task feedbackutility + recency
generalBalanced RAG, document retrievalsimilarity
proceduralSkill and workflow storageconfidence, slow decay

Key features

FeatureDescription
Auto-embeddingText automatically embedded via OpenAI, local, or custom providers with LRU cache
Conflict detectionNear-duplicate scan, contradiction tracking, contradicts edges
Credibility learningBayesian source trust updates based on validation/refutation
RerankingOptional LLM cross-encoder reranking after fusion
Label filteringFilter retrieval by node labels
Background workersMemory consolidation and active recall
RBACToken-based read/write/admin permissions per tenant
Snapshot/restoreNDJSON namespace export and import
Python SDKREST client for Python applications
TypeScript SDKREST client for TypeScript/Node.js applications
Scaled deploymentQdrant + Redis + Postgres for high throughput
BenchmarksMTEB, adversarial, LongMemEval, fitness suite
Admin UIBuilt-in dashboard on observe port

Epistemics layer

Features that make AI memory auditable and trustworthy:

FeatureDescription
Belief reconciliationStructured disagreements between agents with evidence chains
Narrative retrieval"Walk me through what you know about X and why" with full citations
Knowledge gap detection"What don't I know?" Sparse region detection with acquisition suggestions
CalibrationBrier score, ECE, Platt scaling. Confidence becomes calibrated probability
GDPR erasureAudit-trailed right-to-erasure across graph, vectors, KV, and event log
Interference detectionLow-credibility sources can't erode well-established claims
Claim federationGossip-based multi-instance replication with Beta-space credibility merge
Cascade retractionNon-destructive "I take this back" that cascades through derived claims
Active learningSystem recommends what information to acquire next
Query DSLPipe syntax and CQL with temporal, graph, and weight clauses

Built with Go. No CGO. Single binary. Scratch Docker image.

Released under the MIT License.