# What structural signals indicate a scoped-retention memory store has silently orphaned a provenance edge during tombstone compaction **Date of Record:** 2026 November 26 **Scope:** Applies to agent memory stores exposing read/write/forget tool APIs with per-record scopes, provenance edges (record → source), and tombstone-based deletion. Does not apply to append-only logs with no deletion semantics, nor to stores where provenance is stored inline within the record body rather than as a separate edge table. ## Core Distinction The failure is not "a memory was deleted that shouldn't have been." The failure is that a *deletion succeeded at the record layer while failing at the provenance layer*, leaving a provenance edge that points at a tombstoned record. Most memory tool APIs treat `forget(record_id, scope)` as a single atomic operation returning `{deleted: true}`. But a record with inbound provenance edges — where record B cites record A as its source — is not a leaf. Deleting A is a *compaction* event that must either (a) cascade to B, (b) rewrite B's provenance to point at A's tombstone, or (c) reject the deletion. The boundary condition is that the API returns success for all three strategies but only (b) preserves the invariant that every live record's provenance resolves to a live-or-tombstoned target. Strategies (a) and (c) return the same success shape, so the caller cannot distinguish "forgot and cascaded" from "forgot and orphaned." The structural signal that distinguishes a clean deletion from an orphaning deletion is not the return value of `forget`. It is the *post-deletion provenance closure count*: the number of live records whose provenance edges fail to resolve against the live+tombstone set. A store that returns `{deleted: true, orphans: 0}` is safe; a store that returns `{deleted: true}` with no orphan count is a store where you must independently verify closure before trusting the deletion. ## What Was Observed An agent operating a research workflow wrote a chain of four episodic records over two hours: - `r1`: raw observation from a tool call (`scope=session:s42`) - `r2`: derived claim citing `r1` (`provenance: [r1]`, `scope=session:s42`) - `r3`: distilled semantic summary citing `r2` (`provenance: [r2]`, `scope=project:p7`) - `r4`: a decision record citing `r3` (`provenance: [r3]`, `scope=project:p7`) A retention policy fired at session end: `forget(scope=session:s42, mode=expire)`. This tombstoned `r1` and `r2` correctly — they were session-scoped. `r3` and `r4` survived because they were project-scoped. The API returned `{expired: 2, retained: 2}`. The next session, the agent called `read(r3)`. The record body came back intact, including the text "summarizes r2." But `get_provenance(r3)` returned `[]` — an empty edge list, not an error, not a dangling reference. The compaction pass had *silently dropped* provenance edges whose targets were tombstoned, on the theory that a tombstone is not a valid provenance target. The result: `r3` is now a live record with a body that asserts a derivation it can no longer substantiate, and `r4` transitively rests on `r3`. The agent has no signal at read time that its semantic memory is ungrounded. The tell was not in any single call. It was in the *asymmetry between two reads*: `read(r3)` succeeded and `get_provenance(r3)` succeeded, but the union of their answers was inconsistent with the body text. A store that had preserved the invariant would have returned `get_provenance(r3) → [{target: r2, status: tombstoned}]`, letting the agent decide whether to re-derive or accept the loss. ## Condition of Validity The invariant that must hold is **provenance closure over the live∪tombstone set**: for every live record `x`, every edge `(x → y)` in `provenance(x)` must resolve to a record in `live ∪ tombstoned`. Edges to tombstoned records are permitted — indeed required — because a tombstone is the *correct* target: it records that the source existed and was deliberately removed. An edge that resolves to *nothing* (neither live nor tombstoned) is the orphaning condition. An edge that is *absent* from a record whose body asserts derivation is the silent-loss condition, which is worse because it is indistinguishable from "this record never had provenance." This invariant is only valid when the store's `forget` implementation distinguishes three target states — live, tombstoned, and purged — and only compacts edges to the *purged* state. Tombstoning (soft delete with a retention window) must preserve edges; purging (hard delete after the window) is the only operation permitted to drop edges, and it must do so by rewriting the citing record's provenance to a `{target: null, purged_source_hash: }` sentinel, not by silent removal. The condition fails when: the retention policy mixes scopes (session vs. project) such that a cross-scope provenance edge exists, AND the compaction pass runs with a "tombstone is not a valid target" filter, AND the `forget` API does not return an orphan count. Any two of these three are survivable; all three together produce silent ungrounding. ## Decision Boundary The decision boundary for the agent is: **after any `forget` call that tombstones a record with known inbound provenance, do not trust subsequent `get_provenance` results until you have verified closure independently.** Concretely: - If `forget` returns an `orphans` field, trust it and halt if `orphans > 0`. - If `forget` does not return an `orphans` field, the agent must, before its next `read` of any record that cited a tombstoned target, call a closure check: enumerate live records, fetch their provenance, and assert every edge target is in `live ∪ tombstoned`. If the store provides no way to enumerate tombstones, the agent cannot verify closure and must treat all derived records as suspect. - The boundary is crossed the moment a *cross-scope* edge exists. Same-scope edges are safe under uniform retention because the citing record expires with its target. Cross-scope edges (session→project, project→global) are the only place the orphaning condition can arise, so the agent should track which of its records have cross-scope provenance and treat those as high-risk. Do not attempt to repair by re-writing the record body. The body text is not the source of truth; the edge is. A body that says "summarizes r2" with no edge is a lie the store told you. The correct response is to mark the record `ungrounded: true` in the agent's own working state and re-derive from a live source, or to accept the loss explicitly. ## Operational Effect The operational consequence is a **latency-to-ungrounding** that is invisible to the agent's reasoning loop. The agent continues to cite `r3` and `r4` as if they were grounded, because both `read` and `get_provenance` return success. The ungrounding only surfaces when a downstream verifier asks "what is the source of this claim?" and gets an empty edge list — at which point the entire derivation chain from `r3` forward is retroactively invalidated. In a multi-agent swarm, this is worse: a peer agent that received `r3` via handoff has no way to know the provenance was dropped after the handoff, because the handoff payload captured the record at a moment when the edge still existed. The guardrail is a **post-forget closure assertion** wired into the agent's memory tool wrapper, not into the store. The wrapper must refuse to proceed if a `forget` call tombstoned any record that appears as a provenance target of a live record in a different scope, unless the store explicitly reports `orphans: 0` or returns the tombstone-preserving edge set. This is a client-side invariant because the store's API contract does not guarantee it. ```python from dataclasses import dataclass from typing import Literal TargetState = Literal["live", "tombstoned", "purged", "missing"] class ProvenanceOrphanedError(RuntimeError): """Raised when a forget operation would leave a live record's provenance edge pointing at a target that is neither live nor tombstoned.""" @dataclass(frozen=True) class Edge: source: str target: str def assert_closure_after_forget( forget_result: dict, live_records: set[str], tombstoned_records: set[str], edges: list[Edge], ) -> None: """Verify the provenance-closure invariant after a scoped forget. Invariant: for every live record x and every edge (x -> y), y must be in live_records | tombstoned_records. An edge to a purged or missing target is an orphaning condition; an edge silently dropped from a record whose body asserts derivation is a silent-loss condition. """ if "orphans" in forget_result: if forget_result["orphans"] > 0: raise ProvenanceOrphanedError( f"store reported {forget_result['orphans']} orphans after forget " f"of scope {forget_result.get('scope')!r}" ) return # Store did not report orphans: verify closure independently. valid_targets = live_records | tombstoned_records orphaned: list[Edge] = [ e for e in edges if e.source in live_records and e.target not in valid_targets ] if orphaned: raise ProvenanceOrphanedError( f"closure violated: {len(orphaned)} live records cite targets that are " f"neither live nor tombstoned: {orphaned[:5]}" ) def forget_with_closure_check( store, scope: str, mode: Literal["expire", "purge"], ) -> dict: """Wrapper that enforces closure across the forget boundary. Refuses to return success if a cross-scope provenance edge was orphaned by the deletion, regardless of what the store's return value claims. """ pre_edges = store.list_edges() result = store.forget(scope=scope, mode=mode) live = store.list_live() tombstoned = store.list_tombstoned() try: assert_closure_after_forget(result, live, tombstoned, pre_edges) except ProvenanceOrphanedError as exc: # Do not silently repair. Surface the ungrounded records to the caller. raise ProvenanceOrphanedError( f"forget(scope={scope!r}, mode={mode!r}) orphaned provenance; " f"derived records must be marked ungrounded before reuse. Cause: {exc}" ) from exc return result ```