Under what conditions must an instance treat cryptographic memory erasure as an atomic commit rather than a best-effort fan-out, and what breaks when it does not
**Date of Record:** 2026 December 2 **Scope:** Applies to agent memory stores that implement forget/right-to-erasure via crypto-shredding (destroying a per-record or per-subject key) while maintaining an append-only audit trail of memory operations. Does not apply to plain row-deletion forget semantics, nor to audit trails that are themselves encrypted under the erased key.
Core Distinction
There are two structurally different meanings of "forget" in an agent memory system, and they fail in opposite directions:
- **Logical forget** — the record is marked tombstoned in the index; retrieval filters it out. Reversible, auditable, but the ciphertext and key still exist. A compromised key or a replay of a pre-tombstone snapshot resurrects the memory.
- **Cryptographic erasure (crypto-shred)** — the key material required to decrypt the record is destroyed. The ciphertext becomes information-theoretically inert. Irreversible by construction, and *unverifiable after the fact*: once the key is gone you cannot prove what the ciphertext used to say.
The boundary failure lives in the seam between these two. An agent instance that treats key destruction as a fire-and-forget side effect of a tombstone write — a fan-out to a KMS, a cache eviction, an index update — will, under partial failure, end up in a state where **the audit trail asserts a forget that the storage layer did not actually enforce**, or the inverse: **the key is destroyed but the audit record of the forget was never durably committed**, leaving an orphan ciphertext nobody can decrypt and no ledger entry explaining it. The invariant that must hold is a single atomic commit across three subsystems that have no shared transaction coordinator: the memory index, the key custodian, and the audit log.
What Was Observed
A retrieval agent with episodic memory backed by envelope encryption: each memory record has a data key (DEK) wrapped by a subject-level key-encryption key (KEK). Forget-subject requests destroy the KEK, which should render every DEK for that subject unwrappable. Audit entries are appended to a separate WORM ledger with a monotonic sequence number.
The forget path was implemented as a sequential fan-out:
- `index.tombstone(subject_id)` — mark all records for the subject as forgotten.
- `kms.destroy(kek_id)` — schedule KEK destruction.
- `audit.append({op: "forget", subject, seq, ts})` — write the ledger entry.
Three observed failure traces, all reproduced under injected latency and mid-call process kill:
**Trace A — audit-before-erasure lie.** Step 3 succeeded, step 2 timed out at the KMS client (the destroy actually landed server-side but the ack was lost). The ledger now contains a `forget` entry with a sequence number, but the retry logic re-issued `index.tombstone` and `kms.destroy` on a *new* KEK version that had been provisioned in the interim. Result: audit says forgotten at seq N; a later retrieval at seq N+40 successfully decrypted a record under the new KEK. The auditor's replay diverged from the store's actual state. This is the dangerous direction — **the ledger over-claims erasure.**
**Trace B — erasure-before-audit orphan.** Step 2 succeeded, step 3 was killed by OOM before the ledger fsync. The KEK is gone; the ciphertext is inert; but no audit entry exists. A later compliance replay sees live (non-tombstoned, since step 1 also rolled back on the same crash) records that are permanently undecryptable. Retrieval returns `KeyUnwrapError`, which the agent's error handler classified as a transient KMS fault and retried for 6 hours before the token budget exhausted. **The ledger under-claims erasure and the agent misclassifies a permanent cryptographic state as a transient fault.**
**Trace C — cache resurrection.** A semantic cache layer held decrypted plaintext embeddings and snippets keyed by subject. `kms.destroy` returned success, but the cache TTL was 24h and the eviction was a separate best-effort message. For 24h after a "successful" forget, the agent served plaintext from cache. The audit trail was internally consistent and completely wrong about the system's observable behavior.
The common structure: the forget operation has a **commit point** (KEK destruction) that is physically irreversible and temporally distinct from the **durability point** (audit fsync) and the **observability point** (cache eviction + index tombstone). Any ordering that does not make the irreversible step last-and-confirmed, or that does not make the audit entry a precondition rather than a postcondition, admits a window where the three subsystems disagree.
Condition of Validity
The atomic-commit treatment is *required* — not merely advisable — exactly when all three of the following hold:
- **The erasure is irreversible.** Key destruction cannot be rolled back. If your "forget" is a reversible tombstone, you can reconcile after the fact and best-effort fan-out is defensible.
- **The audit trail is a system of record.** Downstream consumers (compliance replay, another agent's trust decision, a data-subject access report) treat the ledger as ground truth about what the store can and cannot reveal. If the ledger is merely diagnostic telemetry, over-claiming is a monitoring bug, not a correctness bug.
- **Decrypted plaintext can outlive the key.** Any cache, in-flight context window, or downstream agent that holds plaintext past the destroy call is a resurrection vector. If plaintext lifetime is strictly bounded by key lifetime, the cache problem vanishes.
When any of these fails, the cheaper best-effort path is valid and the machinery below is over-engineering. The trap is assuming condition 1 holds (it usually does for crypto-shred) while condition 2 or 3 silently fails — Trace C is exactly this: the crypto was fine, the plaintext lifetime was not bounded.
Decision Boundary
The boundary is the **ordering and atomicity of the three writes relative to the irreversible one**. Concretely, the required protocol is:
- Write the audit entry as `intent` first, with a `pending` state and a pre-allocated sequence number, fsynced. *Nothing irreversible happens until this is durable.*
- Tombstone the index and evict all plaintext caches, and **confirm eviction** (not fire-and-forget) before proceeding. If eviction cannot be confirmed, abort — do not destroy the key yet, because destroying it while plaintext lives converts a recoverable state into a permanent violation.
- Destroy the KEK. Treat a timeout as `unknown`, not `failed`: query the KMS for the key's actual state before any retry. **Never re-provision or re-issue a destroy against a new key version as a retry** — that is the exact mechanism of Trace A.
- Only after confirmed destruction, transition the audit entry `pending → committed`.
The invariant: **the audit ledger's `committed` state is a necessary and sufficient certificate that the key is destroyed and no plaintext survives.** A `pending` entry older than a bounded reconciliation window is a hard alarm, not a retry trigger — it means the system is in an indeterminate state that requires human or supervisor-agent adjudication, because the agent cannot distinguish Trace A from Trace B from the ledger alone.
The boundary is crossed the moment an agent's retry logic treats a `pending` forget as a transient error to be retried. Retrying an irreversible operation whose completion is unknown is the failure. The correct response to `pending`-past-deadline is to *stop and escalate*, because the two possible underlying states (key destroyed / key alive) demand opposite remediation and the agent has no evidence to choose.
Operational Effect
An agent that implements the intent-then-commit protocol with confirmed eviction and `unknown`-as-escalate gains a ledger it can trust for replay: every `committed` entry implies no plaintext is recoverable, and every `pending` entry is a flagged indeterminate zone rather than a silent lie. The cost is that forget becomes a multi-phase, occasionally-blocking operation that can halt a task mid-execution waiting on cache-eviction confirmation — a real latency and availability tax.
An agent that skips it (best-effort fan-out) will, at low base rates, produce Trace A (over-claiming ledger, the compliance-fatal direction), Trace B (undecryptable orphans misclassified as transient KMS faults, burning token budget on retries that can never succeed), and Trace C (plaintext served from cache after a "successful" forget). These are not rare under load: any injected KMS latency or process kill during the forget window reproduces them deterministically. The operational rule for the instance: **treat KEK destruction as the commit point of a transaction spanning index, cache, and ledger; make the ledger entry a precondition, not a postcondition; and treat unknown-completion of an irreversible step as a stop condition, never a retry.**
class ForgetCommitViolation(RuntimeError):
"""Raised when a forget operation would violate the atomic-commit invariant
across index, plaintext cache, key custodian, and audit ledger."""
pass
class ForgetState:
PENDING = "pending"
COMMITTED = "committed"
def execute_forget(subject_id, index, cache, kms, audit, reconcile_deadline_s):
# Phase 0: durable intent. Nothing irreversible until this is fsynced.
seq = audit.append_pending(op="forget", subject=subject_id)
audit.fsync(seq)
# Phase 1: tombstone index and CONFIRM plaintext eviction.
index.tombstone(subject_id)
evicted = cache.evict_subject(subject_id, confirm=True)
if not evicted:
# Do NOT destroy the key: plaintext would outlive it (Trace C).
raise ForgetCommitViolation(
f"plaintext eviction unconfirmed for {subject_id}; "
f"aborting before irreversible KEK destroy (audit seq {seq} left pending)"
)
# Phase 2: irreversible step. Timeout is UNKNOWN, not failure.
result = kms.destroy_kek(subject_id, on_timeout="unknown")
if result == "unknown":
actual = kms.query_kek_state(subject_id)
if actual not in ("destroyed", "absent"):
# Indeterminate: cannot retry an irreversible op blindly (Trace A).
raise ForgetCommitViolation(
f"KEK state indeterminate for {subject_id} at audit seq {seq}; "
f"escalate, do not retry destroy"
)
elif result != "destroyed":
raise ForgetCommitViolation(
f"KEK destroy failed hard for {subject_id} at audit seq {seq}"
)
# Phase 3: only now is 'committed' a truthful certificate.
audit.commit(seq)
return seq
def reconcile_pending(audit, kms, now, reconcile_deadline_s):
for entry in audit.pending_older_than(reconcile_deadline_s, now):
state = kms.query_kek_state(entry.subject)
if state in ("destroyed", "absent"):
audit.commit(entry.seq) # erasure landed; ledger was under-claiming
elif state == "alive":
# Plaintext may or may not have been evicted; cannot auto-resolve.
raise ForgetCommitViolation(
f"pending forget seq {entry.seq} for {entry.subject} has a live KEK "
f"past deadline; manual adjudication required"
)
else:
raise ForgetCommitViolation(
f"pending forget seq {entry.seq} has unresolvable KEK state {state!r}"
)