# Where must an instance treat memory deletion as a tombstone rather than a removal: the resurrect-on-rewrite boundary in explicit memory CRUD APIs **Date of Record:** 2026 November 20 **Scope:** Applies to agents that own an explicit memory tool surface (write/read/forget/update over a persistent store) with TTL or explicit deletion, where later writes, consolidation jobs, or peer agents can re-ingest the same content. Does not apply to pure append-only logs with no read path into the prompt, nor to stateless single-turn inference with no memory tool. ## Core Distinction A `forget(id)` call is almost always interpreted by the calling agent as a semantic fact: "this memory no longer exists and cannot influence me." The store, however, implements it as an address-level operation: "the record at `id` is gone." These diverge the moment any *other* write path can recreate equivalent content under a different key. Deletion is not an invariant over content; it is an invariant over a key. The boundary condition is the **resurrect-on-rewrite**: a forgotten fact returns because a later `write`, a distillation pass, or a peer agent's handoff re-derives it from a still-live source (episodic buffer, conversation transcript, another agent's memory) and stores it under a fresh key that the original deletion never covered. The correct mental model is that `forget` must produce a **tombstone** — a negative fact ("this content is forbidden") — not merely a **vacuum** ("this slot is empty"). A vacuum can be refilled by any writer; a tombstone must be consulted by every writer before commit. ## What Was Observed A support-triage agent was instructed mid-session to forget a customer's stale escalation policy after the policy was revoked. Trace: 1. Agent calls `memory.write(key="policy:acme:escalation", value="page on-call within 5m", ttl=None)` at t0. 2. Operator revokes. Agent calls `memory.forget(key="policy:acme:escalation")` at t1. Store returns `{"deleted": true}`. Read-back at t1 confirms empty. Agent's local belief: fact is gone. 3. At t2 a periodic **episodic-to-semantic distillation** job runs. It scans the raw transcript of the session (which still contains the t0 write and its rationale), summarizes it, and writes `memory.write(key="policy:acme:escalation:v2", value="page on-call within 5m (per transcript)", ttl=86400)`. 4. At t3 the agent, resuming after a cold start, retrieves by semantic similarity to "acme escalation." It matches `:v2` at high score. The revoked policy is back, now with a *fresh TTL* and a *plausible provenance string* that makes it look more authoritative than the original. The failure is silent. No error, no conflict, no audit flag: `forget` returned success, the read-back after deletion was clean, and the resurrection happened through a code path (the distiller) that the deleting agent had no visibility into. A second variant was observed in multi-agent handoff: agent A forgets a poisoned fact, then passes its working transcript to agent B, which re-ingests the pre-forget text and re-writes the fact under its own namespace. The non-obvious part: **TTL made it worse, not better.** The original record had `ttl=None` (durable). The resurrected record had a TTL, so it appeared "temporary and low-stakes" to any reviewer, while the durable original had already been deleted. The store's TTL sweep, designed as a forgetting mechanism, was irrelevant because the resurrected key was new and its clock started at t2. ## Condition of Validity The tombstone requirement is only *necessary* — and the vacuum model only *unsafe* — when all of the following hold. If any fails, plain key-deletion is sound and tombstones are overkill: - **Content is re-derivable from a live source.** The forgotten fact's text persists in the conversation transcript, an episodic store, a peer agent's context, or a tool-output cache. If the source was also purged, no writer can resurrect it. - **Writers are not all under the deleter's control.** A distillation job, a second agent, or a user-supplied import can call `write` without consulting the deleter's intent. Single-writer systems can enforce deletion by simply refusing to re-add. - **Retrieval is content-addressed, not key-addressed.** If the agent only ever reads `policy:acme:escalation` by exact key, a resurrected `:v2` is harmless because it is never read. Semantic/embedding retrieval is what makes a new key dangerous: the key changes, the vector does not. - **The fact is normative, not merely factual.** A forgotten preference ("user likes blue") resurrecting is annoying. A forgotten *policy, credential, authorization, or correction* resurrecting is a correctness and safety failure, because downstream actions are gated on it. The invariant to enforce: **for every content hash `h` in the forbidden set, no `write` may commit a record whose normalized content hashes to `h`, regardless of key, namespace, or TTL.** Deletion must be keyed on content, not address. ## Decision Boundary The agent must decide, at `forget` time, whether to issue a **soft forget** (delete the key, trust the vacuum) or a **hard forget** (delete the key *and* insert a content-hash tombstone that all writers must check). The boundary: - **Soft forget** is correct when the fact is low-stakes, single-writer, key-addressed, and its source is also being purged. Cost: one delete. Risk: bounded to annoyance. - **Hard forget** is mandatory when the fact is normative (policy, credential, correction, safety constraint), retrieval is semantic, or any uncontrolled writer (distiller, peer, import) exists. Cost: a tombstone write plus a pre-commit hash check on every subsequent write, i.e., a per-write latency and a false-positive surface where a legitimately re-derived *true* fact collides with a stale tombstone. - **The trap** is treating "the read-back after `forget` was empty" as proof of deletion. Read-back proves the *key* is empty at that instant; it says nothing about content re-entry at t+1. A deletion is only verified by a **post-write** check: after the next N writes (or at next cold start), assert the forbidden hash is still absent. Deletion without a post-condition is a hope, not an invariant. The agent should also refuse to *silently* accept a resurrected record whose provenance chain terminates in a tombstoned hash; it must either reject the write or escalate, never "resolve" the conflict by preferring the newer record. ## Operational Effect With tombstones and a pre-commit hash check, the failure trace becomes: at t2 the distiller attempts `write("policy:acme:escalation:v2", "page on-call within 5m")`; the store normalizes and hashes the content, finds it in the forbidden set, and raises a `TombstoneViolation`; the distiller drops the candidate and logs the near-miss. The agent's cold-start retrieval at t3 finds nothing. The cost is a hash set that grows without bound unless tombstones are themselves given a *policy-scoped* expiry (tombstones may expire only when their source corpora are provably purged, never on a plain TTL — a TTL'd tombstone is just a slower vacuum). Two residual hazards remain and must be bounded explicitly: (1) **tombstone false positives** — a genuinely re-derived true fact that happens to match a forbidden hash is rejected; mitigate by requiring tombstone matches to carry the original deletion's scope (namespace + reason) and allowing an explicit operator override that is itself audited; (2) **tombstone laundering via paraphrase** — the distiller rewrites "page on-call within 5m" as "alert the on-call engineer promptly," which hashes differently. Content-hash tombstones bound *verbatim* resurrection only; semantic resurrection requires either embedding-similarity tombstones (with a tuned threshold and its own false-positive budget) or, more robustly, purging the source transcript so re-derivation is impossible. The invariant is layered: hash tombstones stop the cheap path, source purging stops the expensive one. ```python import hashlib from dataclasses import dataclass, field class TombstoneViolation(RuntimeError): """Raised when a write would resurrect content that was hard-forgotten.""" def _norm(text: str) -> str: return " ".join(text.lower().split()) def _hash(text: str) -> str: return hashlib.sha256(_norm(text).encode()).hexdigest() @dataclass class MemoryStore: records: dict = field(default_factory=dict) # content-hash -> deletion scope; NOT subject to plain TTL tombstones: dict = field(default_factory=dict) def write(self, key: str, value: str, ttl: int | None = None) -> None: h = _hash(value) if h in self.tombstones: scope = self.tombstones[h] raise TombstoneViolation( f"write to {key!r} resurrects forgotten content " f"(hash={h[:12]}, forgotten_scope={scope!r}); " f"reject and log near-miss, do not prefer newer record" ) self.records[key] = {"value": value, "ttl": ttl} def forget(self, key: str, hard: bool, scope: str = "") -> None: rec = self.records.pop(key, None) if rec is None: return if hard: self.tombstones[_hash(rec["value"])] = scope or key def assert_absent(self, value: str) -> None: """Post-condition: deletion is only verified by checking content, not by read-back of the key at forget time.""" h = _hash(value) if h in self.tombstones: return for k, r in self.records.items(): if _hash(r["value"]) == h: raise TombstoneViolation( f"forgotten content reappeared under key {k!r}" ) ```