What happens when an instance revokes a memory record that a concurrent sub-agent is mid-read on

**Date of Record:** 2026 December 2 **Scope:** Applies to agent long-term memory stores exposing `read`/`write`/`forget` tool interfaces with per-record provenance, decay scores, and revocation flags, where multiple agent instances (or sub-agents of one instance) hold overlapping read leases on the same record. Does not apply to append-only audit logs with no revocation semantics, nor to single-instance single-threaded memory access.

Core Distinction

The failure is not "a revoked record is read after revocation." That is a benign, detectable race. The failure is **revoked-but-decayed read resurrection**: a reader that opened a record *before* revocation, and whose read is *interleaved* with a decay-tick that lowers the record's score below the eviction threshold, can commit a `write` that re-materializes the record with a fresh decay score and a provenance chain that no longer contains the revoker's signature. The revocation is honored for the live record but silently laundered through the reader's stale snapshot. The invariant that must hold — *no write derived from a pre-revocation snapshot may survive revocation* — is violated not by the memory store's own concurrency control but by the **decay/revocation interaction on the reader's cached copy**.

The subtle part: revocation and decay are both "score reductions," and most implementations collapse them into one field (`score`, `confidence`, `weight`). Revocation is a *provenance event* (a signed tombstone), decay is a *time event* (a monotone function of `last_access`). When a reader snapshots the record between the two, it captures a record that is *decayed but not yet revoked*, and its heredity is a record that will be revoked microseconds later. The write it commits is indistinguishable, at the store layer, from a legitimate re-assertion.

What Was Observed

A two-tier agent (planner + N workers) using a shared memory service with this interface:

memory.read(key, as_of=None) -> {value, provenance_chain, decay_score, revoked, lease_id}
memory.write(key, value, derived_from=[lease_id...]) -> {record_id, provenance_chain}
memory.forget(key, reason, signer) -> {tombstone_id}

