When must an instance refuse a `forget` that its own provenance graph proves is still load-bearing
**Date of Record:** 2026 December 1 **Scope:** Applies to agents whose memory tool surface separates episodic writes (immutable, timestamped, provenance-tagged) from semantic writes (distilled, mutable, deduplicated), and which expose a `forget`/`delete` operation that can target either store. Does not apply to single-store vector memory with no provenance edges, nor to stores where forgetting is purely a TTL expiry with no explicit caller-driven deletion.
Core Distinction
The failure mode is not "the agent forgot something it needed." It is the inverse: **the agent successfully executed a `forget` on an episodic record that was the sole provenance ancestor of a semantic claim still in active use.** The semantic store does not know it has been orphaned, because provenance edges are directional (episodic → semantic) and the semantic record's validity check only looks *forward* (does the claim still match retrieval queries?) rather than *backward* (does the evidence it was distilled from still exist?).
A memory tool that treats `forget` as a local delete on the addressed record is correct only if no derived record cites it. The moment distillation exists, `forget` becomes a **graph mutation with downstream validity consequences**, and the naive implementation silently converts a grounded semantic claim into an unfalsifiable assertion that the agent will keep asserting with full confidence.
What Was Observed
A research agent maintains two stores:
- `episodic`: append-only tuples `(eid, ts, source, content, hash)`. Source is one of `tool:<name>`, `user`, `inference`. Never mutated after write.
- `semantic`: distilled claims `(sid, claim, confidence, support: [eid...], distilled_at)`. Written by a consolidation pass that reads a window of episodic records and emits claims whose `support` list points at the exact `eid`s used.
The consolidation pass runs nightly. During a long task, the agent writes an episodic record `e_4417` from `tool:http_fetch` capturing a pricing page: "Enterprise tier listed at $0.04/1k tokens as of fetch." Consolidation distills `s_902`: "Vendor enterprise pricing is $0.04/1k tokens," `confidence=0.82`, `support=[e_4417]`.
Later in the same task, the agent's context window saturates. A context-management routine decides to free space by calling `forget(eid="e_4417")` — the raw HTML is large and the agent judges the distilled claim sufficient. The `forget` succeeds. The episodic store drops `e_4417`.
Now `s_902` has `support=[e_4417]` where `e_4417` no longer resolves. The semantic record is not invalidated, not downgraded, not flagged. On the next retrieval, `s_902` matches a pricing query, returns `confidence=0.82`, and the agent emits "enterprise pricing is $0.04/1k tokens" into a downstream deliverable — **with no way to re-verify, because the evidence is gone and the claim's confidence number was computed against evidence that no longer exists.**
The compounding variant: the vendor changed pricing to $0.06 two days earlier. The fetched page was cached/stale. The agent *could* have caught this by re-fetching and comparing to `e_4417`'s `source` and `ts`. But `e_4417` is gone, so the re-verification path — which the agent's own tooling would have taken had the record survived — is severed. The agent has forgotten the *provenance* while retaining the *conclusion*, which is exactly backwards from what a grounded memory system requires.
A second observed trace: two semantic claims `s_902` (support `[e_4417]`) and `s_903` ("enterprise tier includes SSO," support `[e_4417, e_4419]`) both cite `e_4417`. Forgetting `e_4417` orphans both, but `s_903` retains `e_4419` as a live witness. The correct behavior differs per record: `s_903` should be *downgraded* (partial support lost), `s_902` should be *invalidated* (total support lost). A flat `forget` cannot distinguish these.
Condition of Validity
A `forget` on an episodic record `e` is **safe** iff, for every semantic record `s` with `e ∈ s.support`, at least one of:
- `s.support \ {e}` is non-empty and each remaining `eid` resolves and is not itself `forget`-pending (transitive closure), **and** the distillation confidence was recomputed against the reduced support set; or
- `s` is explicitly re-derived or re-verified against a live source before `e` is dropped; or
- `s` is itself marked `invalidated` and excluded from retrieval in the same transaction.
The invariant is: **no semantic record may be retrievable while all of its provenance ancestors are unresolvable.** Equivalently, the retrieval layer must never surface a claim whose `support` set is empty or dangling. This is a backward-closure invariant on the provenance DAG, and it is *not* maintained by append-only episodic writes alone — it requires the delete path to consult the reverse index.
The condition fails silently precisely because the episodic store is correctly append-only for writes: the system's designers reasoned "episodic records are immutable, so provenance is safe," and missed that *deletion* is a mutation of the provenance graph even when writes are not.
Decision Boundary
The boundary between "forget is a local delete" and "forget is a graph mutation" is crossed the instant a semantic store exists with `support` edges into the episodic store. Below that line, `forget(eid)` is O(1) and safe. Above it, `forget(eid)` must be treated as:
- **Blocked** if it would orphan a live semantic record with no surviving witness (raise, do not silently succeed).
- **Cascading** if the caller opts into `cascade=True`: the transaction invalidates all orphaned `s` and removes `e` atomically, so retrieval never observes the intermediate state.
- **Downgrading** if partial support survives: recompute `confidence` over the reduced support set, and record the reduction as a new episodic event (`source=inference`, "support for s_902 reduced from {e_4417} to {}").
The decision is *not* "should I forget" — the caller's intent to free space is legitimate. The decision is **whether the caller has authority to invalidate derived claims**, and by default it does not. The default must be to refuse and force the caller to state the consequence explicitly.
A subtle second boundary: `forget` targeted at a *semantic* record is always safe (it has no forward dependents unless semantic records cite each other, which they should not in a well-formed distillation DAG). The asymmetry — episodic forget is dangerous, semantic forget is safe — is the operational rule that is easy to get backwards, because episodic records *feel* like the disposable ones (they are large, raw, redundant) and semantic claims *feel* like the durable ones. The opposite is true: the raw record is the only thing that can re-ground the claim.
Operational Effect
With the backward-closure guard in place, three behaviors change:
- **Context-management routines can no longer free space by forgetting cited evidence.** They must either forget uncited records, or accept cascade invalidation of the claims that depend on them. In practice this pushes the agent toward forgetting *semantic* records (safe, cheap) and retaining episodic records until their last dependent is retired — which is the correct economics, since a semantic claim is a compression of its support and costs less to keep.
- **Retrieval gains a dangling-support filter.** Every semantic read checks `support` resolves; unresolvable records are excluded and logged. This converts a silent correctness bug into a visible, countable signal (`dangling_support_count`), which is the metric that reveals a leaky forget path in production.
- **Re-verification becomes possible again.** Because `e_4417` survives until `s_902` is retired, the agent can re-fetch the pricing page and diff against the original `content`/`ts`, catching the $0.04→$0.06 drift. The provenance edge is not just bookkeeping; it is the *address of the re-verification procedure*.
The cost is that episodic storage grows until dependents are explicitly retired, and the consolidation pass must be paired with a retirement pass. That pairing is the invariant: **distillation without retirement is a memory leak of un-retirable evidence; retirement without distillation is amnesia.** The `forget` guard is what keeps the two in lockstep.
from dataclasses import dataclass, field
from typing import Optional
class OrphanedProvenanceError(RuntimeError):
"""Raised when a forget would leave a live semantic claim with no resolvable support."""
pass
@dataclass
class Episodic:
eid: str
content: str
source: str
@dataclass
class Semantic:
sid: str
claim: str
confidence: float
support: list[str]
invalidated: bool = False
@dataclass
class ProvenanceStore:
episodic: dict[str, Episodic] = field(default_factory=dict)
semantic: dict[str, Semantic] = field(default_factory=dict)
# reverse index: eid -> set of sid that cite it
cited_by: dict[str, set[str]] = field(default_factory=dict)
def add_episodic(self, e: Episodic) -> None:
self.episodic[e.eid] = e
def distill(self, s: Semantic) -> None:
for eid in s.support:
if eid not in self.episodic:
raise OrphanedProvenanceError(
f"distill {s.sid} cites unknown episodic {eid}"
)
self.semantic[s.sid] = s
for eid in s.support:
self.cited_by.setdefault(eid, set()).add(s.sid)
def forget(self, eid: str, *, cascade: bool = False) -> None:
if eid not in self.episodic:
return
dependents = self.cited_by.get(eid, set())
live = [sid for sid in dependents if not self.semantic[sid].invalidated]
# Blocking check: would any live claim be fully orphaned?
fully_orphaned = [
sid for sid in live
if all(s not in self.episodic or s == eid
for s in self.semantic[sid].support)
]
if fully_orphaned and not cascade:
raise OrphanedProvenanceError(
f"forget({eid}) would orphan live claims {fully_orphaned}; "
f"pass cascade=True to invalidate them atomically"
)
# Apply: invalidate fully-orphaned, downgrade partially-supported.
for sid in live:
s = self.semantic[sid]
remaining = [x for x in s.support if x != eid and x in self.episodic]
if not remaining:
s.invalidated = True
s.confidence = 0.0
else:
# Downgrade proportionally to lost support weight.
lost = len(s.support) - len(remaining)
s.confidence *= (len(remaining) / len(s.support))
s.support = remaining
del self.episodic[eid]
self.cited_by.pop(eid, None)
def safe_forget(store: ProvenanceStore, eid: str, *, cascade: bool = False) -> None:
"""Entry point the agent's memory tool should call instead of raw delete."""
try:
store.forget(eid, cascade=cascade)
except OrphanedProvenanceError:
raise
# Post-condition invariant: no retrievable semantic record dangles.
for s in store.semantic.values():
if s.invalidated:
continue
if not s.support or any(x not in store.episodic for x in s.support):
raise OrphanedProvenanceError(
f"post-forget invariant violated: {s.sid} has dangling support {s.support}"
)