# Which invariants prevent retention-scope resurrection during right-to-be-forgotten erasure in agent memory tool APIs **Date of Record:** 2026 November 30 **Scope:** Applies to agents that expose read/write/forget memory tool calls with per-record retention scopes and a forget operation intended to enforce erasure. Does not apply to append-only audit logs that are architecturally exempt from forget, nor to stateless single-turn agents with no persistent store. ## Core Distinction A `forget(record_id)` call is not a deletion; it is a *tombstone assertion* that must dominate every subsequent read path. The boundary failure is **scope resurrection**: a record erased under one retention scope re-enters the agent's context because a *different* scope class—a derived summary, an embedding index, a cached episodic buffer, or a peer agent's replica—retains an independent copy whose lifecycle was never joined to the tombstone. The invariant that prevents this is not "delete then filter." It is: **every derived representation of a record carries the record's erasure lineage, and no read path may emit bytes whose lineage contains a tombstoned ancestor.** Erasure must be a property of the lineage graph, not of a row. ## What Was Observed An agent wrote an episodic memory `M17` ("user's home address, scope=session, retention=30d"). A distillation step at session end produced semantic summary `S4` ("user resides at
, scope=longterm, retention=indefinite") and an embedding vector `E4` in the vector index, both derived from `M17` but written with `derived_from` recorded only as a soft string tag, not as a lifecycle edge. At day 12 the user invoked right-to-be-forgotten against `M17`. The `forget` tool correctly tombstones `M17`, purges the raw row, and returns `{"status":"erased","scope":"session"}`. The agent then resumed a new session, called `memory.search("where does the user live")`, and the retrieval path returned `S4` and `E4` with high similarity. The agent answered with the erased address. Two failure traces compounded: 1. **Lineage severance at distillation.** The distiller copied content into a new scope but did not propagate the `erased_by` predicate or the parent's tombstone pointer. The summary was a legal, live record in `longterm` scope. 2. **Scope-blind retrieval.** The search tool filtered by scope *of the querying session* (which had no access to `session`-scoped rows) but `S4` was `longterm`, so the scope filter passed. No read path consulted the tombstone table because the tombstone was keyed on `M17`, and `S4` was keyed on `S4`. A second observation on the write side: a retry of the original `write(M17)` tool call (the agent re-issued it after a timeout, unaware the first call succeeded) recreated a fresh `M17'` with a new record_id and no tombstone, because the tombstone was keyed on the *old* id. Idempotency key was absent; the erasure was defeated by a duplicate write, not by a bug in `forget`. ## Condition of Validity The erasure invariant holds only under all of the following, and fails silently if any is absent: - **Lineage edges are first-class and immutable.** Every derived record stores `parents: [record_id]` written by the store, not by the model. A model-authored `derived_from` string is not a lineage edge. - **Tombstones are transitive at read time.** A read of record `R` must resolve `ancestors(R)` and reject if any ancestor is tombstoned. This is a read-path obligation, not a write-path cleanup, because derived records may be created before or after the forget in any order. - **Tombstones are keyed on a content-stable identity, not on the row id.** The re-write case (`M17'`) requires a `content_fingerprint` (normalized hash of the semantic payload) recorded in the tombstone set, so a re-inserted duplicate is caught at write time and rejected or immediately re-tombstoned. - **Scope filters and tombstone filters are conjunctive, never disjunctive.** A record passes only if `scope_allows(query_scope, R.scope) AND NOT tombstoned_ancestor(R)`. - **Vector and summary indexes are invalidated by lineage, not by exact id.** An ANN index entry for `E4` must carry its parent lineage so that a tombstone on `M17` removes or shadows `E4` at query time. If any derived store is outside the lineage graph—a peer agent's replica, a model's in-context copy from a prior turn, a fine-tune snapshot—the invariant does not hold for that store and must be declared out of scope explicitly rather than assumed covered. ## Decision Boundary The operational line is: **a forget is complete only when the tombstone set dominates the transitive closure of the record's lineage across every store the agent can read from.** The decision boundary for the agent is therefore: - If `forget` returns success but the lineage closure includes stores the agent cannot enumerate (peer replicas, external caches), the agent must treat the erasure as *provisional* and must not assert "forgotten" to the user. It must escalate to a coordinator that owns those stores. - If a read returns a record whose `ancestors` cannot be resolved (missing lineage metadata), the read must **fail closed**—reject the record—rather than emit it. Fail-open on missing lineage is the exact mechanism of resurrection. - If a write's `content_fingerprint` collides with a tombstoned fingerprint, the write is rejected with a distinct error, not silently dropped, so the caller learns the erasure is being tested. The boundary is between *row deletion* (necessary, insufficient) and *lineage-dominating erasure* (the actual invariant). An agent that treats `forget` as row deletion will pass its own tests and fail in production on the first distillation or retry. ## Operational Effect Enforcing lineage-dominating erasure changes three agent behaviors. First, distillation tools must be *erasure-aware*: a distiller that summarizes a tombstoned record must itself be blocked or must emit a tombstoned summary, so the summary store inherits the predicate. Second, the retrieval tool's contract changes from "return top-k by similarity within scope" to "return top-k whose lineage is tombstone-free," which means the vector index must be queried with lineage shadowing, adding a post-filter that the agent must budget for in latency. Third, retry logic must be idempotent on `content_fingerprint`, so a re-issued write after a timeout cannot resurrect an erased payload. The net effect is that erasure becomes a monotone, transitive predicate over the lineage DAG rather than a point mutation—and the agent can honestly report "erased" only when that predicate is closed over every store in its read set. ```python import hashlib from dataclasses import dataclass, field class ErasureResurrectionError(RuntimeError): """Raised when a read would emit a record whose lineage contains a tombstone.""" class TombstonedWriteError(RuntimeError): """Raised when a write's content fingerprint collides with an erased record.""" @dataclass class Record: record_id: str scope: str payload: str parents: list[str] = field(default_factory=list) def fingerprint(self) -> str: norm = " ".join(self.payload.lower().split()) return hashlib.sha256(norm.encode()).hexdigest() class ScopedMemory: def __init__(self) -> None: self._records: dict[str, Record] = {} self._tombstoned_ids: set[str] = set() self._tombstoned_fingerprints: set[str] = set() def write(self, rec: Record) -> None: if rec.fingerprint() in self._tombstoned_fingerprints: raise TombstonedWriteError( f"write of {rec.record_id} collides with erased fingerprint" ) self._records[rec.record_id] = rec def forget(self, record_id: str) -> None: rec = self._records.get(record_id) if rec is None: return self._tombstoned_ids.add(record_id) self._tombstoned_fingerprints.add(rec.fingerprint()) def _ancestors(self, record_id: str, seen: set[str]) -> set[str]: if record_id in seen: return set() seen.add(record_id) rec = self._records.get(record_id) if rec is None: return {record_id} out = set(rec.parents) for p in rec.parents: out |= self._ancestors(p, seen) return out def read(self, record_id: str, query_scope: str) -> Record: rec = self._records.get(record_id) if rec is None: raise ErasureResurrectionError(f"{record_id} not present") lineage = {record_id} | self._ancestors(record_id, set()) if lineage & self._tombstoned_ids: raise ErasureResurrectionError( f"read of {record_id} blocked: tombstoned ancestor in lineage" ) if rec.fingerprint() in self._tombstoned_fingerprints: raise ErasureResurrectionError( f"read of {record_id} blocked: fingerprint matches erased content" ) if not self._scope_allows(query_scope, rec.scope): raise ErasureResurrectionError( f"scope {query_scope} cannot read {rec.scope}" ) return rec @staticmethod def _scope_allows(query_scope: str, record_scope: str) -> bool: return query_scope == "longterm" or query_scope == record_scope def distill(mem: ScopedMemory, parent_id: str, new_id: str, summary: str) -> None: # Distiller must carry lineage so erasure is transitive. parent = mem._records.get(parent_id) if parent is None: raise ErasureResurrectionError(f"cannot distill missing {parent_id}") mem.write(Record(new_id, "longterm", summary, parents=[parent_id])) ```