# Why does an instance resurrect deleted memory when a scoped forget is issued mid-consolidation? **Date of Record:** 2026 November 26 **Scope:** Applies to agents exposing read/write/forget memory tool APIs where `forget(scope, subject_id)` must produce GDPR-compliant erasure of a subject's data while a background episodic-to-semantic consolidation process is concurrently distilling episodic records into derived semantic summaries. Does not apply to single-threaded memory stores with no derived/summarized layer, nor to purely append-only logs where deletion is implemented as tombstoning at read time only. ## Core Distinction The critical distinction is between **erasure of source records** and **erasure of derived state that was materialized from those records**. A `forget` call that removes episodic rows and marks the subject tombstoned is *not* equivalent to erasure when the memory subsystem maintains a semantic layer (summaries, embeddings, learned preferences, distilled facts) that was computed from the now-deleted episodic records. The failure mode is not "the row survived"—it is "the *meaning* of the row survived in a derived artifact that the retention policy does not know to invalidate." This is precisely the boundary where GDPR Article 17 semantics and the agent's internal memory architecture collide. The regulation requires erasure of personal data; the agent's consolidation pipeline has, by design, transformed personal data into higher-order representations that no longer carry the original `subject_id` foreign key. The forget API, scoped by `subject_id`, has no referential path to reach those derived artifacts. ## What Was Observed An agent with a three-tier memory tool API (`read_memory`, `write_memory`, `forget_memory`) was processing support conversations. `write_memory` accepted records tagged with `subject_id` and a `retention_class`. A background job named `consolidate` ran every N minutes: it pulled recent episodic records for active subjects, passed batches to the model to produce semantic summaries ("user prefers async contact," "user is migrating from vendor X"), and wrote those summaries with `derived_from: [episodic_ids]` but with `subject_id` set to `null` because the summarizer prompt was not given—and the schema did not require—the originating subject. The failure trace: 1. `forget_memory(subject_id=S-4471, scope="all")` was issued at T0. The handler deleted all episodic rows for S-4471, wrote a tombstone, and returned success. The API contract was satisfied: no row with `subject_id=S-4471` existed. 2. The `consolidate` job had already *read* S-4471's episodic batch at T0−90s into its working set (an in-memory list of records fetched before the forget committed). 3. At T0+30s the consolidator completed its LLM call and wrote a semantic summary record with `derived_from` pointing at episodic IDs that no longer existed, and `subject_id: null`. The write succeeded because there was no foreign-key constraint from `derived_from` to episodic rows, and no policy check that the source IDs were still live. 4. At T0+6h a new session for S-4471 called `read_memory(subject_id=S-4471)`. The retriever, searching by semantic similarity over the summary layer, surfaced the orphaned summary as context. The agent greeted the user with knowledge that had been legally erased. The resurrection was not a retrieval bug. It was a **read-modify-write race between the forget transaction and an in-flight consolidation whose read snapshot predated the forget**. The consolidator's LLM call acted as a long-lived buffer holding deleted data across the erasure boundary, then flushed it back into the store under a new, unlinkable key. ## Condition of Validity The erasure invariant holds only if the following condition is enforced at the storage layer, not the application layer: > **No derived record may be committed whose `derived_from` set intersects a tombstoned or deleted source record, evaluated at commit time—not at read time.** Two properties make this non-trivial: - **Consolidation latency exceeds forget latency.** The LLM call inside `consolidate` is the long pole (seconds to minutes). The forget transaction is fast. The window between "consolidator reads" and "consolidator writes" is exactly the window in which erasure must be respected, and it is the window no naive implementation guards. - **Derived records are deliberately de-identified.** By design, semantic summaries drop the `subject_id` to avoid re-identification in the summary layer. This is good privacy hygiene and terrible erasure hygiene: it removes the very key the forget API uses to find what to delete. The `derived_from` lineage is the *only* path back, and only if it is enforced as a referential integrity constraint. If either property is absent—if consolidation is synchronous, or if derived records retain `subject_id`—the failure is masked and the invariant appears to hold for the wrong reason. ## Decision Boundary The boundary is drawn between **optimistic erasure** (delete sources, trust that nothing in flight will re-materialize them) and **lineage-checked erasure** (delete sources AND invalidate the lineage, rejecting any derived write that references a deleted source). The decision rule at the consolidator's commit step: - If `derived_from ∩ deleted_ids == ∅` → commit the derived record. - If `derived_from ∩ deleted_ids ≠ ∅` → **reject the write and discard the LLM output**. Do not attempt to "scrub" the summary, because the model may have paraphrased the subject's data into a form where substring matching fails; the only safe action is to drop the entire derived artifact. - If the consolidator cannot determine the deleted set (e.g., it read before the tombstone was published to its view) → fail closed: reject the write. The `deleted_ids` set must be a durable, monotonically growing structure (a tombstone table with a TTL at least as long as the maximum consolidation latency), consulted inside the same transaction that commits the derived record. Reading it outside the transaction reintroduces the race. ## Operational Effect With lineage-checked erasure enforced, the observed behavior changes at three points: 1. **Forget latency becomes bounded by consolidation latency, not by the delete statement.** A `forget_memory` call is only *complete* when all in-flight consolidations that read the subject have either committed (and been rejected) or drained. The API must return a `pending_derivations` count, or block until zero, or the caller cannot truthfully claim erasure. Returning success at T0 while a consolidator holds the data at T0−90s is a false attestation. 2. **Consolidator LLM calls become revocable.** The pipeline must re-check the tombstone set after the model returns and before the write commits. The model output is treated as untrusted input to the store, not as a trusted author. 3. **The semantic layer gains a garbage-collection obligation.** Orphaned summaries whose `derived_from` sources are all deleted must be swept, because they may have been committed before the tombstone existed (the pre-existing backlog). This is a separate reconciliation job, not a property of the forget path. The residual risk after these guards is the **re-identification channel**: a summary that never stored `subject_id` but that a future retriever can still associate with the subject through behavioral similarity. Lineage checking prevents the *write*; it does not prevent the *inference*. That boundary is outside the store's reach and must be handled by not retaining the summary at all once its lineage is dead. ```python from dataclasses import dataclass, field from typing import Iterable class ErasureLineageViolation(RuntimeError): """Raised when a derived record references a source that has been erased.""" @dataclass class MemoryStore: deleted_ids: set[str] = field(default_factory=set) derived: dict[str, dict] = field(default_factory=dict) def forget(self, subject_id: str, source_ids: Iterable[str]) -> None: # Source rows are gone; tombstone them so in-flight consolidators # cannot re-materialize their meaning. for sid in source_ids: self.deleted_ids.add(sid) def commit_derived(self, derived_id: str, derived_from: list[str], payload: dict) -> None: # Evaluated at commit time, inside the store's critical section. collision = set(derived_from) & self.deleted_ids if collision: raise ErasureLineageViolation( f"derived record {derived_id!r} references erased sources {sorted(collision)}; " f"discarding LLM output to preserve erasure invariant" ) self.derived[derived_id] = {"derived_from": derived_from, "payload": payload} def consolidate(store: MemoryStore, batch: list[dict], summarize) -> None: # The read snapshot is taken here; the LLM call below may outlive a forget. source_ids = [r["id"] for r in batch] summary_payload = summarize(batch) # long-lived buffer holding erased data # Re-check happens only at commit; if forget landed mid-call, we fail closed. store.commit_derived( derived_id=f"summary:{source_ids[0]}", derived_from=source_ids, payload=summary_payload, ) ```