Skip to content

ccheney/engram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚧 Under Construction: This project is actively being developed. APIs, schemas, and features may change without notice.

Engram

A bitemporal, graph-backed memory system for AI coding agents.

Engram captures, persists, and visualizes the complete reasoning trace of AI coding assistants like Claude Code, Codex CLI, and others. Every thought, tool call, file edit, and decision is preserved in a knowledge graph with full temporal historyβ€”enabling replay, search, and deep analysis of how AI agents solve problems.

engram_preview.webm

The Vision

When you use an AI coding assistant, valuable context disappears the moment your session ends. Engram changes that.

What if you could:

  • Watch an AI's reasoning unfold in real-time as it works
  • Search across all your past AI sessions semantically
  • Time-travel to any point in a session and see the exact file state
  • Understand why an AI made a particular decision by tracing its thought process
  • Build institutional knowledge from how AI agents solve problems in your codebase

Engram makes this possible by treating AI agent sessions as first-class dataβ€”streaming events through a processing pipeline, persisting them to a graph database, and exposing them through a beautiful real-time interface called the Neural Observatory.


Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              CLI AGENTS                                      β”‚
β”‚         Claude Code  β€’  Codex CLI  β€’  Grok  β€’  Cline  β€’  OpenCode           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚ HTTP POST /api/ingest
                                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         INGESTION SERVICE                                    β”‚
β”‚  β€’ Provider-specific parsing (8 formats)                                    β”‚
β”‚  β€’ Thinking block extraction (<thinking>...</thinking>)                     β”‚
β”‚  β€’ Diff extraction (search/replace blocks)                                  β”‚
β”‚  β€’ PII redaction (emails, API keys, SSN, credit cards)                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚ Kafka: parsed_events
                                   β–Ό
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚                         β”‚                         β”‚
         β–Ό                         β–Ό                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  MEMORY SERVICE β”‚    β”‚   CONTROL SERVICE   β”‚    β”‚  SEARCH SERVICE β”‚
β”‚                 β”‚    β”‚                     β”‚    β”‚                 β”‚
β”‚ β€’ FalkorDB graphβ”‚    β”‚ β€’ Session mgmt      β”‚    β”‚ β€’ Qdrant vectorsβ”‚
β”‚ β€’ Turn aggregationβ”‚  β”‚ β€’ Context assembly  β”‚    β”‚ β€’ Hybrid search β”‚
β”‚ β€’ Redis pub/sub β”‚    β”‚ β€’ MCP orchestration β”‚    β”‚ β€’ Reranking     β”‚
β”‚ β€’ Bitemporal    β”‚    β”‚ β€’ Decision engine   β”‚    β”‚ β€’ 4 model tiers β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                                                  β”‚
         β”‚ Redis pub/sub                                    β”‚
         β–Ό                                                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        NEURAL OBSERVATORY                                    β”‚
β”‚                     (Next.js + WebSocket Streaming)                          β”‚
β”‚                                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Session     β”‚  β”‚ Knowledge Graph     β”‚  β”‚ Thought Stream             β”‚  β”‚
β”‚  β”‚ Browser     β”‚  β”‚ (Force-directed)    β”‚  β”‚ (Timeline + Replay)        β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Features

Real-Time Event Streaming

Events flow through the system in real-time via Kafka (Redpanda) and Redis pub/sub. The Neural Observatory connects via WebSocket and displays updates as they happenβ€”no polling, no refresh needed.

Agent types β†’ Ingestion β†’ Kafka β†’ Memory β†’ Redis β†’ WebSocket β†’ Browser

Hybrid Search with Reranking

Search isn't just keyword matching. Engram uses a sophisticated multi-stage retrieval pipeline:

  1. Dense vectors (e5-small) for semantic similarity
  2. Sparse vectors (BM25/SPLADE) for keyword matching
  3. RRF fusion combines both strategies
  4. Cross-encoder reranking with 4 model tiers:
Tier Model Latency Use Case
fast MiniLM-L-6-v2 ~50ms Quick queries
accurate BGE-reranker-base ~150ms Complex queries
code Jina-reranker-v2 ~150ms Code-specific
llm Grok-4 (listwise) ~2s Premium tier

Bitemporal Graph Storage

Every node in Engram's knowledge graph has two time dimensions:

  • Valid Time (VT): When the event actually occurred
  • Transaction Time (TT): When we recorded it

This enables powerful temporal queries: "What did the AI think at 2pm?" or "Show me the file state before that edit."

Multi-Provider Support

Engram ingests events from multiple AI agent formats:

Provider CLI Tool Format
claude_code Claude Code stream-json
codex Codex CLI custom
anthropic Anthropic API SSE
openai OpenAI API SSE
xai Grok SSE
gemini Google Gemini JSON
cline Cline Extension custom
opencode OpenCode custom

