Knowledge Base
Dream
Memory consolidation protocol — the maintenance pass that keeps the KB compact and retrievable.
Last dream: 2026-08-10
DREAM.md — memory consolidation
"Dreaming" is the maintenance pass that keeps the KB compact and retrievable —
the agent equivalent of sleep consolidating the day's memories. Run it manually,
on a /loop, or whenever the KB feels noisy (duplicates, sprawl, stale facts).
When to dream
- The index
MEMORY.mdhas grown large or has near-duplicate lines. - Several notes restate the same fact, or one note has grown into many facts.
- A note contradicts newer knowledge, or its
updated:/timestampis old and may be stale. - A note is orphaned (no
[[links]]), or links/tags have sprawled. - Links
[[slug]]point at notes that don't exist (or should). - New unprocessed files sit in
raw/. - On a schedule, e.g.
/loop 1d "run ~/kb/DREAM.md consolidation".
The pass
- Load. Read
MEMORY.md, everymemory/**/*.md(recursive — excluding reservedindex.md,log.md, and_TEMPLATE.md),raw/inbox/*.md, theraw/source docs, and.agent/state.json. - Ingest & rewrite. Read
raw/inbox/*(daily captures) and anyraw/source doc not instate.json.processed. Promote durable, general, public facts intomemory/— create new notes or rewrite/merge existing ones to absorb them (perAGENTS.md§2 + the standard). Then clean up:- inbox files: once distilled, delete them (they're ephemeral).
- source docs: keep them (immutable ground truth); record in
processed.
- Dedupe & merge. Fold duplicate/overlapping notes into one. Keep the clearest, most recent phrasing. Lossless of meaning, not of words.
- Split. If a note holds multiple facts, split into atomic notes.
- Validate frontmatter. Every note has top-level
name(== filename stem),description,type,tags,created,updated,timestamp(ISO 8601). Fix the<type>-filename prefix iftypechanged. No nestedmetadata:blocks. - Refresh from sources. For notes with a
sources:URL whosetimestamp/updated:is stale (>~30 days) or whose facts look outdated, fetch the source (preferllms.txt), update the note, and bumpupdated:andtimestamp. - Compact. Trim notes to the essential facts. Drop filler. Aim ≤~25 lines.
- Relink & retag. Fix
[[slug]]references; ensure no orphans (every note links ≥1 other); merge tag sprawl into the controlled vocabulary; drop links to deleted notes. - Prune. Delete notes that are wrong, obsolete, or now-private — and their index lines.
- Rebuild index. Regenerate
MEMORY.mdfrom surviving notes — grouped bytype, one line each:[Title](file) — hook. Then runkb gento regenerate everymemory/**/index.md(OKF listings) +viz.html(graph viewer) so they stay in sync with the nested layout. Append a new dated entry tomemory/log.mdsummarizing the pass (what merged/split/pruned). - Verify scope. Confirm no secrets/hosts/confidential facts slipped in
(
AGENTS.md§3). Remove any that did. - Stamp & sync. Set
state.json.last_dreamto today, then~/kb/scripts/sync.sh.
Principles
- Lossless of meaning. Compaction removes words and redundancy, never facts.
- Atomic. One fact per file after the pass.
- Retrieval-first. Every
descriptionmust let an agent judge relevance from the index alone; every note is reachable via tags and[[links]]. - Conservative deletes. Only prune what is wrong, redundant, or out-of-scope — never delete a fact just because it's old (refresh it instead, step 6).
- Idempotent. Running the pass twice in a row should change nothing the second time.