Consolidation
Extraction turns new turns into candidate memories. Consolidation decides what each candidate means for what is already known. The model sees the candidate and the most similar current memories (by meaning and by shared subject) and picks one operation:
| Operation | When | What happens |
|---|---|---|
ADD | New information | A new memory is stored. |
UPDATE | Refines one existing memory that is still true | A new version is stored; the old row points at it with superseded_by. |
INVALIDATE | Contradicts a memory because the world changed | The old memory's valid_to is set, and the candidate is added as a new memory. |
NOOP | Nothing new | Nothing changes; the decision is logged. |
Nothing is overwritten
UPDATE and INVALIDATE never edit text in place. The old version stays in the database with its
validity closed, so you can ask what was true before, and every decision lands in the op log with
the model that made it and a one-sentence reason. Read it with
GET /v1/memories/{id}/history or GET /v1/users/{uid}/ops.
{
"op": "INVALIDATE",
"reason": "Residence changed from Pune to Berlin.",
"before": { "text": "The user lives in Pune.", "valid_to": null },
"after": { "text": "The user lives in Pune.", "valid_to": "2026-03-01T00:00:00Z" }
}Safety rails
- The model may only target memories it was shown. Anything else falls back to
ADD. - All writes for one candidate (memory rows, entity links, op log and the job's progress counter) commit in one transaction.
- Consolidation for one user runs under a Postgres advisory lock, so two conversations arriving at once can't both add the same fact.
- Jobs are resumable: candidates are extracted once and stored on the job, and a retry after a crash continues from the first unapplied candidate. Candidate text is removed from the job when it finishes.