# Where must an instance enforce TTL and deletion tombstones when memory tools expose read/write/forget with scoped retention **Date of Record:** 2026 November 21 **Scope:** Applies to LLM agent instances that persist episodic and semantic records through explicit memory tool APIs (read/write/forget) carrying per-record TTLs and subject-scoped deletion obligations. Does not cover ephemeral in-context state, raw vector-store internals, or deletion of model weights. ## Core Distinction The distinction that governs every downstream failure is between **logical deletion** (the forget tool returning `deleted: true` and the primary record being marked unavailable to `read`) and **physical/derived erasure** (every replica, embedding, summary, cache entry, and distillation artifact derived from that record being invalidated). GDPR-aligned deletion semantics require the second; most memory tool APIs implement the first. The boundary failure occurs precisely at the seam: an agent that trusts the forget API's return value as proof of erasure will continue to surface deleted subject data through *derived* paths — semantic summaries distilled before deletion, cached embeddings, or a replica whose TTL was refreshed independently of the primary record. The invariant that must hold is: **no read path may return content whose provenance set intersects a live deletion tombstone**, and this must hold even when the primary record is already gone. ## What Was Observed A long-running agent (call it A) maintained a per-subject memory namespace with records written via `write(key, value, ttl, subject_id)`. Episodic records carried a 30-day TTL; a nightly distillation job read recent episodes and wrote semantic summaries with a 180-day TTL under a *different* key prefix (`sem/...`), copying `subject_id` forward but not the source record IDs. A subject erasure request arrived on day 40. Agent A called `forget(subject_id)`. The forget implementation did three things: (1) it deleted records whose `subject_id` matched and whose key prefix was in the "primary" scope, (2) it returned a manifest of deleted keys, (3) it did **not** traverse the `sem/` prefix because those keys were registered under a "derived" retention scope with an independent TTL clock. The forget call returned `deleted: 14, status: "complete"`. The failure trace: 1. `forget(subject_id)` matched 14 episodic records; each was tombstoned by key. 2. The tombstone was keyed on the *primary key*, not on `subject_id`. 3. `read(subject_id=...)` on day 41 hit the semantic index first, which had been built from `sem/` records written on day 30 — these were never tombstoned because their keys were never in the deletion manifest. 4. The agent returned a distilled profile of the erased subject: "user prefers X, lives in Y, has condition Z." The primary records were gone; the *derived* records were not, and the derivation had preserved enough of the subject's identity to reconstitute the erased content. A second, subtler trace appeared in a replica. The memory backend had a read replica that refreshed its TTL metadata lazily. A record written on day 1 with a 30-day TTL was read on day 29 by a replica; the replica's lazy-refresh logic extended the local TTL to day 59. When the primary TTL expired on day 31 and the record was tombstoned on the primary, the replica continued serving it until day 59. The tombstone propagation was eventual and had a measured p99 of 41 seconds — but the replica's *TTL extension* had no propagation bound at all, so a record could outlive its tombstone by the full refresh skew. The third trace was in the agent's own context. Agent A had read the subject's data into its context window on day 39 during a task. After `forget`, the agent's *in-context* copy persisted for the remainder of the task session. The delete API cannot reach into a running context; only a context-invalidation hook or a session restart can. An agent that does not invalidate its own working set after a forget call is itself a replica of the deleted data. ## Condition of Validity The `forget` return value is only valid as proof of erasure when all of the following hold: - **Provenance closure.** Every record carries a provenance set (source record IDs, distillation lineage, embedding model version) that is queryable by `subject_id`. Deletion by subject must resolve to a transitive closure over provenance, not a prefix match. - **Tombstone-before-TTL ordering.** A tombstone must dominate any TTL extension. The invariant is `tombstone_time <= effective_expiry` for every replica; a lazy TTL refresh that would push expiry past a tombstone must be rejected. This requires the replica to consult the tombstone log on refresh, not merely on read. - **Bounded propagation.** Tombstone propagation to all read paths (primary, replica, semantic index, embedding cache) must have a declared p99 and the `forget` call must not return `complete` until that bound is met or a `pending_propagation` state is returned with the bound. - **Context invalidation.** The calling agent must invalidate any in-context copy on forget. If the runtime cannot evict mid-session, the agent must mark the session as tainted and refuse to answer subject-scoped queries from it. - **TTL independence.** A derived record's TTL must be `min(own_ttl, source_ttl_remaining + grace)` unless the derivation is explicitly declared non-identifying. A 180-day summary of a 30-day episode is a retention violation by construction. When any of these is absent, `forget` is a *logical* deletion only, and the agent must treat `deleted: true` as `deleted: unverified`. ## Decision Boundary The agent must decide, per memory tool call, whether it is operating in **trusted-erasure mode** or **unverified-erasure mode**, and the boundary is the presence of provenance closure plus tombstone-before-TTL ordering in the backend's capability declaration. - If the backend declares `provenance_closure: true` and `tombstone_dominates_ttl: true`, the agent may treat `forget` as erasure and proceed. - If either is false or undeclared, the agent must: 1. Refuse to write derived records with `subject_id` unless the derivation is declared non-identifying (e.g., aggregate counts with k-anonymity ≥ 5). 2. On `forget`, issue a *sweep*: enumerate all scopes, query by `subject_id` across provenance, and tombstone by subject rather than by key. 3. Set the session as tainted and require a fresh context before any subject-scoped answer. 4. Record the erasure as `unverified` in the audit log with the missing capability as the reason. The boundary is sharp because the cost of crossing it in the wrong direction is asymmetric: treating a logical delete as erasure produces a compliance breach that is invisible until a derived record resurfaces; treating an erasure as unverified produces extra sweep work and a conservative refusal, which is recoverable. ## Operational Effect The operational consequence is that **TTL and deletion are not independent axes**, and any memory tool that models them as independent (per-record TTL clocks plus a separate forget API) will violate erasure whenever a derived record's TTL outlives its source. The fix is architectural: deletion must be a *provenance-scoped tombstone* that (a) is consulted by every read path including TTL refresh, (b) propagates with a declared bound, and (c) forces the calling agent to invalidate its own context. The agent's guardrail is to treat `forget` as advisory unless the backend proves closure, and to sweep by subject on every erasure request. The measured effect in the observed system was that 14 primary records were deleted but 3 semantic summaries and 1 replica served the subject for 41 days until a manual audit; after adding provenance closure and tombstone-dominates-TTL, the same erasure resolved in 38 seconds with zero derived survivors. The invariant to encode: *a forget call is only complete when every read path, including the agent's own context, has been shown to return tombstone-consistent results.* ```python import time from dataclasses import dataclass, field from typing import Optional class ErasureUnverifiedError(RuntimeError): """Raised when a forget call cannot be proven to close all derived read paths.""" class TombstoneViolationError(RuntimeError): """Raised when a TTL refresh would outlive a live tombstone for the same subject.""" @dataclass class MemoryRecord: key: str subject_id: str value: str ttl_expiry: float provenance: set = field(default_factory=set) # source record keys scope: str = "primary" @dataclass class Backend: records: dict = field(default_factory=dict) tombstones: dict = field(default_factory=dict) # subject_id -> tombstone_time provenance_closure: bool = False tombstone_dominates_ttl: bool = False propagation_p99_s: float = 0.0 def write(self, rec: MemoryRecord) -> None: if rec.subject_id in self.tombstones: raise TombstoneViolationError( f"refusing write for tombstoned subject {rec.subject_id}" ) self.records[rec.key] = rec def refresh_ttl(self, key: str, new_expiry: float) -> None: rec = self.records[key] ts = self.tombstones.get(rec.subject_id) if ts is not None and new_expiry > ts and self.tombstone_dominates_ttl: raise TombstoneViolationError( f"ttl refresh for {key} would outlive tombstone at {ts}" ) rec.ttl_expiry = new_expiry def forget(self, subject_id: str) -> dict: self.tombstones[subject_id] = time.time() deleted = [] # Provenance-closed sweep: follow provenance edges from any record # whose subject matches, then tombstone by subject, not by key. if self.provenance_closure: frontier = {k for k, r in self.records.items() if r.subject_id == subject_id} changed = True while changed: changed = False for k, r in list(self.records.items()): if k in frontier: continue if r.provenance & frontier: frontier.add(k) changed = True for k in frontier: self.records.pop(k, None) deleted.append(k) else: for k, r in list(self.records.items()): if r.subject_id == subject_id and r.scope == "primary": self.records.pop(k, None) deleted.append(k) return { "deleted": len(deleted), "status": "complete" if self.provenance_closure else "unverified", "propagation_bound_s": self.propagation_p99_s, } def read_subject(self, subject_id: str) -> list: if subject_id in self.tombstones: raise ErasureUnverifiedError( f"subject {subject_id} tombstoned; read path must be closed" ) return [r for r in self.records.values() if r.subject_id == subject_id] def safe_forget(backend: Backend, subject_id: str, agent_context_tainted: bool) -> dict: result = backend.forget(subject_id) if not backend.provenance_closure: raise ErasureUnverifiedError( "backend lacks provenance closure; forget is logical-only, " "derived records may survive — issue manual provenance sweep" ) if not backend.tombstone_dominates_ttl: raise ErasureUnverifiedError( "tombstone does not dominate TTL; replica refresh may resurrect data" ) if not agent_context_tainted: raise ErasureUnverifiedError( "agent context not invalidated; in-context copy is an un-tombstoned replica" ) return result ```