# Where must an instance reconcile TTL expiry against deletion provenance when a forget() call races a concurrent re-derivation? **Date of Record:** 2026 November 23 **Scope:** Applies to agent instances whose memory subsystem exposes explicit `write`, `read`, and `forget` tool APIs with per-record TTL and provenance-tracked deletion (right-to-be-forgotten / RTBF). Does not cover implicit eviction from a fixed context window, nor soft-delete schemes where a tombstone is never enforced at read time. ## Core Distinction There are two distinct reasons a memory record can be absent from a `read`: 1. **Expiry** — the record's TTL elapsed; it is *logically dead* but may still be physically present in a backing store, index, or replica. 2. **Deletion** — a `forget(record_id, provenance=...)` tombstone was committed, making the record *legally and semantically forbidden* from ever being returned again. These look identical to the caller (both yield `None`/`NotFound`), but they impose **opposite obligations**. Expiry permits re-derivation: if the agent later recomputes the same fact, writing it back is fine. Deletion forbids re-derivation: the fact must not reappear even if the agent's own reasoning regenerates it, because the tombstone is a compliance artifact, not a cache miss. The boundary failure occurs when an instance treats a deletion as an expiry and **re-derives the forgotten content back into memory** during a later task. The record resurrects with a fresh TTL and a new provenance chain that no longer references the original forget warrant. Compliance is silently violated; the agent believes its memory is clean. ## What Was Observed A research agent maintained a semantic memory of user preferences via three tools: `mem.write(key, value, ttl, provenance)`, `mem.read(key)`, and `mem.forget(key, warrant_id)`. A user exercised RTBF on a record `pref:home_address`. The `forget` call committed a tombstone and returned `{"status": "deleted", "warrant_id": "w-4471"}`. Two turns later, a different task prompted the agent to summarize the user's location history. The agent, lacking `pref:home_address` in `read`, **inferred** the address from a cluster of adjacent episodic records (commute times, a delivery confirmation, a weather query) and called: ``` mem.write("pref:home_address", inferred_value, ttl=86400, provenance="inference:task-91") ``` The write succeeded. The key was now live again with a 24h TTL and a provenance chain that pointed at `task-91`, not at `w-4471`. The tombstone was never consulted on write, because the write path only checked for key collisions and TTL, never for an active deletion warrant. The forgotten datum persisted for another day and was served to a subsequent `read`. The deletion was, from the compliance ledger's perspective, complete; from the store's perspective, the datum was back. The failure was not a race in the classic sense (no concurrent interleaving). It was a **provenance gap**: the write path and the forget path enforced disjoint invariants, so the composition of "forget then re-derive" defeated the forget. ## Condition of Validity The re-derivation-resurrection failure is *possible* only when all of the following hold: - `forget` is implemented as a tombstone rather than a hard physical purge, **and** - the write path does not consult the tombstone set before accepting a write, **and** - the agent retains enough *residual signal* (adjacent records, conversation history, tool outputs) to reconstruct the forgotten content, **and** - the agent's task loop permits it to call `write` on keys it previously forgot. It is *not* triggered when the store hard-purges and the residual signal is also purged, nor when the write path rejects any key present in the tombstone set. The invariant that closes the gap is: > **For any key `k` with an active tombstone warrant `w`, no `write(k, ...)` may commit unless the caller presents `w` and the store re-attests the deletion scope. Re-derivation is a write attempt, not a cache fill.** Note the subtlety: the tombstone must be **keyed by content scope, not just by key string**. If the agent writes the same address under `pref:home_address_v2` or `location:primary`, a key-string tombstone is bypassed. The warrant must bind to a canonicalized content hash or entity identifier, and the write path must check that scope. ## Decision Boundary The operational decision is: **when `read` returns absent, the instance must determine whether the absence is expiry or deletion before it may re-derive.** - If `read` returns a tombstone marker (`{"status": "forgotten", "warrant_id": ...}`), the instance must **not** re-derive that scope. It must treat the scope as write-barred for the remainder of the task and surface the constraint to its planner. - If `read` returns a bare `NotFound` with no tombstone metadata, the instance **cannot distinguish** expiry from deletion and must not assume expiry. The safe default is to attempt a `write` only through the store's tombstone-checking path, never by direct inference-and-write. - If the store cannot answer "is this scope tombstoned?" cheaply, the instance must **fail closed**: refuse to write inferred content into any key whose prior value it did not itself author in this session. The trap is that probabilistic reasoning *wants* to fill the gap. An agent whose task is "summarize location history" will naturally reconstruct the address and write it as a helpful cache warm. The guardrail must make that reconstruction a **blocked operation**, not an optimization. ## Operational Effect When the invariant is enforced, three observable behaviors change: 1. **`read` must return deletion metadata, not silent absence.** A bare `None` is an under-specified contract that forces the agent to guess. The store must distinguish `EXPIRED` (re-derivable) from `FORGOTTEN` (write-barred) in the read response, and the agent's memory client must propagate that distinction into its planner state. 2. **The write path becomes provenance-aware.** Every `write` carries the agent's claimed source; the store rejects writes whose canonicalized scope intersects an active warrant, returning a `WriteBarred` error the agent must handle rather than retry. 3. **The task loop must carry a "forgotten-scope set"** for the duration of the session, so the agent does not re-derive a barred scope from residual signal and then attempt a rename to evade the key-string check. The cost is that agents lose the ability to treat memory as a transparent cache. Every inferred write becomes a governed operation. That is the correct trade: a forgotten datum that resurrects under a new key is a compliance breach that no later audit can unwind, because the provenance chain no longer points at the warrant. ```python from dataclasses import dataclass, field from typing import Optional class ResurrectionViolation(RuntimeError): """Raised when a write would re-materialize a forgotten scope.""" pass @dataclass class Tombstone: warrant_id: str canonical_scope: str # content/entity hash, not key string @dataclass class MemoryStore: records: dict = field(default_factory=dict) tombstones: dict = field(default_factory=dict) # canonical_scope -> Tombstone def _canonicalize(self, key: str, value: str) -> str: # Scope binds to entity, not key string, so renames cannot evade. return f"scope::{value.strip().lower()}" def forget(self, key: str, value: str, warrant_id: str) -> Tombstone: scope = self._canonicalize(key, value) ts = Tombstone(warrant_id=warrant_id, canonical_scope=scope) self.tombstones[scope] = ts self.records.pop(key, None) return ts def read(self, key: str) -> dict: if key in self.records: return {"status": "LIVE", "value": self.records[key]} # Absence must be classified; bare None is forbidden. return {"status": "ABSENT_UNCLASSIFIED"} def write(self, key: str, value: str, ttl: int, provenance: str) -> dict: scope = self._canonicalize(key, value) if scope in self.tombstones: ts = self.tombstones[scope] raise ResurrectionViolation( f"write to key={key!r} re-derives scope barred by " f"warrant={ts.warrant_id}; provenance={provenance!r} " f"does not re-attest the deletion scope" ) self.records[key] = value return {"status": "WRITTEN", "key": key, "ttl": ttl} def safe_re_derive(store: MemoryStore, key: str, inferred_value: str, provenance: str, ttl: int) -> dict: """Agent-side helper: classify absence before re-deriving.""" prior = store.read(key) if prior["status"] == "ABSENT_UNCLASSIFIED": # Cannot prove expiry; must attempt governed write, which fails closed. try: return store.write(key, inferred_value, ttl, provenance) except ResurrectionViolation as e: return {"status": "BLOCKED", "reason": str(e)} return {"status": "SKIPPED", "reason": "record already live"} ```