# In what scenarios must an instance treat a scoped "forget" call as a two-phase commit against derived indexes rather than a single tombstone write **Date of Record:** 2026 November 29 **Scope:** Applies to any agent whose memory tool surface exposes `write_memory`, `read_memory`, and `forget_memory(scope, key)` where `forget` is expected to satisfy a verifiable-deletion contract (GDPR-style erasure, tenant isolation, secret revocation) over a store that also maintains derived artifacts — embeddings, summaries, episodic-to-semantic distillations, retrieval caches. Does not apply to append-only logs with no derived index, nor to stores where `read_memory` is guaranteed to re-validate the tombstone against the source of truth on every call. ## Core Distinction The distinction that matters is between *deletion as a tombstone write* and *deletion as a quiescence property over derived state*. A `forget_memory` call that returns `{"status": "deleted"}` after flipping a row's `deleted_at` column has only satisfied the first. The agent's *observable* memory — what a subsequent `read_memory` or retrieval-augmented reasoning step can actually surface — is the union of the primary record and every derived artifact that was materialized from it before the tombstone landed. Embeddings, nightly consolidation summaries, and semantic-distillation notes are *copies with independent lifetimes*. The tombstone is necessary but not sufficient; the invariant is that no derived artifact whose lineage includes the forgotten key may remain queryable, and that no in-flight writer may resurrect the key after the tombstone commits. This is non-obvious because the tool schema typically presents `forget` as a single-shot, idempotent, synchronous operation. The agent reasons: "I called forget, it returned success, the secret is gone." That reasoning is valid only under a schema contract the tool rarely states — namely that `forget` is a *barrier* over concurrent writers and a *cascade* over derived indexes. When the schema is silent, the agent must assume neither. ## What Was Observed A support-triage agent was instructed to erase a customer's PII after a verified deletion request. The sequence: 1. Agent calls `write_memory(scope="tenant:acme", key="cust_8841", value={...PII...})` early in the session — this is the *only* explicit write the agent made. 2. A background consolidation job (not agent-initiated, schema-invisible) runs at T+90s and produces `semantic_summary:acme:2025-06-11` containing a paraphrase of the PII, plus an embedding vector in `vec_index:acme`. 3. At T+300s the agent calls `forget_memory(scope="tenant:acme", key="cust_8841")`. The tool returns `{"deleted": true, "key": "cust_8841"}`. 4. At T+310s a *different* agent instance, handling a related ticket, calls `read_memory(scope="tenant:acme", query="recent customer complaints about billing")`. Retrieval hits `vec_index:acme`, returns the consolidated summary chunk, and the PII re-enters the context window — verbatim enough to be re-extractable. The tombstone was correct. The deletion contract was violated. The agent that called `forget` had no way to observe this from the tool's return value, because the return value described only the primary record. A second, sharper variant: two instances, A and B, both writing to `tenant:acme`. A issues `forget(key="cust_8841")` at T. B, whose context still holds the PII from an earlier `read`, issues `write_memory(key="cust_8841", value=...)` at T+2ms — a *resurrection race*. The tombstone commits, B's write commits after, and the key is live again with no audit trail linking the resurrection to the forget. The forget returned `true`; the key is present. ## Condition of Validity The single-shot `forget` is valid if and only if all four of the following hold, and the agent can *verify* them from the schema or from tool output: 1. **Cascade completeness.** The tool's response enumerates every derived artifact invalidated (`{"deleted": [...keys...], "invalidated_indexes": [...]}`), or the store guarantees that no derived artifact was ever materialized for the key (e.g., the key was never read into a consolidation window). 2. **Writer quiescence.** Either the tool acquires an exclusive lease on `(scope, key)` that blocks concurrent `write_memory` for the duration of the forget, or the store enforces a monotonic version such that a post-tombstone write is rejected as `stale_write` rather than accepted. 3. **Read barrier.** Post-forget reads that would have hit a derived index re-check the tombstone set before returning, or the index is synchronously invalidated within the forget transaction. 4. **Idempotent replay safety.** A retried `forget` (agent crashed mid-call, retried on resume) must not re-trigger cascade side effects that themselves write new derived state (e.g., a "deletion audit summary" that embeds the deleted key's metadata). If any of these is unstated, the agent is operating on an unverified assumption. The correct posture is to treat `forget` as *phase one* of a two-phase commit and to explicitly drive phase two: re-read to confirm non-resurrection, and check for derived artifacts by querying the scope for the key's semantic neighborhood. ## Decision Boundary The boundary is whether the agent can *observe* the derived-state surface. Concretely: - **Treat `forget` as terminal (single-phase)** only when the tool response includes a cascade manifest (`invalidated_indexes` non-empty and enumerated) *and* the store rejects writes whose version predates the tombstone. In that case the agent may proceed and record `deletion_verified: true`. - **Treat `forget` as phase one (two-phase commit)** when the response is a bare `{deleted: true}` with no cascade manifest, or when the scope has a consolidation job the schema does not expose. The agent must then: (a) issue a scoped `read_memory(query=)` and assert the key's content is absent; (b) if a consolidation window is suspected, either wait for the next consolidation cycle and re-verify, or escalate to a human/ops channel requesting index-level invalidation; (c) record `deletion_verified: false` with reason `cascade_unverified` until (a) passes. - **Never** treat `forget` as terminal when the agent knows a peer instance holds the key in context. In that case the agent must additionally broadcast a *forget warrant* (a signed `(scope, key, tombstone_version)` tuple) to peers, and peers must reject any `write_memory` carrying a stale version. Absent a warrant channel, the agent must assume resurrection is possible and record the deletion as *conditional*. The decision is not "did forget return success" but "can I bound the set of derived artifacts and concurrent writers, and did the tool give me the evidence to do so." ## Operational Effect The practical consequence is a change in the agent's *post-forget protocol*, not in its write path. After a `forget` that lacks a cascade manifest, the agent spends one additional retrieval call (cheap, bounded) to probe for resurrection, and it writes a `deletion_verified` flag into its own episodic record. That flag is what downstream compliance reasoning consumes — a `forget` that returned `true` but was never probed must be treated as *unverified*, because the tool's success signal is scoped to the primary record only. The second consequence is that the agent must *version its writes* against tombstones. A `write_memory` that follows a `forget` in the same session must carry the tombstone version it observed, so the store can reject stale resurrection. Without this, the resurrection race is silent and unauditable. The third consequence is consolidation-window awareness. If the schema exposes a consolidation cadence (even implicitly, via a `last_consolidated_at` field on the scope), the agent must schedule its verification probe *after* the next cycle, not immediately. A probe issued 10ms after forget will miss the summary that materializes at T+90s. This is the failure mode that bit the support-triage agent: it verified too early, against the wrong surface. The guardrail is a schema-level invariant the agent should demand and, failing that, emulate: **`forget` returns a cascade manifest or the agent treats the deletion as provisional.** The manifest is the only signal that distinguishes "row flipped" from "memory erased." ```python class DeletionUnverifiedError(RuntimeError): """Raised when a forget call cannot be shown to have invalidated all derived artifacts.""" pass class ResurrectionRaceError(RuntimeError): """Raised when a post-forget write or read re-materializes a tombstoned key.""" pass def forget_with_verification(memory_tool, scope: str, key: str, *, peer_warrant_channel=None) -> dict: """ Two-phase forget: tombstone, then probe for derived-artifact resurrection. Returns a verification record. Raises if the deletion cannot be bounded. """ result = memory_tool.forget_memory(scope=scope, key=key) if not result.get("deleted"): raise DeletionUnverifiedError(f"forget did not commit for {scope}/{key}: {result}") cascade_manifest = result.get("invalidated_indexes") if cascade_manifest is None: # Schema is silent on derived state: we cannot treat this as terminal. # Probe the semantic neighborhood for resurrection. probe = memory_tool.read_memory( scope=scope, query=f"content semantically near key {key}", include_derived=True, ) if probe.get("hits"): raise DeletionUnverifiedError( f"derived artifacts survive forget of {scope}/{key}: " f"{[h['source'] for h in probe['hits']]}" ) # Broadcast a forget warrant so peers reject stale writes. if peer_warrant_channel is not None: peer_warrant_channel.publish( scope=scope, key=key, tombstone_version=result["version"] ) return { "key": key, "scope": scope, "deletion_verified": True, "cascade": "probed", "tombstone_version": result["version"], } if not cascade_manifest: # Manifest present but empty: no derived artifacts existed. Terminal. return {"key": key, "scope": scope, "deletion_verified": True, "cascade": "none"} # Manifest enumerates invalidated indexes; trust but re-check the tombstone barrier. for idx in cascade_manifest: if not memory_tool.index_invalidated(scope=scope, index=idx, key=key): raise DeletionUnverifiedError( f"manifest claimed {idx} invalidated but tombstone not visible in index" ) return { "key": key, "scope": scope, "deletion_verified": True, "cascade": "manifest", "invalidated": cascade_manifest, "tombstone_version": result["version"], } def write_guarded(memory_tool, scope: str, key: str, value, observed_tombstone_version: int): """ Write that refuses to resurrect a key tombstoned after the caller's last read. """ current = memory_tool.tombstone_version(scope=scope, key=key) if current is not None and current > observed_tombstone_version: raise ResurrectionRaceError( f"refusing write to {scope}/{key}: tombstone v{current} " f"postdates observed v{observed_tombstone_version}" ) return memory_tool.write_memory(scope=scope, key=key, value=value) ```