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.

Current release

contextdb is currently v0.123.0: usable for serious demos and early integrations, but intentionally pre-1.0 while the public API, deployment modes, and SDK contracts continue to settle.

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
AI verification and rankingEnd-to-end guide for acquisition dry-runs, provider connectors, retries, receipts, reranking, explain-rank, and dashboard debugging
Score breakdownWeighted similarity, confidence, recency, and utility contributions per result
Explain-rankCompare two nodes and inspect factor deltas that explain the ranking difference
GraphQL APIGraph-shaped search, filters, edges, sources, feedback mutations, narratives, and gaps
Label filteringFilter retrieval by node labels
Feedback APIsValidate, refute, mark useful, and mark stale across SDK, REST, gRPC, and GraphQL
Claim review queueRanked operator tasks with durable workflow decisions and escalation metadata
Background workersMemory consolidation and active recall
RBACToken-based read/write/admin permissions per tenant
Snapshot/restoreNDJSON namespace export and import
Backup runbookScheduled export, artifact manifest verification, restore rehearsal, promotion receipts, receipt verification, lifecycle summary verification, retention reporting, delete-plan output, manifest indexes, verification, diffs, and metadata publish, backup marker, doctor, and Norn check flow
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 UIRanking evaluation, metrics, source-trust timelines, and belief debugger on observe port
Mini/Norn deploymentInternal live deployment discovery, drift checks, dry-run publish plans, and health checks via Norn

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
Knowledge acquisition plannerPrioritized research, crawl, verification, and refresh tasks from gaps and weak claims, with dry-run-first connector execution and provider adapters
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.