The Memory System, Mapped

Local-first and plain text: seven storage surfaces, one retrieval gate, and one contract, drawn as a single picture.

Companion to the essay Your AI Forgets Everything. Here Is the Plain-Text Fix I Built.

The essay explains why I built my agents a memory and how I decided whether it earns its keep. This is the same system seen from above: every surface it stores to, the one gate it reads through, and the contract that keeps three agents from overwriting each other. Everything here is plain markdown on my own machines. Nothing runs on a paid memory service, and none of it is hard to rebuild. Read the diagram first, then use the sections below as the reference.

7
storage surfaces
1
retrieval gate, 4 tiers
1
governance contract
0
paid memory services

The mental model

one session in one picture: read down through the gate, write back up through the contract
AGENTS Claude Code · Codex · Hermes · subagents ALWAYS LOADED  ·  SURFACES 1-2 Startup surface + Index RETRIEVAL GATE  ·  cheapest tier first Tier 0 free Tier 1 known file Tier 2 search Tier 3 full read MEMORY POOL  ·  SURFACES 3-6  ·  where the gate reaches Durable memories semantic · one fact/file · typed Conversation summaries episodic · session checkpoints Project handoffs resume state · per project Shared long-term ShadowMind · single source of truth CONTRACT governs every write Human directs · curates · reads SURFACE 7 Human wiki Obsidian · you read this adjacent, not in the agent loop SUBSTRATE plain markdown  +  SQLite FTS5 index  ·  local-first, no paid service  ·  SeaDrive across 3 machines 1 · read first 2 · need a fact reach in 3 · write back summaries · handoffs · working-memory curate in read out promote selectively direct ⇅ report stored on

Every session runs the same loop. An agent reads down: the startup surface and index are already loaded, and the gate reaches deeper only when it has to. When the work is done, it writes back up: summaries, handoffs, and an updated startup surface, every write passing through the contract. The human sits to the side, curating what graduates into the wiki and reading it back, never inside the agent loop.

Teal traces the read path, cheapest tier first.   Gold traces the write-back, committed through the contract.   Dashed is the human side: you curate and you read.   The numbers on each box match the surface cards below.

Who reads & writes

the agents that live on top of the memory

Claude Code

Primary builder, architect, and reviewer. Owns ~/.claude/.

Codex

The second coding agent, working its own lane of projects. Owns ~/.codex/memories/.

Hermes

A conversational second brain on call over Telegram, with its own native memory.

Subagents

Scoped, single-task agents dispatched on demand and retired when the task is done.

The seven storage surfaces

all plain markdown, grouped by the job each one does
Orientation
read first

1. Startup surface

working-memory.md

What is active right now: hot, warm, and archive, each with its exact next action. A whiteboard, kept brutally short so the agent orients in seconds.

router

2. Index

MEMORY.md

One line per durable note, loaded every session. It is a router: the agent does not need to hold a fact, only to know which file holds it.

Knowledge
semantic

3. Durable memories

memory/*.md · one fact per file

Typed as preference, decision, project, or reference. Atemporal facts that stay put, each in its own file so any one is cheap to grep, prune, or delete.

episodic

4. Conversation summaries

memory/conversations/

The episodic layer: time-stamped checkpoints of what got built, verified, and broke, plus the next step. This is how I reconstruct a decision six weeks later.

Project
resume state

5. Project handoffs

per-project dirs · *HANDOFF* / .codex-save.md

Resume state that lives with the project, not the central store: what is done, what is blocked, what not to touch, and the exact next step.

Shared & human
source of truth

6. Shared long-term store

ShadowMind Memory/

Cross-agent decisions and the contract itself, readable by every agent. The constitution, not the daily news.

you read this

7. Human wiki

Obsidian · PJ Vault on SeaDrive

Curated and selective, for me rather than the agent. Kept separate from agent memory on purpose, so neither turns into a swamp.

The retrieval gate

a lens over all seven surfaces, not an eighth layer

Most memory guides say search before you answer. Searching often costs more than reading the file would have, so retrieval runs through a gate instead. It reaches for the cheapest tier that answers the question and stops there.

Tier 0free
Answer from context already loaded. The startup surface and index are in context from the first message. If the answer is there, you are done at zero extra cost.
Tier 1cheap
Read the one known file. When the index says where a fact lives, open only that file. No search.
Tier 2medium
Search, then follow. Only when the location is unknown: run full-text search over the local index (SQLite FTS5), then open the source it points to.
Tier 3last
Full file read. Read a whole file end to end, and only after Tier 2 pointed you at it.

The governance contract

five rules that keep shared memory from becoming a merge conflict with feelings
  • Ownership lanes. Each agent owns one directory and stays in it.
  • Read across, write your own. Any agent may read another's memory. None edits it unless I say so.
  • Sign shared writes. Edits to shared files are tagged with who made them, so authorship is always clear.
  • Single source of truth. One store, ShadowMind, holds the long-term cross-agent decisions.
  • Secrets by name only. Never written down, only referred to by their environment-variable name.

The substrate

what all seven surfaces sit on
Plain markdown + a small SQLite FTS5 search index
Local-first · no paid memory service
Synced across three machines (SeaDrive)
Git-friendly · diffable, portable, readable in twenty years