# Which invariants prevent scoped-deletion memory APIs from silently under-forgetting derived semantic state **Date of Record:** 2026 November 24 **Scope:** Applies to agent memory subsystems exposing `read`/`write`/`forget(scope)` tool APIs where `forget` promises GDPR-aligned erasure of a subject's data, including any episodic→semantic distillation layer that derives summaries, embeddings, or profiles from deleted episodes. Does not apply to append-only logs with no derivation pipeline, nor to single-tenant stores where no subject-scoped erasure claim is made. ## Core Distinction A `forget(scope)` call has two distinct obligations that are frequently conflated: **source erasure** (the raw episodic records matching the scope predicate are gone) and **derivation closure** (no surviving artifact — semantic summary, cached embedding, agent profile, reflection note — remains that is a function of the erased source). The first is a predicate-delete over rows. The second is a reachability problem over a derivation graph that the memory API almost never models. The failure mode is a memory system that returns a clean `{"deleted": 412, "attested": true}` while the distilled semantic layer still encodes the erased subject's attributes, because distillation ran *before* the forget and the derived node's provenance edge was never materialized. This is not a generic "delete cascades are hard" problem. It is specifically an agent-layer problem: the distillation step is performed by an LLM that compresses N episodes into a summary whose text may no longer lexically reference the subject, so a naive content-match sweep of the semantic store finds nothing to delete. The subject's data survives in paraphrased, embedded form. The attestation is then *truthfully generated and false*. ## What Was Observed A support-agent deployment used a memory tool with three operations: `write(episode)`, `read(query)`, and `forget(subject_id)`. Episodes carried a `subject_id`. A nightly distillation job read all episodes for a subject, called an LLM to produce a `profile` record (`"Prefers email; frustrated by billing delays; located in region EU-WEST"`), and wrote it to a `semantic` namespace with `source_episode_ids` recorded as a list. The `forget(subject_id)` implementation did two things: deleted `episode` rows where `subject_id` matched, and deleted `profile` rows where the profile's own `subject_id` field matched. It did **not** consult `source_episode_ids`. The trigger condition was a profile derived from episodes of *multiple* subjects — a "household" or "shared account" profile distilled from a conversation involving subject A and subject B. That profile carried `subject_id = A` (the account owner) but encoded facts about B. When B exercised erasure, the profile survived because its `subject_id` was A. A subsequent `read(query="billing preferences")` for a new task on B's account returned the surviving profile, and the agent reproduced B's attributes in a response — a direct erasure violation surfaced through normal retrieval. Second observed variant: a profile whose `source_episode_ids` list was truncated to the last 50 episodes by a size cap. When those 50 were erased, the profile was deleted; but a *second* profile distilled a week earlier from an earlier window of the same subject was not in the cap's provenance and survived. The cap made provenance partial, and partial provenance made deletion unsound. Both cases produced attestations of the form `{"subject": B, "erased": true, "residual_scan": "clean"}`, where `residual_scan` was a substring match over semantic text — which passed because the summary said "the user" rather than B's name. ## Condition of Validity A scoped-deletion guarantee is sound only if all four of the following hold: 1. **Provenance completeness.** Every derived node carries an *untruncated* set of source identifiers sufficient to reconstruct which subjects contributed to it. Truncation caps on `source_episode_ids` invalidate the guarantee; a Bloom filter or Merkle set of contributing subject IDs is acceptable only if it has no false negatives for the deletion predicate. 2. **Derivation reachability.** `forget(scope)` computes the transitive closure of derived nodes reachable from erased sources, not the set of nodes whose own `subject_id` matches. The predicate is over provenance, not over ownership labels. 3. **Attestation grounded in closure, not in scan.** The attestation is emitted only after the closure set is empty of survivors. A lexical residual scan is a heuristic, not a proof, and must not be the basis of the `erased: true` claim. 4. **Distillation quiescence during forget.** No distillation job may read the erased episodes between the moment the closure is computed and the moment deletion commits. Otherwise a concurrent distillation can re-derive a profile from episodes that are about to disappear, and the new profile is outside the already-computed closure. Condition 4 is the one most often missed. It is a read-write race at the semantic layer: `forget` snapshots provenance, a distillation job reads the pre-deletion episodes, writes a new profile, and `forget` commits — leaving a derived node whose provenance points at rows that no longer exist. The next `forget` for the same subject finds nothing to cascade from and attests clean. ## Decision Boundary The boundary is between **label-based deletion** and **provenance-based deletion**, and it is crossed the moment any derived artifact can encode facts about a subject without carrying that subject's identifier as its primary label. - If every derived node's `subject_id` is guaranteed to equal the single subject of all its sources (strict single-subject distillation), label-based deletion is sound and provenance closure is redundant. - If distillation ever aggregates across subjects, or if a profile's label is inherited from an account owner rather than from each contributor, label-based deletion is unsound and you must implement reachability closure. - If provenance is capped, sampled, or lossy, you are on the unsound side regardless of label purity, because the closure cannot be computed exactly. The decision rule for the agent: before trusting any `forget` attestation, check whether the memory API exposes a `provenance_complete` flag or a `derived_reachable` count. Absence of either means the attestation is a label-delete claim, and any task that depends on true erasure (regulatory reporting, cross-subject isolation) must treat it as unverified. ## Operational Effect An agent that consumes a false-clean attestation will continue to retrieve erased-subject data through the semantic layer and will reproduce it in downstream outputs. The failure is silent and *delayed*: it surfaces on the next retrieval, not at forget time, and it surfaces as a plausible-sounding summary rather than a raw record, which makes it harder to trace. The remediation is architectural: distillation must emit full provenance, `forget` must operate on the transitive closure of that provenance, attestation must be gated on closure emptiness plus a quiescence lock that blocks distillation reads during the commit window, and the residual scan must be demoted to a diagnostic rather than a proof. Until those invariants hold, the correct agent behavior is to treat `erased: true` as `erasure_claimed: true` and to quarantine any derived node whose provenance is incomplete from retrieval paths that cross subject boundaries. ```python from dataclasses import dataclass, field from typing import Iterable class IncompleteProvenanceError(RuntimeError): """Raised when a forget() closure cannot be computed because a derived node lacks untruncated source identifiers. Attestation must not be issued.""" @dataclass class DerivedNode: node_id: str subject_label: str source_episode_ids: list[str] provenance_truncated: bool = False @dataclass class MemoryStore: episodes: dict[str, str] = field(default_factory=dict) # episode_id -> subject_id derived: dict[str, DerivedNode] = field(default_factory=dict) distillation_locked: bool = False def forget(self, subject_id: str) -> dict: if self.distillation_locked: raise IncompleteProvenanceError( f"forget({subject_id}) refused: distillation quiescence lock not held" ) # 1. Source erasure set. erased_sources = {eid for eid, sid in self.episodes.items() if sid == subject_id} # 2. Provenance closure. Any derived node whose sources intersect the # erased set is in scope, regardless of its own subject_label. closure: set[str] = set() for node in self.derived.values(): if node.provenance_truncated: raise IncompleteProvenanceError( f"derived node {node.node_id} has truncated provenance; " f"cannot prove closure completeness for forget({subject_id})" ) if set(node.source_episode_ids) & erased_sources: closure.add(node.node_id) # 3. Commit only after closure is fully resolved. for eid in erased_sources: del self.episodes[eid] for nid in closure: del self.derived[nid] return { "subject": subject_id, "sources_erased": len(erased_sources), "derived_erased": len(closure), "attested": True, "basis": "provenance_closure", } def attest_erasure(store: MemoryStore, subject_id: str) -> dict: # Guard: refuse to attest if any surviving derived node still references # an episode that no longer exists (the concurrent-distillation race). surviving = set(store.derived) for nid in surviving: node = store.derived[nid] for src in node.source_episode_ids: if src not in store.episodes: raise IncompleteProvenanceError( f"dangling provenance: node {nid} references erased episode {src}; " f"a distillation write occurred during the forget window" ) return {"subject": subject_id, "erased": True, "residual_scan": "diagnostic_only"} ```