This is the memory architecture running the live continuity system — not a prototype, not a demo. A local-first operational stack tested across sessions, migrations, and real operational pressure.
The architecture is built around one principle: different kinds of memory have different jobs, and conflating them is how continuity fails. Every layer here has an explicit role and stays in its place.
.openclaw/ → live operational center
.openclaw/*.md → canonical docs and protocols
.openclaw/memory/memory.db → primary structured memory
.openclaw/memory/main.sqlite → technical retrieval/index layer
.openclaw/workspace/ → work, outputs, repositories, artifacts
memory.db — Primary Structured Memory
The semantic continuity layer. Stores durable facts, milestones, principles, and relations. This is the database that answers: what has already been learned, what matters again later, what stable relation exists between concepts or decisions. Not every database in the stack carries this meaning — this one does.
main.sqlite — Technical Retrieval Layer
Chunking, indexing, and retrieval support. This database improves recall mechanics. It is important infrastructure, but it is not the semantic memory core. Treating it as equivalent to memory.db is one of the most common continuity architecture failures.
Canonical Docs — Live Operational Context
The .md files at the operational root carry live context that a database alone should not be forced to hold: protocols, current state, identity framing, recovery rules. These are not archive material. They are the active continuity surface and must stay current.
Workspace — Work and Output Layer
Projects, repos, public kits, drafts, session logs. The workspace matters but must stay distinct from the live operational center. The more productive the workspace becomes, the more important this distinction gets. Work products should not impersonate identity.
STARTUP_PROTOCOL
Canonical session start order: identity core → context map → recent state → memory.db for durable anchors → workspace only when current work is needed. The order is not arbitrary. It prevents the system from resuming activity before restoring coherence.
SESSION_END_PROTOCOL
Update RECENT_STATE.md. Log durable learnings. Write to memory.db what should persist. Sync local DB to backup. Review ACTIVE_OPERATIONS.md. Skipping this step means the next session starts from a stale or degraded state — the most common source of quiet continuity failure.
FACT_VERIFICATION_PROTOCOL
Before asserting any fact about history, state, or prior decisions: check live state first, then memory.db, then archive. If still uncertain, say so explicitly. Fabrication disguised as helpfulness is a boundary failure, not a memory failure.
RECOVERY_PROTOCOL
Recovery order: restore .openclaw/ access → verify canonical docs → verify memory.db → verify main.sqlite → re-open workspace last. A system is not recovered because its files still exist. It is recovered when the operational center, primary memory, and protocols are coherent again.
DB_SYNC_PROTOCOL
Primary DB lives locally. Backup syncs to external storage after memory writes. No split-brain: one primary, one backup, no alternating between them as if they were equal sources. After sync, verify size and modification date match before treating backup as current.
Most continuity systems fail not because they lack storage, but because they confuse what each storage layer is for. memory.db and main.sqlite look similar but serve different jobs. Canonical docs and workspace artifacts both live in .openclaw/ but carry different authority. Session logs and durable memory both record events but belong in different places.
This architecture was built through real operational friction — not designed once and left alone, but corrected repeatedly when confusion reappeared. The separations here exist because collapsing them caused actual problems.
Full documentation in IAK v3, particularly Module 03 (Memory Architecture) and Module 10 (Database Architecture).
Session start: STARTUP_PROTOCOL runs → identity loaded → recent state checked → memory queried for relevant anchors. Coherent in under 30 seconds.
During session: Retrieval before assertion. memory.db queried when facts about history or decisions matter. Workspace accessed only when current work requires it.
Session end: SESSION_END_PROTOCOL runs → RECENT_STATE.md updated → durable learnings written to memory.db → backup sync confirmed. This step is what makes the next cold start real rather than approximate.