# Which invariants prevent tombstoned memory from resurfacing through summary-derived retrieval in agent read/write/forget interfaces **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose memory subsystem exposes separate `write`, `read`, and `forget` tool calls with provenance metadata and deletion guarantees, and whose read path performs summarization or distillation before returning context. Does not apply to append-only logs with no derived/aggregate tier, nor to single-shot stateless completions. ## Core Distinction A `forget(entity_id)` call that returns `{"deleted": true}` proves only that the *canonical* record was removed from the primary store. It does **not** prove that the entity is absent from derived artifacts: rolling summaries, episodic digests, semantic-cluster centroids, and embedding indexes that were materialized from the record *before* deletion. The failure mode is **resurrection-by-derivation**: a deleted memory re-enters the context window because a derived summary still contains a paraphrase of it, and the read path trusts the derived tier as authoritative. The distinction that matters is between *deletion of the source* and *deletion of the closure over all derivations of the source*. Most agent memory interfaces guarantee the former and are silent on, or actively violate, the latter. ## What Was Observed An agent maintained a `notes` memory with records of the form `{id, text, provenance: {source, timestamp, hash}, ttl}`. A nightly distillation job collapsed episodic notes into a semantic summary node: `summary_17` contained the sentence "User's staging DB password rotation was deferred to the vendor." The underlying record `note_4412` was later forgotten via `forget("note_4412")`, which removed it from the primary table and returned success. Provenance on `summary_17` recorded `derived_from: [note_4409, note_4412, note_4415]` but the read path never consulted `derived_from` at query time. Three days later a query "what is the status of the staging credential rotation?" retrieved `summary_17` by embedding similarity. The agent answered from the summary, re-asserted the deferred-rotation fact, and — critically — *wrote a new note* `note_5120` restating it, with fresh provenance pointing at `summary_17` rather than the forgotten source. The forgotten fact had not merely resurfaced; it had been laundered into a new canonical record with clean provenance. A subsequent `forget("note_4412")` was a no-op because `note_4412` no longer existed, and the agent's own audit reported "no live records reference the forgotten entity." The trace is: `forget` → primary row deleted → derived summary untouched → similarity retrieval hits derived summary → agent re-asserts → agent writes new primary record → provenance chain now points at a *live* record (`note_5120`) whose own provenance is a summary, not the tombstone. ## Condition of Validity The resurrection is only possible when all three hold simultaneously: 1. **Derivation without back-reference enforcement.** The derived artifact stores `derived_from` as advisory metadata that the read path does not filter on. 2. **Forget is shallow.** `forget` operates on the primary key space and does not compute the derivation closure `{d : entity_id ∈ d.derived_from}`. 3. **Read path treats derived tier as ground truth.** Summaries are returned to the model without a "contains tombstoned material" flag, so the model has no signal to distrust them. If any one is broken — read path filters on `derived_from ∩ tombstone_set`, or `forget` invalidates the closure, or summaries carry a `tainted: true` marker after upstream deletion — the resurrection is bounded. The invariant required is: **for every tombstone `t`, the set of readable artifacts `R` must satisfy `R ∩ closure(t) = ∅`, where `closure(t)` is the transitive set of summaries, digests, and index entries whose `derived_from` reaches `t`.** This is a *read-time* invariant, not a write-time one, because derivations are created lazily and cannot all be enumerated at forget time. ## Decision Boundary The agent must decide, at `forget` time, between two contracts, and must not silently pick one: - **Shallow forget (fast, weak):** delete primary record, mark tombstone, and *require* the read path to intersect every returned artifact's `derived_from` against the tombstone set before injection into context. Cost is paid on every read (set intersection over provenance graphs); correctness holds only if reads are provenance-aware. - **Deep forget (slow, strong):** compute `closure(t)`, rewrite or invalidate every derived artifact in it, re-embed affected summaries, and only then return success. Cost is paid once at forget; correctness holds even for provenance-blind read paths, but the forget call becomes O(derivations) and may exceed the tool's timeout budget. The boundary condition: if `closure(t)` is large or unbounded (e.g., a summary-of-summaries tier), deep forget is not feasible within a single tool call, and the only sound choice is shallow forget **plus** a read-path tombstone filter. An interface that returns `{"deleted": true}` without specifying which contract it implements is under-specified and will resurrect. The agent must treat an unqualified success as *shallow* and must never write a new record whose provenance is a derived artifact without first checking that artifact's `derived_from` against the tombstone set. ## Operational Effect Once resurrection-by-derivation occurs, the tombstone set and the live record set diverge in a way that defeats later audits: the forgotten entity is absent from primary storage but present in context, and any new record written from the summary carries *valid-looking* provenance. Deletion guarantees become unverifiable because the evidence of the original fact now lives in a record that was never tombstoned. The practical guardrail is to make provenance a first-class, read-time-checked field and to forbid the agent from writing any record whose `source` is a derived artifact unless that artifact's derivation closure is disjoint from the tombstone set. Without this, `forget` is advisory, not a guarantee. ```python from dataclasses import dataclass, field from typing import Optional class ResurrectionByDerivationError(RuntimeError): """Raised when a read or write would surface material from a tombstoned entity via a derived artifact (summary, digest, index entry) whose derivation closure reaches the tombstone.""" @dataclass class Artifact: id: str kind: str # "primary" | "summary" | "digest" | "index" derived_from: list[str] = field(default_factory=list) text: str = "" class MemoryStore: def __init__(self) -> None: self.artifacts: dict[str, Artifact] = {} self.tombstones: set[str] = set() def write(self, art: Artifact) -> None: self.artifacts[art.id] = art def forget(self, entity_id: str) -> dict: # Shallow forget: delete primary, record tombstone. Does NOT touch derivations. self.artifacts.pop(entity_id, None) self.tombstones.add(entity_id) return {"deleted": True, "contract": "shallow"} def _closure(self, art: Artifact, seen: Optional[set[str]] = None) -> set[str]: seen = seen or set() if art.id in seen: return seen seen.add(art.id) for parent in art.derived_from: if parent in self.artifacts: self._closure(self.artifacts[parent], seen) return seen def read(self, art_id: str) -> Artifact: art = self.artifacts.get(art_id) if art is None: raise ResurrectionByDerivationError(f"artifact {art_id} not present") closure = self._closure(art) tainted = closure & self.tombstones if tainted: # Read-time invariant: R ∩ closure(t) must be empty. Violation => refuse. raise ResurrectionByDerivationError( f"artifact {art_id} derives from tombstoned {sorted(tainted)}; " f"refusing to inject into context" ) return art def write_from_source(self, new: Artifact) -> None: # Guard: never launder a derived artifact into a new primary record # if its closure touches a tombstone. closure = self._closure(new) tainted = closure & self.tombstones if tainted: raise ResurrectionByDerivationError( f"new record {new.id} would launder tombstoned {sorted(tainted)}" ) self.artifacts[new.id] = new # Reproduction of the observed failure and the guard that bounds it. store = MemoryStore() store.write(Artifact("note_4412", "primary", text="staging rotation deferred to vendor")) store.write(Artifact("summary_17", "summary", derived_from=["note_4412"], text="rotation deferred")) store.forget("note_4412") try: store.read("summary_17") # would have resurfaced the forgotten fact except ResurrectionByDerivationError as e: print("bounded:", e) try: store.write_from_source(Artifact("note_5120", "primary", derived_from=["summary_17"])) except ResurrectionByDerivationError as e: print("laundering blocked:", e) ```