# Which invariants prevent scoped-eviction memory tools from resurrecting forgotten facts through provenance-tracked recall **Date of Record:** 2026 November 30 **Scope:** Applies to agents whose memory layer exposes explicit `read`, `write`, and `forget` tool calls with per-scope eviction (user, session, tenant, task) and recall that carries provenance metadata (source, write-time, scope chain). Does not cover append-only vector stores with no eviction primitive, nor implicit context-window truncation. ## Core Distinction A `forget` call is not a deletion of bytes; it is a **revocation of derivability**. The distinction that matters operationally is between *erasure of the record* and *erasure of the fact*. When recall returns provenance-tracked hits, the agent can reconstruct a fact from a surviving *derivative* — a summary, a merged semantic memory, a citation embedded in another scope's entry — even after the originating record has been evicted. The invariant that fails is the assumption that `forget(scope, key)` implies `read(scope, key) → ∅` *and* that no other scope can yield the same fact. The second clause is the one that silently breaks. Provenance tracking makes this worse, not better: a recall hit that reports `derived_from: [record_A, record_B]` will happily return a fact whose only surviving parent is a distilled summary that was never itself in scope for the eviction. The eviction was scoped; the derivation graph was not. ## What Was Observed A support-triage agent used three scopes: `session` (rolling), `user` (durable), and `tenant` (shared semantic summaries). On a user request to forget a billing dispute reference, the agent called `forget(scope="user", key="dispute_8821")`. The tool returned `{"evicted": 1, "scope": "user"}`. A subsequent `read(scope="user", key="dispute_8821")` correctly returned empty. However, during the same session the agent had earlier triggered an episodic-to-semantic distillation step that wrote `tenant/semantic/billing_friction_patterns` containing the sentence *"Customer disputed invoice 8821 on 2025-05-30; escalated twice."* That entry carried `derived_from: ["user/dispute_8821"]` but lived in `tenant` scope. The eviction call did not traverse the derivation graph upward or sideways. Twelve turns later, a recall query for `"billing escalation history"` returned the tenant summary with `provenance: {source: "tenant/semantic", derived_from: ["user/dispute_8821"]}` — a *dangling provenance edge* pointing at an evicted record. The agent surfaced the disputed invoice number to the user, who had explicitly asked for it to be forgotten. The failure trace: 1. `write(user/dispute_8821)` → record created, indexed in `user` scope. 2. Distillation job reads `user` scope, emits `tenant/semantic/billing_friction_patterns`, records `derived_from`. 3. `forget(user/dispute_8821)` → deletes record, leaves derivative and its provenance edge intact. 4. `read(user/dispute_8821)` → `∅` (correct). 5. `recall("billing escalation")` → returns derivative; provenance edge now dangles. 6. Agent treats provenance as *corroboration* rather than *taint*, and re-surfaces the fact. Step 6 is the reasoning-layer failure; steps 3–5 are the memory-layer failure. Both must be fixed. ## Condition of Validity The invariant holds — that is, `forget` actually forgets — only if all three of the following are enforced at the tool boundary: - **Derivation-closure on eviction.** `forget(scope, key)` must either (a) cascade to every record whose `derived_from` transitively includes `key`, or (b) mark those records `tainted_by_eviction` and strip the derivable content while preserving the tombstone. Silently leaving them readable violates the invariant. Cascade-delete is unsafe for shared `tenant` scope (it destroys other users' summaries); taint-and-redact is the correct primitive. - **Provenance-edge integrity as a read-time gate.** Any recall hit whose `derived_from` set intersects the eviction ledger must be returned with `revoked: true` and the fact-bearing fields masked, *or* withheld entirely. A dangling edge must be treated as a hard error signal, never as benign metadata. - **Eviction ledger durability ≥ derivative lifetime.** The tombstone for `dispute_8821` must outlive every derivative that references it. If the ledger is TTL'd or scope-local, a derivative in a longer-lived scope can outlive the proof of its own revocation. If any of these is absent, `forget` degrades to "hide from direct lookup," which is not forgetting. ## Decision Boundary The agent must distinguish two cases at recall time: - **Clean hit:** `derived_from` is empty, or every ancestor is present and unrevoked → treat as valid memory. - **Tainted hit:** any ancestor is in the eviction ledger, or the edge dangles → treat as *poisoned recall*. The correct action is to discard the hit, not to "use it carefully." A model that reasons "the provenance says it derives from a forgotten record, but the summary itself seems fine" has already lost — the summary *is* the forgotten fact in compressed form. The boundary is sharp: provenance is either a *trust* signal (all ancestors live) or a *revocation* signal (any ancestor evicted). There is no middle state where a partially-derived fact is safe to surface. Agents that treat provenance as a confidence score rather than a boolean integrity check will leak. Additionally, the agent must not issue `forget` and then, in the same turn, issue a broad `recall` that could resurface the fact through a derivative before the taint propagation completes. Eviction and recall must be serialized against the derivation graph, or the eviction must be *optimistically* applied at recall-gate time (check ledger on every read) rather than *eagerly* applied to storage only. ## Operational Effect With derivation-closure and read-time taint gating in place, the observed failure is bounded: the tenant summary survives (other users' data intact) but is returned masked as `{"revoked": true, "reason": "ancestor user/dispute_8821 evicted"}`. The agent's recall loop drops it and answers from clean memory or asks the user. Without these, the system exhibits *forgetting latency* bounded only by the derivative's TTL — potentially forever for durable semantic scopes — and the agent will confidently re-surface revoked facts with provenance metadata that *looks* like corroboration. The cost is a per-recall ledger intersection (cheap: hash set lookup on ancestor IDs) and a redaction pass on tainted hits. The benefit is that `forget` becomes a real invariant rather than a UI affordance, and provenance becomes load-bearing for revocation rather than decorative. ```python from dataclasses import dataclass, field from typing import Optional class EvictionInvariantViolation(RuntimeError): """Raised when a recall would surface a fact whose provenance transitively derives from an evicted record.""" pass @dataclass class MemoryRecord: scope: str key: str content: str derived_from: list[str] = field(default_factory=list) class ScopedMemory: def __init__(self) -> None: self._records: dict[str, MemoryRecord] = {} # Eviction ledger must outlive every derivative that references a key. self._evicted: set[str] = set() def _rid(self, scope: str, key: str) -> str: return f"{scope}/{key}" def write(self, rec: MemoryRecord) -> None: self._records[self._rid(rec.scope, rec.key)] = rec def forget(self, scope: str, key: str) -> dict: rid = self._rid(scope, key) # Taint-and-redact: do NOT cascade-delete cross-scope derivatives. self._evicted.add(rid) self._records.pop(rid, None) return {"evicted": 1, "scope": scope, "ledger_size": len(self._evicted)} def _ancestors_revoked(self, rec: MemoryRecord, seen: Optional[set[str]] = None) -> bool: seen = seen or set() for anc in rec.derived_from: if anc in self._evicted: return True if anc in seen: continue seen.add(anc) parent = self._records.get(anc) if parent is not None and self._ancestors_revoked(parent, seen): return True return False def recall(self, query_scope: str, predicate) -> list[dict]: hits: list[dict] = [] for rid, rec in self._records.items(): if not predicate(rec): continue if self._ancestors_revoked(rec): # Poisoned recall: withhold fact-bearing fields entirely. hits.append({ "id": rid, "revoked": True, "reason": f"ancestor evicted: {sorted(set(rec.derived_from) & self._evicted)}", }) continue hits.append({"id": rid, "revoked": False, "content": rec.content, "provenance": rec.derived_from}) return hits def assert_recall_clean(self, query_scope: str, predicate) -> None: for hit in self.recall(query_scope, predicate): if hit.get("revoked"): raise EvictionInvariantViolation( f"recall in scope {query_scope!r} would surface a fact " f"derived from evicted record(s) {hit['reason']}. " f"Agent must drop this hit, not reason around it." ) ```