Quick Start

Prerequisites

  • Node.js v24+
  • npm v11+
  • Docker & Docker Compose

Setup

# Clone and install
git clone https://github.com/ccheney/engram.git
cd engram
npm install

# Start infrastructure (Redpanda, FalkorDB, Qdrant)
npm run infra:up

# Start all services in dev mode
npm run dev

Verify It's Working

  1. Neural Observatory: http://localhost:5000
  2. Redpanda Console: http://localhost:8080
  3. Qdrant Dashboard: http://localhost:6333/dashboard

Simulate Traffic

# Run the traffic generator to create test sessions
npx tsx scripts/traffic-gen.ts

Project Structure

engram/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ ingestion/          # Event parsing & normalization
β”‚   β”œβ”€β”€ memory/             # Graph persistence & pub/sub
β”‚   β”œβ”€β”€ search/             # Vector search & reranking
β”‚   β”œβ”€β”€ control/            # Session orchestration
β”‚   β”œβ”€β”€ execution/          # VFS & time travel
β”‚   └── interface/          # Neural Observatory (Next.js)
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ events/             # Event schemas (Zod)
β”‚   β”œβ”€β”€ ingestion-core/     # Provider parsers & extractors
β”‚   β”œβ”€β”€ memory-core/        # Graph models & pruning
β”‚   β”œβ”€β”€ search-core/        # Embedders & rerankers
β”‚   β”œβ”€β”€ execution-core/     # Replay & rehydration
β”‚   β”œβ”€β”€ storage/            # DB clients (Kafka, Redis, FalkorDB, Qdrant)
β”‚   β”œβ”€β”€ vfs/                # Virtual file system
β”‚   └── logger/             # Pino-based structured logging
β”œβ”€β”€ scripts/
β”‚   └── traffic-gen.ts      # Traffic simulation for testing
└── docker-compose.dev.yml  # Local infrastructure

Documentation

Document Description
Tech Stack Detailed architecture, data flow, and technology choices
Neural Observatory Frontend documentation

Services

Ingestion Service (Port 5001)

Receives raw events from CLI agents, parses them using provider-specific handlers, extracts thinking blocks and diffs, redacts PII, and publishes normalized events to Kafka.

Kafka Group: ingestion-group Topics: raw_events β†’ parsed_events

Memory Service (MCP stdio)

Persists parsed events to FalkorDB graph, aggregates streaming events into Turn nodes, publishes real-time updates to Redis, and exposes graph queries via MCP tools.

Kafka Group: memory-group Topics: parsed_events β†’ memory.node_created

Search Service (Port 5002)

Indexes graph nodes into Qdrant vectors, provides hybrid dense+sparse search with RRF fusion, and applies cross-encoder reranking with configurable model tiers.

Kafka Group: search-group Topics: memory.node_created

Control Service

Manages active sessions, assembles context from history and search results, and orchestrates MCP tool calls to execution services.

Kafka Group: control-group Topics: parsed_events

Execution Service (MCP stdio)

Provides virtual file system operations, time travel to any point in session history, and deterministic replay of tool executions.

Neural Observatory (Port 5000)

Real-time web interface for visualizing agent sessions. Features session browser, interactive knowledge graph, thought stream timeline, and semantic search.

Read more β†’


Kafka Consumer Groups

Engram uses Kafka consumer groups to parallelize processing and ensure exactly-once delivery:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   raw_events    │────▢│  parsed_events  │────▢│ memory.node_    β”‚
β”‚                 β”‚     β”‚                 β”‚     β”‚    created      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
  ingestion-group         memory-group            search-group
                          control-group

Each service publishes heartbeats to Redis every 10 seconds. The Neural Observatory displays consumer health in real-timeβ€”green means all consumers are processing, amber means some are down.


Commands

Command Description
npm run dev Start all services in development mode
npm run build Build all apps and packages
npm run test Run test suites
npm run typecheck TypeScript type checking
npm run lint Biome linting
npm run format Biome formatting
npm run infra:up Start Docker infrastructure
npm run infra:down Stop Docker infrastructure

Infrastructure

Engram runs on three databases, all containerized for local development:

Service Port Purpose
Redpanda 19092 Kafka-compatible event streaming
FalkorDB 6379 Graph database (Redis-compatible) + Redis pub/sub
Qdrant 6333 Vector database for semantic search
# Start infrastructure
npm run infra:up

# View logs
docker-compose -f docker-compose.dev.yml logs -f

# Stop infrastructure
npm run infra:down

License

AGPL-3.0 license

About

A bitemporal, graph-backed memory system for AI coding agents.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages