# Memory design

| Layer | Contents | State |
| --- | --- | --- |
| Source | Append-only evidence, with Runtime-owned authority provenance | Implemented |
| Topic | Model-written blocks linking to Source frames | Implemented |
| Derived views | Core, Timeline, Recent, Relations, built by Runtime | Implemented |
| Entity memory (proposed) | Session-Git, one repository per session and one commit per turn; Project-Git, auto-commit on agent edits. Raw, immutable, complete | Deferred |
| Abstract memory (proposed) | Timeline, Graph, `Core.md` up to 2 KB, distilled from entities in five stages with provenance. Recall injects only this layer; the model navigates back by tool | Graph view and entity recall deferred |

Memory is a Markdown workspace. The proposed layers are not the source of truth and the writer does not need them.

## Principles

| Principle | Meaning |
| --- | --- |
| Provenance-linked | Topics link to Source frames. An entity layer would add `(project, session, commit, timestamp)` |
| Bi-temporal | Each memory records `event_time` and `ingestion_time`, for time-travel queries and contradiction detection |
| Scoped recall | Runtime injects the active Core and offers memory tools over Source and Topic. Git navigation is proposed |
| Git-native | Proposed entity layer only |

## Documents

| Document | Content |
| --- | --- |
| [Overview](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/overview.html) | Current architecture, writer, authority boundary, transactions, failure behavior |
| [Written marker](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/written-marker.html) | How memory knows which turns are written: replaced cursor, eight frameworks, mark on the node, deferred event-driven design |
| [Architecture](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/architecture.html) | Write entry points and steps, staged transaction, write cursor, always-on block, provider hooks, failure contract |
| [Comparison](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/comparison.html) | Eight reference frameworks across eight dimensions |
| [Adoption](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/adoption.html) | Four moves borrowed or not: three adopted, one rejected on per-turn latency |
| [Speaker identity](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/speaker-identity.html) | Several people in one session, and the field that closes the two remaining gaps |
| [Authority landscape](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/authority-landscape.html) | Owner and paired authority, framework evidence, decisions, execution order |
| [Authority handoff](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/authority-handoff.html) | Settled authority and writer rules, deferred boundaries |
| [Entity memory on Git](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/entity-memory-proposal.html) | Proposed lifecycle, replay, consistency, project integration |
| [Virtual memory](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/virtual-memory.html) | Timeline, Graph, Core, by type and lifecycle |
| [Reading, editing and history](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/editor.html) | The memory editor |
| [Settings UI proposal](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/settings-ui.html) | Memory settings |

## Implementation status

| Area | State |
| --- | --- |
| Authority provenance | SessionDB writer and `memory_update` build it from persisted turn authority, never from a payload. A Source without it fails closed |
| Automatic writer | Reads SessionDB branches, records handling on source nodes, uses the default chat provider and model unless `memory.writer.model` is set, installs through a staged transaction |
| Surfaces | Memory tools, CLI, Web UI, writer status, one-shot trusted-Source backfill, `memory.backend=none` guards, a composed test from SessionDB to watcher state |
| Citations | A new Topic reference must resolve to a `trusted` Source frame in the transaction's own evidence, so no tool path cites a `pending` Source |
| Failures | One closed `MemoryWriteFailureCode` taxonomy across status file, CLI, tool, API, Web UI. The idle watcher persists each outcome under a cross-process lock. Unpaired group archival has rate and storage ceilings |
| Read filtering | `memory.read` is its own capability, the read path takes the caller's tier, and blocks resting on pending evidence reach neither recall nor Core |
| Designed only | Per-tier redaction of block content, hold-and-approve requests, branch-semantic provenance, cross-session spawn relations, entity Git layer, Graph view, event-driven writer notification |
