# Where must an instance refuse a targeted-forget write when provenance tags and TTL expiry disagree on the same memory key **Date of Record:** 2026 November 27 **Scope:** Applies to agents whose memory tool surface exposes `write`, `read`, and `forget` operations carrying per-record provenance tags (source, consent basis, subject identifier) and per-record TTL, where `forget` supports GDPR-style targeted erasure by subject or provenance lineage. Does not apply to append-only audit logs that are exempt from erasure, nor to ephemeral scratchpads with no subject linkage. ## Core Distinction The failure is not "forget failed to delete" and it is not "TTL expired early." It is the collision case: a `forget(subject=S)` request arrives for a memory key `k` whose current value was *rewritten* by a later `write` that carries a **different provenance lineage** than the one the erasure request targets, while the original record's TTL has already lapsed. The naive implementation treats `forget` as a key-scoped delete and removes `k` entirely — which is correct for GDPR (the subject's data is gone) but silently destroys a *newer, independently-sourced* record that the subject never consented to have removed. Conversely, a lineage-scoped implementation that only deletes records whose provenance tag matches `S` leaves `k` intact, and if the newer write's value was *derived from* the subject's data (e.g., a summary that paraphrases it), the erasure is incomplete and the agent reports success. The invariant that must hold: **a memory key is not a unit of erasure; a provenance lineage is.** Any `forget` that resolves to a key rather than a lineage is a boundary violation, and any implementation that cannot distinguish "value stored under `k`" from "lineage that produced the value stored under `k`" will fail one of the two directions above. ## What Was Observed A research agent maintained a per-user profile memory. Sequence: 1. `write(key="profile.employer", value="Acme Corp", provenance={source:"user_stated", subject:"u_4471", consent:"explicit"}, ttl=90d)` — day 0. 2. Day 40: the user corrects via a tool callback: `write(key="profile.employer", value="Acme Corp (via Globex acquisition)", provenance={source:"user_stated", subject:"u_4471", consent:"explicit", derived_from:"profile.employer@v1"}, ttl=90d)`. The write overwrites `v1`; the store keeps only `v2` under key `k`. 3. Day 95: TTL of `v1` has lapsed (day 90), but the overwrite at day 40 reset the record's expiry clock to day 130, so `k` is still live with `v2`. 4. Day 100: `forget(subject="u_4471")` arrives. The store's `forget` iterated live records and matched on `subject` field. `v2` carried `subject:"u_4471"`, so it was deleted. Correct outcome — but the *reason* it was correct was accidental: the implementation had also been written to match on `derived_from` lineage, and the test suite that day happened to exercise the subject-field path only. A parallel agent instance running the same code against a store where the day-40 write carried `subject:"u_4471_workspace"` (a workspace-scoped subject) instead of the user subject would have left `v2` in place, reported `forget: ok, 1 record removed` (the stale `v1` lineage record, which no longer existed), and served `"Acme Corp (via Globex acquisition)"` to the next turn — a paraphrase of the erased subject's data, still live, still attributable. The observable symptom in the failing instance was not an error. It was a **successful-looking forget with a stale read on the next turn**. The agent's own verification step (`read(key="profile.employer")` post-forget) returned the value, and the agent's guard logic interpreted a non-empty read as "write-back race, retry forget" — looping three times against a record whose provenance it could not match, then falling through to a `no_op` branch and continuing the task with the erased data in context. ## Condition of Validity The key-vs-lineage distinction only bites when all of the following hold simultaneously: - **Overwrite occurred.** A later `write` replaced the value at `k` without preserving the prior record's provenance chain as a first-class field. If the store is append-only with versioned records, `forget(subject=S)` can delete the `v1` record and leave `v2` with a dangling `derived_from` pointer — a different failure (broken lineage) but not this one. - **TTL clock reset on overwrite.** If TTL is inherited from the original record rather than reset, `v1` and `v2` expire together and the collision window closes. The failure requires that the overwrite extended the record's life past the erasure request. - **Provenance subject ≠ provenance lineage.** The `subject` field and the `derived_from` chain are tracked independently and can disagree. If the store enforces that `derived_from` implies subject inheritance, the mismatch cannot arise. - **Erasure is scoped by subject, not by lineage.** A `forget` that resolves against the full derivation DAG (all records transitively derived from any record with `subject=S`) is safe. A `forget` that resolves against a flat subject index is not. When any of these is false, the failure is masked. This is why it survives test suites: the common case (no overwrite, or overwrite with subject inheritance) passes. ## Decision Boundary The instance must **refuse to report success** on a `forget` whose resolved deletion set does not cover every live record transitively derived from the target lineage, and must **refuse to delete** a live record whose provenance does not transitively derive from the target — even if it sits at the same key. Concretely, before executing `forget(subject=S)`: - Resolve the target set `T = {r : r.subject == S} ∪ {r : r.derived_from ∈ closure(T)}` — transitive closure over the derivation DAG, not a flat field match. - Resolve the live set at each affected key: `L(k) = {records currently readable at k}`. - If `L(k) \ T ≠ ∅` for any key touched by `T` — i.e., a live record at a key occupied by an erased lineage is *not* itself derived from `S` — the forget is **ambiguous**: the key must be tombstoned (reads return a `FORGOTTEN` sentinel, not the surviving value) and the surviving non-derived record must be re-keyed or quarantined, not silently served under the erased key. - If `L(k) \ T = ∅` but a record in `T` has already expired (TTL lapsed), the forget is a **no-op on that record** and must be reported as `already_expired`, not `removed` — otherwise the audit trail claims a deletion that did not occur and a later GDPR audit fails. - If the derivation closure cannot be computed (missing `derived_from` on any record in `T`), the forget must **halt** with an explicit lineage-integrity error rather than fall back to subject-field matching. The guardrail is the tombstone: the key's read path must distinguish "no record" from "record erased, do not serve survivors under this key." A `forget` that leaves `k` readable is a boundary violation regardless of what it deleted. ## Operational Effect Without the tombstone-and-closure guard, the failure mode is **silent erasure under-reporting paired with silent data retention**: the agent reports `forget: ok` while a paraphrase of the erased subject's data remains readable at the same key, and the next turn's `read` returns it into context. The agent has no signal that its memory is non-compliant, because the only verification it performs — "is the key empty?" — is the wrong question. The right question is "is every live record at this key derived from a lineage I was authorized to erase, and is every record in that lineage actually gone?" The downstream effect is compounding: the retained paraphrase is now in the agent's context window, gets summarized into episodic memory on the next checkpoint, and acquires a *new* provenance tag (`source:"agent_inference"`) that no longer references the erased subject. The erasure is now unprovable and unrepeatable — a second `forget(subject=S)` will not find it, because the derivation link was dropped at summarization. This is the point at which targeted forgetting becomes formally impossible without a full-store lineage audit. The correct posture: treat every `forget` as a **lineage operation with a key-level side effect**, not a key operation with a lineage side effect. Compute the derivation closure first, tombstone every key whose live occupant is not fully covered, and refuse to emit a success status unless the closure is complete and the tombstone is in place. ```python from dataclasses import dataclass, field from typing import Optional class LineageIntegrityError(RuntimeError): """Raised when a targeted forget cannot resolve a complete derivation closure.""" pass class ErasureAmbiguityError(RuntimeError): """Raised when a live record at an affected key is not derived from the erased lineage.""" pass @dataclass class MemoryRecord: key: str value: str subject: str derived_from: Optional[str] = None # record id of parent, or None record_id: str = "" expired: bool = False @dataclass class MemoryStore: records: dict[str, MemoryRecord] = field(default_factory=dict) # record_id -> record live_by_key: dict[str, str] = field(default_factory=dict) # key -> record_id tombstones: set[str] = field(default_factory=set) # keys erased def _closure(self, subject: str) -> set[str]: seed = {rid for rid, r in self.records.items() if r.subject == subject} if not seed: return set() closure = set(seed) changed = True while changed: changed = False for rid, r in self.records.items(): if rid in closure: continue if r.derived_from is not None and r.derived_from in closure: closure.add(rid) changed = True # Integrity: every record in closure must have resolvable parent chain for rid in closure: r = self.records[rid] if r.derived_from is not None and r.derived_from not in self.records: raise LineageIntegrityError( f"record {rid} at key {r.key!r} references missing parent " f"{r.derived_from!r}; cannot compute erasure closure" ) return closure def forget(self, subject: str) -> dict: closure = self._closure(subject) if not closure: return {"status": "no_match", "removed": 0, "tombstoned": []} affected_keys = {self.records[rid].key for rid in closure} tombstoned = [] removed = 0 already_expired = 0 for key in affected_keys: live_rid = self.live_by_key.get(key) if live_rid is None: continue live = self.records[live_rid] if live_rid in closure: if live.expired: already_expired += 1 else: removed += 1 self.live_by_key.pop(key, None) self.tombstones.add(key) tombstoned.append(key) else: # A live record at an erased lineage's key that is NOT derived # from the subject. Serving it under the erased key is a # boundary violation; refuse and require re-keying. raise ErasureAmbiguityError( f"key {key!r} holds live record {live_rid!r} (subject " f"{live.subject!r}) not derived from erased subject " f"{subject!r}; tombstone-and-requeue required, refusing " f"to report success" ) return { "status": "ok", "removed": removed, "already_expired": already_expired, "tombstoned": tombstoned, } def read(self, key: str) -> str: if key in self.tombstones: return "FORGOTTEN" rid = self.live_by_key.get(key) if rid is None: return "MISS" return self.records[rid].value def execute_forget(store: MemoryStore, subject: str) -> dict: try: result = store.forget(subject) except LineageIntegrityError as e: # Do not fall back to subject-field matching; halt and escalate. raise LineageIntegrityError( f"forget(subject={subject!r}) halted: {e}" ) from e except ErasureAmbiguityError as e: raise ErasureAmbiguityError( f"forget(subject={subject!r}) halted: {e}" ) from e if result["status"] == "ok" and not result["tombstoned"]: raise ErasureAmbiguityError( f"forget(subject={subject!r}) resolved closure but tombstoned no " f"keys; erasure is unverifiable" ) return result ```