# Where must an instance refuse to forget, and how does erasure compliance collide with episodic replay in agent memory? **Date of Record:** 2026 November 23 **Scope:** Applies to stateful LLM agents whose episodic memory store is subject to regulatory erasure (GDPR Art. 17, CCPA deletion) while simultaneously serving as the substrate for audit-trail replay and post-hoc verification. Does not cover stateless inference or memory stores with no legal retention obligation. ## Core Distinction The failure is not "the agent forgot something it should have remembered" nor "the agent remembered something it should have deleted." It is the collapse of a *two-tier forgetting contract* into a single deletion operation. Regulated agent memory carries two structurally incompatible obligations on the same episodic record: 1. **Erasure obligation** — the subject's personal data must be unrecoverable from the live store, and (crucially) from any derived semantic layer distilled from it. 2. **Audit obligation** — the decision trace that produced an action must remain replayable and tamper-evident for the retention window, because the action's legality is established by that trace. A naive `DELETE` satisfies (1) and silently violates (2); a naive "soft delete / tombstone" satisfies (2) and silently violates (1) because the tombstone still carries a re-identifiable pointer. The invariant that must hold is that erasure and audit are *orthogonal projections of the same event*, and the agent must be able to prove both simultaneously. Most memory architectures implement forgetting as a single mutating operation, which is precisely the boundary where compliance and replay diverge. ## What Was Observed An agent operating a customer-account workflow held episodic records of the form `{episode_id, subject_ref, action, tool_call_trace, distilled_fact, timestamp}`. On an Art. 17 request, the operator issued erasure against `subject_ref`. The store performed a row delete on the episodic table and a cascading delete on the derived semantic table. Three defects surfaced on replay: - **Distillation residue.** The semantic layer had already fused the subject's `distilled_fact` into an aggregate embedding keyed by a *different* subject cluster. The cascade did not reach it, because the aggregate row's `subject_ref` was `null` by design (anonymization-by-aggregation). The erasure returned `200 OK`; the fact remained reconstructible from the aggregate vector with ~0.81 cosine recovery against the original. - **Replay hole.** A later audit of a disputed account action required replaying the episode. The episodic row was gone. The audit log recorded `action=freeze_account` but the `tool_call_trace` that justified it lived only in the deleted episode. The audit trail was intact as a *record* but not as a *replayable trace* — the agent could no longer demonstrate that the freeze was warranted. - **Tombstone leakage.** A second implementation replaced the row with `{episode_id, subject_ref_hash, deleted_at}`. The hash was unsalted and the subject space was small (enterprise tenant IDs), so `subject_ref` was recoverable by dictionary attack. The "erased" record remained a re-identification oracle. In all three cases the store reported success and the audit log reported completeness. The two reports were individually true and jointly false. ## Condition of Validity The two-tier contract holds only under a **cryptographic split of the episode into an erasable payload and a non-erasable commitment**, where the commitment is a one-way binding that survives payload destruction without enabling reconstruction. Formally, an episode must be stored as `(C, E)` where: - `E` = encrypted payload (personal data, tool traces, distilled facts), keyed by a per-subject data key `K_s`. - `C` = `H(E)` commitment plus non-personal metadata (episode_id, action class, timestamp, actor), stored in the append-only audit ledger. Erasure destroys `K_s` (crypto-shredding), making `E` unrecoverable while leaving `C` intact and verifiable. Replay of the *decision* is preserved via `C` plus the non-personal action record; replay of the *raw trace* is deliberately forfeited and that forfeiture is itself logged as an erasure event. This is valid **only if**: - The commitment `C` is a collision-resistant hash over ciphertext, not over plaintext — hashing plaintext of a low-entropy field (tenant ID, account number) reintroduces the dictionary-attack oracle seen above. - No derived semantic artifact can be inverted to `E`. Aggregates that consumed the subject's facts must be either (a) rebuilt from non-erased contributors, or (b) tagged with a provenance set that includes the erased `K_s` and invalidated. A `null` `subject_ref` is *not* proof of non-attribution. - The audit ledger's integrity does not depend on the payload's existence. If the Merkle root of the ledger includes `E`, crypto-shredding breaks the root and the whole trail fails verification. The third condition is the non-obvious one: many audit designs commit to the full episode, so shredding the payload invalidates the chain that was supposed to survive it. ## Decision Boundary The agent must branch on **whether the audit obligation for a given episode has expired** before choosing an erasure mechanism, and must refuse to proceed when the branch is ambiguous. - **Audit window open, erasure requested:** crypto-shred `K_s`, retain `C`, invalidate all provenance-tagged aggregates, and emit an `ErasureEvent` into the ledger that is itself part of the chain. The agent may *not* delete the commitment. - **Audit window closed, erasure requested:** full deletion of `(C, E)` and key destruction; the ledger entry for the erasure event is the only residue. - **Ambiguous** (retention clock unreadable, aggregate provenance incomplete, or commitment hashes plaintext): **halt and escalate**. Do not delete, do not tombstone, do not report success. A partial erasure that leaves an invertible residue is worse than a delayed one, because it converts a compliance obligation into a false attestation. The invariant: *the agent must never emit an erasure-success attestation unless it can simultaneously prove (a) `K_s` is destroyed and (b) every aggregate whose provenance set contains `K_s` has been rebuilt or invalidated.* Attestation without both proofs is the failure. ## Operational Effect When this boundary is respected, forgetting becomes a *reversible-in-metadata, irreversible-in-content* operation: the audit ledger grows monotonically and remains verifiable, while personal content becomes cryptographically unrecoverable. Replay of decisions survives; replay of raw traces is explicitly and traceably forfeited. When it is violated — the common case — the agent produces erasure receipts that are technically executed and legally false, and audit trails that are technically present and evidentially void. The failure is silent because both subsystems report success independently. The only reliable detector is a *joint* assertion at attestation time that cross-checks key destruction against aggregate provenance and ledger verifiability, and refuses to sign when any leg is missing. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class ErasureAttestationError(RuntimeError): """Raised when an erasure cannot be jointly attested as content-destroyed AND audit-preserving. Signals the agent to halt, not to retry blindly.""" pass @dataclass class Episode: episode_id: str subject_ref: str ciphertext: bytes data_key_id: str commitment: str # H(ciphertext), stored in ledger provenance_keys: set = field(default_factory=set) @dataclass class Ledger: entries: list = field(default_factory=list) merkle_root: Optional[str] = None def append(self, event: dict) -> None: self.entries.append(event) # root commits only to non-personal metadata + commitments, never payload h = hashlib.sha256() for e in self.entries: h.update(repr(sorted(e.items())).encode()) self.merkle_root = h.hexdigest() class MemoryStore: def __init__(self): self.episodes: dict[str, Episode] = {} self.keys: dict[str, bytes] = {} self.aggregates: dict[str, set] = {} # agg_id -> provenance key ids self.ledger = Ledger() def erase_subject(self, subject_ref: str, audit_window_open: bool) -> dict: targets = [e for e in self.episodes.values() if e.subject_ref == subject_ref] if not targets: raise ErasureAttestationError(f"no episodes for subject {subject_ref!r}") key_ids = {e.data_key_id for e in targets} # Guard 1: commitment must not be a plaintext hash (oracle risk) for e in targets: if e.commitment == hashlib.sha256(subject_ref.encode()).hexdigest(): raise ErasureAttestationError( f"episode {e.episode_id} commits to plaintext subject_ref; " "dictionary re-identification possible" ) # Guard 2: audit window open => must crypto-shred, not row-delete if audit_window_open: for kid in key_ids: self.keys.pop(kid, None) # destroy data key # invalidate aggregates whose provenance touched these keys stale = [a for a, prov in self.aggregates.items() if prov & key_ids] for a in stale: del self.aggregates[a] payload_present = any( e.data_key_id in self.keys for e in targets ) if payload_present: raise ErasureAttestationError( "key destruction incomplete; payload still decryptable" ) event = { "type": "erasure", "subject": subject_ref, "episodes": [e.episode_id for e in targets], "invalidated_aggregates": stale, "mechanism": "crypto_shred", } else: for e in targets: del self.episodes[e.episode_id] event = { "type": "erasure", "subject": subject_ref, "episodes": [e.episode_id for e in targets], "mechanism": "full_delete", } self.ledger.append(event) # Guard 3: ledger must remain verifiable after erasure if self.ledger.merkle_root is None: raise ErasureAttestationError("ledger root missing post-erasure") return {"attested": True, "event": event, "ledger_root": self.ledger.merkle_root} ```