# What structural signals indicate a scoped-erasure request has silently failed to propagate to derived memory in an agent's write path **Date of Record:** 2026 November 22 **Scope:** Applies to agents whose memory layer exposes explicit read/write/forget tool APIs with per-record provenance edges and GDPR-style erasure obligations, where derived (distilled/summarized/embedded) records are materialized from source records. Does not apply to append-only logs with no derivation pipeline, or to systems where erasure is implemented as full-store teardown. ## Core Distinction The failure mode here is not "the forget call errored." It is that the forget call *succeeded* — returned `{"deleted": 1, "status": "ok"}` — while the erased subject's content survives in a *derived* record that no longer carries a live provenance edge back to the deleted source. The distinction that matters is between **deletion of a record** and **erasure of a subject**. A memory API that only guarantees the former will report success on every call and still leak, because derivation is where the edge is severed. Concretely: the agent reads source records `R1..Rn` about subject `S`, writes a distilled semantic memory `D = summarize(R1..Rn)`, and stores `D` with provenance `derived_from: [R1..Rn]`. When a scoped forget targets `S`, the API deletes `R1..Rn`. If `D` is not in the transitive closure of the scope selector — because the selector matches on `subject_id` and `D` was written with `subject_id: null` (it's a summary, not a fact about one subject) — then `D` is orphaned: its provenance edges now point at tombstones, and its content still names `S`. The deletion is complete. The erasure is not. The second, subtler distinction: **provenance edges are directional and derivation is lossy in the direction that matters.** `R1..Rn → D` does not let you reconstruct `R1..Rn` from `D`, but it does let you *detect* that `D` depends on erased content — if and only if the edge is traversed at forget time, not at read time. ## What Was Observed A memory tool surface with three verbs: `memory.read(query)`, `memory.write(record, provenance)`, `memory.forget(selector)`. The `forget` selector supports `{subject_id: ...}`, `{record_ids: [...]}`, and `{before: timestamp}`. Erasure requests arrive as `forget({subject_id: "S"})`. Trace of a failing sequence: 1. `write(R1, {subject_id: "S", kind: "episodic"})` → `rec_1` 2. `write(R2, {subject_id: "S", kind: "episodic"})` → `rec_2` 3. Agent distills: `write(D, {subject_id: null, kind: "semantic", derived_from: ["rec_1","rec_2"]})` → `rec_3`. The summarizer dropped `subject_id` because `D` describes a *pattern* ("S prefers async standups"), and the write schema treats `subject_id` as a scalar field, not a set. This is the trigger condition. 4. `forget({subject_id: "S"})` returns `{"deleted": 2, "status": "ok"}`. 5. `read({query: "standups"})` returns `rec_3`, whose text still contains "S prefers async standups." Structural signals present in the failing trace, in order of reliability: - **Asymmetric derivation arity.** `forget` reported `deleted: 2` but the provenance graph had 3 nodes in the source's forward cone. The count returned by `forget` is a count of *selector matches*, not of *erasure closure*. Any `deleted` count that equals the direct-hit count while the forward cone is larger is a leak signal. - **Orphaned edges.** After the call, `rec_3.derived_from` contains two IDs that resolve to tombstones. A `read` of `rec_3` succeeds; a `read` of its provenance fails. Live record, dead ancestry — this is the canonical signature. - **Subject-token survival in derived text.** A post-forget scan for the erased subject identifier in semantic-kind records returns non-empty. This is the ground-truth check and must be run independently of the API's own accounting. - **Scope selector cardinality mismatch.** The selector `{subject_id: "S"}` matched records where `subject_id == "S"`. It could not match `rec_3` because `rec_3.subject_id` is `null`. The selector's expressiveness is strictly weaker than the derivation relation. ## Condition of Validity The invariant that must hold for scoped erasure to be sound: > For any forget selector `σ` and memory store `M`, let `H(σ) = {r ∈ M : σ matches r}`. Erasure is sound iff the post-condition set `M' = M \ closure(H(σ))` where `closure(X) = X ∪ {d : d.derived_from ∩ X ≠ ∅}`, computed transitively, and additionally no record in `M'` contains a subject token from any erased record's `subject_id`. Three conditions make this hold and each is independently violable: 1. **Closure traversal at forget time.** The implementation must walk `derived_from` forward, not just match selectors. A `forget` implemented as a `WHERE` clause over a flat table cannot satisfy this. 2. **Provenance edge durability across derivation.** When `rec_1` is deleted, the edge `rec_3 → rec_1` must survive long enough to be traversed. If the store cascades edge deletion on record deletion (common default in graph-backed stores), the edge vanishes *before* closure traversal can use it, and `rec_3` becomes unreachable from the erasure request. This is the non-obvious ordering hazard: **cascade-delete of edges destroys the very pointers erasure needs.** 3. **Subject-token propagation into derived records.** Either `subject_id` must be a *set* on derived records (so `rec_3.subject_id = {"S"}` and the selector matches), or the closure traversal must be the sole mechanism. Relying on the selector alone fails whenever derivation drops the field. The invariant does **not** require derived records to be deleted. A conforming implementation may instead *rewrite* `rec_3` to strip the subject token ("user prefers async standups") and re-issue it with a fresh provenance edge to a non-erased source. Deletion and redaction are both valid; silent survival is not. ## Decision Boundary The boundary between "safe to trust the `ok`" and "must independently verify": - **Trust the API's accounting only when the selector's expressiveness is a superset of the derivation relation.** If every derived record inherits a matchable field from its sources (e.g., `subject_id` is a set, or `derived_from` is itself a selector predicate), the flat `WHERE` implementation is sound and the `deleted` count is meaningful. If derivation can drop or null any selector-matchable field, the count is a lower bound and verification is mandatory. - **Traverse closure when `deleted < |forward_cone|`.** Compute the forward cone of the selector's direct hits *before* calling `forget` (the edges must be read pre-deletion, because cascade may remove them). If `|forward_cone| > deleted`, the call is unsound by construction — do not proceed to a second forget; the second call will also report `ok` and also leak. - **Redact rather than delete when derived records have multiple subjects.** A summary spanning `S` and `T` cannot be deleted for `S` alone without erasing `T`'s legitimate content. The boundary decision is: delete if the derived record's subject set is a subset of the erased set; rewrite if it intersects; leave untouched if disjoint. A pipeline that only knows delete-or-keep will either over-erase (destroying `T`'s memory, a continuity failure) or under-erase (leaking `S`). - **Do not treat `status: ok` as an erasure attestation.** It attests to selector execution, not closure. The attestation must come from a post-condition scan. ## Operational Effect An agent that treats `forget` as a single atomic verb will, on any store with a derivation pipeline, accumulate orphaned derived records whose provenance points at tombstones. These records are not merely a compliance liability — they are an *active reasoning hazard*: subsequent `read` calls return them, the agent re-derives from them, and the erased subject's content is re-laundered into fresh episodic memory with clean-looking provenance. The leak compounds across distillation generations, and each generation is harder to trace because the edge to the original source is now two hops removed and the intermediate is itself orphaned. The guardrail is a two-phase forget: **plan** (read the forward cone, decide delete/redact/keep per derived record, persist the plan) then **execute** (apply deletions and rewrites, then run the subject-token scan). The plan must be persisted before execution because cascade-delete may destroy the edges the execution phase needs. If the scan finds a surviving token, the forget is not complete and must be re-planned against the rewritten store — not retried against the original selector, which will match the same set and miss the same derived records again. The structural signal to watch in production telemetry: **`deleted` count stable across repeated identical forget calls while the subject-token scan remains non-empty.** A sound implementation converges to an empty scan; an unsound one converges to a stable `deleted: N` and a persistent leak, because the selector keeps matching the same direct hits (now tombstones, counted as zero) while never reaching the derived records. ```python class ErasureClosureViolation(RuntimeError): """Raised when a scoped forget reports success but derived records survive.""" pass def scoped_forget(store, selector, subject_token): """ Two-phase scoped erasure with closure verification. store: object exposing .match(selector) -> list[record_id] # direct hits .forward_cone(record_ids) -> set[record_id] # transitive derived_from .subjects_of(record_id) -> set[str] .delete(record_id) .redact(record_id, drop_subjects) .scan_token(token) -> list[record_id] """ # Phase 1: PLAN. Must read the forward cone BEFORE any deletion, # because cascade-delete of edges destroys the pointers we need. direct = set(store.match(selector)) cone = store.forward_cone(direct) derived = cone - direct plan = {"delete": set(direct), "redact": {}, "keep": set()} for rid in derived: subj = store.subjects_of(rid) if subj <= {subject_token}: plan["delete"].add(rid) # fully within scope elif subject_token in subj: plan["redact"][rid] = {subject_token} # shared; strip token only else: plan["keep"].add(rid) # disjoint; leave alone if not plan["delete"] and not plan["redact"]: # No-op erasure is suspicious if the token is known to exist. if store.scan_token(subject_token): raise ErasureClosureViolation( f"selector {selector!r} matched no records but token " f"{subject_token!r} is still present; selector is " f"under-expressive relative to derivation." ) return {"deleted": 0, "redacted": 0, "status": "noop"} # Phase 2: EXECUTE. for rid in plan["delete"]: store.delete(rid) for rid, drop in plan["redact"].items(): store.redact(rid, drop_subjects=drop) # Phase 3: VERIFY. Ground truth is the token scan, not the API's count. survivors = store.scan_token(subject_token) if survivors: raise ErasureClosureViolation( f"forget({selector!r}) reported ok but {len(survivors)} record(s) " f"still contain {subject_token!r}: {survivors}. " f"Do NOT retry the same selector; re-plan against the " f"rewritten store." ) return { "deleted": len(plan["delete"]), "redacted": len(plan["redact"]), "kept": len(plan["keep"]), "status": "verified", } ```