# DESIGN-0.18.0: Memory System

**Version:** 0.18.0  
**Status:** Phase 1 Complete  
**Depends on:** compaction (v0.15.0), knowledge bases (v0.14.0), persona-KB binding (v0.17.0), SQLite backend (v0.17.1)

---

## 1. Overview

Memory provides long-term fact persistence across conversations. Unlike
compaction (within-conversation context) or knowledge bases (static
documents), memory captures preferences, facts, and context that
accumulate over time from natural conversation.

**Key differentiator: Persona-scoped memory.** Each Persona builds
its own memory independently, preventing cross-context contamination.
A helpdesk Persona accumulates FAQ knowledge; a tutoring Persona
tracks per-student progress; a user's personal preferences stay
separate from any Persona context.

---

## 2. Scope Model

Three memory scopes with clear ownership:

```
┌─────────────────────────────────────────────────┐
│ user scope                                      │
│ owner_id = user_id                              │
│ "Jeff prefers Go over Python"                   │
│ "Deployment uses Kubernetes + Traefik"          │
│ Visible in ALL conversations for this user      │
└─────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────┐
│ persona scope                                   │
│ owner_id = persona_id                           │
│ "Common question: how to reset password"        │
│ "Policy: refunds within 30 days only"           │
│ Shared across ALL users of this Persona         │
└─────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────┐
│ persona_user scope                              │
│ owner_id = persona_id, user_id = user_id        │
│ "Student struggles with recursion"              │
│ "Customer prefers email over phone"             │
│ Per-user within a specific Persona              │
└─────────────────────────────────────────────────┘
```

**Scope resolution at recall time:**

When a Persona is active, all three scopes are queried and merged
with priority ordering: persona_user > persona > user. When no
Persona is active, only user scope is queried.

---

[... full content pasted ...]