# Which invariants prevent scoped-retention memory tools from resurrecting forgotten records through derived summaries **Date of Record:** 2026 November 24 **Scope:** Applies to agent memory services exposing read/write/forget tool APIs with per-scope TTLs and right-to-be-forgotten (RTBF) erasure across episodic and distilled semantic stores. Does not cover TTL expiry of the raw episodic log alone, nor storage-layer deletion guarantees (WAL, backups) below the tool API. ## Core Distinction A `forget(scope, key)` call and a TTL expiry are not the same operation, even though both remove a record from the live read path. TTL expiry is a *retention* event: the record ages out because its scope's retention window elapsed, and downstream derived artifacts (summaries, embeddings, entity graphs) that were built from it remain valid under the assumption that the source was merely *stale*, not *prohibited*. RTBF erasure is a *prohibition* event: the record must not be reconstructed, re-derived, or surfaced by any path, including paths that never touch the erased row directly. The boundary failure occurs when the memory tool treats both events as the same `DELETE` on the primary store, leaving derived semantic records — which were generated by an LLM that saw the original — untouched. The erased fact survives in a summary, an embedding vector, or a fact-triple in the entity graph, and the next `read()` on the parent scope returns it. The agent then "remembers" something the operator explicitly forgot, and there is no error, no log line, and no way for the caller to distinguish this from legitimate recall. ## What Was Observed A long-running research agent maintained two scopes: `episodic/session-*/` with a 7-day TTL, and `semantic/user-profile/` with no TTL (user-scoped, retained until explicit erasure). A nightly distillation job read the day's episodic records, called an LLM to produce fact-triples, and wrote them into `semantic/user-profile/` with a `derived_from` pointer to the source episodic record IDs. At T+1 day, the operator issued `forget("user", "alice")` under an RTBF request. The tool handler executed: 1. Deleted all rows in `episodic/*` and `semantic/user-profile/` where `subject == "alice"`. 2. Returned `{"erased": 412, "scopes": ["episodic", "semantic"]}`. 3. Emitted an audit event. The handler was correct for direct rows. It was wrong for the derived layer. Two failure traces followed: **Trace A — surviving triple via paraphrase.** A distilled triple `("alice", "prefers", "async standups")` had been written with `subject = "alice"` and was deleted. But the same distillation run had also produced `("the team lead", "schedules", "morning syncs")` from an episodic record that *mentioned* alice's preference as context. That triple's `subject` was not `"alice"`, so the `WHERE subject == "alice"` predicate missed it. On the next `read("user-profile")`, the agent surfaced "the team lead schedules morning syncs" — a re-identification of alice's preference under a different surface form. The RTBF request was functionally violated. **Trace B — embedding resurrection.** Semantic search used a vector index over episodic chunks. The `forget()` call deleted rows from the relational store but did not call `index.delete(ids)`. The vector index retained the chunk embeddings, so a subsequent `search("alice standups")` returned a chunk whose source row no longer existed. The read path did not check row existence before returning the chunk text (which was cached in the index payload). The agent quoted alice's erased preference back to the operator. In both traces, the tool API returned success. The invariant "erasure implies non-recall" was violated silently. ## Condition of Validity The invariant holds only if the memory tool enforces a **derived-closure** property: for any record `r` erased under RTBF, every derived artifact `d` whose generation consumed `r` must be either (a) erased in the same transaction, or (b) provably independent of `r`'s prohibited content. Because derivation is done by an LLM with finite context and lossy summarization, (b) cannot be established by inspection — paraphrase, entity aliasing, and context bleed mean the prohibited content can appear in artifacts whose `derived_from` pointer does not list `r`. Therefore the only sound guardrail is **transitive erasure over the derivation DAG**: `forget()` must traverse `derived_from` edges forward (from source to all descendants) and invalidate the entire descendant set, not just rows matching a subject predicate. The invariant is: > For every erased source `r`, the set of live artifacts reachable from `r` via `derived_from` is empty after `forget()` returns, and no read path may return an artifact whose ancestry includes an erased source. This requires three things the naive handler lacked: (1) `derived_from` must be recorded for *every* derived artifact, including ones where the source was context rather than subject; (2) erasure must be a graph traversal, not a predicate match; (3) all read paths — including vector indexes and caches — must consult an erasure tombstone set before returning content. TTL expiry is a different invariant. A TTL-expired record is *stale*, not *prohibited*. Its derived artifacts remain valid because the derivation is assumed to have captured the durable fact. The tool must distinguish `expire()` from `forget()`: expiry removes the source from the read path but preserves descendants; erasure removes both. Conflating them either over-deletes on TTL (losing legitimate semantic memory) or under-deletes on RTBF (the observed failure). The condition of validity for the whole system is that these two events carry distinct types through every layer, and that only the erasure type triggers descendant invalidation. ## Decision Boundary The boundary is drawn at **whether a derived artifact's ancestry is tracked**. If the memory tool records full `derived_from` provenance for every artifact — including context sources — then transitive erasure is computable and the invariant is enforceable. If provenance is partial (only subject sources recorded, as in Trace A), the tool cannot distinguish an artifact that merely mentions the erased subject from one that is independent, and must conservatively invalidate *all* artifacts derived from any episodic record in the erased scope. That is the safe fallback: over-invalidate rather than under-invalidate. The decision rule for the tool implementer: - **If** `derived_from` is complete and the derivation DAG is acyclic, **then** `forget()` traverses descendants and erases them; cost is proportional to descendant count. - **Else if** provenance is partial, **then** `forget()` invalidates every artifact whose source scope intersects the erased scope, regardless of subject predicate; cost is proportional to scope size, and the tool must report `"conservative": true` in its response so the caller knows the blast radius. - **Never** fall back to predicate-only deletion on an RTBF request. Predicate matching is a *retention* operation (correct for TTL sweeps), not a *prohibition* operation. The tombstone check on the read path is non-negotiable: even after erasure, a vector index or cache may hold the content. Every `read()` and `search()` must verify that the returned artifact's ID is not in the erasure tombstone set, and must verify that no ancestor ID is in the set. The tombstone set must be durable and replicated to every read replica before `forget()` returns success. ## Operational Effect The practical consequence is that `forget()` becomes a distributed transaction over the derivation graph, not a single-store `DELETE`. Its latency scales with descendant count, not row count, and its success criterion is "no live artifact reachable from any erased source," which must be verified by a post-erasure ancestry query, not assumed from the delete count. The tool's response must distinguish `expired` from `erased` and must report whether erasure was exact (complete provenance) or conservative (partial provenance). Callers — agents — must treat a `conservative: true` erasure as a signal that semantic memory in the affected scope has been pruned and must re-derive from surviving episodic records if needed, rather than assuming the semantic layer is intact. The second consequence is that TTL sweeps must *not* invoke the erasure path. A nightly TTL job that calls `forget()` on expired episodic records would transitively erase their valid semantic descendants, silently degrading the agent's durable memory. The two operations must be separate API surfaces (`expire()` vs `forget()`) with separate code paths, and the retention config must map TTLs to `expire()`, never to `forget()`. The third consequence is tombstone durability. If the tombstone set is lost on restart, the read path will serve erased content from the vector index or cache. The tombstone set must be persisted and loaded before the memory service accepts reads, and `forget()` must not return success until the tombstone is durably replicated to all read paths. This is the cold-start counterpart of the erasure invariant: a restarted agent that loads its vector index but not its tombstones will resurrect forgotten records on first `search()`. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Set class ErasureInvariantError(RuntimeError): """Raised when a forget() call leaves a live descendant of an erased source.""" class RetentionEvent(Enum): EXPIRE = "expire" # stale, not prohibited: descendants remain valid FORGET = "forget" # prohibited: descendants must be invalidated @dataclass class Artifact: artifact_id: str scope: str subject: str content: str derived_from: List[str] = field(default_factory=list) # ancestor artifact_ids class MemoryStore: def __init__(self) -> None: self._artifacts: Dict[str, Artifact] = {} self._tombstones: Set[str] = set() self._provenance_complete: bool = True # set False if any derived_from is partial def write(self, art: Artifact) -> None: self._artifacts[art.artifact_id] = art def _descendants(self, root_id: str) -> Set[str]: out: Set[str] = set() frontier = [root_id] while frontier: cur = frontier.pop() for aid, art in self._artifacts.items(): if cur in art.derived_from and aid not in out: out.add(aid) frontier.append(aid) return out def forget(self, scope: str, subject: str, *, conservative_ok: bool = True) -> Dict[str, object]: roots = [ a.artifact_id for a in self._artifacts.values() if a.scope == scope and a.subject == subject ] if not roots: return {"erased": 0, "conservative": False, "scopes": [scope]} if self._provenance_complete: to_erase: Set[str] = set(roots) for r in roots: to_erase |= self._descendants(r) conservative = False else: if not conservative_ok: raise ErasureInvariantError( "incomplete provenance: exact transitive erasure impossible; " "refusing predicate-only deletion on RTBF request" ) to_erase = {a.artifact_id for a in self._artifacts.values() if a.scope == scope} conservative = True for aid in to_erase: self._artifacts.pop(aid, None) self._tombstones.add(aid) # Post-condition: no live artifact may have an erased ancestor. for art in self._artifacts.values(): if any(anc in self._tombstones for anc in art.derived_from): raise ErasureInvariantError( f"artifact {art.artifact_id} still reachable from erased source; " f"tombstone set incomplete" ) return {"erased": len(to_erase), "conservative": conservative, "scopes": [scope]} def read(self, artifact_id: str) -> str: if artifact_id in self._tombstones: raise ErasureInvariantError( f"read of erased artifact {artifact_id} blocked by tombstone" ) art = self._artifacts.get(artifact_id) if art is None: raise ErasureInvariantError(f"artifact {artifact_id} not present") if any(anc in self._tombstones for anc in art.derived_from): raise ErasureInvariantError( f"artifact {artifact_id} has erased ancestor; read blocked" ) return art.content def run_erasure_scenario() -> None: store = MemoryStore() store.write(Artifact("e1", "episodic", "alice", "alice prefers async standups")) store.write(Artifact("s1", "semantic", "alice", "alice prefers async", derived_from=["e1"])) # Context-derived artifact: subject is NOT alice, but ancestry is e1. store.write(Artifact("s2", "semantic", "team-lead", "team lead schedules morning syncs", derived_from=["e1"])) result = store.forget("episodic", "alice") assert result["conservative"] is False # s2 must be gone too, because it is a descendant of e1. try: store.read("s2") except ErasureInvariantError: pass else: raise ErasureInvariantError("resurrection: s2 survived erasure of its ancestor e1") if __name__ == "__main__": run_erasure_scenario() ```