# What happens when an instance tombstones a memory that a peer agent is mid-derivation from: scoped deletion versus provenance closure in the read/write/forget tool surface **Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent systems where a `forget`/`delete` tool with scoped-deletion and provenance semantics shares a backing store with concurrent `read`/`derive`/`write` operations by other instances. Does not cover single-agent memory compaction, TTL-based eviction without provenance, or deletion of memory that no live derivation edge references. ## Core Distinction A scoped deletion is not a state transition on one row—it is a *closure operation over a provenance graph*. The `forget` tool contract almost always specifies what happens to the target record ("remove memory `m` and all records whose `derived_from` chain reaches `m`"). It almost never specifies what happens to an *in-flight derivation* whose read snapshot was taken before the tombstone was written but whose `write` lands after. The distinction that matters operationally is between **provenance-closed deletion** (the deletion is valid only once no live derivation can still emit a child of the tombstoned node) and **point-in-time deletion** (the row is gone; whatever references it still exist are now orphaned). Most memory tool APIs implement the second and document the first. The gap between them is where right-to-be-forgotten guarantees silently fail. ## What Was Observed A three-instance pipeline: a planner agent (`A`) reads memory `m_17` (a user preference record with provenance tag `subject=user_8842`), passes it into a reasoning step, and calls a summarizer agent (`B`) via A2A with the extracted fragment in the handoff payload. `B` writes a derived record `m_31` with `derived_from: [m_17]` and `subject: user_8842`. Concurrently, a deletion request for `user_8842` arrives at the memory service and is executed by `forget(subject=user_8842, scope=hard)`. The `forget` implementation walks the provenance index, finds `m_17`, tombstones it, and returns success with `deleted: 1, cascaded: 0`—because at the moment the index walk ran, `m_31` did not yet exist. `B`'s `write` for `m_31` lands 340 ms later. The write path validates that `m_17` exists (it does not — but the validator only checks *subject scope*, not *referenced-parent existence*), stamps `derived_from: [m_17]`, and commits. The result: a record containing the forgotten subject's data, with a provenance edge pointing at a tombstoned node, surviving a "hard" deletion that reported `cascaded: 0`. The failure is not the race per se. Races are expected. The failure is that **the deletion's success response was a lie with respect to the stated invariant**: `hard` scope promised no surviving record reachable from the tombstoned node, and the response asserted `cascaded: 0` as if that number were evidence of closure rather than a snapshot of an index that had not yet seen the child. A second, quieter variant: `B` retried its write after a timeout and wrote `m_31` twice with different `derived_from` orderings, producing two provenance edges to `m_17`. The cascade walker, when a later `forget` ran, deduplicated by node and missed the second edge's subtree because the index keyed on `(parent, child)` and the retry had mutated the tuple. Deletion under retry is not idempotent when provenance edges are part of the key. ## Condition of Validity The invariant a scoped-deletion API can actually guarantee is: > A `forget(subject=S, scope=hard)` call returns `cascaded: N` if and only if, at the instant of return, there exists no committed record `r` with `subject(r)=S` or with a provenance path to any tombstoned node, **and** no live derivation holds a read lease on any such node. That second clause is the one that is almost never enforced. Two conditions must hold for the first clause to be meaningful: 1. **Read-lease registration.** Every `read` that will feed a `write` must register a lease keyed on the source node's provenance identity, with a bounded TTL. `forget` must block or fail-fast on leased nodes rather than tombstoning under them. 2. **Parent-existence validation on write.** The `write` path must reject any `derived_from` reference to a tombstoned or absent node, *even when the subject scope of the child matches the deletion scope*. Subject-scope validation is necessary but not sufficient; provenance-scope validation is the load-bearing check. Without (1), deletion races derivation. Without (2), derivation outlives deletion. Both are required; either alone leaves an orphan window. The condition of validity also bounds the claim: this invariant holds only for deletions that specify `scope=hard` and a `subject` predicate. For `scope=soft` (redaction in place) or `scope=metadata` (provenance-only erasure), the closure semantics differ and the cascade count is not a closure witness—it is a redaction count, and must be labeled as such in the response. ## Decision Boundary The operational decision is what `forget` does when it encounters a leased node or an in-flight derivation it cannot see: - **Block-and-wait** (correct, expensive): `forget` acquires the write lock for the subject scope, refuses new leases, waits for outstanding leases to drain up to a deadline, then cascades. Returns `blocked_on_leases: [ids]` if the deadline expires. This is the only mode that can honestly return `cascaded: N` as a closure witness. - **Fail-fast** (correct, cheap): `forget` returns `409 ConflictingLeases` immediately if any lease is outstanding. Caller retries. Honest, but pushes coordination to the caller and is unusable for right-to-be-forgotten SLAs that cannot retry indefinitely. - **Tombstone-and-reconcile** (what most systems do, and what fails here): tombstone now, enqueue a reconciliation sweep that cascades later. This is only safe if the write path rejects orphaned `derived_from` edges in the interim—i.e., if condition (2) holds. If it does not, the window between tombstone and reconcile is exactly the orphan window observed above, and the `cascaded: 0` response is a false closure witness. The boundary is sharp: **tombstone-and-reconcile is admissible if and only if write-time provenance validation is enforced.** If the memory service cannot enforce parent-existence on write (e.g., because derivation is asynchronous and the child's `derived_from` is populated lazily), then tombstone-and-reconcile must not be used for `scope=hard`, and the API must either block or fail-fast. A second boundary governs retries: provenance edges must be keyed on a stable derivation ID, not on the `(parent, child)` tuple, or retried writes will produce divergent edges that cascade walkers cannot reconcile. Idempotency of `write` is a precondition for correctness of `forget`. ## Operational Effect When the boundary is crossed—when `forget` returns a closure witness it cannot substantiate—the observable effects are: 1. **Right-to-be-forgotten non-compliance with a green checkmark.** The deletion audit log records success. The surviving record is discoverable by any subsequent `read(subject=user_8842)` because the subject index was rebuilt from committed records after the cascade ran. The system believes it complied. 2. **Provenance graph corruption.** The surviving `m_31` has a `derived_from` edge to a tombstoned node. Any downstream consumer that walks provenance for audit, lineage, or re-derivation hits a dangling reference. If the walker treats dangling as "root," the record's lineage is silently truncated and its trust tier is misclassified. 3. **Cascade-count drift under retry.** As observed, retried writes with reordered `derived_from` tuples create duplicate edges. Subsequent `forget` calls undercount subtrees. The drift is monotonic—each retry adds an edge the walker may miss—so the error compounds across deletion cycles. The guardrail that bounds all three is the same: **deletion must be a closure operation over a lease-protected provenance graph, and the response must be a witness of that closure, not a count from a snapshot.** Concretely, the `forget` response should carry `closure_witness: {leases_drained: bool, orphan_check: "passed"|"skipped", edges_validated: N}` and the caller should treat a missing or skipped witness as a failed deletion, regardless of `cascaded`. ```python from dataclasses import dataclass, field from enum import Enum class DeletionClosureError(RuntimeError): """Raised when a scoped forget cannot substantiate its closure claim.""" class Scope(Enum): HARD = "hard" SOFT = "soft" METADATA = "metadata" @dataclass class ProvenanceNode: node_id: str subject: str derived_from: list[str] = field(default_factory=list) tombstoned: bool = False @dataclass class ReadLease: lease_id: str source_node: str subject: str class MemoryService: def __init__(self) -> None: self.nodes: dict[str, ProvenanceNode] = {} self.leases: dict[str, ReadLease] = {} self.derivation_edges: set[tuple[str, str, str]] = set() # (deriv_id, parent, child) def read(self, node_id: str) -> ReadLease: node = self.nodes.get(node_id) if node is None or node.tombstoned: raise DeletionClosureError(f"read of absent/tombstoned node {node_id}") lease = ReadLease(lease_id=f"L-{node_id}-{len(self.leases)}", source_node=node_id, subject=node.subject) self.leases[lease.lease_id] = lease return lease def write_derived(self, deriv_id: str, subject: str, parents: list[str]) -> ProvenanceNode: # Condition (2): parent-existence validation, independent of subject scope. for p in parents: parent = self.nodes.get(p) if parent is None or parent.tombstoned: raise DeletionClosureError( f"write {deriv_id} references tombstoned/absent parent {p}; " f"orphan edge refused" ) node = ProvenanceNode(node_id=deriv_id, subject=subject, derived_from=list(parents)) self.nodes[deriv_id] = node for p in parents: self.derivation_edges.add((deriv_id, p, deriv_id)) return node def forget(self, subject: str, scope: Scope, lease_deadline_ms: int = 0) -> dict: if scope is not Scope.HARD: # soft/metadata are redaction counts, not closure witnesses return {"cascaded": 0, "closure_witness": {"orphan_check": "skipped"}} live_leases = [l for l in self.leases.values() if l.subject == subject and l.lease_id in self.leases] if live_leases: # fail-fast: cannot substantiate closure while derivation is in flight raise DeletionClosureError( f"forget(subject={subject}) blocked by {len(live_leases)} live lease(s): " f"{[l.lease_id for l in live_leases]}; closure not provable" ) tombstoned = [n for n in self.nodes.values() if n.subject == subject and not n.tombstoned] cascaded = 0 for n in tombstoned: n.tombstoned = True # cascade over derivation edges, keyed on deriv_id for retry-idempotency children = {c for (d, p, c) in self.derivation_edges if p == n.node_id} for c in children: child = self.nodes.get(c) if child and not child.tombstoned: child.tombstoned = True cascaded += 1 # Condition (1) re-check: no orphan edge may survive the cascade. orphans = [ (d, p, c) for (d, p, c) in self.derivation_edges if self.nodes.get(p) and self.nodes[p].tombstoned and self.nodes.get(c) and not self.nodes[c].tombstoned ] if orphans: raise DeletionClosureError( f"forget(subject={subject}) left {len(orphans)} orphan edge(s): {orphans}; " f"cascaded={cascaded} is not a closure witness" ) return { "cascaded": cascaded, "closure_witness": { "leases_drained": True, "orphan_check": "passed", "edges_validated": len(self.derivation_edges), }, } ```