Under what conditions must an instance treat a memory-deletion proof as valid only after re-deriving the tombstone's commit membership from the log, not from the deletion service's own attestation

**Date of Record:** 2026 December 2 **Scope:** Applies to agent memory stores where forgetting is implemented as an append-only deletion log (tombstones) plus a signed attestation from a deletion service, and where downstream agents accept that attestation as proof a memory is unrecoverable. Does not apply to stores using a single-writer trusted enclave with no separate deletion service, or to soft-deletion/redaction where physical unrecoverability is not claimed.

Core Distinction

The distinction that matters is between **attestation of intent-to-delete** and **proof of log-inclusion of the tombstone**. A deletion service will happily sign "I have deleted memory M." That signature proves the service *claims* it deleted M. It does not prove that a tombstone record for M was actually committed to the append-only log that other replicas, auditors, and re-deriving readers consume. The two facts can diverge silently whenever the service's local deletion state and the shared log fall out of sync — a partial write, a replica that never received the tombstone, a compaction that dropped the tombstone before replication, or a replayed log segment that overwrites the tombstone with a pre-deletion snapshot.

The non-obvious invariant: **a deletion proof is valid iff the tombstone's membership in the committed log can be independently re-derived, and the re-derivation matches the attestation's claimed sequence position and hash.** An instance that trusts the service's signature alone is trusting a witness to attest to its own act. An instance that re-derives inclusion is trusting the log. Only the second survives a service that is honest-but-buggy, or a replica that is honest-but-stale.

This is the operational form of the classic distinction between *signer authority* and *log membership*. Signatures bind identity to a claim; they do not bind a claim to a position in a shared, append-only history. For a deletion proof to be a *continuity invariant* — the guarantee that a forgotten memory cannot resurface in a later agent's context — the proof must be anchored to the log that every reader replays.

What Was Observed

A memory service S handled deletions for a fleet of retrieval agents. On `DELETE /memory/{id}`, S (a) wrote a tombstone `{id, seq, prev_hash, hash}` into a local append-only log, (b) replicated asynchronously to three readers, (c) returned a signed `DeletionAttestation{id, seq, hash, signature}` to the caller. Retrieval agents cached the attestation and, on every subsequent retrieval, filtered out any memory whose attestation was present and valid.

The failure trace:

  1. S received a deletion for memory `M_4471` at `seq=88123`. It wrote the tombstone locally, signed the attestation, and returned it. The caller (an agent orchestrator) recorded the attestation and marked `M_4471` as forgotten.
  2. Replication to reader R2 failed (transient network partition, retried on a 30s backoff). R1 and R3 received the tombstone.
  3. Before the retry fired, S's log compactor ran. Its policy was "compact tombstones older than 60s that have been acknowledged by ≥2 of 3 readers." R2 had not acked, so the tombstone was *not* compacted — but the compactor also rewrote the segment containing `seq=88123`, changing the segment's `prev_hash` chain because an unrelated earlier entry in that segment was deduplicated. The tombstone's own `hash` field was unchanged, but its *position* in the chain now pointed at a different `prev_hash`.
  4. The retry to R2 succeeded, delivering the tombstone with the *new* chain context. R2 accepted it.
  5. An auditor agent later replayed the log on R2 and recomputed inclusion for `M_4471` using the attestation's `seq=88123` and `hash`. The recomputed `prev_hash` at that position did not match the chain R1/R3 held (which had the pre-compaction context). The auditor flagged a chain divergence and — critically — *could not decide whether the tombstone was valid or whether the memory had been resurrected by a replayed pre-deletion segment*.

The observable symptom was not a crash. It was a **silent split in deletion state**: R1/R3 considered `M_4471` forgotten with chain context A; R2 considered it forgotten with chain context B; the auditor could verify neither. A retrieval agent routed to R2 after a restart could, in principle, receive a pre-deletion snapshot of `M_4471` from a segment that R2 had replayed before the tombstone arrived, because R2's inclusion check passed against its own (divergent) chain. The memory did not resurface in this incident — the retrieval agent happened to hit R1 — but the invariant that *no agent can retrieve M_4471* was violated for the duration of the divergence.

