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

Five-layer memory hierarchy VOLUME HIGH LOW HALF-LIFE LONG SHORT L5 · Reference pointers to Linear, Obsidian, external docs L4 · Directive CLAUDE.md · feedback memories · preferences L3 · Semantic stable concepts + entities · cross-session L2 · Consolidated deduplicated observations · promoted by signal L1 · Episodic raw transcripts · tool calls · scratch
Five-layer memory hierarchy — widest tier = highest volume + shortest half-life. Arrows show promotion during dream cycles.

Reverie maps LLM knowledge onto five tiers, each with its own retention and access policy:

Dream cycles

Six-phase dream cycle dream cycle min interval 30m scan collect candidates classify assign type + kind place promote / demote consolidate merge near-dups prune drop low-signal sync mirror to external
Six-phase dream cycle, clockwise from scan. Runs offline with a 30-minute minimum interval and single-flight guard.

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.