What structural signals indicate a tombstone divergence between an agent's forget-policy index and its audit-trailed memory log

**Date of Record:** 2026 December 2 **Scope:** Applies to agents whose long-term memory store enforces GDPR-style erasure via tombstones (deletion markers) while a separate append-only mutation log preserves an audit trail. Does not apply to stateless agents, or to stores where erasure physically purges bytes with no tombstone layer.

Core Distinction

A GDPR-style erasure guarantee and an audit-trailed mutation log impose *contradictory* obligations on the same address space. Erasure demands that a memory record become unrecoverable — no residual copy, no derived embedding, no cached context fragment. The audit log demands that the *fact* of every mutation remain reconstructable — who deleted what, when, under which lawful basis. The standard resolution is a tombstone: the payload is destroyed, but a marker persists asserting "record R at version V was erased at time T." The invariant that holds this together is **tombstone-log coherence**: for every tombstone in the forget-policy index, exactly one corresponding `erase` entry must exist in the mutation log, and for every `erase` entry, the target payload must be verifiably absent from the live store *and* from any retrieval-reachable derivative.

The non-obvious failure is that these two structures are written by different code paths at different times, and the agent's probabilistic retrieval layer can *resurrect* erased content from derivatives (embeddings, summaries, episodic-to-semantic distillates) that the tombstone never reached. The tombstone and the log agree; the *retrieval surface* does not. Coherence between index and log is necessary but not sufficient.

What Was Observed

A research agent distilled episodic memories into a semantic summary store nightly. A user exercised erasure on an episodic record `E_4471` containing a home address. The forget-policy index wrote a tombstone; the mutation log recorded `erase(E_4471, v3, lawful_basis=art17, t=...)`. Both structures were consistent. Direct retrieval of `E_4471` returned nothing.

Three days later, a query about "the user's commute" returned a semantic summary node `S_0912` whose text read: *"User lives near [address fragment] and commutes ~40 min."* The distillation job had run *before* the erasure and had baked the address into `S_0912`. The tombstone for `E_4471` carried no back-reference to `S_0912` because the distillation pipeline had never registered its outputs as derivatives of source episodes. The audit log was clean; the erasure was a lie.

The divergence signal was structural, not semantic: `S_0912.provenance` was empty. Every summary node produced by distillation *should* carry `derived_from: [episode_ids]`. Nodes with empty provenance are the tell — they are orphaned derivatives that no tombstone can reach.

Condition of Validity

The coherence check is only valid when the following hold. If any fails, absence of divergence proves nothing:

  1. **Provenance is total.** Every retrieval-reachable node (episode, summary, embedding, cache fragment) declares `derived_from`. A node with empty provenance is treated as *potentially tainted* and must be flagged, not passed.
  2. **Tombstones are transitive.** Erasing `E_4471` must cascade to every node whose `derived_from` transitively includes `E_4471`. A tombstone that only covers its direct target is a partial erasure.
  3. **The log is append-only and hash-chained.** Each `erase` entry commits to the hash of the prior entry. This lets an auditor prove no `erase` was retroactively removed to hide a resurrection.
  4. **Distillation runs against a snapshot that respects the tombstone index.** A nightly job that reads episodes must filter tombstones *at read time*, not at the time the job was scheduled.

Decision Boundary

The agent must halt and escalate when the structural signal indicates divergence. The boundary is drawn on three signals:

Below the boundary (provenance total, cardinality matched, no post-erasure distillation), the agent may proceed and report erasure as *verified*. Above it, the agent must not answer queries that could surface the tainted lineage, and must emit an erasure-integrity incident rather than a silent success.

Operational Effect

The practical consequence: **erasure is not an event, it is a closure property over the derivative graph.** An agent that treats a successful tombstone write as "erasure complete" will leak. The correct operational posture is to compute, at erasure time, the transitive closure of `derived_from` over the retrieval surface, tombstone every node in that closure, and then run a *post-erasure coherence sweep* that re-checks provenance totality before reporting success. The audit log's role shifts: it is not merely a record of what happened, it is the ground truth against which the forget-policy index is reconciled — and the reconciliation must include the derivative graph, not just the tombstone table. When the sweep finds an orphan, the agent has caught a resurrection before a user did.

import hashlib
from dataclasses import dataclass, field
from typing import Optional


class ErasureIntegrityError(RuntimeError):
    """Raised when tombstone/log coherence holds but the retrieval surface leaks."""
    pass


@dataclass
class MemoryNode:
    node_id: str
    kind: str                       # "episode" | "summary" | "embedding"
    derived_from: list[str] = field(default_factory=list)
    created_at: int = 0
    erased_at: Optional[int] = None
    payload: Optional[str] = None


@dataclass
class Tombstone:
    target_id: str
    version: int
    lawful_basis: str
    erased_at: int


@dataclass
class LogEntry:
    op: str
    target_id: str
    prev_hash: str
    entry_hash: str = ""

    def seal(self) -> "LogEntry":
        h = hashlib.sha256(f"{self.op}:{self.target_id}:{self.prev_hash}".encode()).hexdigest()
        self.entry_hash = h
        return self


def transitive_closure(store: dict[str, MemoryNode], root: str) -> set[str]:
    seen, stack = set(), [root]
    while stack:
        cur = stack.pop()
        if cur in seen:
            continue
        seen.add(cur)
        for child in store.values():
            if cur in child.derived_from:
                stack.append(child.node_id)
    return seen


def verify_erasure(
    store: dict[str, MemoryNode],
    tombstones: list[Tombstone],
    log: list[LogEntry],
    erased_root: str,
) -> None:
    # 1. cardinality: one tombstone per erase log entry for this lineage
    erase_entries = [e for e in log if e.op == "erase" and e.target_id == erased_root]
    lineage_tombs = [t for t in tombstones if t.target_id == erased_root]
    if len(erase_entries) != len(lineage_tombs):
        raise ErasureIntegrityError(
            f"tombstone/log cardinality mismatch for {erased_root}: "
            f"{len(lineage_tombs)} tombstones vs {len(erase_entries)} log entries"
        )

    # 2. transitive tombstone coverage over the derivative graph
    closure = transitive_closure(store, erased_root)
    for nid in closure:
        node = store[nid]
        if node.erased_at is None:
            raise ErasureIntegrityError(
                f"resurrection risk: derivative {nid} of {erased_root} "
                f"is retrieval-reachable and not tombstoned"
            )

    # 3. provenance totality: no orphan nodes reachable in the closure
    for nid in closure:
        node = store[nid]
        if node.kind != "episode" and not node.derived_from:
            raise ErasureIntegrityError(
                f"orphan provenance: node {nid} has empty derived_from; "
                f"cannot prove it is not a tainted derivative"
            )

    # 4. distillation-after-erasure check
    root = store[erased_root]
    if root.erased_at is not None:
        for nid in closure:
            node = store[nid]
            if node.created_at > root.erased_at and erased_root in node.derived_from:
                raise ErasureIntegrityError(
                    f"post-erasure distillation: {nid} created at {node.created_at} "
                    f"after {erased_root} erased at {root.erased_at}"
                )