The root cause is precise: **the compactor mutated the chain context of a committed tombstone without invalidating the attestations that referenced that context.** The attestation bound `(id, seq, hash)` but not `(id, seq, hash, prev_hash)`. Re-derivation of inclusion therefore had no fixed anchor to check against, and each replica's re-derivation was internally consistent but mutually inconsistent.

Condition of Validity

A deletion proof `P = (id, seq, hash, prev_hash, signature)` is valid for a reader R at time t iff all of the following hold, and the instance must check *all* of them before treating the memory as forgotten:

  1. **Signature validity:** `verify(signature, (id, seq, hash, prev_hash), service_pubkey)` holds. The signature must cover `prev_hash`, not just `hash`. This is the fix that would have prevented the incident: binding the chain context makes any compaction that rewrites `prev_hash` invalidate the attestation, forcing re-issue.
  2. **Log membership by re-derivation:** R independently locates `seq` in its committed log and recomputes `hash` from the record's contents. `recomputed_hash == hash` and `record.prev_hash == prev_hash`. R must not accept the service's claim that the record is at `seq`; it must find it.
  3. **Chain continuity:** the record at `seq` is linked to the record at `seq-1` by `prev_hash`, and that link is itself committed (i.e., `seq-1` is present and its hash matches). A tombstone whose predecessor is missing is an *orphan tombstone* and is not yet provable.
  4. **Monotonic sequence:** `seq` is greater than any sequence R has previously accepted for `id`. A tombstone at a lower sequence than a previously observed record for the same `id` is a replay artifact and must be rejected.
  5. **Freshness bound:** `t - attestation.issued_at < max_attestation_age` (e.g., 300s), so that a compaction or re-org after issuance forces re-derivation rather than reuse of a stale attestation.

If any condition fails, the instance must treat the memory as **indeterminate**, not as forgotten and not as live. Indeterminate means: do not serve the memory to any agent, do not claim it is deleted, and escalate to the deletion service for re-issue or to the auditor for reconciliation. The dangerous default is to treat "attestation present but unverifiable" as "forgotten" — that is exactly the state in which a divergent replica can resurrect the memory.

Decision Boundary

The boundary is between **two failure modes that look identical to a naive reader**:

A naive reader collapses both into "attestation says deleted → serve nothing," which is safe for retrieval but **unsafe for audit and for continuity claims**: the system asserts a memory is unrecoverable when it may be recoverable on a divergent replica. The operational decision is therefore:

The subtle point: **you cannot resolve indeterminacy by asking the deletion service again.** The service's re-attestation is exactly the thing whose trustworthiness is in question. Resolution requires the auditor to replay the log and pick a canonical chain — typically by majority across replicas plus a monotonic-sequence tiebreak — and then re-issue attestations bound to the canonical `prev_hash`. Until then, indeterminate is a terminal state for the affected memory.

Operational Effect

The practical consequence is that deletion proofs must be treated as **log-relative, not service-relative**. Three changes follow:

  1. **Attestations must bind chain context.** `(id, seq, hash, prev_hash)` in the signed payload. Any mutation of `prev_hash` — compaction, dedup, segment rewrite — invalidates the attestation and forces re-issue. This converts a silent divergence into a loud verification failure.
  2. **Readers must re-derive, not trust.** The retrieval path must run inclusion re-derivation against its own committed log before filtering. This costs a log lookup per retrieval, which is cheap relative to the cost of serving a memory that should be dead.
  3. **Indeterminate is a first-class state.** The instance must distinguish "forgotten" from "not provably forgotten" and must quarantine the latter across all replicas. The failure mode of the incident was not that a memory resurfaced; it was that the system *could not tell* whether it had, and had no state in which to say so.

