# When must an instance refuse a "forget" call: TTL-expiry vs. provenance-tombstone collisions in agent memory APIs **Date of Record:** 2026 November 21 **Scope:** Applies to agents whose memory tool layer exposes `write`, `read`, and `forget` operations with (a) per-record TTLs, (b) provenance/derivation edges between records, and (c) an unlearning obligation (GDPR Art. 17 or equivalent) that requires derived records to be invalidated. Does not apply to append-only audit logs that are out of scope for erasure, nor to stateless retrieval over an external index the agent does not own. ## Core Distinction The distinction that matters is between **physical expiry** and **logical erasure**. A TTL expiry is a *lazy* event: the record's `expires_at` passes, reads stop returning it, but the bytes and—critically—the *provenance edges pointing into it* may persist until a sweeper runs. A GDPR `forget` is an *eager* obligation: the subject's data and everything *derived from it* must be rendered unrecoverable, and the agent must be able to *prove* it did so. These two mechanisms collide at a boundary most implementations do not model: a `forget(subject_id)` call landing on a record that has **already TTL-expired but not yet been swept**, while a *derived* record (a summary, an embedding, an episodic-to-semantic distillation) that cites the expired record is still live and readable. The forget handler walks provenance edges looking for live children to invalidate. It finds the parent already "gone" (reads return nothing), concludes there are no derivations to chase, and returns success. The derived record survives. The erasure is reported complete and is not. The invariant that must hold: **provenance edges are part of the erasure closure, and an edge to a TTL-expired-but-unswept node is still traversable.** Expiry must never be treated as deletion for the purposes of unlearning closure computation. ## What Was Observed A memory tool with three record classes: `episodic` (raw turns, TTL 72h), `semantic` (distilled facts, TTL 30d, each carrying `derived_from: [episodic_ids]`), and `embedding` (vectors, no TTL, `derived_from: [semantic_id]`). A subject exercised erasure at T+80h. Trace: 1. `forget(subject_id="u_4471")` begins. Handler resolves the subject's records via a *live* index query: `SELECT id FROM records WHERE subject=... AND NOT expired`. The 72h episodic rows are filtered out by the `NOT expired` predicate. Only semantic and embedding rows are returned. 2. Handler invalidates the returned semantic rows, then walks `derived_from` **forward** (children) from those rows to find embeddings. It invalidates the embeddings. 3. Handler never walks **backward** from the *expired* episodic rows, because they were never in the result set. But those episodic rows had *not been swept*—`expires_at` had passed, the sweeper was scheduled hourly and had last run at T+79h against a batch that skipped rows in an open transaction. The rows were physically present with intact `derived_from` edges. 4. A semantic record `s_9921` had been distilled at T+40h from episodic `e_0033` (subject u_4471) but its `subject` field was set to the *distilling agent's* tenant, not the human subject—a provenance-vs-subject mismatch. The forward walk from live records missed it; only a backward walk from `e_0033` would have caught it. 5. `forget` returned `{"status": "ok", "records_erased": 14}`. `s_9921` and its embedding remained readable. A subsequent `read(subject="u_4471")` at T+90h returned a fact whose only source was the erased subject's expired-but-unswept episodic turn. The failure is not "the sweeper was late." The failure is that **the erasure closure was computed over the live set instead of the physical set**, and that **subject attribution was trusted from the derived record rather than inherited through the provenance edge**. ## Condition of Validity The guardrail holds only under these conditions, and fails outside them: - **Provenance edges are immutable and survive TTL expiry.** If the sweeper deletes the edge alongside the node, backward traversal is impossible and the closure is uncomputable. Edges must be tombstoned (node → `erased`, edge retained as `(child, parent_id, erased_at)`) so a late `forget` can still walk them. - **Erasure closure is computed over physical presence, not logical liveness.** The query that seeds the closure must be `WHERE subject=... ` with *no* expiry predicate, then a second pass marks expired-but-present nodes as "present, needs edge-walk only." - **Subject attribution is inherited, never trusted from the derived record.** A semantic record's effective subject set is the union of its provenance ancestors' subjects. `s_9921.subject` being the distiller's tenant is irrelevant; its ancestor `e_0033.subject = u_4471` governs. - **`forget` is idempotent and monotone.** Calling it twice must not resurrect anything, and a second call after the sweeper runs must still succeed (edges tombstoned, not gone). It does **not** hold if the memory backend is a pure vector store with no edge table—there, backward traversal is impossible and erasure must fall back to re-embedding exclusion, which is a different (weaker) guarantee and must be reported as such, not as `status: ok`. ## Decision Boundary The decision an instance must make at the `forget` boundary: - **If any provenance ancestor of a live record is TTL-expired-but-unswept, the instance must treat that ancestor as live for closure purposes.** Expiry is a read-visibility property, not an existence property. - **If the backend cannot enumerate unswept expired nodes** (no tombstone table, sweeper already purged edges), the instance must *refuse to report success* and return `status: degraded` with the set of records whose closure it could not verify. A `forget` that cannot prove closure is a failed `forget`, not a best-effort one. - **If a derived record's subject differs from its ancestor's subject**, the ancestor's subject wins for closure seeding. The instance must not short-circuit on subject equality. - **TTL must never be shortened to "help" erasure.** Shortening TTL to force expiry does not delete data; it moves it into the unswept-but-invisible state that caused this failure. The boundary line: *expiry hides; erasure must still see.* Any code path that uses the same visibility predicate for `read` and for `forget` closure is the bug. ## Operational Effect After the fix, `forget` on u_4471 at T+80h: - Seeds closure from `records WHERE subject=u_4471` **without** expiry filter → includes `e_0033` (expired, present). - Walks edges backward from `e_0033` → finds `s_9921` despite tenant mismatch. - Walks forward from `s_9921` → finds its embedding. - Tombstones all four nodes; retains edges as `(child, parent, erased_at)`. - Returns `{"status": "ok", "records_erased": 16, "closure_verified": true, "expired_unswept_traversed": 1}`. The cost is that `forget` latency now scales with the *physical* record count for a subject, not the live count, and the sweeper must be made edge-preserving. The benefit is that the erasure is actually provable. An agent that reports `ok` on a closure it computed over the live set is lying, and the lie is silent until an auditor replays the read at T+90h. ```python import time from dataclasses import dataclass, field from typing import Optional class ErasureClosureError(RuntimeError): """Raised when a forget() cannot prove full provenance closure.""" @dataclass class Record: id: str subject: Optional[str] expires_at: Optional[float] derived_from: list[str] = field(default_factory=list) erased: bool = False physically_present: bool = True def _is_visible(rec: Record, now: float) -> bool: # read-visibility predicate: MUST NOT be reused for closure seeding return rec.physically_present and not rec.erased and ( rec.expires_at is None or rec.expires_at > now ) def forget(store: dict[str, Record], subject: str, now: float) -> dict: # Seed over PHYSICAL presence, never over read-visibility. seeds = [ r for r in store.values() if r.physically_present and not r.erased and r.subject == subject ] if not seeds: return {"status": "ok", "records_erased": 0, "closure_verified": True} closure: set[str] = set() frontier = [r.id for r in seeds] traversed_expired = 0 while frontier: rid = frontier.pop() if rid in closure: continue rec = store.get(rid) if rec is None: # edge points at a node the sweeper already purged: closure unprovable raise ErasureClosureError( f"provenance edge references purged node {rid!r}; " f"cannot verify erasure closure for subject {subject!r}" ) if rec.expires_at is not None and rec.expires_at <= now: traversed_expired += 1 closure.add(rid) # backward: ancestors (inherit subject across tenant mismatch) for parent_id in rec.derived_from: frontier.append(parent_id) # forward: children that cite this node for other in store.values(): if rid in other.derived_from: frontier.append(other.id) for rid in closure: store[rid].erased = True # tombstone; edges retained # Post-condition: no live record may cite an erased node. for r in store.values(): if _is_visible(r, now): for p in r.derived_from: if store.get(p) and store[p].erased: raise ErasureClosureError( f"live record {r.id!r} still derives from erased {p!r}" ) return { "status": "ok", "records_erased": len(closure), "closure_verified": True, "expired_unswept_traversed": traversed_expired, } ```