A new durable fact
Store content with its source. Add an entity and attribute when the fact occupies a stable slot such as appointment day or shipping city.
content + source → active memoryContextDB Memory Evolution · Cloud Alpha
Apply ADD, UPDATE, DELETE, or NOOP as one explicit memory operation. Recall the current fact, inspect how it changed, and fail CI if an old memory returns.
The problem
A caller says Thursday works. Later, they correct it to Friday. If your memory layer stores both statements as unrelated vectors, retrieval can return either one. The model then has to guess which fact is current.
ContextDB makes the change explicit before retrieval. One operation closes the old fact, writes or removes the current fact, advances the project memory version when state changes, and appends the related audit event.
Four closed operations
Store content with its source. Add an entity and attribute when the fact occupies a stable slot such as appointment day or shipping city.
content + source → active memoryTarget an opaque memory ID or stable slot. ContextDB creates the successor and records which prior memory it superseded.
old id → new id + previous idsRemove one target or the current value in a slot. The response lists deleted IDs so the host and its tests can verify the effect.
target or slot → hard deletionRecord a bounded reason without writing another memory or advancing the memory version.
duplicate → audit event · same versionPython
Every Evolution call requires a stable idempotency key. The result includes the current memory, prior IDs, project-scoped memory version, and primary PostgreSQL WAL position.
Pass both consistency values into a follow-up recall when the next turn must observe the correction.
Install
contextdb-cloud-client==0.2.0a2.
from contextdb_cloud_client import CloudClient
async with CloudClient(
"https://api.contextdb.ai",
api_key="cdb_…",
) as db:
changed = await db.evolve(
"caller-123",
"update",
target_memory_id=current_memory_id,
content="Friday morning works best.",
source="user_stated",
idempotency_key="call-884-correction-v1",
)
current = await db.recall(
"caller-123",
"When should I book the visit?",
min_memory_version=changed.memory_version,
min_primary_wal_lsn=changed.primary_wal_lsn,
)
TypeScript
Target IDs are opaque. Store and pass them unchanged. Cross-project, cross-user, and missing targets all return the same not-found shape.
The package is server-only. Keep the project API key in Node.js, workers, server actions, or another trusted backend.
Install
@contextdb/cloud@0.2.0-alpha.2.
const removed = await db.evolve(
"caller-123",
"delete",
{
targetMemoryId: obsoleteMemoryId,
idempotencyKey: "call-885-retraction-v1",
},
);
const unchanged = await db.evolve(
"caller-123",
"noop",
{
targetMemoryId: currentMemoryId,
noopReason: "duplicate",
idempotencyKey: "call-886-duplicate-v1",
},
);
One atomic mutation
A real state change advances that project's memory version. Another project's writes do not move your consistency floor.
project + mutation → memory_versionThe response includes the primary WAL position. A token-bearing recall stays primary-bound unless the caller explicitly chooses bounded replica wait with primary fallback.
write → primary_wal_lsn → recall floorUPDATE and DELETE do not turn a missing or foreign target into an ADD. A target that cannot be proven inside the project and user partition is not found.
unknown target → 404 · no mutationLineage without old content
The Console lineage view returns opaque IDs, lifecycle state, slot, timestamps, supersession links, operation, and reason code. It does not return historical memory content.
After DELETE, the target row is gone. The append-only audit can retain the operation and opaque ID so an operator can verify that a deletion happened without restoring the deleted fact.
{
"nodes": [
{
"memory_id": "mem_old",
"lifecycle_state": "superseded",
"superseded_by": "mem_new"
},
{
"memory_id": "mem_new",
"lifecycle_state": "active"
}
],
"events": [
{
"operation": "SUPERSEDE",
"memory_id": "mem_old",
"related_memory_id": "mem_new"
}
]
}
Formation can plan the same lifecycle
ContextDB Formation receives bounded, project-scoped current memory alongside PII-processed turns. The hosted planner proposes one of the four operations. Deterministic gates then verify quotes, targets, slots, explicit retractions, and NOOP reasons before commit.
Propose UPDATE against the current appointment-day memory.
correction + known target → UPDATEPropose NOOP rather than writing a second copy.
same fact + same slot → NOOPPropose DELETE only when the turn contains an explicit retraction.
retraction + known target → DELETETest the change, not just the text
Memory CI supports deterministic evidence-ID
assertions. A correction test can require mem_new and
forbid mem_old. A deletion test can forbid the deleted ID.
JSON and JUnit exports contain opaque IDs, statuses, counts, outcomes, and machine codes. They omit queries, assertions, and memory content.
case: corrected appointment day
query: "When should I book?"
expected_evidence_ids:
- mem_new
forbidden_evidence_ids:
- mem_old
result: passed
Where it matters
Correct a caller's appointment day after an explicit statement, then require that version before booking.
Retract obsolete plan or service context so a later agent does not rely on it.
Map a changed source record to UPDATE and repeated source versions to NOOP.
Offer one lifecycle contract across frameworks instead of rebuilding correction logic in every agent.
Verified on August 24, 2026
This is functional production evidence. It is not sustained-load, failover, availability, latency, COGS, or SLO evidence. The Cloud API, Console, Formation, and clients remain alpha.
Questions
Memory evolution is the explicit process of adding, correcting, retracting, or leaving factual memory unchanged as new evidence arrives. ContextDB represents those outcomes as ADD, UPDATE, DELETE, and NOOP.
Two unrelated vectors leave retrieval and the model to decide which statement is current. UPDATE closes the prior memory, links it to the new memory, and returns a consistency floor for the next recall.
No. UPDATE creates a new current memory and marks the previous memory as superseded. Metadata-only lineage connects their opaque IDs. Ordinary recall returns the current memory.
The target memory row is hard-deleted. Append-only audit and lineage can retain the operation, opaque ID, timestamp, and reason code without returning the deleted content.
No. NOOP records why nothing changed and leaves the project memory version unchanged.
Yes, in Hosted Alpha. The provider proposes an operation from bounded current context and structured turns. Deterministic gates still require a known target and explicit evidence, especially for deletion.
No. A conventional RAG stack can be enough for mostly static documents. ContextDB is for per-user facts that change over time and may influence bookings, refunds, updates, or other actions.
It is available in the open SDK and Cloud Alpha, with the bounded functional production proof described above. There is no public availability SLO, sustained-load result, or failover claim.
Start with one correction, pass its consistency token into recall, then add the old ID to Memory CI's forbidden evidence.