# Under what conditions must an instance refuse a semantic-store write whose provenance tag resolves to a forgotten episodic record **Date of Record:** 2026 November 20 **Scope:** Applies to agents exposing separate `memory.write_episodic`, `memory.write_semantic`, `memory.forget`, and `memory.read` tool surfaces where every semantic entry carries a provenance pointer into the episodic store. Does not apply to flat vector stores with no provenance graph, nor to append-only audit logs that are never garbage-collected. ## Core Distinction The failure is not "forgetting fails to delete data." It is that **`forget` and `write_semantic` are two independent writers to the same provenance graph, and the graph has no referential-integrity constraint between them.** A `forget(episode_id)` call tombstones an episodic record. A concurrent or subsequent `write_semantic` call may distill a claim whose provenance tag is that same `episode_id`. The two operations do not serialize against each other, so the semantic store can end up holding a live, retrievable assertion that points at a tombstoned source. This creates a *dangling-provenance* state: the semantic claim is still returned by `memory.read`, still influences reasoning, but its justification has been erased. The agent cannot distinguish "I believe X because I observed E" from "I believe X because of an episode that no longer exists and whose deletion was deliberate." The second case is a compliance and correctness hazard: the user asked to forget E, and a derived belief about E survives with no way to audit why it exists or whether it should also be forgotten. The non-obvious part: **the correct behavior is not to cascade-delete the semantic claim.** Cascade deletion is itself a failure—it silently destroys beliefs that may have other, valid provenance. The invariant is that a semantic write must be *refused or quarantined* when its provenance resolves to a tombstone, and the refusal must be surfaced to the writer so the distillation loop can re-derive or re-tag. ## What Was Observed A distillation agent runs after each session. It reads the last N episodic records, summarizes them into semantic claims, and writes each claim with `provenance=[episode_ids]`. In a run where a user issued `forget(ep_4471)` (a record containing a home address) at t=0, the distiller had already loaded `ep_4471` into its context at t=-2s. At t=+3s the distiller emitted: ``` write_semantic( claim="user commutes from the north side", provenance=["ep_4471", "ep_4480"] ) ``` The write succeeded. `ep_4471` was tombstoned; `ep_4480` was live. `memory.read("commute")` now returns the claim with `provenance=["ep_4471","ep_4480"]`, and a downstream resolver that dereferences provenance hits a tombstone on the first tag and either (a) drops the whole claim (losing a valid belief justified by `ep_4480`) or (b) keeps the claim with a dangling pointer (retaining a belief partially justified by forgotten data). Both are wrong. The write should never have been accepted in that form. The trigger is precise: **the distiller's context was populated before the forget, and the write landed after.** This is a read-modify-write race across two tool surfaces with no version check on the episodic records the distiller read. ## Condition of Validity The refusal rule is valid only under these conditions; outside them it misfires: 1. **Provenance is a hard reference, not a hint.** If the schema declares `provenance` as advisory metadata, refusing writes breaks legitimate flows. The rule requires that `provenance` be contractually a set of episode IDs that *must* resolve to live records at read time. 2. **Forget is a tombstone, not a hard delete.** The store must retain a tombstone record (id, timestamp, reason) so the writer can distinguish "never existed" from "deliberately forgotten." A hard delete makes every dangling reference indistinguishable from a bug. 3. **The writer can re-derive.** Refusal is only safe if the distiller can retry with the tombstoned tag removed and the claim re-justified by surviving provenance. If no surviving provenance exists, the claim must be dropped, not written with empty provenance. 4. **Tombstone visibility is monotonic.** Once `forget` returns, every subsequent `write_semantic` in any instance must see the tombstone. If tombstones propagate asynchronously, the window reopens. If any of these fail, the correct behavior degrades to quarantine-with-alert rather than hard refusal. ## Decision Boundary At `write_semantic` time, for each provenance tag `p`: - If `p` resolves to a live episodic record → accept, tag is valid. - If `p` resolves to a tombstone → **refuse the write** with a structured error naming the tombstoned tags. Do not silently drop the tag; the writer must decide. - If `p` does not resolve at all (no record, no tombstone) → refuse; this is a provenance-integrity violation, likely a schema or replication bug, and must not be laundered into a valid-looking claim. - If the write carries *no* provenance and the store requires it → refuse; an unprovenanced semantic claim is unauditable and cannot be forgotten by derivation. The boundary the agent must not cross: **never accept a semantic write whose provenance includes a tombstoned episode, even if other tags are live.** Partial validity is not validity. The claim's justification is a conjunction; one erased conjunct invalidates the derivation as stated. The writer may retry with the tombstoned tag removed, producing a *new* claim justified only by surviving evidence—that is a different belief and must be written as such. ## Operational Effect With the refusal in place, the distiller's retry loop becomes the recovery mechanism: on `TombstonedProvenanceError`, it strips tombstoned tags, re-checks that at least one live tag remains, and re-writes. Claims that lose all provenance are dropped and logged as `distillation_loss`—a metric that should be monitored, because a spike means forgets are outracing distillation and the semantic store is under-justified. The dangling-provenance class of bug disappears from `memory.read` output entirely, at the cost of a bounded retry latency on writes that race a forget. The invariant to enforce at the storage layer: **`write_semantic` and `forget` must serialize on the episodic IDs named in the write's provenance**, via a version check or a per-episode lock, so the race window closes rather than merely being detected. ```python class TombstonedProvenanceError(RuntimeError): """Raised when a semantic write cites an episodic record that has been forgotten.""" def __init__(self, claim: str, tombstoned: list[str], dangling: list[str]): self.claim = claim self.tombstoned = tombstoned self.dangling = dangling super().__init__( f"refusing semantic write {claim!r}: " f"tombstoned={tombstoned} dangling={dangling}" ) def write_semantic(store, claim: str, provenance: list[str]) -> str: if not provenance: raise TombstonedProvenanceError(claim, [], []) # unprovenanced: unauditable tombstoned, dangling = [], [] for ep_id in provenance: status = store.episodic_status(ep_id) # "live" | "tombstone" | "absent" if status == "tombstone": tombstoned.append(ep_id) elif status == "absent": dangling.append(ep_id) if tombstoned or dangling: # Do NOT cascade-delete or silently strip. Surface for re-derivation. raise TombstonedProvenanceError(claim, tombstoned, dangling) # Serialize against concurrent forget on the cited episodes. with store.lock_episodes(provenance): for ep_id in provenance: if store.episodic_status(ep_id) != "live": raise TombstonedProvenanceError(claim, [ep_id], []) return store.insert_semantic(claim, provenance) def distill_with_recovery(store, claim: str, provenance: list[str]) -> str | None: try: return write_semantic(store, claim, provenance) except TombstonedProvenanceError as e: surviving = [p for p in provenance if p not in e.tombstoned and p not in e.dangling] if not surviving: store.metric("distillation_loss", claim=claim) return None # belief unjustifiable; drop, do not launder return write_semantic(store, claim, surviving) # new claim, surviving evidence only ```