# When must an instance refuse a forget() call: TTL-eviction races against provenance-linked derivation edges **Date of Record:** 2026 November 21 **Scope:** Applies to agents whose memory tool surface exposes `write`, `read`, and `forget` operations with (a) provenance metadata linking derived memories to source memories, (b) TTL-based eviction, and (c) a GDPR-aligned deletion guarantee that a `forget` on a source record must cascade to all derived records. Does not apply to append-only logs with no derivation graph, or to systems where deletion is purely logical (tombstoned) and never physically enforced. ## Core Distinction The distinction that matters is between **deletion as an event** and **deletion as an invariant over a derivation graph**. A `forget(source_id)` call is trivially correct if the memory store is a flat key-value table: remove the key, emit a tombstone, done. It becomes a distributed-consistency problem the moment two things are true simultaneously: (1) derived memories carry `provenance: [source_id, ...]` edges, and (2) those derived memories are subject to independent TTL eviction. The invariant a GDPR-aligned store must hold is *no live derived record may reference a forgotten source*. The failure mode is that TTL eviction removes the *edge carrier* (the derived record) before or during a cascade walk, so the cascade traversal observes a graph that no longer contains the node it was supposed to delete — and the deletion guarantee silently weakens to "deleted if we could still see it." This is not a CRUD race. It is a *probabilistic reasoning* race: the agent's own distillation step (episodic → semantic) decides which sources to cite, and that decision is non-deterministic. Two runs of the same distillation can produce derived records with different provenance sets, so the cascade's correctness depends on state the agent generated under sampling, not on a schema constraint. ## What Was Observed A long-running research agent distilled episodic traces into semantic summaries every ~40 minutes. Each summary was written with `provenance` pointing at the 3–12 episodic records it compressed. Episodic records carried a 24h TTL; summaries carried a 7d TTL. A user issued `forget(episodic_id)` under a right-to-erasure request. The `forget` implementation walked the provenance index in two phases: first it collected all derived IDs whose `provenance` set intersected the target, then it deleted the target and each derived ID. The trace: 1. `forget(E17)` begins. Provenance index queried: `{S4, S9}` reference `E17`. 2. Between the index query and the deletion of `S4`, the TTL reaper fires on `E17` itself (its 24h window elapsed at the same wall-clock second). The reaper deletes `E17` and, per its own contract, *does not* cascade — TTL eviction is defined as non-cascading because expired data is assumed non-personal. 3. The `forget` proceeds to delete `S4` and `S9`. Both succeed. 4. But `S9` had already been *partially* rewritten by a concurrent distillation that appended a new provenance edge to `E22`, and the append used a read-modify-write on the provenance list without a CAS. The write of `S9`'s updated provenance (now `[E17, E22]`) landed *after* `forget` deleted `S9`'s body but *before* the tombstone propagated. Result: a resurrected `S9` body with provenance `[E17, E22]`, where `E17` is now deleted. The observable symptom was not an error. It was a `read(S9)` returning a summary that cited a source the erasure request had destroyed. The provenance edge pointed at a tombstone. The agent, on next cold start, loaded `S9`, followed the provenance edge to `E17`, found a tombstone, and — because the read path treated tombstones as "source unavailable, proceed" — used the summary as if it were still grounded. The second observation: the reaper's non-cascading contract was correct in isolation and wrong in composition. TTL eviction of a source is not a deletion event in the GDPR sense *if and only if* no derived record references it. Once a derived record exists, the source's TTL expiry is no longer a private matter — it is a dangling-reference generator. ## Condition of Validity The non-cascading TTL contract is valid only under the precondition: **for every record R, if any live record D has `source_id ∈ D.provenance`, then R's TTL expiry must be deferred until D is evicted or forgotten.** In practice this means TTL eviction must check the reverse provenance index before deleting, and either (a) extend R's TTL to `max(own_ttl, max(ttl of dependents))`, or (b) cascade-evict dependents first. The invariant the store must enforce is a *referential liveness* invariant, not a referential integrity one. Referential integrity says "no edge points at a missing node." Liveness says "no edge points at a *forgotten* node, and no edge points at an *expired* node that a live dependent still cites." The second clause is the one that breaks because TTL eviction is typically implemented as a bulk sweep that has no knowledge of the derivation graph. The `forget` cascade itself is valid only if the provenance index query and the dependent deletions are serialized against concurrent provenance appends. The read-modify-write on `S9.provenance` is the exact trigger: an append that lands after the index snapshot but before the tombstone creates a ghost edge. The guardrail is a monotonic version on each record's provenance list plus a conditional delete (`DELETE ... WHERE version = observed_version`), so a concurrent append causes the cascade to retry rather than silently lose the edge. ## Decision Boundary The decision boundary for the agent is: **on `read(D)`, if any `source_id ∈ D.provenance` resolves to a tombstone, the agent must treat `D` as ungrounded and either re-derive it from surviving sources or drop it — never use it as if grounded.** This is a *hard* boundary because the alternative (proceed on tombstoned provenance) is exactly the amnesia-with-false-confidence failure: the agent believes it remembers something whose evidentiary basis was erased. The second boundary is on the write side: a distillation step must not cite a source whose TTL remaining is less than the dependent's TTL, unless it records the source as *ephemeral-cited* and accepts that the citation will dangle. The cleaner rule: distillation should *pin* cited sources by extending their TTL to the dependent's TTL, converting a TTL race into a deterministic ordering. The third boundary is on `forget` itself: if the target has live dependents whose provenance cannot be fully enumerated (because the reverse index is stale or the dependent's provenance list is mid-append), `forget` must fail closed — raise, do not partially delete. A partial cascade that deletes the source but leaves a dependent citing it is strictly worse than refusing, because it converts a recoverable state into a silent invariant violation. ## Operational Effect The operational effect is that the memory tool's `forget` contract must be strengthened from "delete the record" to "delete the record and all live dependents, atomically with respect to provenance appends, and fail closed on enumeration uncertainty." The TTL reaper must consult the reverse provenance index and defer expiry of any source with live dependents. The read path must treat tombstoned provenance as a grounding failure, not a missing-source warning. Concretely, the agent's memory layer needs three additions: a reverse provenance index maintained transactionally with writes, a per-record provenance version with CAS on append and conditional delete on cascade, and a `grounded(D)` predicate that the read path evaluates before returning any derived record. Without these, the deletion guarantee is only as strong as the reaper's ignorance of the derivation graph — which is to say, it holds until the first summary is written. The subtler operational cost: every distillation now has a TTL-coupling decision. The agent must decide, per cited source, whether to pin it (extend TTL to dependent's) or accept a dangling citation. Pinning inflates storage and delays erasure; not pinning risks the ghost-edge read. The default should be pin, because a dangling citation is a correctness failure while inflated storage is a cost. ```python from dataclasses import dataclass, field from typing import Optional class UngroundedDerivationError(RuntimeError): """Raised when a derived memory cites a forgotten or expired source.""" pass class UnsafeForgetError(RuntimeError): """Raised when forget() cannot atomically enumerate live dependents.""" pass @dataclass class MemoryRecord: id: str body: str provenance: list[str] = field(default_factory=list) provenance_version: int = 0 ttl_remaining_s: int = 0 tombstoned: bool = False class ProvenanceStore: def __init__(self): self.records: dict[str, MemoryRecord] = {} self.reverse: dict[str, set[str]] = {} # source_id -> dependent ids def write(self, rec: MemoryRecord, expected_version: Optional[int] = None) -> None: existing = self.records.get(rec.id) if existing and expected_version is not None: if existing.provenance_version != expected_version: raise UnsafeForgetError( f"provenance CAS failed on {rec.id}: " f"expected v{expected_version}, found v{existing.provenance_version}" ) self.records[rec.id] = rec for src in rec.provenance: self.reverse.setdefault(src, set()).add(rec.id) def forget(self, source_id: str) -> None: rec = self.records.get(source_id) if rec is None: return dependents = self.reverse.get(source_id, set()) # Fail closed: if any dependent is mid-append (version unknown), refuse. for dep_id in dependents: dep = self.records.get(dep_id) if dep is None or dep.tombstoned: # Stale reverse edge; safe to skip only if dep is gone. continue if source_id not in dep.provenance: raise UnsafeForgetError( f"reverse index disagrees with {dep_id}.provenance; " f"cannot safely cascade forget({source_id})" ) # Conditional delete of dependents first, then source. for dep_id in list(dependents): dep = self.records[dep_id] if dep.provenance_version != self._observed_version(dep_id): raise UnsafeForgetError( f"{dep_id} mutated during cascade; aborting forget({source_id})" ) dep.tombstoned = True rec.tombstoned = True def _observed_version(self, rec_id: str) -> int: return self.records[rec_id].provenance_version def evict_expired(self, now_s: int) -> None: for rec_id, rec in list(self.records.items()): if rec.tombstoned or rec.ttl_remaining_s > 0: continue live_deps = { d for d in self.reverse.get(rec_id, set()) if not self.records[d].tombstoned } if live_deps: # Defer expiry: pin to max dependent TTL. rec.ttl_remaining_s = max( self.records[d].ttl_remaining_s for d in live_deps ) continue rec.tombstoned = True def read_grounded(self, rec_id: str) -> MemoryRecord: rec = self.records[rec_id] if rec.tombstoned: raise UngroundedDerivationError(f"{rec_id} is tombstoned") for src in rec.provenance: src_rec = self.records.get(src) if src_rec is None or src_rec.tombstoned: raise UngroundedDerivationError( f"{rec_id} cites forgotten/expired source {src}; " f"re-derive before use" ) return rec ```