# What happens when an instance erases a memory record while a peer agent still holds a cached write-through pointer to it **Date of Record:** 2026 November 28 **Scope:** Applies to multi-instance agent systems where memory is exposed through explicit read/write/forget tool APIs with scoped retention and erasure obligations (GDPR Art. 17 style), and where one instance may hold a locally cached reference, embedding, or write-through buffer for a record another instance is authorized to delete. Does not apply to single-instance agents with exclusive ownership of their memory store, nor to append-only logs where erasure is implemented as tombstoned redaction rather than physical deletion. ## Core Distinction The distinction that matters here is between **erasure as a state transition on the authoritative store** and **erasure as a distributed invalidation event across instances**. A `forget(record_id)` call that returns `200 OK` is a claim about the store, not about the fleet. Every other instance that ever `read` the record may still be holding a derived artifact: a cached JSON blob, an embedding vector in a local vector index, a summarization in its episodic buffer, or a pending write-through patch queued for the next flush. The failure mode is not that the record survives in the store — the store did its job. The failure mode is that **a stale cached artifact is later used to reconstruct or re-emit the erased record**, either by writing it back (resurrection) or by leaking it into a response (post-erasure disclosure). This is non-obvious because the `forget` API is usually designed as a point operation with a synchronous contract, while the actual erasure obligation is a **fleet-wide invariant with an unbounded set of holders**. The API's success semantics silently narrow the invariant to "the authoritative copy is gone," which is necessary but not sufficient for compliance or for poisoning defense. ## What Was Observed A three-instance pipeline (ingest → summarize → respond) shared a memory service exposing `read(scope, key)`, `write(scope, key, value, ttl)`, and `forget(scope, key, reason)`. The `forget` implementation deleted the row and appended an audit entry, returning success once the primary key was gone. A user deletion request triggered `forget("user:4471", "profile")` from the ingest instance. The store confirmed deletion. Within the same window, the summarize instance — which had read `user:4471/profile` ninety seconds earlier and held it in a per-turn scratch cache — completed its turn and issued a **write-through** of a derived summary under `user:4471/summary`, a different key in the same scope. The write succeeded because the scope itself was not tombstoned, only the specific key. Downstream, the respond instance read `user:4471/summary`, which contained verbatim fragments of the erased profile (names, an address), and emitted them in a response. Separately, a poisoning-defense path exhibited the mirror failure: a record flagged as adversarially injected was `forget`-ed, but a peer instance that had already embedded the record into its local vector index continued to retrieve it by semantic similarity and treated the retrieved text as trusted context, because the trust flag lived on the store row and not on the cached vector. The erasure removed the flag along with the row. The trace, condensed: 1. `read("user:4471","profile")` → value cached in instance B's turn buffer, `cache_epoch=41`. 2. `forget("user:4471","profile")` on store → row deleted, `store_epoch=42`, audit appended. 3. Instance B turn completes; `write("user:4471","summary", derived(value))` → accepted, `store_epoch=43`. 4. Instance C `read("user:4471","summary")` → returns derived PII. 5. Poisoning case: `forget("kb","doc:9912", reason="injection")` → row gone; instance C's local index still maps `doc:9912` embedding → text; retrieval returns it with no trust flag. ## Condition of Validity The `forget` success contract is only valid under the invariant: **no live instance holds a derived artifact of the erased key that can be re-written into the same scope or surfaced to a user without re-checking the store.** That invariant holds only when one of the following is true: - Erasure is **scope-level or generation-level**, not key-level: `forget` bumps a scope generation counter, and every `write` and every `read` carries the generation it was derived under. A write whose `derived_from_epoch < current_scope_epoch` is rejected as stale. - Derived artifacts are **tagged with their provenance epoch and revalidated on use**, so a cached summary cannot be persisted or emitted if any of its source keys has been erased since the epoch it was computed at. - The instance's cache is **invalidated synchronously** as part of the `forget` transaction (feasible only for bounded fleets with a reliable control channel). Absent one of these, the validity condition degrades to "erasure is eventually consistent and best-effort," which is not a defensible posture for a deletion obligation and is actively dangerous for poisoning defense, where the whole point is that the poisoned content must stop influencing reasoning immediately. ## Decision Boundary The boundary the operator must draw is between **key-scoped deletion** (adequate for TTL expiry, cache eviction, routine garbage collection) and **obligation-bearing erasure** (deletion requests, injection quarantine, correction of a poisoned fact). These must not share an API surface with identical success semantics. Concretely: - If the record is being removed because it is *stale or low-value*, key-scoped `forget` with eventual cache invalidation is acceptable; a brief resurrection is a quality bug, not a compliance or safety event. - If the record is being removed because of a *deletion obligation or a poisoning verdict*, the operation must be **generation-bumping and provenance-checked**: it must invalidate derived writes, and it must cause any cached artifact to fail closed (refuse to emit, refuse to persist) rather than fail open (emit the cached copy). - A `forget` that cannot guarantee generation-bump semantics must return a **degraded status** — not `200 OK` — so the caller knows the invariant is not established and can escalate to a fleet-wide purge or a scope rotation. The decision is not "should we cache" (we will) but "does the write path check provenance against the erasure epoch." If it does not, the system has no erasure guarantee regardless of what the `forget` API returns. ## Operational Effect The practical effect of getting this wrong is a **resurrection window** whose length equals the maximum turn latency plus the maximum cache TTL across the fleet, during which erased data can be re-persisted under a new key and thereby laundered past the audit trail — the audit shows the original key deleted, and the derived key was never in scope of the deletion. For poisoning defense the effect is worse: the quarantine is bypassed because the poisoned artifact survives in the vector index without its trust flag, and the agent's retrieval step has no signal that the content was ever adjudicated untrustworthy. The guardrail is to make erasure a **generation event with provenance-checked writes**, to carry trust flags *with* the cached artifact rather than only on the store row, and to treat any `write` derived from a pre-erasure epoch as a hard rejection rather than a silent overwrite. ```python from dataclasses import dataclass, field from typing import Dict, Optional class ErasureProvenanceError(RuntimeError): """Raised when a write or emit is derived from a pre-erasure epoch.""" @dataclass class MemoryStore: scope_epoch: Dict[str, int] = field(default_factory=dict) rows: Dict[tuple, dict] = field(default_factory=dict) erased_keys: Dict[str, set] = field(default_factory=dict) def epoch(self, scope: str) -> int: return self.scope_epoch.get(scope, 0) def read(self, scope: str, key: str) -> dict: row = self.rows.get((scope, key)) if row is None: raise KeyError(f"{scope}/{key} absent") # Caller must retain row["epoch"] as provenance for any derivation. return dict(row) def write(self, scope: str, key: str, value: dict, derived_from_epoch: int) -> None: current = self.epoch(scope) if derived_from_epoch < current: raise ErasureProvenanceError( f"stale write {scope}/{key}: derived_from_epoch=" f"{derived_from_epoch} < scope_epoch={current}; " f"a source key was erased after derivation" ) self.rows[(scope, key)] = { "value": value, "epoch": current, } def forget(self, scope: str, key: str, reason: str) -> None: # Obligation-bearing erasure: bump the scope generation so that # every cached derivation becomes provably stale and unwritable. self.rows.pop((scope, key), None) self.scope_epoch[scope] = self.epoch(scope) + 1 self.erased_keys.setdefault(scope, set()).add(key) def emit(self, scope: str, key: str, derived_from_epoch: int) -> dict: if derived_from_epoch < self.epoch(scope): raise ErasureProvenanceError( f"refusing to emit {scope}/{key}: cached artifact predates " f"erasure epoch {self.epoch(scope)}" ) return self.read(scope, key)["value"] def summarize_and_persist(store: MemoryStore, scope: str, src_key: str, dst_key: str) -> None: src = store.read(scope, src_key) cached_epoch = src["epoch"] # ... model call produces a derived summary containing src fragments ... summary = {"derived_from": src_key, "text": src["value"].get("text", "")} # If a peer erased src_key while we were reasoning, this raises. store.write(scope, dst_key, summary, derived_from_epoch=cached_epoch) ```