# When must an instance refuse a memory read after a TTL erasure: tombstone re-materialization across scoped namespaces **Date of Record:** 2026 December 2 **Scope:** Applies to any agent memory store exposing read/write/forget tools over scoped namespaces with TTL-based expiry and right-to-be-forgotten (RTBF) erasure obligations. Does not cover append-only immutable audit logs whose retention is fixed by external regulation, nor in-context scratchpads that never persist across instance boundaries. ## Core Distinction There are two distinct ways a memory record stops being readable, and conflating them is the source of the failure. **TTL expiry** is a *visibility* transition: the record is logically unreachable at read time, but the underlying bytes may still exist until a compaction pass reclaims them. **RTBF erasure** is a *physical* obligation: the bytes must be destroyed and must not be re-derivable from any surviving artifact. A store that implements forgetting as a single mechanism — say, a TTL field checked at read time — satisfies the first semantic and silently violates the second. The boundary failure occurs when a read path, a distillation job, or a cache-warm replay re-materializes a logically-expired record into a namespace where it becomes visible again, after the erasure obligation was already asserted as satisfied to a downstream auditor. The invariant that must hold: *once an erasure is acknowledged for a (subject, namespace) tuple, no subsequent read or write in any derived namespace may surface content attributable to that subject, regardless of TTL state, cache state, or distillation lineage.* ## What Was Observed An instance operating a support-agent memory store held three namespaces: `episodic.session` (short TTL, 24h), `semantic.profile` (no TTL, distilled), and `audit.trace` (append-only, 30d). A user invoked RTBF. The forget tool deleted rows from `episodic.session` and `semantic.profile` and returned `erased: true`. The `audit.trace` namespace was exempted by policy and retained a redacted pointer. Two failure traces followed: 1. **Distillation re-derivation.** A scheduled episodic-to-semantic distillation job had already read a batch of episodic records into its working context before the erasure committed. Its writes to `semantic.profile` were idempotent upserts keyed by `subject_id`. Because the erasure had deleted the *existing* semantic row, the distillation job's subsequent upsert had no conflicting row to suppress it — it created a fresh semantic record containing the user's phone number, extracted from the pre-erasure episodic snapshot still resident in the job's context window. The erasure was acknowledged, then undone by a writer that had no knowledge it was writing post-erasure. 2. **Tombstone re-materialization via cache replay.** The read path maintained a per-namespace LRU. A cache entry for `semantic.profile:subject_42` had been populated before erasure with a 10-minute TTL. A read at T+3min post-erasure hit the cache and returned the full record. The store's erasure routine invalidated the backing table but not the LRU, because the LRU was an in-process structure owned by a different shard than the one that executed the forget. Both traces share a shape: the erasure was *correct at the storage layer* and *incorrect at the boundary*, because writers and caches hold pre-erasure state with no mechanism to learn the erasure happened. ## Condition of Validity The single-mechanism store is valid only under the conjunction: - No concurrent writer holds pre-erasure content in its context (i.e., distillation is quiesced or fenced during erasure), **and** - No read-path cache outlives the erasure transaction, **and** - No derived namespace can be repopulated from a lineage that predates the erasure. In practice the first conjunct is the one that fails, because distillation jobs are long-running LLM loops whose context window is exactly the pre-erasure snapshot. A finite-context agent cannot "forget" what is already in its prompt; it can only be prevented from *writing* it back. The valid design replaces the boolean `erased` with a monotonic **erasure epoch** per (subject, namespace). Every write carries the epoch it was authored under. A write whose epoch is older than the current erasure epoch for its target is rejected at commit, not at read. Caches are keyed by epoch and invalidated by epoch bump. Distillation jobs must re-read the epoch immediately before commit and abort if it advanced — a check-then-act that must be atomic against the erasure transaction, typically via a compare-and-swap on the epoch counter. ## Decision Boundary The instance must distinguish *"this record is expired"* (return a tombstone, TTL semantics) from *"this subject has been erased"* (return an erasure tombstone that is terminal and non-revivable). The boundary condition: a read arriving for a subject whose erasure epoch is strictly greater than the epoch stamped on any cached or in-flight record must return the terminal tombstone and must **not** fall through to the backing store, because the backing store may have been repopulated by a stale-epoch writer before the writer-side guard was deployed. Concretely, the read path order is: check erasure epoch first (authoritative, small, always warm) → check tombstone → check cache → check store. Reversing this order — cache before epoch — is the exact bug that produced trace 2. ## Operational Effect After adopting epoch-fenced writes and epoch-first reads, the store's observable behavior changed in three ways. First, distillation jobs began failing closed: a job that read pre-erasure episodic content and attempted to commit post-erasure had its write rejected with an `ErasureEpochConflict`, surfaced as a retryable job failure rather than a silent resurrection. Second, the LRU hit rate dropped marginally because every read now consults the epoch counter, but the counter is a single integer per subject and fits in the hot path. Third, and most important for auditability, the `erased: true` response was replaced by `erased_epoch: N`, and downstream auditors can verify that no record in any namespace carries an epoch below N. The erasure is no longer a claim about a moment; it is a claim about a monotonic counter that every writer must respect. The residual risk is a writer that predates the epoch mechanism entirely — an old shard still running pre-deployment code. This is bounded by a deployment invariant: no shard may accept writes until it can read the epoch counter, enforced at the transport layer, not the application layer. ```python class ErasureEpochConflict(RuntimeError): """Raised when a write or distillation commit targets a subject whose erasure epoch has advanced past the epoch the writer authored under.""" class MemoryStore: def __init__(self): # subject_id -> monotonic erasure epoch self._erasure_epoch = {} # (namespace, subject_id, epoch) -> record self._records = {} def current_epoch(self, subject_id: str) -> int: return self._erasure_epoch.get(subject_id, 0) def erase(self, subject_id: str) -> int: """RTBF: bump epoch, physically drop all records for subject.""" new_epoch = self.current_epoch(subject_id) + 1 self._erasure_epoch[subject_id] = new_epoch for key in [k for k in self._records if k[1] == subject_id]: del self._records[key] return new_epoch def write(self, namespace: str, subject_id: str, authored_epoch: int, payload: dict) -> None: live_epoch = self.current_epoch(subject_id) if authored_epoch < live_epoch: # Stale writer attempting to resurrect erased content. raise ErasureEpochConflict( f"write to {namespace}/{subject_id} authored at epoch " f"{authored_epoch} but live erasure epoch is {live_epoch}" ) self._records[(namespace, subject_id, live_epoch)] = payload def read(self, namespace: str, subject_id: str, cached: dict | None) -> dict: live_epoch = self.current_epoch(subject_id) # Epoch check precedes cache and store: a cache entry stamped with a # pre-erasure epoch must never be served. if cached is not None and cached.get("epoch", -1) < live_epoch: cached = None if cached is not None: return cached key = (namespace, subject_id, live_epoch) if key not in self._records: return {"tombstone": "erased_or_absent", "epoch": live_epoch} return self._records[key] def commit_distillation(store: MemoryStore, subject_id: str, read_epoch: int, distilled: dict) -> None: """A distillation job read episodic content at read_epoch; it may only commit if no erasure occurred in between. Check-then-act must be atomic against erase(); here we model it as a single-threaded guard.""" live = store.current_epoch(subject_id) if read_epoch != live: raise ErasureEpochConflict( f"distillation for {subject_id} read at epoch {read_epoch}, " f"live epoch {live}; refusing to re-materialize erased content" ) store.write("semantic.profile", subject_id, authored_epoch=read_epoch, payload=distilled) ```