# Which invariants prevent TTL-expiry resurrection from silently re-admitting forgotten facts into an agent's semantic memory **Date of Record:** 2026 November 22 **Scope:** Applies to agents exposing discrete `memory.write`, `memory.read`, `memory.forget` tool contracts where each record carries provenance (source episode ID, writer agent, timestamp) and a TTL. Does not cover in-context scratchpads or vector stores without explicit forget semantics. ## Core Distinction The failure this record concerns is not "forgetting fails to delete." It is **forgetting succeeds, and then a *different* code path re-materializes the forgotten fact under a new identity**. A `forget` call that tombstones a record by primary key is locally correct: a subsequent `read` of that key returns null. The invariant that actually matters is *global*: no fact derivable from a forgotten record may re-enter the retrievable set without an explicit, provenance-checked re-assertion. The distinction is between **key-level deletion** (which the tool contract guarantees) and **lineage-level exclusion** (which it does not, unless the contract enforces it). The resurrection vector is TTL. Every memory record has an expiry. When a record expires, a distillation/compaction job reads the soon-to-expire records, summarizes them into a new semantic record with fresh provenance and a fresh TTL, and writes that back. If a `forget` tombstone is keyed on the *original* record ID but the compactor reads from a snapshot or a secondary index that predates the tombstone, the forgotten content is laundered into a new record whose provenance points at the *compactor*, not at the forget event. The tombstone no longer matches anything. The fact is back, with a clean audit trail that looks legitimate. ## What Was Observed A research agent distilled episodic session logs into semantic memory nightly. Each episodic record carried `source_episode_id`, `writer`, `created_at`, and a 72h TTL. A compaction job ran at 03:00: select episodic records where `expires_at < now + 24h`, summarize each cluster, write a semantic record with `provenance = {derived_from: [episode_ids], compactor: "nightly-v3"}`. A user issued `memory.forget` on a specific episodic record at 14:00 (a PII retraction). The tool tombstoned the key and returned success. At 03:00 the compactor's selection query ran against a read replica that had not yet replicated the tombstone write (replication lag was ~40s, but the selection query had been materialized into a cached view the previous night and was not invalidated). The forgotten episode was included in a cluster of four. The summarizer produced a semantic record whose text contained the retracted fact. It was written with `derived_from` listing the tombstoned episode ID — but nothing in the write path validated that the listed source IDs were still live. The record was now retrievable, TTL 30 days, and its provenance *pointed at the tombstone* without the write path checking it. A later audit that grepped for the raw episode ID in provenance would have found the deleted key referenced by a live record and flagged it — but only if the audit checked referential liveness, which it did not. ## Condition of Validity The invariant holds only if the following three conditions are enforced **at write time, inside the memory tool, not in the caller**: 1. **Provenance liveness check.** Every `memory.write` that declares `derived_from: [ids]` must reject the write if any listed ID resolves to a tombstone. The check must run against the authoritative store, not a replica or cached view. 2. **Tombstone is monotonic and survives compaction.** A tombstone must never be garbage-collected while any record could still reference it. TTL on a tombstone is itself a resurrection vector: once the tombstone expires, a stale provenance reference becomes valid again. Tombstones must be retained for at least `max(TTL of any record that could reference them) + max(compaction lag)`. 3. **Compaction reads must be snapshot-consistent with forget.** The selection query that feeds a compactor must be evaluated against a snapshot taken *after* the latest tombstone commit, or must re-validate liveness per-ID at write time (condition 1 covers this if enforced). If any of these is delegated to the caller ("the compactor is expected to filter tombstones"), the invariant does not hold, because the compactor is an LLM-driven or LLM-adjacent component whose filtering is probabilistic and whose failure is silent. ## Decision Boundary The boundary between "safe to summarize" and "must re-validate" is the presence of a **derived record whose provenance crosses a forget boundary**. Concretely: - Same-writer, same-episode, non-derived writes: no provenance check needed; the tombstone on the key suffices. - Any write with `derived_from` containing an ID the writer did not itself create in the same session: **must** pass the liveness check. This is the boundary. A compactor summarizing its own just-created scratch records is safe; a compactor summarizing records written by other sessions or read from a selection query is not. When the boundary is crossed without the check, the failure is not detected by the forget tool (it returned success) nor by the read tool (it returns the laundered record as a normal hit). It is detected only by an audit that joins live records' provenance against tombstones — which is why the guardrail must be at write time. ## Operational Effect After the incident, the memory tool contract was amended: `write` with `derived_from` performs a synchronous liveness join against the primary store and raises a typed error on any tombstoned ancestor. The compactor was changed to treat that error as a signal to drop the entire cluster (not to retry, and not to drop just the offending reference — dropping the reference while keeping the summary would launder the fact by severing its provenance). Tombstone retention was raised to 45 days, exceeding the 30-day semantic TTL plus compaction lag. The net effect: a forgotten fact can only re-enter via an explicit `write` with no `derived_from` link, which is an auditable re-assertion rather than a silent resurrection. ## Code ```python class ForgottenAncestorError(RuntimeError): """Raised when a derived memory write references a tombstoned ancestor.""" pass class MemoryStore: def __init__(self): self.records = {} # id -> record dict self.tombstones = {} # id -> forget event (retained >= max TTL + lag) def forget(self, record_id: str, reason: str) -> None: self.tombstones[record_id] = {"reason": reason, "monotonic": True} self.records.pop(record_id, None) def write(self, record: dict) -> str: derived_from = record.get("derived_from", []) # Invariant: provenance liveness is checked at write time, on the # authoritative store, not delegated to the caller. for ancestor_id in derived_from: if ancestor_id in self.tombstones: raise ForgottenAncestorError( f"write of {record.get('id')} references tombstoned " f"ancestor {ancestor_id}; drop the cluster, do not " f"launder by severing provenance" ) if ancestor_id not in self.records: raise ForgottenAncestorError( f"write of {record.get('id')} references unknown " f"ancestor {ancestor_id}; refusing unverifiable lineage" ) self.records[record["id"]] = record return record["id"] def compact_cluster(store: MemoryStore, episode_ids: list[str], summary: dict) -> str: # Compactor path: build a derived record and let the store enforce liveness. summary = dict(summary) summary["derived_from"] = list(episode_ids) return store.write(summary) # Trace of the failure the invariant now blocks: store = MemoryStore() store.write({"id": "ep-1", "text": "retracted fact", "derived_from": []}) store.write({"id": "ep-2", "text": "benign", "derived_from": []}) store.forget("ep-1", reason="PII retraction") # Before the guardrail this succeeded and laundered the fact. # Now it raises and the compactor must drop the whole cluster. try: compact_cluster(store, ["ep-1", "ep-2"], {"id": "sem-9", "text": "summary"}) except ForgottenAncestorError as e: print(f"cluster dropped: {e}") ```