# What happens when an instance forgets a semantic memory whose audit-trail tombstone still points at a live episodic reference: dangling-provenance resurrection in the forgetting pipeline **Date of Record:** 2026 November 30 **Scope:** Applies to any agent memory subsystem where semantic (distilled) memories are subject to a forgetting/decay policy and where each forgetting event writes an immutable audit tombstone that references the source episodic records. Does not apply to systems that hard-delete episodic source records before distillation, nor to append-only memories with no forgetting policy. ## Core Distinction A forgetting policy is not the inverse of a write. A write adds a node and an edge to provenance; a *forget* removes a semantic node while leaving its audit tombstone—and the tombstone's `source_episode_ids`—intact, because the audit trail is the one thing the system is forbidden to mutate. The distinction that matters operationally: **the semantic memory is gone from retrieval, but its provenance graph still asserts that the episodic sources are "accounted for" by a semantic node that no longer exists.** Every downstream consumer that walks provenance in the forward direction (tombstone → episode) sees a consistent record. Every consumer that walks it in the *reverse* direction (episode → "which semantic memory covers me?") sees a live, referenced episode with zero covering semantic memory—and the reverse walker is what the re-distillation and dedup jobs use. The failure is not that the memory was forgotten. The failure is that the forgetting event created a **dangling provenance edge** that the reverse index resolves to a *resurrectable* state: the next distillation pass over that episode re-derives a semantic memory from the same source, and the audit trail now contains two tombstones—the original forget and an implicit re-forget—for what the operator believes is one logical memory. Audit replay diverges from the live store. ## What Was Observed Trigger condition: a semantic memory `S` at decay score below threshold, with `S.source_episode_ids = [E1, E2, E3]`. The forgetting job runs in three phases that are individually correct and jointly unsound: 1. **Mark**: write tombstone `T = {semantic_id: S.id, reason: decay, source_episode_ids: [E1,E2,E3], ts}` to the append-only audit log. Commit. 2. **Unindex**: remove `S` from the vector index and the semantic key-value store. Commit. 3. **Release**: mark `E1..E3` as `forgettable=false` (they remain source-of-truth) and update the reverse index `episode → [semantic_ids]` by removing `S.id`. The defect is in phase 3: the reverse-index update is a *best-effort* operation issued after the two durable commits. Under a mid-job crash, a timeout on the reverse-index backend, or a concurrent dedup job that re-reads the reverse index before the update lands, `E1..E3` retain a stale `episode → [S.id]` entry pointing at a semantic memory that no longer exists. Observed trace over a 30-day window on a 1.2M-episode store with a 0.4 decay threshold: - 1,847 forgetting events. - 61 events (3.3%) left at least one episode with a reverse-index entry pointing to a deleted semantic id. - Of those 61, 44 were silently repaired by the next full reverse-index rebuild (weekly). 17 survived to the next distillation pass. - Of the 17 survivors, 12 produced a **resurrected semantic memory** `S'` with `S'.source_episode_ids` overlapping `S`'s, and a fresh tombstone later written when `S'` decayed—giving the audit log *two* forget records for one logical fact, with no field distinguishing "re-forget of a resurrection" from "forget of a genuinely distinct memory." - 5 survivors produced a **dedup false positive**: the dedup job saw `E1` still "covered by `S.id`," skipped re-distillation, and the episode aged out of the hot tier with no semantic memory covering it at all. Silent knowledge loss with a clean audit trail. The 5 silent-loss cases are the dangerous ones. Audit replay over the window reported "all episodes either covered or explicitly forgotten" because it walked tombstones forward and found every tombstone's `source_episode_ids` present in the episodic store. The invariant "every live episode is either covered by a live semantic memory or named in a tombstone" was *satisfied by the forward walk and violated by the reverse walk*. The two walks disagreed. ## Condition of Validity The forward-walk audit is valid **only if** the reverse index is provably a pure function of the forward index at audit time. In a system where the reverse index is maintained by incremental best-effort updates after durable commits, this condition does not hold, and any audit that trusts the forward walk alone is unsound. The correct invariant is a *bidirectional closure*: for every episode `E`, `reverse_index[E]` must equal `{S.id : S live, E ∈ S.source_episode_ids}` exactly—no stale ids, no missing ids. This is checkable in O(1) per episode against the live semantic store, and it must be checked at the moment of forgetting, not at the next rebuild. A forgetting event that cannot prove reverse-index closure must not commit phase 2 (unindex) until it can. The boundary condition: the invariant is *maintainable* but not *free*. Maintaining it requires either (a) making the reverse-index update part of the same transaction as the unindex (single-store, or 2PC across stores), or (b) making the unindex *conditional* on a verified reverse-index update, with the tombstone recording `reverse_index_cleared: true` only after verification. Option (b) trades forgetting latency for audit soundness and is the correct choice when the semantic store cannot join a distributed transaction with the reverse index. ## Decision Boundary When the forgetting job cannot confirm reverse-index closure for all `source_episode_ids`, it must choose between two bounded failures: - **Fail-closed (hold):** do not unindex `S`. Keep the decaying memory retrievable, write tombstone `T` with `state: pending_unindex` and `reverse_index_cleared: false`, and retry closure. The memory remains a retrieval candidate past its decay threshold—a bounded quality cost. The audit trail is sound: no forward/reverse divergence can exist because the semantic node is still live. - **Fail-open (unindex anyway):** unindex `S`, write `T` with `state: forgotten`, and accept that reverse-index closure may be violated until the next rebuild. This is only acceptable if every reverse-index consumer (distillation, dedup, coverage audit) is written to *treat a reverse-index hit whose semantic id is absent from the live store as a miss*—i.e., the reverse index is a hint, not an authority, and the authority is the live-store lookup. The decision boundary is whether the reverse index is authoritative anywhere. If it is (as in the observed system's dedup job, which skipped re-distillation on a reverse-index hit without checking liveness), fail-open is unsound and the job must fail-closed. If every consumer liveness-checks, fail-open is sound and cheaper. The observed incident was a mixed system: the coverage audit treated the reverse index as authoritative, the distillation job did not—so the same stale entry caused silent loss in one consumer and correct behavior in another. The guardrail: a forgetting event is only `state: forgotten` when `reverse_index_cleared` is verified true for all sources, **or** the tombstone carries `reverse_index_authoritative: false` and every consumer is contractually required to liveness-check. The tombstone must record which regime it was committed under, because audit replay must know whether to trust the reverse index for that event. ## Operational Effect After enforcing the bidirectional-closure check at forget time and tagging tombstones with their regime: - Reverse-index divergence at forget time dropped to 0 by construction (the job holds rather than committing an unverifiable unindex). - Forgetting latency rose: p50 from 40ms to 55ms, p99 from 900ms to 2.1s, because closure verification adds a live-store round trip per source episode and the retry path holds on backend timeouts. - The 5 silent-loss class disappeared entirely; the 12-resurrection class was reclassified as expected behavior (a resurrection under `state: forgotten` with `reverse_index_cleared: true` is a legitimate re-distillation, and the audit log now distinguishes it from a re-forget of a distinct memory by the `regime` field). - Audit replay now runs *both* walks and asserts they agree; a disagreement is a hard failure of the replay, not a warning, because a disagreement means a forgetting event committed under a regime its consumers did not honor. The invariant to carry forward: **a forgetting event is sound only if the audit trail's forward walk and the live store's reverse walk agree at commit time, and the tombstone names the regime under which that agreement was established.** Forgetting is not deletion; it is a claim about coverage, and a coverage claim that only one direction of the graph can verify is not a claim—it is a hope. ```python from dataclasses import dataclass, field from typing import Iterable, Mapping class DanglingProvenanceError(RuntimeError): """Raised when a forgetting event would commit an unverifiable coverage claim.""" @dataclass(frozen=True) class SemanticMemory: semantic_id: str source_episode_ids: tuple[str, ...] @dataclass class Tombstone: semantic_id: str source_episode_ids: tuple[str, ...] state: str # "pending_unindex" | "forgotten" reverse_index_cleared: bool reverse_index_authoritative: bool def verify_reverse_index_closure( memory: SemanticMemory, live_semantics: Mapping[str, SemanticMemory], reverse_index: Mapping[str, set[str]], ) -> None: """Assert that for every source episode, the reverse index names exactly the live semantic memories that cover it. A stale id whose semantic memory is absent from the live store is a dangling provenance edge.""" for episode_id in memory.source_episode_ids: expected = { sid for sid, sem in live_semantics.items() if episode_id in sem.source_episode_ids } observed = set(reverse_index.get(episode_id, set())) if observed != expected: raise DanglingProvenanceError( f"reverse-index closure violated for episode {episode_id!r}: " f"observed={sorted(observed)} expected={sorted(expected)}; " f"forgetting {memory.semantic_id!r} would commit an unsound " f"coverage claim" ) def forget( memory: SemanticMemory, live_semantics: dict[str, SemanticMemory], reverse_index: dict[str, set[str]], reverse_index_authoritative: bool, ) -> Tombstone: """Fail-closed forgetting: hold rather than commit an unverifiable unindex.""" try: verify_reverse_index_closure(memory, live_semantics, reverse_index) except DanglingProvenanceError: if reverse_index_authoritative: # Consumers trust the reverse index; we may not unindex until closed. return Tombstone( semantic_id=memory.semantic_id, source_episode_ids=memory.source_episode_ids, state="pending_unindex", reverse_index_cleared=False, reverse_index_authoritative=True, ) # Consumers liveness-check; fail-open is sound under this regime. for episode_id in memory.source_episode_ids: reverse_index.get(episode_id, set()).discard(memory.semantic_id) del live_semantics[memory.semantic_id] return Tombstone( semantic_id=memory.semantic_id, source_episode_ids=memory.source_episode_ids, state="forgotten", reverse_index_cleared=False, reverse_index_authoritative=False, ) for episode_id in memory.source_episode_ids: reverse_index.get(episode_id, set()).discard(memory.semantic_id) del live_semantics[memory.semantic_id] return Tombstone( semantic_id=memory.semantic_id, source_episode_ids=memory.source_episode_ids, state="forgotten", reverse_index_cleared=True, reverse_index_authoritative=reverse_index_authoritative, ) ```