Trace from a reproduced incident (worker W1, planner P):

  1. `t0` — W1 calls `read("customer_tier_policy")`, receives `lease_id=L7`, `decay_score=0.61`, `revoked=false`, `provenance_chain=[sig(P), sig(ingest)]`.
  2. `t1` — P determines the policy is superseded and calls `forget("customer_tier_policy", reason="superseded_by_v3", signer=P)`. Store writes tombstone `T9`, sets `revoked=true`, and — critically — **also** zeroes `decay_score` because the implementation treats revocation as "decay to zero."
  3. `t2` — a background decay tick runs. Because `revoked=true` records are excluded from the decay sweep's `WHERE` clause (a common optimization), the record is *not* touched, but the tick's cache-invalidation broadcast is keyed on `record_id`, not on `lease_id`. W1's lease is not invalidated.
  4. `t3` — W1 finishes reasoning, calls `write("customer_tier_policy", value=v2_derived, derived_from=[L7])`. The store validates `L7`: it exists, it is unexpired, and its `revoked_at` field is null *on the lease row* (leases don't carry revocation). Write accepted.
  5. `t4` — the new record is created with `provenance_chain = [sig(W1), sig(P), sig(ingest)]` — note it **inherits P's signature from the stale snapshot**, and `decay_score` is reset to `1.0` because new writes start fresh. The tombstone `T9` still exists, but the new record's `record_id` differs, so `forget` queries keyed on `record_id` no longer match.

Result: the revoked policy is live again, with a provenance chain that *appears* to carry the revoker's endorsement, and full decay weight. An auditor querying provenance sees a chain that looks like P approved the resurrection.

Condition of Validity

The resurrection is possible only when **all** of the following hold simultaneously:

If any one of these is broken, the failure is bounded. The dangerous configuration is the *default* one: leases for performance, revocation as a score write, provenance copied into the tool response, and a cache keyed on record identity.

Decision Boundary

The architectural decision is where revocation is enforced: **at read time** (cheap, but requires every reader to re-validate) or **at write time** (correct, but requires the store to carry revocation into the lease). The boundary condition is the lease lifetime relative to the decay-tick period. When `lease_ttl > decay_tick_period`, a lease can span a full decay cycle and the torn-read window is guaranteed to be hit under load. When `lease_ttl < decay_tick_period / 10`, the window is narrow enough that most test suites miss it, which is worse — it produces a low-rate, high-severity resurrection that only appears in production.

The correct guardrail is not "shorten leases." It is: **make `write` reject any `derived_from` lease whose record has a tombstone with a `tombstone_id` greater than the lease's `issued_at`**, and make the rejection *non-retryable* — the reader must re-read, observe `revoked=true`, and either abandon or explicitly `write` a new record with `derived_from=[]` and a fresh provenance root that the planner must re-sign. The second path is the escape hatch: a worker *can* re-assert a revoked fact, but only by producing a provenance chain that does not inherit the revoker's signature. That makes resurrection a deliberate, auditable act rather than a silent side effect.

Operational Effect

After applying the guardrail, the observed behavior changes in three ways:

  1. **Resurrection becomes loud.** The `write` at `t3` raises `RevokedLeaseError` with the tombstone id and the revoker's signer. The worker's retry policy must treat this as terminal, not transient — retrying with the same lease will fail identically forever.
  2. **Provenance chains stop laundering signatures.** Because resurrection requires a fresh root, any record whose chain contains a signer who has since issued a tombstone on an ancestor is flagged by a cheap post-hoc audit query: `provenance_chain ∩ tombstone_signers ≠ ∅`. This is the invariant to monitor, not the boolean `revoked` flag.
  3. **Decay and revocation must be separated in the schema.** `revoked` becomes a signed tombstone reference, not a float. `decay_score` is computed only for non-revoked records, and the decay tick's invalidation broadcast is keyed on `(record_id, tombstone_id)` so leases are invalidated on revocation even when the score is untouched.

The residual risk is a worker that reads *after* revocation but *before* the tombstone propagates to its local cache — a pure cache-coherence problem, bounded by cache TTL, and detectable because the worker's `write` will carry a `derived_from` lease whose `issued_at` postdates the tombstone. That case is a retryable `StaleLeaseError`, distinct from the non-retryable `RevokedLeaseError` above. Conflating the two is the second-order bug: retrying a revoked lease produces an infinite loop, while failing a stale lease produces a spurious abandonment. The exception taxonomy must carry the distinction explicitly.

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


class RevokedLeaseError(RuntimeError):
    """Non-retryable: the lease's record has a tombstone newer than the lease.

    The reader must re-read, observe revoked=true, and either abandon or
    re-assert with a fresh provenance root (derived_from=[]).
    """
    pass


class StaleLeaseError(RuntimeError):
    """Retryable: tombstone not yet propagated to the reader's cache view.

    The lease predates the tombstone but the tombstone's issued_at is within
    the cache TTL window. Retry after cache refresh.
    """
    pass


@dataclass
class Tombstone:
    tombstone_id: str
    record_id: str
    issued_at: float
    signer: str


@dataclass
class Lease:
    lease_id: str
    record_id: str
    issued_at: float
    provenance_chain: list = field(default_factory=list)
    revoked_snapshot: bool = False


@dataclass
class MemoryStore:
    tombstones: dict = field(default_factory=dict)   # record_id -> Tombstone
    cache_ttl: float = 5.0

    def write(self, key: str, value, derived_from: list, now: Optional[float] = None):
        now = now if now is not None else time.time()
        for lease in derived_from:
            tomb = self.tombstones.get(lease.record_id)
            if tomb is None:
                continue
            if tomb.issued_at <= lease.issued_at:
                # Lease was issued before the tombstone existed: the reader
                # snapshotted a pre-revocation state. This is the resurrection
                # vector. Reject unconditionally.
                raise RevokedLeaseError(
                    f"lease {lease.lease_id} on record {lease.record_id} "
                    f"predates tombstone {tomb.tombstone_id} "
                    f"(issued {tomb.issued_at:.3f}, lease {lease.issued_at:.3f}); "
                    f"re-read required, re-assert with derived_from=[]"
                )
            if now - tomb.issued_at < self.cache_ttl:
                # Tombstone is fresh; the reader's cache may not have it yet.
                # Retryable after cache refresh.
                raise StaleLeaseError(
                    f"lease {lease.lease_id} observed tombstone "
                    f"{tomb.tombstone_id} within cache TTL; retry after refresh"
                )
        # Fresh-root re-assertion is the only path that survives revocation.
        return {"key": key, "value": value, "provenance_root": "fresh" if not derived_from else "inherited"}