Synapse - Brain RAG & Agent Memory
Semantic retrieval and memory over a company knowledge corpus — local embeddings, pgvector, and a retrieval eval harness built to catch its own regressions.
Overview
Synapse is the knowledge layer: it turns a corpus of decisions, project docs, and business notes spread across nineteen repositories into something an agent can actually query. Documents are chunked, embedded locally through Ollama's mxbai-embed-large — no corpus text leaves the machine — and stored in Postgres with pgvector. Retrieval runs over that index and answers through a document-QA workflow on an event-driven FastAPI and Celery pipeline. The part worth arguing about is the measurement. Retrieval systems degrade quietly: a change improves one query class and silently breaks another, and without a harness you find out months later. Synapse carries a golden set, a tracked eval run history, and a corpus fingerprint guard that refuses to compare two runs taken against different corpora — an incomparable verdict instead of a misleading improvement. Query-log mining reads the real query log and classifies gaps into abstained, low-confidence-answered, and suspected-confidently-wrong, which is how new golden cases get proposed from live traffic rather than from imagination. The memory layer models peers, episodes, and facts, with extraction at ingest time, consolidation on a schedule, confidence decay, and explicit contradiction resolution — so a fact that was true last quarter is superseded rather than silently overwritten. One deliberate boundary: Synapse owns the semantic half of the Brain. The structural half — graph queries over the wikilink structure between documents — lives in the Rust Console instead. Semantic similarity and structural adjacency answer different questions, and collapsing them into one index makes both worse.
Technical Stack
Retrieval
- ▸pgvector
- ▸PostgreSQL
- ▸Ollama (mxbai-embed-large)
- ▸Chunking + embedding pipeline
Memory
- ▸Peers / episodes / facts
- ▸Ingest-time extraction
- ▸Scheduled consolidation
- ▸Confidence decay
- ▸Contradiction resolution
Evaluation
- ▸Golden set
- ▸Tracked eval runs
- ▸Corpus fingerprint guard
- ▸Query-log mining
Platform
- ▸Python
- ▸FastAPI
- ▸Celery
- ▸Redis
- ▸Alembic
- ▸pytest
Key Features
Local embeddings via Ollama — the corpus is indexed without any document text leaving the machine
Semantic retrieval over a corpus spanning nineteen repositories, answered through a document-QA workflow
Golden-set retrieval eval with tracked run history, so a change's effect on quality is measured rather than assumed
Corpus fingerprint guard returns an incomparable verdict rather than a misleading delta when two runs span different corpora
Query-log mining classifies live gaps into abstained, low-confidence-answered, and suspected-confidently-wrong
Memory layer models peers, episodes and facts with confidence decay and explicit supersession
Event-driven FastAPI and Celery pipeline underneath, with reversible Alembic migrations
Deliberately owns only the semantic half of the Brain — structural graph queries live in the Rust Console
Code Examples
Technical Challenges
Measuring retrieval honestly — a golden set that grows to fit the system's current behaviour stops being a test
Detecting when two eval runs are simply not comparable, instead of reporting a delta that means nothing
Modelling supersession so an outdated fact is visibly replaced rather than silently overwritten
Drawing the semantic/structural boundary: similarity and adjacency answer different questions and one index serves both badly