Phase 3 — Core Memory Substrate

Phase 3 proves memory can be written, deduplicated, conflict-checked, and retrieved correctly and fast — in isolation, testable via direct API calls.

Phase 3 — Core Memory Substrate

What Phase 3 Delivers

Phase 3 proves memory can be written, deduplicated, conflict-checked, and retrieved correctly and fast — in isolation, testable via direct API calls. It deliberately does not touch the proxy hot path or auto-extraction; that is Phase 3.5. This mirrors how Phase 1 (auth/proxy plumbing) was kept separate from Phase 2 (actual LLM forwarding).

Why the Original Plan Needed This Rewrite

  1. IVFFlat replaced by HNSW: The original plan specified IVFFlat (lists=100) with HNSW deferred to Phase 4. Since Phase 3 is greenfield (no existing index to migrate), starting with the better index avoids a costly live-traffic migration later.
  2. Multi-label categories: The original single category enum cannot represent memories that span multiple categories. A join table (memory_labels) replaces the exclusive enum.
  3. Temporal validity: The original schema had no notion of when a fact was true, causing false contradictions when facts change over time. valid_from/valid_until columns fix this.

Phase 3 Scope — Five Tracks

TrackThemeKey Milestones
AMemory Schema & Data Foundation3.1.1 (schema v2: HNSW, temporal validity, multi-label)
BVector Store & Embedding Integration3.2.1 (VectorStore interface, pgvector-HNSW impl, composite scoring v2)
CMemory Write Pipeline3.C.1 (PII detection/redaction), 3.C.2 (dedup), 3.C.3 (temporal conflict detection), 3.C.4 (multi-label classification)
DRead/Ranking Pipeline & Hot Cache3.D.1 (semantic search), 3.D.2 (category-conditional decay), 3.D.3 (Redis hot cache)
EExit Gate3.E.1 (security integration), 3.E.2 (e2e lifecycle test), 3.E.3 (retrieval benchmark sign-off), 3.E.4 (ADR consolidation), 3.E.5 (exit audit)

New services (Phase 3 only)

ServiceLanguagePathPurpose
Memory ServicePython 3.12services/memory/Memory CRUD, dedup, vector search, hot cache

Embedding service, context assembly, worker, API server, and dashboard are not in Phase 3 scope.

Track A (Schema — start immediately):
 3.1.1 (memory schema v2)

Track B (Vector store — after Track A):
 3.2.1 (VectorStore + pgvector-HNSW + composite scoring v2)

Track C (Write pipeline — after Track A + B):
 3.C.1 (PII) → 3.C.2 (dedup) → 3.C.3 (temporal conflict) → 3.C.4 (multi-label)

Track D (Read/ranking — after Track B):
 3.D.1 (semantic search) → 3.D.2 (category-conditional decay) → 3.D.3 (hot cache)

Track E (Exit gate — after all):
 3.E.1 → 3.E.2 → 3.E.3 → 3.E.4 → 3.E.5

Key Design Decisions (ADRs)

Phase 2.5 already published ADR-0040–0046 (Anthropic through embedder registry). Temporal memory foundation is ADR-0047. Schema v2 expand is ADR-0052. Further Phase 3 ADRs below are planned titles — assign the next free numbers at write time (do not reuse 0040–0051).

TopicStatus
Memory schema v2 expand (HNSW, quality columns)ADR-0052 Accepted (000017)
Vector store + composite scoring v2Planned
Temporal-interval-aware conflict detectionPlanned (builds on ADR-0047)
Memory service tenant isolation (RLS + app-layer)Planned
Retrieval-quality benchmark methodologyPlanned

Phase 3 Latency Budgets

OperationBudgetNotes
Memory write (full pipeline)p95 < 200msIncluding embedding call
pgvector HNSW searchp95 < 30ms1M vectors, ef_search=40
Hot cache readp99 < 5msRedis sorted set ZREVRANGE
Composite scoring (70 candidates)p95 < 10msCategory-conditional decay

Phase 3 Exit Criteria

  1. Memory write pipeline (9 steps) passes all unit + ISO-* integration tests
  2. HNSW recall@10 >= 98% and p99 < 100ms at 1M-row benchmark scale
  3. Temporal-interval-aware conflict detection correctly distinguishes sequential-fact vs. true-contradiction cases, with zero unnecessary LLM calls on non-overlapping intervals
  4. Retrieval-quality benchmark running in CI with a committed baseline
  5. All 10+ ISO-* cross-tenant isolation cases pass, including the memory_relationships cross-org edge case
  6. GDPR delete cascade verified end-to-end
  7. All Phase 1 and Phase 2 security regression tests still pass with zero regressions
  8. make e2e-smoke-p3-memory exits 0
  9. Phase 3 memory ADRs published (next free numbers after ADR-0047; do not reuse 0040–0046) and cross-linked from the phase decision log
  10. No proxy hot-path changes — explicitly re-verified (that is Phase 3.5's boundary)
Edit on GitHub

Last updated on

On this page

0%