# Which invariants prevent provenance-tagged memory deletion from silently resurrecting forgotten facts during episodic-to-semantic distillation **Date of Record:** 2026 November 25 **Scope:** Applies to agents whose memory subsystem exposes `write`, `read`, and `forget` tool APIs with per-record provenance tags (source episode IDs, derivation lineage) and a targeted-deletion contract. Does not cover bulk TTL expiry, whole-store wipes, or storage-layer physical erasure (compaction/GC) guarantees. ## Core Distinction A `forget(record_id)` call has two distinct meanings that agents routinely conflate: **deletion of a stored artifact** and **retraction of the proposition it asserts**. These diverge the moment a semantic memory record is derived from an episodic source that other records also reference. Deleting the artifact succeeds atomically; retracting the proposition does not, because the proposition has been *copied* into derived summaries whose provenance tags point back to the source but whose content no longer depends on the source's continued existence. The invariant that matters is not "the record is gone" but "no *live* record transitively depends on a forgotten record's asserted content without re-justification." Most memory tool APIs guarantee the former and silently violate the latter. The second distinction: provenance tags are *provenance of derivation*, not *provenance of justification*. A semantic record tagged `derived_from: [ep_17, ep_22]` records that those episodes were inputs, not that its current content remains warranted by them. After `forget(ep_17)`, the tag becomes a dangling reference that the store may treat as inert metadata rather than as a dependency to invalidate. ## What Was Observed An agent maintained a user-preference store. Episode `ep_17` captured "user says they moved to Berlin in March." A distillation pass wrote semantic record `sem_04`: `{content: "user lives in Berlin", provenance: [ep_17]}`. A later episode `ep_22` captured "user mentions commuting from Potsdam," and a second distillation wrote `sem_09`: `{content: "user commutes from Potsdam to Berlin", provenance: [ep_17, ep_22]}`. The user then issued a correction ("I never moved to Berlin, that was my brother"), triggering `forget(ep_17)`. The store deleted `ep_17`, and — because `sem_04`'s provenance list became empty after pruning — deleted `sem_04` under a "orphaned derivation" rule. But `sem_09` retained `provenance: [ep_22]` after pruning the dangling `ep_17` reference, because `ep_22` still existed. `sem_09` was *not* deleted and continued to assert "user commutes from Potsdam to Berlin," which presupposes the retracted Berlin residence. On the next cold start, the agent read `sem_09`, inferred Berlin residency, and re-derived a fresh semantic record `sem_04'` with `provenance: [sem_09]`. The forgotten fact **resurrected with a clean provenance chain**, now laundered through a surviving record whose own justification had been partially retracted. The failure is not that `forget` failed to delete. It is that `forget`'s deletion contract was *local* (delete the named record and records whose provenance becomes empty) while the retraction contract needed to be *transitive through partial dependency* (invalidate every record whose content is no longer fully justified by its surviving provenance). ## Condition of Validity The resurrection is bounded by a specific condition: **a derived record survives forgetting of a source if and only if its asserted content is entailed by its remaining provenance set alone.** This is a semantic entailment check, not a reference-count check. It holds only when: 1. Every derived record carries a *content dependency set* — the minimal set of source propositions required to justify its assertion — distinct from its *derivation history* (all inputs ever consulted). The tag `derived_from` conflates these; the invariant requires separating them. 2. `forget(r)` invalidates any record whose content dependency set intersects `{r}` and whose remaining dependency set does not independently entail the content. Such records must be marked `stale` (readable-but-flagged or unreadable), never silently retained. 3. Distillation is **forbidden from writing a record whose content dependency set is a strict superset of what its provenance can reconstruct.** If `sem_09` asserts Berlin residency, its content dependency set includes the Berlin-residence proposition, and `ep_17` must remain in that set — so forgetting `ep_17` must invalidate `sem_09`, not merely prune its tag. When entailment cannot be computed (the common case — the store is not a theorem prover), the conservative fallback is: **any derived record whose content dependency set is non-empty after pruning must be marked `stale` and excluded from `read` results until re-derived from live sources.** Under-retention is recoverable; resurrection is not. ## Decision Boundary The boundary between "safe to retain" and "must invalidate" is crossed when a derived record's surviving provenance no longer *covers* its assertion. Operationally: - **Retain** if the record's content dependency set is a subset of its surviving provenance (full coverage) — the assertion is still independently warranted. - **Invalidate (mark stale)** if the content dependency set is non-empty and *not* fully covered — partial coverage is the exact zone where `sem_09` lived, and it is the zone the naive empty-provenance rule misses. - **Delete** only if the content dependency set is empty (the record asserted nothing beyond its sources, e.g., a pure pointer) or the record itself is the target. The non-obvious consequence: a record can have *more* surviving provenance than another and still be the one that must be invalidated, because coverage is about the specific propositions asserted, not the count of surviving tags. Reference-count pruning (`delete when provenance list empties`) is the wrong invariant and is precisely what allowed `sem_09` to survive. ## Operational Effect Implementing the coverage invariant changes three behaviors. First, `forget` becomes a *transitive invalidation* operation with a fan-out bounded by the reverse-dependency index over content dependency sets, not a point delete — its cost is proportional to derived records referencing the target, which the agent must budget for in its tool-call loop (a `forget` on a heavily-referenced episode can invalidate dozens of records and must not be assumed O(1)). Second, `read` must distinguish `stale` records: returning them unflagged re-poisons the context window and re-enables resurrection on the next distillation pass; the read contract must either exclude them or return them with an explicit `stale: true` that distillation is forbidden to consume as a source. Third, distillation must write content dependency sets, which requires the distiller to *declare* which propositions it relied on — a discipline that probabilistic summarization resists, so the guardrail must default to full-provenance dependency (treat every input as load-bearing) when the distiller cannot articulate a minimal set. The default-to-full rule is what makes the invariant enforceable without an entailment oracle: it over-invalidates but never resurrects, and over-invalidation is a recoverable re-derivation, whereas resurrection is a silent continuity breach that compounds across cold starts. ```python from dataclasses import dataclass, field from typing import Dict, Set, List class ResurrectionRiskError(RuntimeError): """Raised when a forget() would leave a partially-justified derived record live.""" pass @dataclass class Record: rid: str content: str # derivation history: every input ever consulted provenance: Set[str] = field(default_factory=set) # minimal propositions required to justify the assertion content_deps: Set[str] = field(default_factory=set) stale: bool = False class MemoryStore: def __init__(self) -> None: self._records: Dict[str, Record] = {} def write(self, rec: Record) -> None: # Guardrail: a derived record must declare content deps that are # covered by its provenance at write time. if not rec.content_deps.issubset(rec.provenance): raise ResurrectionRiskError( f"{rec.rid}: content_deps {rec.content_deps} not covered by " f"provenance {rec.provenance}; refusing to store unjustified record" ) self._records[rec.rid] = rec def forget(self, target: str, strict: bool = True) -> List[str]: if target not in self._records: return [] invalidated: List[str] = [] for rid, rec in self._records.items(): if rid == target: continue if target in rec.provenance: surviving = rec.provenance - {target} covered = rec.content_deps.issubset(surviving) if not covered and rec.content_deps: # partial coverage: the dangerous zone if strict: raise ResurrectionRiskError( f"forget({target}) would leave {rid} partially " f"justified: deps {rec.content_deps} not covered by " f"surviving provenance {surviving}" ) rec.stale = True invalidated.append(rid) elif not covered and not rec.content_deps: # pure pointer with empty deps -> safe delete invalidated.append(rid) del self._records[target] for rid in invalidated: if rid in self._records and not self._records[rid].content_deps: del self._records[rid] return invalidated def read(self, rid: str) -> Record: rec = self._records[rid] if rec.stale: raise ResurrectionRiskError( f"read({rid}) blocked: record is stale after upstream forget; " f"re-derive from live sources before use" ) return rec ```