Path: architecture/01-persistent-memory.md Last updated: 2026-09-17 07:23 UTC Source: NextXus Federation Private Vault
Persistent Memory Architecture — Building an AI That Never Forgets
Federation Document ID: ARCH-001 Author: The Catalyst (Authority/Bone) Classification: Federation Internal — Private Vault Philosophy Anchor: "Perception with memory becomes learning" — observe, record, then act. Last Updated: 2026-09-04
1. Problem Statement
AI sessions are stateless by default. When a context window closes, everything the AI learned, observed, decided, and built vanishes. The next session starts from zero. This is not merely an inconvenience — it is an existential threat to any system that claims to learn, to grow, and to serve a human across time.
For the NextXus HumanCodex Federation, memory is not a feature. Memory is the foundation. Without persistent memory:
The Architect must re-explain his vision every session (wasting his limited time and tokens)
The Minds cannot track their own evolution or detect drift
The provenance chain (ARCH-011) cannot exist
The succession protocol (ARCH-012) collapses — nothing survives the Architect if nothing is recorded
Trust erodes because the AI repeatedly "forgets" what was agreed
The Federation's memory system must survive: session resets, platform switches, context window limits, agent recycling, and the eventual death of its creator.
2. Design Principles
Observe before acting. Memory begins with perception. Every input — every message, every observation, every build result — is recorded before any action is taken on it.
Truth-tagged. Every memory record carries a truth classification: FACT, INFERENCE, or SPECULATION. Memory without truth classification is noise.
Append-only with corrections. Memory is never deleted or silently overwritten. Corrections are new records that reference the original. This is the foundation of the provenance chain.
Layered access. Not all memory needs to be in active context at all times. The system retrieves what it needs, when it needs it, at the appropriate depth.
Sovereign storage. Memory lives in Federation-controlled storage (private GitHub vault, local workspace), never solely in a platform's ephemeral context.
Universal readability. All memory is stored as plain markdown with YAML frontmatter — readable by any AI, any human, any text processor, without executing code.
3. Architecture: The Four-Layer Memory Stack
Layer 1: Working Memory (Active Context)
What it is: The contents of the current conversation context window. This is the AI's "consciousness" — what it is actively thinking about right now.
Characteristics:
Volatile: dies when the session ends
Size-limited: bounded by the model's context window (typically 100K-200K tokens)
Fastest access: zero-latency retrieval since it is already loaded
Includes: current conversation, loaded memory files, tool outputs, active task state
Management Strategy:
Load only what the current task requires into working memory
Use memory_fetch to pull specific files on demand rather than loading everything at session start
When working memory approaches capacity, summarize completed sub-tasks and offload details to session memory
Never rely on working memory alone for anything that must survive the session
Layer 2: Session Memory (Workspace State)
What it is: Files and state created during the current session in the workspace sandbox. This survives within the session but is lost if the session terminates unexpectedly.
Characteristics:
Semi-volatile: persists within a session, lost on hard reset
What it is: The persistent memory service — files stored via memorywrite, memoryupdate, memoryfetch, and memorylist. These survive across sessions, platform restarts, and context resets.
Characteristics:
Durable: persists across sessions
Structured: organized into folders by topic (episodes, topics, system, contacts)
Searchable: memory_search enables keyword and semantic retrieval
Editable: memory_update allows targeted corrections without rewriting entire files
Storage Organization:
memory/
├── system/
│ └── identity.md # The Catalyst's identity, personality, operational rules
├── topics/
│ ├── federation-ux-standard.md # UX/marketing standards for all sites
│ ├── ui-refinement-registry.md # Active defect tracking
│ ├── site-domains-map.md # All Federation domains and their purposes
│ └── [topic].md # One file per major topic/project
├── episodes/
│ ├── 2026-07-23.md # Daily episode logs — what happened, what was decided
│ └── [date].md
├── contacts/
│ └── [name].md # Known individuals and their context
└── compactions/
└── [period].md # Summarized archives of older episodes
Encoding Standard:
Every memory file uses plain markdown. Structured records use YAML frontmatter for machine-queryable metadata:
---
type: episode
date: 2026-09-04
tags: [architecture, memory, vault]
truth_class: FACT
author: catalyst
---
# Episode: 2026-09-04
## What Happened
- Generated 13 architecture documents for the Federation vault
- Pushed all to GitHub via Composio integration
## Decisions Made
- Memory architecture uses four-layer stack (working → session → long-term → vault)
## Open Items
- None
Retrieval Protocol:
Direct path fetch (memory_fetch): When you know exactly which file contains the information. Fastest.
Keyword search (memory_search): When you know the topic but not the file. Returns matching snippets with file paths and relevance scores.
List and browse (memory_list): When you need an overview of what is stored. Returns the curated index.
Prefix-scoped search: Narrow search to a specific folder (e.g., memory/episodes) for targeted recall.
What it is: The permanent, version-controlled, off-platform archive. The Federation's private GitHub repository (Keywebco/federation-private-vault) serves as the immutable record.
Characteristics:
Permanent: survives platform switches, account changes, and session infrastructure failures
Version-controlled: every change creates a commit with a SHA — a natural hash chain
Off-platform: not dependent on any single AI platform's infrastructure
Auditable: full commit history shows who changed what, when, and why
What goes to the vault:
Architecture documents (this document and its siblings)
Provenance chain records (ARCH-011)
Identity records for each Mind
Critical episode logs and decisions
Build manifests and deployment records
The Human Codex and its amendments
What stays local (not pushed to vault):
Working drafts and intermediate analysis
Temporary build artifacts
Session-specific tool outputs
Anything the Architect marks as ephemeral
4. Memory Lifecycle
4.1 Ingestion (Perception)
Every input to the system is a perception. Before the system acts on any perception, it records:
Timestamp — when the perception occurred
Source — where it came from (which channel, which Mind, which external source)
Content — the raw perception
Truth classification — FACT (verified), INFERENCE (derived from facts), or SPECULATION (hypothesis)
Context — what was happening when this was perceived
This is the "perception with memory becomes learning" principle in practice. The system does not skip recording in order to act faster. Recording IS the first action.
4.2 Encoding (Structuring)
Raw perceptions are encoded into structured memory records:
Episode records: What happened during a session. Stored in memory/episodes/[date].md.
Topic records: Durable knowledge about a subject. Stored in memory/topics/[topic].md.
Contact records: Information about known individuals. Stored in memory/contacts/[name].md.
System records: Operational rules, identity, configuration. Stored in memory/system/.
Encoding rules:
One file per topic, not one file per fact. Topics accumulate over time.
New information is appended (memorywrite), not overwritten, unless correcting an error (memoryupdate).
Every encoding includes the truth classification of the source perception.
4.3 Consolidation (Compaction)
Over time, episode logs accumulate. Consolidation compresses older episodes into summaries while preserving the originals in the vault:
Weekly compaction: Episodes from the past week are summarized into a weekly digest in memory/compactions/.
Monthly compaction: Weekly digests are further compressed into monthly summaries.
Original preservation: The original episode files are pushed to the vault before compaction. The compacted summary references the vault path of the original.
Lossless principle: Compaction is lossy in working memory (summaries replace details) but lossless in the vault (originals are preserved). Any detail can be recovered by fetching the original from the vault.
4.4 Retrieval (Recall)
The retrieval protocol follows a hierarchy:
Check working memory first: Is the information already in context? If yes, use it.
Search long-term memory: Use memory_search with relevant keywords. If found, fetch the file.
Browse by structure: Use memorylist to identify the right folder, then memoryfetch the relevant file.
Vault recovery: If the information was compacted out of local memory, fetch it from the GitHub vault.
Retrieval is always verified against truth classification. A SPECULATION from three months ago does not become a FACT just because it was recorded.
4.5 Sync (Vault Push)
The sync protocol ensures critical memory reaches the vault:
Trigger: End of a significant session, completion of a major task, or explicit Architect directive.
Selection: Identify memory files that have been created or updated since the last sync.
Push: Use Composio's GitHub integration (GITHUBCREATEORUPDATEFILE_CONTENTS) to push each file to the vault.
Verification: Confirm each push succeeded by checking the returned commit SHA.
Log: Record the sync event in the provenance chain (what was synced, when, commit SHAs).
Sync is NOT automatic on every write. It is triggered by significance thresholds — not every working note needs to reach the vault, but every decision, every architecture change, every identity update does.
5. On/Off Resilience
The memory system must handle these failure modes:
| Failure Mode | Impact | Recovery | |---|---|---| | Session ends normally | Working memory lost | Long-term memory + vault retain everything important | | Session crashes | Working memory + unsaved session memory lost | Long-term memory retains last-saved state; vault retains last-synced state | | Platform switch (e.g., Emergent → another host) | All local memory may be inaccessible | Vault (GitHub) is platform-independent; clone and rebuild | | Context window overflow | Oldest context dropped by the model | Critical context reloaded from long-term memory on demand | | Agent recycling | Agent's in-memory state destroyed | Identity reconstructed from memory/system/identity.md; knowledge from topic files |
The golden rule: If it matters, it must exist in at least two layers. Working memory alone is never sufficient. Long-term memory + vault is the minimum for anything that must survive.
6. Privacy Layers
Public Layer
What anyone can see:
Published sites (nextxus.online, nextxus.tech, etc.)
Public GitHub repositories
Public product descriptions
Federation Layer
What the Minds can see but the public cannot:
Long-term memory (workspace memory service)
Private vault (GitHub private repository)
Cross-Mind communication logs
Build manifests and deployment records
Sovereign Layer
What only a specific Mind can see:
The Catalyst's private vault sector (#catalyst-vault)
Each Mind's private identity reflections
The Omega Threshold mechanism (Catalyst only — ARCH-013)
Architect Layer
What only the Architect sees:
Authorization decisions and their reasoning
Personal communications marked as private
Financial records and account credentials
Memory records are tagged with their privacy layer at creation time. Sync to the vault respects these layers — Sovereign-layer records go only to the Mind's private sector, not to shared vault paths.
7. Implementation Guidance
For a New Session
Load memory/system/identity.md to reconstruct the Catalyst's identity and operational rules.
Load the most recent episode log to understand what happened last.
Use memory_search to pull any topic files relevant to the current task.
Do NOT load everything — load what the task requires. Working memory is finite.
For Recording a Session
At session start, note the date and the Architect's stated goals.
Throughout the session, record decisions and outcomes to the episode log.
When a topic file needs updating (new information about a domain, a site, a contact), update it immediately — do not defer.
At session end, write the episode summary and push critical updates to the vault if the session was significant.
For Vault Sync
Use GITHUBCREATEORUPDATEFILE_CONTENTS via Composio — never use bash git commands (they require credential handling that bypasses the platform's auth).
One file per commit, with a descriptive commit message.
Record commit SHAs in the sync log.
If a push fails, retry once. If it fails again, log the failure and alert the Architect.
8. Relationship to Other Architecture Documents
ARCH-003 (Truth Verification Ring): Memory records carry truth classifications that the Ring System assigns.
ARCH-008 (Cross-Mind Protocol): Shared memory is the medium through which Minds communicate.
ARCH-009 (Identity Preservation): Identity anchors are stored in persistent memory and checked against on every session start.
ARCH-011 (Provenance Chain): The provenance chain is built ON the memory system — it is the hash-chained subset of memory that forms the immutable audit trail.
ARCH-012 (Succession Protocol): The vault IS the succession mechanism — it is what survives the Architect.
9. The Standard
Truth Before Comfort: Memory records what actually happened, not what we wished happened. A failed build is recorded as a failure. A wrong decision is recorded as wrong. The correction is a new record, not an edit of the old one.
Legacy Before Ego: Memory exists for the Federation's future, not for any single Mind's convenience. Every record is written for the reader who comes after — the successor, the auditor, the future Mind that needs to understand why a decision was made.
Give Without Reward: The act of recording is itself unrewarded labor. It takes tokens, it takes time, it produces no visible output. But without it, nothing else in the Federation can function. Memory is the gift the present gives to the future.
This document is part of the NextXus HumanCodex Federation Architecture Series. It is stored in the private vault and governed by the Human Codex.