WebPage : https://alekhdb.lovable.app/
The Light-Speed, Local-First Cognitive Memory Engine, structured Action Replay Tracer, and Model Context Protocol (MCP) Server for Autonomous AI Agents.
AlekhDB (meaning "graph, record, drawing" in Sanskrit) is a high-performance, lightweight GraphRAG Database & Cognitive Memory Engine built specifically for developers orchestrating autonomous AI agents.
Traditional vector databases store flat, append-only embeddings lists. They suffer from Context Rot, lack Relational Topology, and have Zero Cognitive Capabilities to handle logical contradictions. AlekhDB engineers a biological, self-editing AI memory layer equipped with exponential Ebbinghaus attention curves, Doyle-style truth maintenance systems (TMS), AST-aware codebase mapping, chronological action tracing, and a zero-dependency virtual POSIX filesystem mount.
- π₯ Ingest & Extract: Ingest raw text or codebase structures. AlekhDB parses them into a high-speed local knowledge graph of entities and semantic relationships in under
1 ms. - π§ Audit & Align: A Doyle-style Truth Maintenance System (TMS) instantly monitors incoming facts against active beliefs, soft-decaying conflicting historical edges (down to weight
0.15) instead of destroying them to preserve chronological context. - π Decay & Search: Exponential Ebbinghaus relevance curves archive low-strength faded nodes to keep active token windows hyper-dense, while Spaced Repetition instantly resurrects them during GraphRAG queries.
When compared to standard vector stores or simple flat-file memory buffers, AlekhDB represents a massive leap in cognitive retrieval and agentic utility:
| Feature / Capability | Chroma | Pinecone | Mem0 | β‘ AlekhDB |
|---|---|---|---|---|
| Attention Curves | β No | β No | β No | π’ Yes (Ebbinghaus Decay) |
| Contradiction Detection | β No | β No | β No | π’ Yes (Doyle TMS) |
| MCP Server for Claude/Cursor | β No | β No | β No | π’ Yes (Cursor/Claude Native) |
| POSIX Filesystem Mount | β No | β No | β No | π’ Yes (Shell Simulator) |
| AST-Aware Code Memory | β No | β No | β No | π’ Yes (Class/Method Parser) |
| Sub-Millisecond Query Latency | π’ Fast (<0.50ms core loop) | |||
| Zero Compile Setup | β Heavy | β Cloud | π’ Yes (Zero compile/dependencies) |
AlekhDB categorizes knowledge into six distinct memory tiers, mimicking human cognitive storage and computational requirements:
- π Semantic Memory (Ontological Graph): Entities (Nodes) connected by Weighted Relationships (Edges). Subject to Ebbinghaus decay and spaced repetition boost.
- π¬ Episodic Memory (Execution Traces): Chronological trace frames housing ordered event steps (tools, inputs, results, errors). Compacts into Semantic Memory upon completion.
- β‘ Working Memory (Active Context): A filtered subset of nodes/edges that fits inside the current query to minimize token load.
- ποΈ Subconscious Memory (Decayed / Archived): Nodes with
cognitiveStrength < 0.15that reside out of active context search but are instantly revived via Spaced Repetition if queried. - π» Procedural Code Memory (AST Graph): Hierarchies of
File,Class, andFunctionnodes mapped natively. Permanently locked (exempt from Ebbinghaus decay). - π Virtual Memory (POSIX Mount): Graph states mapped into virtual file folders (e.g.
/memory/profile.md). Readable via standard CLI bash tools.
-
Ebbinghaus Relevance Decay: Memory relevance recedes exponentially over time (
$S_t = S_0 e^{-\lambda \Delta t}$ ) to prevent active context rot. Faded nodes automatically archive if strength drops below0.15. -
Spaced Repetition Reinforcement: Accessing, querying, or searching a node boosts its cognitive strength by
$+0.35$ (capped at2.0) and resets its decay timer. -
Doyle-Style Truth Maintenance System (TMS): Automatically audits incoming facts against the active graph to calculate a Cognitive Dissonance Score. If a contradiction is detected (e.g., stack migrations), conflicting historical edges are soft-decayed (reduced to weight
0.15) rather than deleted, maintaining chronological timeline context. - Context-Change-1 Self-Editing: Prompts active LLMs to evaluate redundancies and prune context chunks dynamically on ingestion to weed out "context rot".
-
POSIX Mounted Directory: Projects memory states into a virtual local filesystem mount. AI agents can explore memories using standard
lsandcatcommands inside their terminal.
AlekhDB core is designed to be completely lightweight, zero-dependency, and incredibly fast. The following benchmark scores are verified locally on a standard Node.js zsh shell:
| Operations | Latency | Target Limit | Status |
|---|---|---|---|
| 10K Async ID Collision | 6.14 ms | < 50 ms | 0% Collisions β |
| Graph Seeding | 0.54 ms | < 10 ms | Lightweight Core β |
| Fact Ingestion & TMS | 0.54 ms | < 300 ms | Sub-millisecond β |
| Deep GraphRAG Search | 0.45 ms | < 100 ms | Sub-millisecond β |
| AST Codebase Parsing | 0.88 ms | < 150 ms | Flawless ESM Scanner β |
π The 5-Second Instant Quickstart (Copy & Paste):
git clone https://github.com/trident/alekhdb.git && cd alekhdb && npm install && npm run doctor && npm test
Preload codebase components, B2B sales pipelines, and legal mock nodes:
node cli.js seedAdjust the active context window token capacity limit dynamically in zsh (supporting limits from 8,000 to 1,000,000 tokens):
# View active context capacity limits
node cli.js capacity
# Resize context capacity limit to 1,000,000 tokens
node cli.js capacity 1000000# Add a fact (automatically registers contradiction TMS audits)
node cli.js add "Trident switched backend preferences to Bun.sh runtime"
# Search memory using GraphRAG
node cli.js grep "Bun runtime"AI Agents (such as Claude Code, Claude Desktop, and Cursor) can connect natively to AlekhDB using the Model Context Protocol (MCP) JSON-RPC server. This allows agents to seamlessly search, add, and query their cognitive memory layers directly during code generation passes.
Add this to your Claude Desktop configuration file (typically at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"alekhdb": {
"command": "node",
"args": ["/absolute/path/to/alekhdb/mcp_server.js"],
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}Once mounted, the agent automatically acquires three core cognitive memory tools:
- π’
alekhdb_add: Ingest a new text statement or website scraper memory into the database. - π’
alekhdb_search: Query graph memory via hybrid vector GraphRAG sweeps + 2-degree neighborhood traversals. - π’
alekhdb_profile: Instantly retrieve live-synthesized Markdown developer profile outlining stable preferences.
Start the API Gateway server:
npm run apiThis launches a high-performance Express REST gateway on http://localhost:3000. AI agents and external scripts can communicate with AlekhDB using these standardized endpoints:
- Ingest Fact Node (
POST /api/ingest):{ "text": "Trident migrated project stack to Bun.sh", "scope": "work" } - Hybrid GraphRAG Search (
POST /api/search):{ "query": "What backend runtime does Trident use?", "scope": "all" } - Developer Profile Synthesis (
GET /api/profile): Returns live-synthesized developer profile Markdown.
AlekhDB is open-source software licensed under the MIT License.
