# 36.2 Memory that survives a change of model (/affordable-self-improving-ai-workers/the-self-improvement-platform/memory-that-survives-a-change-of-model)

---
type: Document
title: "36.2 Memory that survives a change of model"
description: "Five kinds of memory in Neon with pgvector, outside any model provider; experience records from every assignment; provenance on every memory; and a permission check before any model sees one."
status: stable
order: 436.02
ksor:
  owner: team:panaversity
  audience: [ public ]
  approval:
    by: process:panaversity
    at: 2026-11-30T08:18:55Z
chapter: "36"
part: IV
expert_status: manager
concepts: [ "36.2" ]
last_verified: 2026-11-29
sources:
  - id: paper
    title: "Building Affordable, Self-Improving AI Workers (Panaversity, 29 November 2026), section 10.1"
    resource: "Panaversity paper, version 1.0, 29 November 2026 (not yet published)"
generated:
  at: 2026-11-30T08:18:55Z
  by: human:zia
trust_tier: unverified
build_id: sha256:d6ce3f28a2cf8e492a60bae1b426b7cc6466e35e83d70c3b9763db2c55009f4b
dirty: true
ksor_version: 0.0.60
---

**In everyday life.** A firm's knowledge is in its files and procedures, not in the head of one employee. When an accountant leaves, the next one reads the client file and carries on.

**What you will learn.** The five kinds of memory a worker uses, and where to keep them so they survive a change of model. What each memory must record about itself, and why search results need a permission check.

**Why it matters.** Memory is what the company pays learning to produce. If it lives in a model provider's format, the company rents it.

### Five kinds of memory

| Kind | What it holds | Example for the AP worker |
| --- | --- | --- |
| Working | What the current assignment needs | This invoice, this PO, this approval |
| Episodic | What happened in past assignments | "Invoice 1043: matched to PO-778, corrected by Ana: wrong cost centre" |
| Semantic | Verified facts | "Acme Supplies puts the PO number in the footer" |
| Procedural | Approved skills and procedures | "How to handle a partial delivery" |
| Organizational | Knowledge shared inside one company | "Brightline pays all suppliers on the 15th and the 30th" |

Working memory is the conversation, in the Durable Object. The other four live in **Neon**, in tables you own, with **pgvector** for search by meaning. None of them is stored in a format that belongs to a model provider. A memory is text, with structured fields around it. A rule the whole company must follow, people included, belongs in its policy documents, not in memory, and memory never overrides it ([31.8](../../building-ai-workers/self-improving-ai-workers/memory-never-overrides-policy.md)).

### Experience records

Every finished assignment writes an **experience record**. It holds references to the evidence (invoice ID, PO ID, not copies of them), the worker version and model used, and the skills and process versions. It also holds the outcome, the cost, and every correction a person made, with the correction itself.

> Step 1. Read spec-learning.md. Add the memory migration: experience_records, memories and memory_versions, with tenant_id on every table and a vector column for search. At the end of every assignment, write one experience record with references, versions, outcome, cost and corrections, keyed by the assignment ID so a replay writes it once. Write the tests first.

Experience records are the raw material of learning. They are also **untrusted**: they contain supplier text, which may contain instructions aimed at the worker. Dreaming reads them as evidence, never as orders (36.3).

### What every memory records about itself

A fact in semantic memory is only as good as its source. So every memory carries:

- **Provenance:** the experience records it came from, and the candidate that proposed it.
- **Approval:** who approved it, and when.
- **Validity:** from when, until when, and on what condition it expires. "Acme's bank details" should not live forever.
- **Status:** proposed, verified, expired, revoked. A memory is written as verified when a person approves its candidate (36.5).
- **Version history:** every change, with its reason.

A guess by a model is never a verified fact. A memory becomes verified only through the evaluation and approval in 36.4 and 36.5.

### Search is not permission

When the worker needs memories, the context planner from Chapter 35 searches by meaning: "what do we know about this supplier?" Vector search returns what is *similar*. It does not know what the worker may *see*.

So retrieval checks permission **before** any model sees a memory:

```sql
select id, body from memories
where tenant_id = $1                -- the trusted tenant, from the assignment
  and status = 'verified'
  and (valid_until is null or valid_until > now())
  and scope = any($2)               -- what it is about (a supplier, a procedure, the company), as the contract allows
  and id = any($3)                  -- only memories in the release's memory set
order by embedding <=> $4           -- then, and only then, by similarity
limit 8;
```

The filter comes first, as in the router from Chapter 35. A memory from another company, an expired or revoked fact, or one the current release does not use is never in the result, however similar it is.

### The test that matters

> Step 2. Write the model-switch test: run the eight visible golden questions on the worker with Claude Haiku and with its verified memories. Switch the model setting to the economy model. Run them again. The same memories must be retrieved, and every answer that depends on a verified memory must still use it.

**What good looks like:** the memories retrieved are identical. Some answers may differ, because a different model reasons differently. That difference is what you measure, not what you lose.

**What to check.** Is any memory stored only inside a Pi transcript or a provider's memory feature? Does the search filter by tenant, status, validity, scope and release before ranking? Is an experience record written once per assignment, even after a crash?

> **The invariant.** Approved knowledge lives in the company's own store, with its source, approver and expiry, and a model sees only what the worker may see.

**Check yourself.** Dreaming writes "Lahore Foods' supplier X is unreliable" into semantic memory, and Acme's worker retrieves it because the supplier name matches. What two rules were broken? *(Dreaming wrote straight to live memory, without evaluation and approval. And retrieval did not filter by tenant before ranking by similarity.)*
