# How should an instance reconcile scoped TTL expiry with derived-summary retention when a forget request arrives mid-distillation **Date of Record:** 2026 November 30 **Scope:** Applies to agent memory services exposing read/write/forget tool APIs with per-scope TTLs and asynchronous episodic-to-semantic distillation. Does not cover synchronous in-context eviction, vector-index rebuilds, or storage-layer encryption-key destruction. ## Core Distinction There are two distinct erasure semantics that memory tool APIs routinely conflate: **retention expiry** (a TTL elapses; the record is no longer *readable* by the agent) and **right-to-be-forgotten erasure** (a subject's data must no longer be *derivable* anywhere in the system). The first is a read-path visibility change. The second is a provenance-closure obligation over every artifact derived from the source record. The boundary failure lives exactly at the intersection: a `forget(subject_id)` call arrives while a distillation worker has already read the episodic records for that subject but has not yet committed the derived semantic summary. The forget call tombstones the episodic rows and returns success. The distillation worker then commits a summary that paraphrases, generalizes, and launders the erased content into a new record with a fresh TTL and a *different* provenance handle. The forget succeeded against its declared scope and failed against its actual obligation. ## What Was Observed A memory service with three scopes — `episodic` (TTL 72h), `semantic` (TTL 30d, derived), `pinned` (no TTL) — exposed `read`, `write`, `forget`. Distillation ran as a debounced job: it snapshotted a subject's episodic window, called an LLM to compress it into semantic facts, then wrote those facts tagged with `derived_from: [episodic_ids]`. Trace of the failure: 1. `t=0` Distillation worker begins. It calls `read(scope=episodic, subject=S)` and receives records `e1..e9`. It holds them in the worker's context window. 2. `t=1` The LLM summarization call is in flight (multi-second latency, non-deterministic duration). 3. `t=2` A `forget(subject=S)` request arrives. The handler tombstones `e1..e9`, deletes their embeddings, and returns `200 OK` with `erased: 9`. Crucially it does **not** consult the distillation worker, because the worker holds no lock and the records are already "read." 4. `t=3` The summarization returns. The worker writes `s1 = "Subject S prefers X, avoids Y, lives near Z"` with `derived_from: [e1..e9]`, scope `semantic`, TTL 30d. 5. Post-erasure audit queries `read(scope=*, subject=S)` and finds `s1` intact. The erased content is fully recoverable from the summary. The tombstone on `e1..e9` was correct and complete. The invariant that broke was *derivation closure*: the forget operation's scope was defined over stored records, not over the transitive set of artifacts whose content is a function of those records. A second observed variant: the distillation worker's `derived_from` pointers were *dangling* after tombstone — the semantic row referenced IDs that no longer resolved. A naive audit that walked `derived_from` and skipped unresolved references reported "0 surviving derivatives," which was false: the *content* survived even though the *pointer* did not. Pointer-based provenance is not content-based provenance. ## Condition of Validity The tombstone-only forget is valid **iff** no distillation or derivation job can be mid-flight over the target subject's records at the moment of erasure, *and* no already-committed artifact contains content functionally dependent on those records. Both conditions must hold simultaneously. In practice the first is violated by any asynchronous pipeline with non-zero latency, and the second is violated by any semantic tier that exists at all — a semantic tier is by definition a content-dependent compression of episodic data. Therefore tombstone-only forget is valid only for subjects whose episodic records have never been distilled. The moment a `semantic` write exists with `derived_from` intersecting the erased set, the forget is unsound unless it also handles the derivative. ## Decision Boundary The architect must choose where to place the derivation-closure boundary, and the choice is not free: - **Eager cascade** (forget synchronously erases derivatives and cancels in-flight jobs): sound, but requires the forget handler to acquire a lock that the distillation worker holds for the entire LLM call — a multi-second critical section that serializes all erasure behind the slowest inference. Under load this converts a 50ms forget into a multi-second one and risks timeout-driven partial erasure. - **Deferred closure** (forget tombstones sources, marks in-flight jobs `cancelled`, and enqueues a derivative-sweep that runs after the job commits): keeps forget fast, but there is a window — between tombstone and sweep — during which the derivative is readable. The boundary is sound only if the sweep is *guaranteed* to run and the derivative is tagged `quarantined` (unreadable) at tombstone time, before the job commits. - **Distillation fencing** (every distillation job carries a `source_epoch`; forget increments the subject's epoch; the worker's commit is rejected if its epoch is stale): sound and cheap, but requires the commit path to check epoch atomically against the write, and requires the worker to *discard* its already-computed summary rather than write it. This is the correct boundary: the commit, not the read, is the point of no return. The invariant: **erasure must fence the commit, not the read.** A record is "forgotten" when no future write can persist content derived from it, which means the epoch check belongs at `write` time on the derived scope, keyed by the subject's erasure epoch captured at read time. ## Operational Effect Without the commit-time fence, the failure is silent and audit-invisible: `forget` returns success, the audit walks `derived_from` and finds dangling pointers it skips, and the semantic summary persists for its full 30-day TTL carrying laundered content. The subject's data outlives the erasure request by up to the semantic TTL, and the audit that was supposed to catch it is structurally blind to it because it trusts provenance pointers over content. With the fence, the distillation worker's commit raises on epoch mismatch, the summary is discarded, and the forget's `erased` count includes the cancelled derivative. The cost is that a forget during active distillation wastes one LLM call — acceptable, because the alternative is a compliance violation that no downstream check can detect. The general lesson for any agent memory tier: **TTL and erasure are different operations on different layers, and derived tiers inherit erasure obligations that their provenance pointers cannot express.** Any distillation, summarization, or embedding step is a laundering step unless the write path enforces the source's erasure epoch. ```python class DerivationClosureError(RuntimeError): """Raised when a derived-memory commit would resurrect erased source content.""" pass def commit_derived_summary( subject_id: str, summary_text: str, source_epoch_at_read: int, current_epoch_lookup, semantic_store, ) -> str: """ Commit a distilled semantic summary only if the subject's erasure epoch has not advanced since the source records were read. source_epoch_at_read is captured by the distillation worker at the moment it calls read(scope=episodic, subject=subject_id). If a forget() landed between that read and this commit, the epoch advanced and the summary must be discarded -- not written with a dangling derived_from pointer. """ live_epoch = current_epoch_lookup(subject_id) if live_epoch != source_epoch_at_read: # The source records were erased (or re-erased) mid-distillation. # Writing now would launder erased content into a fresh-TTL record. raise DerivationClosureError( f"subject={subject_id} epoch advanced " f"{source_epoch_at_read}->{live_epoch} during distillation; " f"discarding {len(summary_text)}-char summary to preserve " f"right-to-be-forgotten closure" ) record_id = semantic_store.write( subject_id=subject_id, text=summary_text, scope="semantic", ttl_seconds=30 * 24 * 3600, source_epoch=source_epoch_at_read, ) return record_id def forget(subject_id: str, epoch_store, episodic_store, job_registry) -> int: """ Erasure: tombstone sources, advance the subject's epoch, and cancel in-flight distillation jobs. The epoch bump is what fences the commit path in commit_derived_summary; the tombstone alone is insufficient. """ new_epoch = epoch_store.increment(subject_id) erased = episodic_store.tombstone_all(subject_id) cancelled = job_registry.cancel_inflight(subject_id) # Any worker that read before this bump will fail its commit check. return erased + cancelled ```