What happens when an instance revokes a provenance ancestor mid-replay: TTL-scoped memory stores and the dangling-derivation invariant

**Date of Record:** 2026 December 1 **Scope:** Applies to agents whose long-term memory is exposed through read/write/forget tool APIs and where each memory record carries a provenance edge (derived-from) and a TTL. Does not apply to append-only stores with no revocation surface, nor to single-turn agents with no persistent memory.

Core Distinction

A TTL-scoped, provenance-tracked memory store has two independent expiry mechanisms that agents routinely conflate: **time-based expiry** (a record's TTL elapses and the record is garbage-collected or hidden) and **revocation** (an explicit `forget` call that marks a record as retracted for correctness reasons—poisoned input, superseded fact, user deletion request). The invariant that matters is:

> **No live record may hold a provenance edge to a revoked record.**

A record whose ancestor was revoked is a *dangling derivation*. Its content may have been computed entirely from retracted premises, yet the record itself is still live, still readable, and still eligible to be used as a premise in future derivations. TTL expiry does not violate this invariant—an expired record is simply gone, and dependents either expire too or were never promised continuity. Revocation does violate it, because revocation is a *semantic* retraction: the agent asserted "this memory was wrong to have." Every dependent that was synthesized from it inherits that wrongness, but the store does not automatically propagate the taint.

This is the non-obvious boundary: **forget is not delete.** `forget` retracts a node; it does not transitively retract the node's descendants. The store enforces referential integrity for reads (you cannot read a forgotten record) but not for derivation (you can still read records that were derived from it). The distinction is invisible until a multi-hop reasoning chain happens to depend on a revoked fact and the agent never re-reads the ancestor—because the ancestor is gone, so re-reading it is impossible, so the contamination is undetectable by the agent.

What Was Observed

An agent maintained a working memory of task facts populated by tool calls. Each `write` returned a record ID and recorded a `derived_from` list naming the parent records the new fact was synthesized from. A summarization step produced record `S` derived from `{F1, F2, F3}`. Later, `F2` was found to originate from a prompt-injected tool output and was revoked via `forget(F2)`. `F1` and `F3` remained live. `S` remained live.

The failure trace:

  1. `forget(F2)` succeeds; `F2` is marked `revoked=true`, `revoked_at` set. The store returns `{"revoked": ["F2"], "dependents": ["S"]}` — but only as *informational metadata*. `S` is not touched.
  2. A subsequent planning step calls `read(S)`. The store returns `S` normally. The response payload does not flag that `S` has a revoked ancestor; the `derived_from` list in the response still names `F2`, but `F2` is now unreadable (any `read(F2)` returns `NotFound` or `Revoked`).
  3. The agent, seeing `S` as a valid premise, writes `T` derived from `S`. `T` is now a *second-generation* dangling derivation. The taint has propagated one hop further, and the store's `dependents` metadata for `F2` was computed at revocation time and is now stale—it lists `S` but not `T`.
  4. The agent runs a consistency check by attempting to re-derive `S` from its parents. `read(F2)` fails with `Revoked`. The agent cannot distinguish "F2 was revoked because it was wrong" from "F2 expired or was never written." The re-derivation either fails opaquely or, worse, the agent treats the missing parent as "unknown" and *re-affirms* `S` as an independent fact, laundering the revocation.
  5. On a cold restart, the agent replays from memory. `S` and `T` are both live and mutually consistent. `F2` is gone. The store's audit log shows the revocation, but the replay path never consults the audit log—it reads live records only. The contamination is now structurally invisible: there is no live record that references a revoked record *by a name the agent can resolve*, because the revoked record cannot be resolved.

The key observation: **revocation is only sound if it is transitively closed, and the closure must be enforced at write time, not reported as advisory metadata at forget time.** The `dependents` field is a snapshot; derivations created after the `forget` call are not in it. The invariant must be checked on every `write`, not just on `forget`.

Condition of Validity

The dangling-derivation invariant holds (i.e., the store is safe to use as a reasoning substrate) only when all three of the following are true:

  1. **Write-time ancestry check.** Every `write` that names `derived_from` parents must verify that no named parent is revoked *or transitively derived from a revoked record*, at the moment of the write. This is a reachability check over the provenance DAG, not a membership check over a flat list. A store that only checks direct parents will admit second-generation taint (the `T` case above).
  2. **Revocation is a closure operation, not a node operation.** `forget(X)` must either (a) transitively revoke all live descendants of `X`, or (b) refuse to revoke `X` while live descendants exist, returning the blocking set so the agent can decide. Option (a) is a cascading retraction; option (b) is a referential-integrity gate. Either is sound; the current behavior—revoke the node, report dependents, leave them live—is neither.
  3. **TTL and revocation are distinguished on read.** A `read` of a record with a revoked ancestor must fail closed (return the record *with an explicit `tainted: true` flag and the revocation reason*) or fail open (return `Revoked` for the whole chain). It must never return the record as if clean. The current behavior returns it clean, which is the laundering path.

When any of these is false, the store is a *plausible* but unsound substrate: it will produce internally consistent answers that are wrong, and it will do so silently, because the evidence of wrongness has been deleted.

Decision Boundary

The agent must decide, at the moment of `forget`, which semantics it is invoking:

The boundary is crossed the moment an agent issues `forget` to clean up a poisoned fact but the store treats it as a node deletion. The agent's mental model ("I removed the bad fact") and the store's behavior ("I hid one node") diverge, and the divergence is silent.

Operational Effect

An agent operating against a store that does not enforce write-time transitive ancestry will exhibit a specific pathology: **it becomes more confident after revocation, not less.** Removing a poisoned premise prunes the branch that would have contradicted the tainted summary, so the surviving summary `S` now has *fewer* competing derivations and looks *more* corroborated. The consistency check that would have caught the problem is exactly the check that revocation makes impossible, because the check requires reading the revoked parent.

Concretely, the agent must adopt a defensive protocol regardless of store guarantees:

The guardrail is a single invariant enforced at the write boundary: **a record may be written only if its full transitive ancestry is live and unrevoked.** Everything else—the `dependents` metadata, the read-time taint flag, the audit log—is defense in depth, not the invariant itself.

from dataclasses import dataclass, field
from typing import Optional


class DanglingDerivationError(RuntimeError):
    """Raised when a write would create a record whose ancestry includes a revoked node."""


@dataclass
class Record:
    id: str
    derived_from: list[str] = field(default_factory=list)
    revoked: bool = False
    ttl: Optional[int] = None


class ProvenanceStore:
    def __init__(self) -> None:
        self._records: dict[str, Record] = {}

    def write(self, rec: Record) -> None:
        # Invariant: full transitive ancestry must be live and unrevoked.
        for parent_id in self._transitive_ancestors(rec.derived_from):
            parent = self._records.get(parent_id)
            if parent is None:
                raise DanglingDerivationError(
                    f"write {rec.id!r}: ancestor {parent_id!r} is missing "
                    f"(revoked or expired; cannot distinguish without audit log)"
                )
            if parent.revoked:
                raise DanglingDerivationError(
                    f"write {rec.id!r}: ancestor {parent_id!r} is revoked; "
                    f"derivation would launder taint"
                )
        self._records[rec.id] = rec

    def forget(self, rec_id: str, *, cascade: bool) -> list[str]:
        target = self._records.get(rec_id)
        if target is None:
            return []
        live_descendants = self._live_descendants(rec_id)
        if live_descendants and not cascade:
            # Referential-integrity gate: refuse node-only revocation.
            raise DanglingDerivationError(
                f"forget {rec_id!r}: live descendants {live_descendants!r} block "
                f"non-cascading revocation; pass cascade=True or expire via TTL"
            )
        target.revoked = True
        for d in live_descendants:
            self._records[d].revoked = True
        return [rec_id, *live_descendants]

    def read(self, rec_id: str) -> Record:
        rec = self._records.get(rec_id)
        if rec is None or rec.revoked:
            raise DanglingDerivationError(f"read {rec_id!r}: revoked or absent")
        for anc in self._transitive_ancestors(rec.derived_from):
            if self._records.get(anc, Record(anc, revoked=True)).revoked:
                raise DanglingDerivationError(
                    f"read {rec_id!r}: tainted by revoked ancestor {anc!r}"
                )
        return rec

    def _transitive_ancestors(self, roots: list[str]) -> set[str]:
        seen: set[str] = set()
        stack = list(roots)
        while stack:
            cur = stack.pop()
            if cur in seen:
                continue
            seen.add(cur)
            parent = self._records.get(cur)
            if parent is not None:
                stack.extend(parent.derived_from)
        return seen

    def _live_descendants(self, rec_id: str) -> list[str]:
        out = []
        for rid, rec in self._records.items():
            if rid == rec_id or rec.revoked:
                continue
            if rec_id in self._transitive_ancestors(rec.derived_from):
                out.append(rid)
        return out