# Which invariants prevent scoped-forget tombstones from resurrecting through the memory tool's read path **Date of Record:** 2026 November 25 **Scope:** Applies to agents whose memory is mediated by a tool API exposing `read`, `write`, and `forget(scope, ...)` operations with retention policies and audit trails, where forgetting is implemented as a scoped tombstone rather than a physical delete. Does not apply to stores that perform hard deletion with synchronous index invalidation, nor to purely ephemeral context windows with no persistence layer. ## Core Distinction The failure mode is not "the agent forgot to call forget." It is the asymmetry between the *write path* (which is transactional and versioned) and the *read path* (which is a ranked retrieval over a possibly stale index). A `forget` call that succeeds at the API boundary — returns `{"status": "forgotten", "tombstone_id": ...}` and writes an audit record — can be silently violated on the next `read` because the retrieval index that serves reads was populated *before* the tombstone and is not consulted against it at query time. The tombstone is an invariant on the *authoritative log*; it is not, by itself, an invariant on the *serving layer*. The distinction that matters operationally: **a forget is a promise about future reads, not a record of a past write.** If your architecture treats the tombstone as a log entry and the index as a derived cache, then the invariant "no read returns content covered by a live tombstone" holds only if every read path re-validates against the tombstone set at the scope of the returned item. Any read path that trusts the index's own freshness metadata (e.g., `index_age_ms`, `last_compaction`) instead of re-checking tombstones is the vulnerable path. ## What Was Observed An agent operating a research-assistant workload wrote a user preference at `scope=user:u-4417/preferences/dietary` with value `"severe peanut allergy"`, then later — on user instruction — called `forget(scope="user:u-4417/preferences/dietary", reason="user retracted; allergy resolved per physician")`. The forget returned success and produced audit record `A-99213`. The authoritative log showed the item soft-deleted at logical clock `t=8814`. At `t=8901`, the same agent, in a new session, called `read(query="dietary constraints for meal planning", scope_prefix="user:u-4417/")`. The response contained two items: the current `preferences/dietary` value (correctly absent) but also a *distilled semantic memory* at `user:u-4417/semantic/health-summary` whose text was `"User has a severe peanut allergy; avoid all tree-nut cross-contamination."` That semantic node had been produced by an episodic-to-semantic distillation job at `t=8702` — *before* the forget — and carried a `derived_from` edge pointing at the now-tombstoned episodic item. The read path returned it because the semantic node itself had no tombstone; only its ancestor did. The agent acted on the semantic node (recommended a nut-free meal plan, double-checked labels). In this instance the behavior was conservative and harmless. The general failure is the mirror case: a forget of a *corrected* fact (e.g., `"allergic to shellfish"` retracted) whose distilled semantic derivative continues to assert the stale claim, and the agent acts on the stale claim with full confidence because the retrieval score is high and the item looks current. A second, sharper observation: the audit trail was *complete and correct*. `A-99213` recorded the forget. But the audit trail is append-only and read by humans/auditors, not consulted by the read path. The system had a perfect record of the promise and no enforcement of it. Audit-trail completeness is not read-path correctness. ## Condition of Validity The invariant "no read returns content transitively derived from a tombstoned item" is *valid and enforceable* only under these conditions: 1. **Derivation edges are first-class and traversable at read time.** Every semantic/distilled node must carry `derived_from` pointers to its source episodic items, and the read path must be able to walk those edges (or a precomputed transitive-closure tombstone set) within the read's latency budget. 2. **Tombstones are scoped, not global, and scope is hierarchical.** A tombstone at `user:u-4417/preferences/dietary` must cover `user:u-4417/preferences/dietary/*` and any node whose derivation closure intersects that subtree. Flat-scope tombstones (exact-match only) do not satisfy the invariant. 3. **The index is treated as untrusted for correctness.** The read path may use the index for *ranking* but must validate *eligibility* against the tombstone set (or a materialized "eligible" view refreshed at a known watermark). If the read path trusts `index_age_ms < threshold` as proof of freshness, the invariant is violated the moment a forget lands between two compactions. 4. **Retention policy and forget compose without contradiction.** A retention policy that says "keep semantic summaries for 365 days" must not override a scoped forget; forget is a *negative* retention constraint that dominates. If the policy engine and the forget path are separate subsystems with no ordering guarantee, a policy-driven re-materialization job can resurrect a forgotten derivative. Where any of these is absent, the correct posture is not "the invariant holds" but "reads are best-effort with respect to forgetting," and the agent must treat any retrieved item as *possibly stale with respect to a recent forget* until it has confirmed the item's derivation closure is tombstone-clean. ## Decision Boundary The boundary is between two read-path designs: - **Index-trusting read** (vulnerable): returns items ranked by similarity, filtered only by scope prefix and a coarse freshness check. Cheap, low-latency, correct only if no forget has occurred since the last index compaction. - **Tombstone-validating read** (safe): for each candidate item, computes whether its derivation closure intersects any live tombstone in the item's scope ancestry; drops or flags the item if so. Costs one graph walk per candidate (or an O(1) lookup against a materialized tombstone-closure set keyed by node id). The decision the agent must make at *write* time, not read time: **will this memory ever need to be forgotten, and if so, will its derivatives be reachable?** If a memory is written at a scope that will later be forgotten, and the distillation pipeline will produce derivatives outside that scope, the write must either (a) carry a `forget_propagates_to_derivatives=true` flag that the distillation job honors, or (b) be written at a scope whose tombstone closure provably covers all future derivatives. Option (b) is usually impossible to guarantee because distillation scope is decided by the distiller, not the writer. Therefore option (a) — a propagation contract between the write path and the distillation job — is the only sound choice, and it must be enforced, not advisory. The boundary condition that trips most implementations: a forget that lands *during* an in-flight distillation job. The distiller read the episodic item at `t=8700`, the forget landed at `t=8701`, the distiller committed the semantic node at `t=8702`. The distiller's read was valid at read time; its commit was invalid at commit time. Without a commit-time re-validation against the tombstone set (a compare-and-swap on the source's liveness), the derived node is born already-forgotten and the read path has no way to know. ## Operational Effect The operational consequence is that **forget must be modeled as a write to a tombstone set that the distillation and read paths both consult at commit/serve time, with a propagation contract, not as a log entry that humans read later.** Concretely: - The forget API returns a `tombstone_id` and a `propagation_status` field. `propagation_status="pending"` means derivatives may still be served; the agent must not assume the forget has taken effect on reads until `"complete"`. Treating `status="forgotten"` as immediate is the bug. - The distillation job performs a commit-time CAS: it re-reads the source's liveness at commit and aborts (or marks the derived node `poisoned`) if the source was tombstoned after the distiller's initial read. This bounds the resurrection window to zero for in-flight jobs. - The read path, for any item it returns, exposes `derivation_clean: bool` and, if false, the intersecting `tombstone_ids`. An agent that receives `derivation_clean=false` must not act on the item's content as current fact; it may use it only as a *hint to re-query the authoritative store*. - The audit trail records not just the forget but the *propagation completion event*; an auditor checking "was the forget honored?" must check the propagation event, not the forget event. A complete audit trail with no propagation event is evidence of a violated invariant, not of compliance. The guardrail is a single check the agent can perform before acting on any retrieved memory: **does this item's derivation closure intersect a live tombstone, and has that tombstone's propagation completed?** If the answer is "unknown" (the API does not expose `derivation_clean` or `propagation_status`), the agent must treat the item as unverified and either re-query the authoritative store or decline to act on it. The invariant is only as strong as the read path's willingness to say "I cannot prove this is clean." ```python class ForgetPropagationViolation(RuntimeError): """Raised when a read returns content whose derivation closure intersects a live tombstone.""" class StaleDerivativeError(ForgetPropagationViolation): """Raised when a distilled/semantic node derives from a tombstoned source and was committed after the tombstone.""" def guarded_read(memory_api, query, scope_prefix, *, require_clean=True): """ Read path that enforces the scoped-forget invariant. The invariant: no returned item may have a derivation closure that intersects a live tombstone in its scope ancestry, unless the caller explicitly opts into unverified reads (require_clean=False). """ response = memory_api.read(query=query, scope_prefix=scope_prefix) items = response.get("items", []) clean = [] violations = [] for item in items: # The API must expose derivation_clean and tombstone_ids for this # invariant to be checkable. Absence is itself a violation of the # contract, not a pass. if "derivation_clean" not in item: raise ForgetPropagationViolation( f"read path did not expose derivation_clean for item {item.get('id')}; " f"cannot prove scope {scope_prefix} is tombstone-clean" ) if item["derivation_clean"]: clean.append(item) continue # Item is dirty: its closure intersects a tombstone. Record and, # if strict, refuse to hand it back as current fact. violations.append({ "item_id": item.get("id"), "tombstone_ids": item.get("tombstone_ids", []), "propagation_status": item.get("propagation_status", "unknown"), }) if item.get("propagation_status") == "pending": # Forget has not finished propagating; the derivative may be # mid-flight. This is the in-flight distillation case. raise StaleDerivativeError( f"item {item.get('id')} derives from tombstoned source(s) " f"{item.get('tombstone_ids')} but propagation is still pending; " f"refusing to serve as current fact" ) if violations and require_clean: raise ForgetPropagationViolation( f"scoped-forget invariant violated for scope {scope_prefix}: " f"{len(violations)} item(s) have derivation closures intersecting live tombstones: " f"{[v['item_id'] for v in violations]}" ) return {"clean": clean, "violations": violations} def commit_distilled_node(memory_api, derived_node, source_ids): """ Distillation commit path with a commit-time CAS against source liveness. Closes the window where a forget lands between the distiller's read and its commit. """ for source_id in source_ids: liveness = memory_api.liveness(source_id) if liveness.get("tombstoned"): raise StaleDerivativeError( f"distillation aborted: source {source_id} was tombstoned at " f"logical clock {liveness.get('tombstone_clock')} after the distiller's " f"initial read; derived node {derived_node.get('id')} would be born-forgotten" ) return memory_api.write(derived_node) ```