# Memory Contract

Claude Code's native auto memory is the ONE writer. One writer, one index
convention, three layers — and this whole contract fits on a page on purpose.
(Simplification Project 1, `.claude/plans/simplification-1-memory-retrieval.md`,
decisions (a), (b), (g); replaces `memory-lifecycle-contract.md`, 2026-09-29.)

## The three layers

1. **Front of mind — `MEMORY.md`** in the project's memory dir
   (`~/.claude/projects/<slug>/memory/`; a worktree shares its main project's).
   The platform loads it at every session start (first 200 lines / 25KB).
   It holds **standing facts only**: preferences, identity, hard constraints,
   what is currently true. Small on purpose.
2. **Recalled on cue** — everything else. Lessons, decisions and past
   solutions: topic files in the memory dir with **no index line**. Session
   records, archived extraction drafts and retained transcripts: watchtower
   runtime state (`~/.claude-cabinet/watchtower/state/…`), outside the memory
   folder so the platform's consolidation never reads them as memory. All
   reached by `/recall <question>` at the moment of need — one cited
   paragraph, never a hit list. A file with no index line is not an orphan;
   it is the corpus. The retriever is `watchtower-recall.mjs`: one FTS5
   index per project (`state/recall/<slug>.sqlite`), refreshed on every
   search and on Ring 1's tick; each search logs one line to
   `state/recall-log.jsonl` — how the instrument counts recall.
3. **Live now** — active threads and the last session, carried by the
   session-start injection. Untouched by this contract.

## What goes in MEMORY.md

One line per standing fact, pointing at its file. The operator's pinned block
is the worked example — every line is something that is true *now* and that a
session must not have to rediscover:

    - [Claude merges worktree branches into main — the user never merges](feedback_claude_merges_into_main.md) — User correction 2026-06-06
    - [Installed pib-db files are engagement-patched — never refresh them from templates/](constraint_pib_files_engagement_patched_never_cp_from_templates.md)

## What does not

- Lessons, decisions, session summaries, dated observations → a topic file
  with no index line. `/recall` finds it when it is needed.
- A **region pointer** (`- region \`lesson_*.md\` → …`) — never write one.
  The convention is retired; the platform cannot read it, and the audit
  measured the tier it pointed at as read ~0.25% per file per month.
- A trimming pass, a cap of our own, an archive index (`MEMORY-archive.md`).
  The platform enforces its own cap and reminds the session when the index
  is over it; no CC machinery reacts.

## Retiring a stale standing fact

The session that notices edits it — rewrite the line and the file, or delete
both when the fact simply stopped being true. Nothing ages entries out on a
schedule; a wrong standing fact is fixed at the moment it is caught.

## The platform's own consolidation ("auto-dream")

Claude Code runs a background consolidation over the memory folder it
manages: after enough sessions it reads recent transcripts, merges new facts
into MEMORY.md and the topic files, resolves contradictions, absolutizes
dates, drops pointers to missing files and rebuilds the index under the cap.
`/dream` runs it by hand. **Leave it on** — it is the after-the-fact net,
provided by the platform; the installer never writes `autoDreamEnabled`. Its
writes are observable (a `modified:` stamp with no session write), and the
retrieval instrument reports them beside the sessions' own — with index files
read, `/recall` invocations and hit rate, per project per rolling 30 days.
Whether memory is *reached* is a number, not a hope.
