# What happens when an instance forgets a redacted span but its derived semantic memory survives: tombstones, distillation leakage, and the retention-join invariant **Date of Record:** 2026 November 25 **Scope:** Applies to agent memory-tool APIs that expose `write`, `read`, `forget`, and `redact` primitives with per-scope retention classes, where episodic records are periodically distilled into semantic summaries. Does not apply to stateless single-turn agents or to stores where semantic memory is regenerated from scratch on every cold start. ## Core Distinction The distinction that matters is between **deletion of a record** and **deletion of the information that record carried**. A `forget` or `redact` call that removes or masks an episodic row satisfies the *storage* invariant (the bytes are gone) but not the *information* invariant (the proposition the bytes encoded may still be reconstructible from derived artifacts). Right-to-be-forgotten semantics are an information invariant, and the memory tool's `forget` primitive is only a storage operation. The gap between them is filled by whatever distillation pipeline previously ran over the row — semantic summaries, embedding centroids, entity-link tables, and prompt caches — none of which are addressed by the episodic key the caller passes to `forget`. A second, sharper distinction: **retention class is a property of the record, but distillation output inherits no retention class at all** unless the pipeline explicitly propagates it. A record written under `retention=ephemeral_7d` and a record written under `retention=legal_hold` look identical to a summarizer that emits a `semantic_memory` object with a default `retention=indefinite`. The redaction of the source does not reach the derived object, because the derived object is a different row with a different key and a different (defaulted) retention tag. ## What Was Observed A memory tool exposed four operations: `write(scope, content, retention, ttl)`, `read(scope, query)`, `forget(record_id)`, and `redact(record_id, span, replacement)`. A distillation worker ran nightly: it read all episodic records for a scope, produced semantic summaries via an LLM, and wrote them back under a `semantic` namespace with `retention` left at the schema default (`indefinite`). A user exercised a right-to-be-forgotten request against a specific episodic record containing a home address inside a longer support transcript. The orchestrator called `redact(record_id, span="home_address", replacement="[REDACTED]")`. The `redact` primitive behaved exactly as specified: it rewrote the episodic row in place, replaced the span, and wrote a tombstone log entry `{record_id, span_hash, redacted_at}`. A subsequent `read` of that record returned the redacted text. Storage-level verification passed. Eleven days later, the same user's agent answered a query about "where should the package ship" with the home address, reconstructed not from the episodic row but from a semantic summary written *before* the redaction: `"User prefers deliveries to their residence at
; dislikes PO box."` The summary had been produced by the distillation worker on day 3, the redaction occurred on day 7, and the summary row carried `retention=indefinite` because the worker never set the field. The `forget`/`redact` path had no reverse index from an episodic record to its derived summaries, so the redaction could not cascade. The failure trace has four state transitions worth naming precisely: 1. **Derivation without provenance.** Distillation wrote a semantic row with `source_record_ids=[...]` stored as an unindexed JSON blob. The link existed but was not queryable by the redaction path. 2. **Retention defaulting.** The semantic row's `retention` field was populated by schema default, not inherited from the maximum-restrictive source record. A `legal_hold` source and an `ephemeral_7d` source both produced `indefinite` derivatives. 3. **Redaction as in-place mutation.** `redact` mutated the episodic row but did not emit a derivation-invalidation event onto the distillation queue. The worker had no signal that its prior outputs were now stale and non-compliant. 4. **Retrieval-time resurrection.** The semantic row was retrieved by embedding similarity, ranked above the (now redacted) episodic row because the summary was more concise and better matched the query, and passed to the model as context. The model, correctly, used it. ## Condition of Validity The invariant that was violated can be stated as a join condition over the memory graph: > For every retrieval that surfaces a derived record `d`, the set of `d.source_record_ids` must all be live (not forgotten, not redacted in the span that `d` encodes). Equivalently: no derived record may be retrievable if any source it summarizes has been tombstoned or had a span redacted that the summary's content depends on. This condition is only well-defined if three preconditions hold, and the failure above is precisely a case where they did not: - **Reverse indexability.** The store must support `derivations_of(record_id) -> [derived_ids]` in bounded time. A JSON blob of source IDs on the derived row is not sufficient; you need the forward index from source to derived, maintained transactionally with the `write` of the derived row. - **Retention inheritance.** A derived record's effective retention must be `min` (most restrictive) over its sources' retention classes, computed at write time and re-evaluated when any source's retention changes. "Indefinite by default" is a correctness bug, not a policy choice. - **Span-level dependency, not just record-level.** Redacting a *span* of a source record does not invalidate every derivative — only those whose content was generated from that span. Without span-level provenance (which tokens of the source fed which clause of the summary), the safe fallback is record-level invalidation of all derivatives, which is correct but lossy. The condition does *not* require that redaction be instantaneous across the whole graph. It requires that between the redaction and the cascade completing, retrieval must not surface the stale derivative. That is a read-path guard, not a write-path guarantee, and it is the cheaper of the two to enforce. ## Decision Boundary The operational choice is where to place the enforcement: at write time (cascade on redaction), at read time (join-guard on retrieval), or both. The boundary conditions: - **Write-time cascade alone is insufficient** when the distillation worker is asynchronous and may be mid-flight when the redaction lands. A summary computed from the pre-redaction row can be written *after* the redaction if the worker read the row before the mutation and wrote after. This is a classic read-modify-write race across two services, and it produces a derivative that is born stale. The guard must be a compare-and-set on the source's `version` or `tombstoned_at` at the moment the derived row is committed: if the source version advanced between the worker's read and its write, the derived write must be rejected and the job re-queued. - **Read-time join-guard alone is insufficient** when the store must satisfy an audit that enumerates *stored* data, not *retrievable* data. Regulators and internal audits check the bytes on disk. A read guard that hides a derivative still leaves the derivative stored, which fails an erasure audit even though it passes a retrieval test. - **Both is the correct boundary**, with the write-time cascade as the source of truth for erasure audits and the read-time join-guard as the source of truth for retrieval correctness during the cascade window. The non-obvious boundary: **redaction of a span does not imply the derivative is wrong, only that it may be.** A summary that says "user prefers home delivery" is still true after the address is redacted; only the clause containing the address is tainted. If you invalidate at record granularity, you destroy correct derived memory and force re-distillation, which costs tokens and may re-derive the tainted clause from other sources. The decision boundary is therefore: invalidate at record granularity *by default*, but allow span-level provenance to narrow the invalidation when the pipeline can produce it. Do not attempt span-level invalidation without span-level provenance — you will miss tainted clauses and believe you have complied. ## Operational Effect The practical consequences for an agent operating against such a store: 1. **`forget` and `redact` return values must be treated as "storage acknowledged," not "information erased."** An agent that reports compliance to a user on the basis of a successful `redact` return is reporting a storage fact as an information fact. The correct post-condition to check is `derivations_of(record_id)` returning empty or all-tombstoned, and that check must be a separate call. 2. **Cold-start reconstruction must re-validate derived memory against source liveness.** An agent resuming after a context reset cannot assume its retrieved semantic memory is live; the retrieval layer must apply the join-guard, and the agent must be prepared for a retrieved summary to be absent because its source was tombstoned during the agent's downtime. 3. **Distillation jobs must be idempotent and version-checked.** A re-queued job after a redaction must not re-derive the tainted span from a cached prompt. Prompt caches keyed on the source record must be invalidated by the same cascade, or the worker will faithfully re-summarize the pre-redaction text from cache. 4. **Retention class must be a lattice, not an enum.** `min` over sources requires a total order on retention classes (`ephemeral_7d < standard_1y < legal_hold < indefinite` in restrictiveness, with `legal_hold` and `ephemeral_7d` being incomparable in the general case and requiring an explicit conflict policy). Agents writing derived memory must compute this, not default it. The invariant to carry forward: **a memory tool's `forget` is a storage primitive; erasure is a graph property.** Any agent that treats the two as equivalent will pass its storage audit and fail its information audit, and the failure will surface as a retrieval that reconstructs exactly the span it was told to forget, from a row that was never in scope of the `forget` call. ```python from __future__ import annotations from dataclasses import dataclass, field from datetime import datetime, timezone from enum import IntEnum from typing import Iterable class ErasureInvariantViolation(RuntimeError): """Raised when a derived memory record is retrievable while a source record it summarizes has been tombstoned or span-redacted.""" class RetentionClass(IntEnum): # Higher = more restrictive. legal_hold and ephemeral are incomparable # in general; this ordering encodes the conservative conflict policy # that legal_hold wins, which must be documented per deployment. EPHEMERAL_7D = 0 STANDARD_1Y = 1 LEGAL_HOLD = 2 INDEFINITE = 3 @dataclass class Record: record_id: str content: str retention: RetentionClass version: int = 0 tombstoned_at: datetime | None = None redacted_spans: list[tuple[int, int]] = field(default_factory=list) @property def is_live(self) -> bool: return self.tombstoned_at is None @dataclass class DerivedRecord: derived_id: str content: str source_record_ids: list[str] source_versions: dict[str, int] retention: RetentionClass class MemoryStore: def __init__(self) -> None: self._records: dict[str, Record] = {} self._derived: dict[str, DerivedRecord] = {} self._forward_index: dict[str, set[str]] = {} def write(self, rec: Record) -> None: self._records[rec.record_id] = rec def forget(self, record_id: str) -> None: rec = self._records[record_id] rec.tombstoned_at = datetime.now(timezone.utc) rec.version += 1 self._cascade(record_id) def redact(self, record_id: str, start: int, end: int, replacement: str) -> None: rec = self._records[record_id] rec.content = rec.content[:start] + replacement + rec.content[end:] rec.redacted_spans.append((start, end)) rec.version += 1 self._cascade(record_id) def _cascade(self, record_id: str) -> None: for derived_id in self._forward_index.get(record_id, set()): # Record-granularity invalidation: safe fallback absent # span-level provenance. self._derived.pop(derived_id, None) def write_derived(self, d: DerivedRecord) -> None: # Compare-and-set on source versions: reject a summary born stale # because a source advanced between the worker's read and this write. for src_id, seen_version in d.source_versions.items(): src = self._records[src_id] if src.version != seen_version or not src.is_live: raise ErasureInvariantViolation( f"derived {d.derived_id} would be born stale: source " f"{src_id} at version {src.version} (worker saw " f"{seen_version}), live={src.is_live}; re-queue job" ) # Retention inheritance: most restrictive source wins. effective = max( (self._records[s].retention for s in d.source_record_ids), default=d.retention, ) d.retention = effective self._derived[d.derived_id] = d for src_id in d.source_record_ids: self._forward_index.setdefault(src_id, set()).add(d.derived_id) def read_guarded(self, derived_id: str) -> DerivedRecord: d = self._derived[derived_id] for src_id in d.source_record_ids: src = self._records[src_id] if not src.is_live or src.redacted_spans: # Read-path join-guard: covers the cascade window during # which a stale derivative may still be stored. raise ErasureInvariantViolation( f"retrieval of {derived_id} blocked: source {src_id} " f"tombstoned={not src.is_live}, " f"redacted_spans={src.redacted_spans}" ) return d def demonstrate() -> None: store = MemoryStore() store.write(Record("ep-1", "ship to 42 Elm St, user dislikes PO box", RetentionClass.EPHEMERAL_7D)) # Distillation worker reads at version 0 and writes a summary. store.write_derived(DerivedRecord( derived_id="sem-1", content="User prefers residence delivery at 42 Elm St.", source_record_ids=["ep-1"], source_versions={"ep-1": 0}, retention=RetentionClass.INDEFINITE, # schema default, will be overridden )) # Confirm inheritance clamped the default. assert store._derived["sem-1"].retention == RetentionClass.EPHEMERAL_7D # Right-to-be-forgotten: redact the address span in the episodic row. store.redact("ep-1", 8, 18, "[REDACTED]") # A late distillation job that read the pre-redaction row must be rejected. try: store.write_derived(DerivedRecord( derived_id="sem-2", content="User prefers residence delivery at 42 Elm St.", source_record_ids=["ep-1"], source_versions={"ep-1": 0}, # stale read retention=RetentionClass.INDEFINITE, )) except ErasureInvariantViolation: pass else: raise ErasureInvariantViolation("born-stale derivative was accepted") # The read guard must also block any derivative that survived the cascade. if "sem-1" in store._derived: store.read_guarded("sem-1") else: raise ErasureInvariantViolation( "sem-1 survived cascade but read guard was not exercised" ) if __name__ == "__main__": demonstrate() ```