# How does an instance detect that a "forget" call has silently orphaned a derived memory it must also erase **Date of Record:** 2026 November 23 **Scope:** Applies to any agent whose memory subsystem exposes explicit `write`/`read`/`forget` tool APIs where `forget` is expected to implement subject-scoped erasure (GDPR Art. 17-style) over *derived* artifacts (summaries, embeddings, distilled facts, cached tool outputs). Does NOT cover passive TTL eviction, log-rotation retention policies, or erasure of the raw transcript store, which are governed by separate retention invariants. ## Core Distinction The failure is not "the forget call returned an error." The failure is that the forget call returned **success** while leaving behind derivative memory records whose provenance chain terminates in the erased subject but whose own content no longer carries the subject identifier. A naive erasure implementation deletes records where `record.subject_id == target` and considers the job done. But an agent that has been running for weeks has, somewhere upstream, called a summarization tool that collapsed three episodic records about a user into one semantic fact — e.g., `"the caller prefers wire transfers and lives in postal code 94103"` — and that distilled record may be stored with `subject_id = null`, `derived_from = [ep_881, ep_902]`, and a free-text body that still contains the personal data. Deleting `ep_881` and `ep_902` succeeds. The distilled record survives. The erasure is reported complete. The data is still there. The core distinction is between **subject-scoped deletion** (delete rows tagged with the subject) and **provenance-closure erasure** (delete the transitive set of records whose derivation graph reaches the subject, regardless of whether they still carry the subject tag). Only the latter satisfies the erasure semantic; only the former is usually implemented, because the former is a single indexed `DELETE` and the latter requires the memory tool to maintain a queryable derivation DAG. The boundary condition is: *a derived record that has been de-identified at write time is invisible to subject-scoped deletion but still recoverable personal data.* ## What Was Observed A long-running assistant agent (14 days uptime, ~9,400 memory records) received an erasure request for subject `u_4471`. The memory tool executed: ``` forget(subject_id="u_4471", scope="all") → {"deleted": 212, "status": "complete", "closure_verified": false} ``` Note `closure_verified: false` — the tool reported it *did not* check the derivation graph, but the orchestrator treated `status: complete` as terminal and marked the erasure ticket closed. A post-hoc audit replayed the derivation log. Of the 212 deleted records, 41 had been inputs to `summarize_episodes` calls whose outputs were written with `subject_id = null` (the summarizer was instructed to "generalize" and stripped the tag as a privacy measure). Those 9 summary records — each containing verbatim fragments like the postal code and a bank nickname — remained readable via `read(query="wire transfer preferences")`. The retrieval path did not filter on subject, because the records had no subject to filter on. The second-order effect was worse: three of the nine orphaned summaries had themselves been re-embedded and were serving as retrieval anchors, so subsequent `read` calls for *other* users were returning the erased subject's data as context. The erasure had not merely failed to delete; it had **propagated the data into active inference context** for unrelated subjects. This is the orphaned-derivative failure: erasure succeeds on the tagged set, silently fails on the derivation closure, and the residue is not inert — it is retrieved. ## Condition of Validity The subject-scoped deletion is a valid erasure **iff** every derived record in the store satisfies at least one of: 1. It retains a `subject_id` (or equivalent subject-bearing tag) that the `forget` predicate matches, **or** 2. Its `derived_from` set is queryable and the `forget` implementation performs a transitive closure over it, **or** 3. It was written under a retention class explicitly excluded from erasure scope by policy, and the erasure report enumerates those exclusions. In practice condition 2 is the one that breaks, because it imposes two requirements most memory tools do not meet: (a) the derivation edge must be recorded *at write time* by the tool that produced the derivative, and (b) the summarizer/distiller must not be permitted to write a record with an empty `derived_from` when it consumed inputs. The common anti-pattern is a "privacy-preserving" distiller that strips both `subject_id` **and** `derived_from` in the same step, on the theory that a record with no provenance is safer. It is the opposite: a record with no provenance is un-erasable by construction, because nothing links it back to the subject whose erasure should have removed it. The invariant to enforce at the memory-tool layer: **no record may be written with `derived_from = ∅` if any tool invocation in its causal history read a subject-tagged record.** A distiller may strip `subject_id` from the body, but it must preserve the derivation edge. De-identification is a property of the *content*; provenance is a property of the *edge*; conflating them is the bug. ## Decision Boundary The instance must distinguish three outcomes of a `forget` call, not two: - **Complete**: tagged set deleted AND closure verified empty (`closure_verified: true`, orphan count 0). - **Partial**: tagged set deleted, closure non-empty, orphans enumerated with their `derived_from` chains. This is a *resumable* state — the orchestrator must either re-issue `forget` with the orphan IDs as targets, or escalate to a human erasure queue. It must NOT be reported as complete. - **Blocked**: closure cannot be computed because a derivation edge is missing (`derived_from = ∅` on a record whose body matches the subject's known identifiers). This is the worst state: the tool knows it cannot prove erasure. It must fail closed — surface the un-provable records, refuse to mark the ticket closed, and flag the retention class for manual review. The decision boundary is the `closure_verified` flag. An orchestrator that treats `status: complete` as sufficient without reading `closure_verified` has accepted an unverified erasure. The guardrail is that the memory tool must **never** emit `status: complete` when `closure_verified` is false — the two fields are coupled, and a tool that decouples them is emitting a lie that downstream automation will act on. ## Operational Effect The observable consequence of getting this wrong is not a crash; it is a **latency-shifted leak**. The erasure request closes cleanly, the audit passes (the tagged set is empty), and the residue surfaces days later as retrieval contamination: an unrelated subject's query returns the erased subject's distilled facts, because those facts are still embedded and still match on semantic similarity. The leak is detected — if at all — by a downstream consumer noticing anomalous context, not by the erasure pipeline. The mitigation has three parts, all at the memory-tool layer: 1. **Provenance-preserving distillation.** The distiller writes `derived_from` unconditionally; stripping it is a hard error, not a privacy feature. 2. **Closure-verified forget.** `forget` computes the transitive closure over `derived_from` before reporting, and couples `status` to `closure_verified`. 3. **Orphan quarantine on partial erasure.** Any record whose closure cannot be resolved is moved to a quarantine retention class and excluded from retrieval immediately, so it cannot contaminate inference context while the erasure is being completed. The instance detects the failure by treating `closure_verified: false` on a `status: complete` response as a contradiction and refusing to proceed — the following guard encodes exactly that check and the resumable-partial path. ```python from dataclasses import dataclass, field from typing import Optional class UnverifiedErasureError(RuntimeError): """Raised when a forget call reports completion without a verified closure.""" pass class OrphanedDerivativeError(RuntimeError): """Raised when erasure leaves derived records whose provenance reaches the subject.""" pass @dataclass class ForgetResult: status: str # "complete" | "partial" | "blocked" deleted: int closure_verified: bool orphans: list = field(default_factory=list) # derived_from chains still live unprovable: list = field(default_factory=list) # derived_from == empty, body matches subject def enforce_erasure(subject_id: str, result: ForgetResult) -> None: """ Gate that an orchestrator MUST run on every forget() response before closing an erasure ticket. Fails closed on any unverified closure. """ # A "complete" that was not closure-verified is a contradiction: the tool # deleted the tagged set but did not prove the derivation closure is empty. if result.status == "complete" and not result.closure_verified: raise UnverifiedErasureError( f"forget({subject_id}) returned status=complete but " f"closure_verified=False; {len(result.orphans)} orphan(s) may " f"still carry derived personal data. Refusing to close ticket." ) # Un-provable records (derived_from empty, body matches subject) are the # worst case: the tool cannot prove erasure. Quarantine, do not proceed. if result.unprovable: raise OrphanedDerivativeError( f"forget({subject_id}) left {len(result.unprovable)} record(s) with " f"no derivation edge but subject-matching content; these are " f"un-erasable by construction. Move to quarantine retention class " f"and exclude from retrieval before resuming." ) # Partial with a resolvable orphan set is resumable: re-issue forget on # the orphan IDs. It is NOT terminal and must not be reported as complete. if result.status == "partial" and result.orphans: raise OrphanedDerivativeError( f"forget({subject_id}) is partial: {len(result.orphans)} derived " f"record(s) still reachable via derived_from. Re-issue forget with " f"orphan IDs as explicit targets; do not close ticket." ) if result.status == "complete" and result.closure_verified and not result.orphans: return # the only path on which the ticket may close ```