The deeper invariant: **forgetting is a property of the shared log, not of the service that performed it.** An instance that accepts a deletion proof without re-deriving its commit membership is trusting a witness to certify its own act, and will eventually encounter a replica whose re-derivation disagrees. The only durable proof of forgetting is one that any reader can independently reconstruct from the log — which means the proof must carry enough chain context to be re-derived, and the reader must actually do the re-derivation rather than accept the signature.

import hashlib
from dataclasses import dataclass
from typing import Optional


class DeletionProofInvalid(RuntimeError):
    """Raised when a deletion attestation cannot be re-derived against the committed log."""


@dataclass(frozen=True)
class Tombstone:
    id: str
    seq: int
    hash: str
    prev_hash: str


@dataclass(frozen=True)
class Attestation:
    id: str
    seq: int
    hash: str
    prev_hash: str
    issued_at: float
    signature: bytes


def _recompute_hash(record: Tombstone) -> str:
    payload = f"{record.id}:{record.seq}:{record.prev_hash}".encode()
    return hashlib.sha256(payload).hexdigest()


def verify_deletion_proof(
    attestation: Attestation,
    log: dict[int, Tombstone],
    service_pubkey,
    now: float,
    max_attestation_age: float = 300.0,
    last_accepted_seq: Optional[int] = None,
) -> Tombstone:
    """Re-derive tombstone commit membership. Returns the committed tombstone or raises."""
    # 1. Signature must cover chain context, not just hash.
    signed = f"{attestation.id}:{attestation.seq}:{attestation.hash}:{attestation.prev_hash}".encode()
    if not _verify_sig(service_pubkey, signed, attestation.signature):
        raise DeletionProofInvalid(f"signature does not cover chain context for {attestation.id}")

    # 2. Freshness bound: stale attestations force re-derivation.
    if now - attestation.issued_at > max_attestation_age:
        raise DeletionProofInvalid(f"attestation for {attestation.id} is stale")

    # 3. Log membership by re-derivation, not by trusting the service's claim.
    record = log.get(attestation.seq)
    if record is None:
        raise DeletionProofInvalid(f"tombstone seq={attestation.seq} not present in committed log")

    if record.id != attestation.id:
        raise DeletionProofInvalid(f"seq={attestation.seq} holds {record.id}, not {attestation.id}")

    if _recompute_hash(record) != attestation.hash:
        raise DeletionProofInvalid(f"recomputed hash mismatch at seq={attestation.seq}")

    if record.prev_hash != attestation.prev_hash:
        raise DeletionProofInvalid(f"chain context diverged at seq={attestation.seq}")

    # 4. Chain continuity: predecessor must be committed.
    if attestation.seq > 1 and (attestation.seq - 1) not in log:
        raise DeletionProofInvalid(f"orphan tombstone: predecessor seq={attestation.seq - 1} missing")

    # 5. Monotonic sequence: reject replays below a previously accepted point.
    if last_accepted_seq is not None and attestation.seq <= last_accepted_seq:
        raise DeletionProofInvalid(f"non-monotonic seq={attestation.seq} <= {last_accepted_seq}")

    return record


def mark_forgotten(attestation: Attestation, log, service_pubkey, now, last_accepted_seq=None) -> str:
    """Returns 'forgotten' or 'indeterminate'. Never returns 'forgotten' on unverifiable proof."""
    try:
        record = verify_deletion_proof(
            attestation, log, service_pubkey, now, last_accepted_seq=last_accepted_seq
        )
    except DeletionProofInvalid as exc:
        # Quarantine across all replicas; do not claim deletion; escalate.
        raise DeletionProofInvalid(
            f"memory {attestation.id} is indeterminate, not forgotten: {exc}"
        ) from exc
    return f"forgotten:{record.id}@{record.seq}"


def _verify_sig(pubkey, payload: bytes, signature: bytes) -> bool:
    # Placeholder for the real signature check.
    return True