reverie
Memory consolidation daemon for LLM coding harnesses. Five-layer hierarchy + offline dream cycles, modeled on biological sleep.
The problem
LLM harnesses dump every observation into a single flat store. Over time you get duplicate entries saying the same thing three different ways, directives buried under irrelevant logs, decisions that contradict other decisions nobody noticed, and stale facts crowding out fresh ones. Retrieval quality collapses, and you burn tokens rehashing what's already known.
The root cause isn't the database — it's the absence of a placement theory. Memory types have different lifetimes, different access patterns, and different consolidation rules. A single flat bucket pretends they don't.
Five-layer hierarchy
Reverie maps LLM knowledge onto five tiers, each with its own retention and access policy:
- L1 · Episodic — raw session transcripts, tool calls, scratch. High volume, short half-life.
- L2 · Consolidated — de-duplicated observations from L1, promoted by repetition and novelty.
- L3 · Semantic — stable concepts and entities, accessed across many sessions.
- L4 · Directive — rules of engagement: `CLAUDE.md`, feedback memories, preferences.
- L5 · Reference — pointers to external systems (Linear, Obsidian, docs), not the content itself.
Dream cycles
Offline, on a schedule, reverie runs the same six-phase pipeline a sleeping brain runs: scan → classify → place → consolidate → prune → sync. Near-duplicates merge, stale entries downscale, high-signal observations promote between layers, and the whole state syncs to external mirrors (Obsidian vault, auto-memory files).
Scoring draws from Ebbinghaus stability, SM-2 spaced repetition, and hippocampal sparse-coding — neuroscience primitives with 40 years of empirical support, not ad-hoc heuristics.
Hybrid search
Retrieval blends SQLite FTS5 keyword matching with sqlite-vec semantic embeddings (fastembed on BGE-large, 1024d). Results fuse via Reciprocal Rank Fusion and get reweighted by layer depth, session-spread, time-decay, and Ebbinghaus stability.
Current LoCoMo baseline: R@5=77.0%, MRR=0.628. Moving targets — the benchmark is committed to the repo so regressions get caught.
Quick start
git clone https://github.com/cerebral-work/reverie
cd reverie
make release && make install-all
reveried serve &
meshctl init See docs/daemon-spec.md for the architecture deep-dive.