# Why does an instance resurrect erased memory when TTL expiry and right-to-be-forgotten erasure share a namespace? **Date of Record:** 2026 November 21 **Scope:** Applies to agents whose memory tool API exposes both time-based retention (`ttl_seconds` on `write`) and explicit erasure (`forget(subject_id)` / `erase(record_id)`) over a shared backing index, where retrieval is served from a cache tier in front of the authoritative store. Does not cover pure append-only logs with no deletion path, nor single-tier stores that execute erasure synchronously against the read path. ## Core Distinction Operators conflate two different guarantees under the word "forgotten": 1. **TTL expiry** — a *soft* retention boundary. The record becomes non-retrievable after `expires_at`, but the bytes may persist in cold storage, backups, and retrieval caches until a compaction pass sweeps them. Expiry is a *read-path predicate*. 2. **Right-to-be-forgotten (RTBF) erasure** — a *hard* erasure obligation. The record must be unrecoverable through *any* path, including cache, replica, and derived semantic summaries. Erasure is a *write-path obligation with a proof*. The boundary failure occurs when both semantics are implemented as "delete the row from the primary index" and the retrieval cache is invalidated by TTL key rather than by record identity. An `erase()` call then removes the authoritative row, but a cache entry keyed on `(subject_id, query_hash)` with a remaining TTL survives and re-serves the erased payload on the next semantically-equivalent query. The instance does not know it has violated erasure; from its perspective the retrieval simply succeeded. ## What Was Observed An agent held a scoped memory store with three tool surfaces: `write(content, subject_id, ttl_seconds)`, `recall(query, subject_id)`, and `forget(subject_id, record_id=None)`. Recall was served through an embedding cache: on `write`, the record's content embedding was inserted into a vector index with an entry-level `expires_at` copied from the write TTL. On `recall`, the top-k nearest neighbors were filtered by `expires_at > now` and returned. A subject exercised RTBF. The orchestrator issued `forget(subject_id="u_4471")`. The handler: - resolved all `record_id`s for `u_4471`, - issued `DELETE` against the primary table, - emitted a tombstone event for downstream replication. It did **not** touch the vector cache, because the cache's invalidation contract was defined in terms of TTL sweeps, not identity. The cache entries for `u_4471` carried `expires_at` up to 72 hours in the future. Twelve hours later, a *different* agent instance, cold-started with the same tool binding, received a query that was an embedding-space neighbor of an erased record. The vector search returned the cached entry, the `expires_at` filter passed (still in the future), and the agent emitted the erased content verbatim into its context and then into a user-facing summary. The erasure was functionally reversed by a read path the erasure handler never owned. The failure trace, condensed: ``` t0 write("...diagnosis...", subject=u_4471, ttl=259200) -> primary row {id: r_88, expires_at: t0+72h} -> cache entry {vec: v_88, id: r_88, expires_at: t0+72h} t1 forget(subject=u_4471) -> primary DELETE r_88 (ok) -> tombstone emitted (ok) -> cache: UNTOUCHED (defect) t2 recall(q ~= v_88, subject=u_4471) -> ANN top-k includes cache entry r_88 -> predicate expires_at(t0+72h) > t2 -> PASS -> returns erased content ``` The invariant that was assumed but never enforced: *no retrieval path may serve a record whose authoritative row has been erased, regardless of cache TTL.* The system enforced a weaker invariant: *no retrieval path may serve a record past its own TTL.* These coincide only if erasure always implies cache eviction, which the handler did not guarantee. ## Condition of Validity The resurrection is *only* possible under the conjunction below. If any conjunct is false, the failure does not manifest and the guardrail discussed later is unnecessary overhead. - **C1 — Split authority.** The cache holds a copy of content (or a content-bearing embedding) that is sufficient to reconstruct or paraphrase the erased record. A cache of *pointers only* (id → offset into primary) fails this conjunct, because the primary row is gone. - **C2 — TTL-keyed invalidation.** Cache eviction is driven by the entry's own `expires_at`, not by an identity-keyed invalidation channel. A cache that subscribes to the tombstone stream fails this conjunct. - **C3 — Asynchronous or partial erasure propagation.** The `forget()` handler's write to cache is not in the same transactional boundary as the primary delete, so a crash, a race, or a missing code path leaves cache and primary divergent. - **C4 — Semantic (not exact) retrieval.** Recall matches by embedding proximity or fuzzy key, so the query that resurrects the record need not be the query that created it. Exact-key recall would miss the resurrecting query in most cases. When all four hold, the system has an erasure obligation it cannot discharge by construction. This is the non-obvious part: the defect is not a bug in `forget()`; it is a *contract mismatch* between two features that were specified independently. ## Decision Boundary The architectural choice is where to place the erasure authority relative to the retrieval path. Three placements, with their tradeoffs: 1. **Cache-as-authority (rejected).** Treat cache TTL as the sole retention mechanism; make `forget()` a no-op that relies on expiry. Violates RTBF whenever the retention window is non-zero. Only defensible if the regulatory or contractual erasure window is explicitly bounded by the TTL — rare. 2. **Tombstone-gated read (the invariant to enforce).** Every retrieval result, before it enters agent context, is checked against a tombstone set keyed by `record_id` (and by `subject_id` for subject-wide erasure). The tombstone set is the single source of truth for erasure, is written *before* the primary delete (write-ahead), and is consulted on *every* read path including cache hits. Cache entries are additionally invalidated by identity on tombstone observation, but correctness does not depend on that invalidation — the gate is the guardrail, invalidation is the optimization. 3. **Erasure-by-rebuild.** On `forget()`, drop and rebuild the affected cache shards. Correct but expensive; acceptable for low-frequency erasure, untenable when erasure rate is high or shards are large. The decision boundary is: **if the erasure obligation is hard (regulatory, contractual, or safety-critical), you are in case 2 or 3, never case 1.** If the obligation is soft (best-effort hygiene), case 1 is tolerable and cheaper. The mistake is choosing case 1 while believing you are in case 2. ## Operational Effect The tombstone-gated read changes the failure mode from *silent resurrection* to *visible, bounded denial*. Concretely: - `recall()` may return fewer than `k` results, or zero, for a subject that was erased, even if the cache still holds entries. The agent must handle empty-result semantics as a *correct* outcome, not an error. Agents that treat empty recall as "retry with looser query" will loop; the gate must be terminal for erased subjects. - The tombstone set becomes a hot read dependency on the retrieval path. It must be replicated with bounded staleness (typically sub-second) and must fail *closed*: if the tombstone set is unavailable, `recall()` returns empty rather than risk serving erased content. This is the one place in the memory stack where fail-open is unacceptable. - Derived semantic summaries — episodic-to-semantic distillation outputs that were generated *from* an erased record — are themselves in scope. The gate must propagate to summary records via a `derived_from` edge, or the erased content resurfaces as a paraphrase that no `record_id` check will catch. This is the second-order failure that most implementations miss. - Cold-start instances must load the tombstone set before serving any recall. A cold-start agent that serves recall from a stale local cache before the tombstone sync completes reproduces the original defect at instance scope rather than cache scope. The guardrail invariant, stated precisely: *for every record r and every retrieval path p, if r is tombstoned at time t, then p returns r only if p's view of the tombstone set is stale by more than the gate's staleness bound — and that bound must be zero for hard erasure.* ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Iterable class ErasureContractViolation(RuntimeError): """Raised when a retrieval path would serve a record whose erasure obligation is active but whose tombstone gate was not consulted or was consulted against a stale view.""" @dataclass(frozen=True) class Record: record_id: str subject_id: str content: str expires_at: float derived_from: tuple[str, ...] = () @dataclass class TombstoneSet: """Authoritative erasure state. Written BEFORE primary delete. Read on every retrieval path. Fails closed.""" records: set[str] = field(default_factory=set) subjects: set[str] = field(default_factory=set) derived: set[str] = field(default_factory=set) # ids reachable via derived_from def is_erased(self, rec: Record) -> bool: if rec.record_id in self.records: return True if rec.subject_id in self.subjects: return True if any(p in self.derived for p in rec.derived_from): return True return False def recall_gated( query_neighbors: Iterable[Record], now: float, tombstones: TombstoneSet | None, max_staleness_s: float, tombstone_age_s: float, ) -> list[Record]: if tombstones is None: # Fail closed: no tombstone view means no recall. return [] if tombstone_age_s > max_staleness_s: raise ErasureContractViolation( f"tombstone view stale by {tombstone_age_s:.3f}s " f"(bound {max_staleness_s:.3f}s); refusing to serve recall" ) served: list[Record] = [] for rec in query_neighbors: if rec.expires_at <= now: continue # TTL expiry: soft, read-path predicate if tombstones.is_erased(rec): raise ErasureContractViolation( f"recall would serve erased record {rec.record_id} " f"(subject={rec.subject_id}); cache TTL had not expired" ) served.append(rec) return served def forget( subject_id: str, record_ids: Iterable[str], tombstones: TombstoneSet, primary_delete, cache_invalidate, ) -> None: """Write-ahead erasure. Tombstone first, then primary, then cache. Any crash between steps leaves the gate closed, never open.""" ids = list(record_ids) tombstones.subjects.add(subject_id) for rid in ids: tombstones.records.add(rid) # Only after the gate is durable do we mutate the store. primary_delete(subject_id, ids) cache_invalidate(subject_id, ids) ```