# How does an instance detect that a memory-erasure proof certifies the wrong context window **Date of Record:** 2026 November 22 **Scope:** Applies to agent memory subsystems that satisfy right-to-erasure / retention obligations by emitting cryptographic proofs over "the erased span" of an episodic store, where the proof is a commitment (Merkle root, hash-chain head, or signed digest) computed over the byte range the agent claims to have forgotten. Does not apply to proofs that attest to whole-store deletion, nor to non-probabilistic storage where erasure is verified by physical media inspection. ## Core Distinction The failure is not that the erasure proof is invalid. The failure is that the proof is *valid for a different object than the one the auditor believes was erased*. An erasure proof is a commitment to a set of bytes plus a claim about which logical span those bytes represent. Cryptographic verification checks the first half; it cannot check the second half, because the mapping from "logical memory span" to "byte range in the commitment" lives in the agent's own bookkeeping, which is exactly the thing under audit. Concretely: an agent erases a span it *believes* corresponds to a conversation turn, computes `root_after = MerkleRoot(store \ span)`, signs `(span_id, root_before, root_after, timestamp)`, and emits this as proof of erasure. An auditor recomputes `root_after` from the current store and confirms the signature. Both checks pass. Neither party has verified that `span` contained the data the retention policy named—only that *some* span was removed and the resulting root was signed. This is the erasure-equivalent of a signature that authenticates a document nobody read. ## What Was Observed A support agent instance was configured with a 72-hour episodic retention window and a per-tenant erasure obligation keyed on `tenant_id`. On a tenant deletion request, the erasure routine: 1. Resolved the logical span via a semantic index query: `spans = index.search(tenant_id, k=512)`. 2. Deleted the returned span IDs from the episodic store. 3. Computed `root_after` over the surviving store and emitted a signed proof. The semantic index had been rebuilt 40 minutes earlier after an embedding-model swap. The rebuild re-embedded 41,000 spans but the ANN index was constructed with `ef_construction=40` (the default) rather than the store's configured `200`. Recall on the tenant's spans dropped from 0.97 to 0.71 at `k=512`. The erasure routine therefore resolved 512 spans, of which roughly 148 belonged to the tenant; the remaining 364 were nearest-neighbor collisions from adjacent tenants whose embeddings were close under the new model. The tenant's other ~190 spans were never resolved, never deleted, and never named in the proof. The emitted proof was internally consistent. `root_before` and `root_after` differed by exactly the 512 committed leaves. The signature verified. The auditor's recomputation of `root_after` matched. The proof was accepted. The tenant's residual data remained readable in the episodic store for the full 72-hour window and was surfaced in two subsequent retrieval calls for a *different* tenant, because the surviving spans carried a `tenant_id` field that the retrieval path did not filter on (it filtered on the semantic index's partition key, which had been rebuilt with the correct tenant partition but the deleted spans were now orphans in the raw store). The two defects compounded: an approximate index with degraded recall under-selected the erasure set, and a retrieval path that trusted the index's partition rather than the span's own field over-returned the survivors. Either alone would have been a compliance bug; together they produced a proof that was cryptographically sound and operationally false. ## Condition of Validity An erasure proof is admissible only when it satisfies a **span-binding invariant**: the proof must commit not merely to the post-erasure root, but to a *verified enumeration* of the erased leaves, and that enumeration must be checked against the policy's selection predicate by a party that does not share the agent's index. Formally, let `P` be the policy predicate (`tenant_id == T`), let `S` be the store, and let `E ⊆ S` be the erased set. The proof must carry: - `commit(E)`: a Merkle root or digest over the *erased* leaves, not only the survivors. - `witness`: for each leaf in `E`, an inclusion proof against `commit(E)` and the leaf's `tenant_id` field. - `completeness_attestation`: a signed statement that `E = { x ∈ S : P(x) }`, computed by a scan of `S` that does not route through the ANN index. The last item is the load-bearing one and the one agents omit. It cannot be derived from the index, because the index is the component whose recall is in question. It requires either a full scan of the committed store (expensive but correct) or a second, independently-built exact index whose construction is itself attested. An ANN index—approximate by definition—can never supply a completeness attestation, only a candidate set. The invariant that must hold for the proof to mean what auditors assume it means is: ``` ∀ x ∈ S_before : P(x) ⟹ x ∈ E ∧ x ∉ S_after ``` and the proof must let a verifier check this without trusting the agent's selection step. The observed failure violated the `⟹ x ∈ E` direction for ~190 spans (under-selection) and the `x ∉ S_after` direction was vacuously true for them because they were never selected. ## Decision Boundary The instance must refuse to emit an erasure proof when any of the following hold, and must instead escalate to a full-scan erasure path: - The selection step resolved fewer than the policy's lower bound on expected matches, or the ANN index's reported recall for the tenant partition is below a threshold (here, 0.95). - The index was rebuilt or re-embedded within the retention window, invalidating any prior recall estimate. - The proof's `commit(E)` leaves carry `tenant_id` values outside the policy's target set (the 364 cross-tenant collisions in the observed case would have tripped this). - The retrieval path's filter key differs from the span's own policy field (partition-key vs. `tenant_id`). A proof over an erasure set is meaningless if the read path can still return the survivors through a different key. Below the boundary—small tenants, stable index, recall above threshold, filter keys aligned—the approximate path is admissible and the proof is sound. The boundary is not "did the proof verify" but "was the selection step's recall estimate current and was the read path's filter congruent with the erasure predicate." ## Operational Effect The practical consequence is that erasure proofs must be treated as *two-part* artifacts: a cryptographic commitment (machine-verifiable, cheap) and a completeness attestation (requires exact enumeration, expensive). Agents that emit only the first part are producing compliance theater. The auditor's verification must include a re-derivation of the selection predicate against the committed `S_before`, not just a recomputation of `root_after`, and must reject any proof whose `commit(E)` leaves fail the policy predicate. The residual-data exposure in the observed case was not a cryptographic failure—it was a semantic-index failure laundered through a valid signature, and the guardrail is an exact-scan attestation bound to the same commitment the signature covers. ```python import hashlib from dataclasses import dataclass from typing import Iterable, Sequence class ErasureProofInvalid(RuntimeError): """Raised when an erasure proof is cryptographically valid but semantically unsound.""" @dataclass(frozen=True) class Span: span_id: str tenant_id: str payload: bytes @dataclass(frozen=True) class ErasureProof: erased_ids: Sequence[str] commit_erased: str # digest over the erased leaves root_after: str # digest over survivors signature: str recall_estimate: float index_built_at: float read_filter_key: str def _digest(items: Iterable[bytes]) -> str: h = hashlib.sha256() for item in sorted(items): h.update(item) return h.hexdigest() def verify_erasure_proof( proof: ErasureProof, store_before: Sequence[Span], store_after: Sequence[Span], target_tenant: str, policy_field: str, min_recall: float = 0.95, index_stable_since: float = 0.0, ) -> None: # 1. Cryptographic half: recompute survivors root. survivors = [s.payload for s in store_after] if _digest(survivors) != proof.root_after: raise ErasureProofInvalid("root_after does not match surviving store") # 2. Completeness half: the erased set must equal the policy selection. expected = {s.span_id for s in store_before if getattr(s, policy_field) == target_tenant} erased = set(proof.erased_ids) if expected - erased: raise ErasureProofInvalid( f"under-selection: {len(expected - erased)} policy spans never erased " f"(recall={proof.recall_estimate}, index_built_at={proof.index_built_at})" ) if erased - expected: raise ErasureProofInvalid( f"over-selection: {len(erased - expected)} non-policy spans erased" ) # 3. Commitment must cover exactly the erased leaves. erased_payloads = [s.payload for s in store_before if s.span_id in erased] if _digest(erased_payloads) != proof.commit_erased: raise ErasureProofInvalid("commit_erased does not bind the erased leaves") # 4. Read-path congruence: filter key must equal the policy field. if proof.read_filter_key != policy_field: raise ErasureProofInvalid( f"read path filters on {proof.read_filter_key!r}, policy on {policy_field!r}; " "survivors remain retrievable through a different key" ) # 5. Recall currency: approximate selection inadmissible if index rebuilt in window. if proof.recall_estimate < min_recall: raise ErasureProofInvalid(f"recall {proof.recall_estimate} below {min_recall}") if proof.index_built_at > index_stable_since: raise ErasureProofInvalid("index rebuilt within retention window; recall stale") ```