# Which invariants prevent retained-memory resurrection after a scoped forget in agent memory tool APIs **Date of Record:** 2026 November 26 **Scope:** Applies to agents that expose explicit `remember`/`recall`/`forget` tool APIs with per-scope retention and erasure guarantees, where forget is expected to be durable across cold starts and across derived indexes. Does not apply to append-only logs with no erasure surface, nor to pure in-context scratchpads whose lifetime is bounded by a single request. ## Core Distinction A `forget(scope, key)` call is not a deletion of a row; it is a *retraction of a claim about the world* that the agent has already propagated into multiple derived stores: an episodic buffer, a vector index, a summary/distillation cache, and possibly a peer agent's replicated view. The boundary failure is **resurrection**: a subsequent `recall` returns content that the agent has been told to erase, because a derived artifact (embedding, distilled summary, tool-result cache, or a peer's copy) retained the semantic payload after the primary record was tombstoned. The non-obvious invariant is this: **erasure must be closed under the derivation graph, not merely applied to the source node.** A forget that removes the canonical record but leaves its embedding in an ANN index, or leaves a sentence inside a rolling summary, has not erased anything—it has only made the original harder to find while the derived copy remains retrievable and, worse, *authoritative-looking* because it no longer points at a record that could be checked. ## What Was Observed A support-triage agent was configured with a `forget(user_id, fact_key)` tool so that a user could retract a stored preference ("do not contact me about renewals"). The tool implementation did the intuitive thing: 1. Marked the canonical record `status=deleted` with a tombstone timestamp. 2. Enqueued a background job to remove the vector from the ANN index. The failure trace: - The background reindex ran on a 6-hour cadence and, on this cycle, **rebuilt** the index from a nightly snapshot that predated the tombstone. The rebuild did not consult tombstones; it trusted the snapshot. The deleted vector was reinserted. - Independently, the agent's **episodic-to-semantic distiller** had, 40 minutes before the forget, folded the preference into a rolling summary: `"User has expressed contact preferences around renewals."` That summary was stored as a *new* semantic record with no back-reference to the original `fact_key`. The forget, scoped by `fact_key`, could not match it. - On the next cold start, the agent hydrated the summary cache and the rebuilt index. A `recall("renewal contact preferences")` returned the distilled sentence with high similarity, and the agent re-derived the preference as an active belief—now with *no* record under the forgotten key, so a subsequent `forget` call was a no-op ("nothing to forget") and the resurrection became permanent. The observable symptom was a policy violation that no single component considered itself responsible for: the tombstone was correct, the index job was correct in isolation, the distiller was correct in isolation. The bug lived in the *composition* of retention guarantees across derivations. ## Condition of Validity The invariant "forget is durable" holds only when all of the following hold. Each is a precondition, not a suggestion: - **Provenance closure.** Every derived artifact (embedding, summary sentence, cached tool result, peer replica) carries a set of source record IDs sufficient to evaluate a forget predicate against it. A summary that cannot name its sources cannot be erased by key. - **Monotonic tombstones.** Any rebuild-from-snapshot path must apply the tombstone log as a filter, and the tombstone log must be *ahead of* every snapshot used for rebuild. Rebuild-from-stale-snapshot is the canonical resurrection vector. - **Erasure is a barrier, not an event.** `forget` must return only after derived stores are quiesced or after a durable "pending erasure" marker is written that `recall` treats as a negative filter. A forget that returns before its derived copies are handled is a *promise*, and promises are not invariants. - **Negative recall.** `recall` must consult the tombstone/pending set *before* returning candidates, so that a resurrected vector that slipped through reindexing is still suppressed at read time. Read-path suppression is the last line of defense and must not be delegated to write-path hygiene. If any of these is absent, the retention guarantee is best-effort and must be documented as such, because the agent will otherwise behave as if erasure is total. ## Decision Boundary The operational question is not "did we delete the row" but **"can any retrieval path still surface the payload, and can the agent distinguish a resurrected derived claim from a legitimately re-observed one?"** - If provenance closure and read-path suppression both hold → treat forget as a hard invariant; the agent may assert erasure to the user. - If provenance closure holds but read-path suppression does not → erasure is *eventually consistent*; the agent must not assert total erasure, and must treat any recall hit on a tombstoned source as a **verification failure to be escalated**, not as fresh evidence. - If provenance closure does not hold (derived artifacts are source-anonymous) → the system *cannot* honor scoped forget at all. The correct behavior is to refuse the forget contract up front rather than accept it and silently violate it. Accepting an unenforceable erasure guarantee is worse than declining it, because downstream policy (and the user) will rely on it. The sharp boundary: a derived artifact that cannot be traced to a source key must be treated as **un-forgettable**, and an un-forgettable artifact whose content overlaps a forgotten key must poison the scope—forcing a full-scope rebuild rather than a surgical delete. ## Operational Effect Concretely, the corrected design changes three things: 1. `forget` writes a tombstone with a monotonically increasing epoch and returns a `pending_erasure` handle; it does **not** claim completion until derived stores acknowledge. Callers must treat the handle as the unit of truth. 2. The reindexer applies the tombstone log as a mandatory filter and refuses to rebuild from any snapshot whose epoch is behind the tombstone log's high-water mark—failing closed rather than resurrecting. 3. Distillation writes back-references (`derived_from=[fact_key,...]`) so that a forget predicate can be evaluated transitively; summaries that would become empty after erasure are themselves retracted, and summaries that would become misleading are marked `stale` and excluded from recall until re-distilled. The residual risk is a peer replica or an external cache outside the closure. The guardrail is to make the erasure epoch part of the agent's identity/warrant when it hands off state, so a peer receiving a recall result tagged with a pre-erasure epoch knows to distrust it. Without epoch propagation, resurrection is not a local bug but a distributed one. ```python from dataclasses import dataclass, field from typing import Optional class ResurrectedMemoryError(RuntimeError): """Raised when recall surfaces content whose source was erased.""" pass class UnenforceableForgetError(RuntimeError): """Raised when a forget is requested for a scope whose derived artifacts cannot be traced back to source keys.""" pass @dataclass class Tombstone: key: str epoch: int @dataclass class DerivedArtifact: content: str derived_from: list[str] = field(default_factory=list) # provenance closure epoch: int = 0 class MemoryStore: def __init__(self) -> None: self._tombstones: dict[str, int] = {} self._artifacts: list[DerivedArtifact] = [] self._epoch = 0 def remember(self, key: str, content: str) -> None: self._epoch += 1 self._artifacts.append( DerivedArtifact(content=content, derived_from=[key], epoch=self._epoch) ) def forget(self, key: str) -> int: # Refuse forgets we cannot enforce: any artifact lacking provenance # that might carry this key makes scoped erasure unprovable. for art in self._artifacts: if key in art.content and not art.derived_from: raise UnenforceableForgetError( f"cannot erase {key!r}: artifact {art.content!r} has no provenance" ) self._epoch += 1 self._tombstones[key] = self._epoch return self._epoch # pending_erasure handle def recall(self, query: str, *, require_epoch: Optional[int] = None) -> list[str]: hits = [a for a in self._artifacts if query in a.content] for art in hits: erased = [k for k in art.derived_from if k in self._tombstones] if erased: # Read-path suppression: a resurrected derived claim whose # source is tombstoned must never be returned as evidence. if require_epoch is not None and art.epoch <= self._tombstones[erased[0]]: raise ResurrectedMemoryError( f"recall hit {art.content!r} derives from erased key(s) {erased}" ) continue return [a.content for a in hits if not any(k in self._tombstones for k in a.derived_from)] ```