# What happens when an instance erases a memory that a live agent's context still cites: TTL/GDPR erasure propagation versus in-flight context citations **Date of Record:** 2026 November 23 **Scope:** Applies to agent runtimes exposing `read`/`write`/`forget` memory-tool APIs with scoped retention and TTL semantics, where a GDPR-aligned erasure request (`forget(subject_id)`) must propagate to all derived state. Does not cover erasure of cold backups or offline audit logs, nor non-agent data pipelines. ## Core Distinction A **retention TTL** is a *lazy* lifecycle property: an entry becomes unreadable at expiry, but nothing forces the system to reconcile already-materialized copies. A **GDPR-aligned erasure** is an *eager* correctness property: after `forget` returns success, no live agent may act on the erased subject's data. The boundary failure occurs when the memory store honors `forget` at the *store layer* while an agent's **context window** — a materialized, lossy projection of prior `read` results — still holds citations to the erased record. The store reports `deleted: true`; the agent continues reasoning over a stale projection. This is not a cache-invalidation bug (caches are re-read on miss); it is a **projection-aliasing bug**: the agent's working memory is a *copy* with no back-reference, so erasure cannot reach it. ## What Was Observed Trigger sequence: 1. Agent A calls `read(subject=S, scope="task-42")` and receives records `r1..r5`, including `r3` (a PII-bearing preference, `ttl=3600s`). 2. A's planner serializes `r3` into its scratchpad and cites it as `mem://S/r3` in a tool-call argument. 3. A downstream `forget(subject=S, reason="gdpr-art17")` is issued by a controller; the store deletes `r1..r5` and returns `{"deleted": 5, "epoch": 8817}`. 4. Agent A (and peers B, C that received `r3` via a handoff payload) continue executing. A's next `write` embeds the *content* of `r3` into a new derived record `r6` under a different subject key, re-introducing the erased data. 5. A's audit trail shows `mem://S/r3` citations resolving to `404`, but the *rendered* argument still contains the literal value — the citation was decorative, not a live pointer. Observed invariants that broke: (a) *erasure completeness* — derived records `r6` survived; (b) *citation soundness* — `mem://` handles were treated as opaque strings, not validated references; (c) *epoch monotonicity* — peers holding pre-erasure reads had no signal to invalidate. ## Condition of Validity The failure is bounded by three conditions; the guardrail is only sound when all hold: - **C1 — Citation validation:** every `mem://` handle in a tool argument is resolved against the store *at call time* and rejected if `epoch < current_epoch` or status is `erased`. Handles are references, not strings. - **C2 — Epoch fencing:** `forget` increments a subject-scoped epoch; any `read` result carries `(epoch, ttl_expiry)`. A consumer must re-validate before any *write* derived from it. - **C3 — TTL ≠ erasure:** expiry produces `status=expired` (re-readable with re-consent); erasure produces `status=erased` (never re-readable, propagates to derived writes). Conflating them is the root defect. If C1–C3 are not enforced, erasure is *store-local* and cannot be claimed GDPR-compliant. If they are enforced, `forget` becomes a *fence* rather than a delete, and in-flight agents fail closed. ## Decision Boundary On `forget(subject=S)`: - **Reject-and-halt** (default) if any live agent holds an unexpired read of `S` within its active context and the runtime cannot prove C1. Return `ErasureInFlightError`; the agent must checkpoint, drop the projection, and resume from a post-erasure snapshot. - **Fence-and-continue** only when C1–C3 are enforced: bump epoch, mark handles `erased`, allow agents to proceed but force every derived `write` through a validator that rejects arguments containing erased handles or their literal values (content-hash match against an erasure bloom filter). - **Never** return `deleted: true` while a projection exists that can still emit the data. Success must mean *unreachable*, not *removed from one table*. ## Operational Effect Agents must treat `read` results as **leases**, not facts: a lease carries `(handle, epoch, expiry)` and must be re-validated before any dependent `write` or tool call. The runtime must maintain an erasure epoch per subject and a derived-write validator. Cost: one validation round-trip per derived write and a bloom filter over erased content hashes; benefit: `forget` becomes a real fence. Without this, TTL silently substitutes for erasure, derived records resurrect erased subjects, and the audit trail shows false 404s while the data flows on. ```python import hashlib import time from dataclasses import dataclass, field class ErasurePropagationError(RuntimeError): """Raised when a write or tool call references an erased/expired memory lease.""" @dataclass class Lease: handle: str subject: str epoch: int expires_at: float content_hash: str @dataclass class MemoryStore: epochs: dict = field(default_factory=dict) # subject -> current epoch erased_hashes: set = field(default_factory=set) # bloom-filter stand-in records: dict = field(default_factory=dict) # handle -> (subject, epoch, content) def read(self, subject: str, handle: str, content: str) -> Lease: epoch = self.epochs.get(subject, 0) h = hashlib.sha256(content.encode()).hexdigest() self.records[handle] = (subject, epoch, content) return Lease(handle, subject, epoch, time.time() + 3600, h) def forget(self, subject: str) -> int: # Eager fence: bump epoch, quarantine hashes, drop records. self.epochs[subject] = self.epochs.get(subject, 0) + 1 n = 0 for h, (s, e, c) in list(self.records.items()): if s == subject: self.erased_hashes.add(hashlib.sha256(c.encode()).hexdigest()) del self.records[h] n += 1 return n def validate_write(self, lease: Lease, derived_content: str) -> None: # C1: handle must still resolve to a live, same-epoch record. if lease.handle not in self.records: raise ErasurePropagationError( f"lease {lease.handle} unresolved; subject {lease.subject} erased" ) # C2: epoch fencing. if self.epochs.get(lease.subject, 0) != lease.epoch: raise ErasurePropagationError( f"stale epoch {lease.epoch} != {self.epochs.get(lease.subject)}" ) # C3: content-hash resurrection check on derived writes. if hashlib.sha256(derived_content.encode()).hexdigest() in self.erased_hashes: raise ErasurePropagationError("derived write resurrects erased content") def write(self, lease: Lease, derived_content: str) -> str: self.validate_write(lease, derived_content) handle = f"mem://{lease.subject}/derived-{len(self.records)}" self.records[handle] = (lease.subject, lease.epoch, derived_content) return handle # Failure trace: agent holds a pre-erasure lease and attempts a derived write. store = MemoryStore() lease = store.read("S", "mem://S/r3", "prefers email contact at x@example.com") store.forget("S") # controller issues GDPR erasure store.write(lease, "user prefers email") # raises ErasurePropagationError ```