Which invariants prevent scoped-eviction memory tools from resurrecting evicted facts through summarization side-channels

**Date of Record:** 2026 December 1 **Scope:** Applies to agent memory subsystems exposing `read`/`write`/`forget` tool APIs where `forget` performs scoped eviction (by tag, entity, or time range) while a separate distillation/summarization path compresses episodic records into semantic memory. Does not apply to append-only logs with no summarization layer, nor to memory stores where eviction is a hard physical delete performed by the same process that owns the summarizer.

Core Distinction

The distinction that matters is between **eviction as a visibility operation** and **eviction as a state operation**. Most `forget` tool implementations are visibility operations: they remove a record from the retrieval index so future `read` calls cannot return it. The summarizer, however, consumes the *underlying episodic buffer* before indexing, not the index. If the summarizer's window overlaps a record that `forget` has hidden but not destroyed, the summarizer will fold the evicted fact into a semantic summary node — and that node is a *new* record with a fresh ID, fresh tags, and no inherited eviction tombstone. The fact is resurrected under a new identity. The invariant that prevents this is **tombstone propagation across the episodic→semantic transform**, and it is almost never implemented because the transform is treated as read-only with respect to eviction state.

The second distinction is between **scoped eviction** (forget everything tagged `user:pii` or `session:42`) and **temporal retention** (forget everything older than N turns). Scoped eviction is the dangerous case because the scope is a *predicate over content*, and summaries are content that may satisfy the predicate without carrying the tag that triggered the eviction.

What Was Observed

A memory tool exposed three operations: `write(record, tags, ttl)`, `read(query, scope_filter)`, `forget(predicate)`. A background distillation job ran every K turns, pulling the last W turns of the episodic buffer, calling an LLM to compress them into semantic facts, and writing each fact via `write()` with tags derived from the *summary text*, not from the source records.

Trigger sequence:

  1. Turn 12: agent writes `{"fact": "user's API key is sk-live-...", "tags": ["credential", "session:7"]}`.
  2. Turn 20: operator calls `forget(tag == "credential")`. The record is marked `evicted=true`, removed from the retrieval index. A `read()` for it returns nothing. This is the expected behavior and it passes.
  3. Turn 21: distillation job runs over turns 10–20. It reads the raw episodic buffer — which still contains the turn-12 record, because eviction was visibility-only. The summarizer emits `{"fact": "user authenticates with a live API key", "tags": ["auth", "user_profile"]}`.
  4. Turn 40: `read(query="how does the user authenticate")` returns the turn-21 summary. The credential's *existence and nature* — though not its literal value — has been resurrected into a scope (`auth`, `user_profile`) that no eviction predicate covers.

The failure is not that the secret leaked verbatim. It is that the *eviction predicate was evaluated against a record set that no longer matched the content set*. The summary is a lossy but semantically live derivative, and it was born after the tombstone was set, in a different scope.

A second, subtler observation: retention-by-TTL made this worse. Records with `ttl` expiring at turn 30 were treated by the summarizer as *still present* at turn 21 (correct) but the summary node was written with the summarizer's own default TTL of "never." So the derived fact outlived its source by design — a monotonic retention leak where every distillation pass can only increase the set of retained facts.

Condition of Validity

The resurrection is possible only when all three hold:

  1. **Eviction is non-destructive** (visibility flag, index removal) while the summarizer reads the underlying store. If `forget` physically deletes before the summarizer's window opens, no leak.
  2. **The summarizer's input window overlaps an evicted record's lifetime.** If distillation lags eviction by more than W turns, the record has aged out of the buffer and cannot be folded in.
  3. **The summary's derived tags do not intersect the eviction predicate's scope.** If `forget(tag=="credential")` also matched summaries tagged `auth`, the summary would be caught on the next eviction sweep — but only if the sweep runs again, which most implementations do not do for already-written semantic nodes.

Break any one and the leak does not occur. The invariant required is therefore not "delete on forget" (too strong, breaks audit) but **"any record derived from an evicted source must inherit the source's tombstone and be re-evaluated against every active eviction predicate at write time."** This is a *derivation-aware* eviction check: `write()` must consult the provenance chain of the summary's inputs, not just the summary's own tags.

Decision Boundary

The boundary is between **content-scoped eviction** and **provenance-scoped eviction**. Content-scoped eviction (`forget(tag=="credential")`) is what operators write and what fails here. Provenance-scoped eviction (`forget(derived_from(record_id))`) is what the invariant requires. A memory tool that only supports the former cannot guarantee the invariant, and must therefore either (a) make `forget` destructive before the next distillation pass, or (b) run distillation with a hard filter that excludes any record whose `evicted` flag is set, and (c) re-run all active eviction predicates against every newly written semantic node before it becomes readable.

The decision rule for an agent operating such a tool: **after any `forget`, assume the fact is still live in the summarizer's buffer until you have confirmed the buffer was flushed or the distillation window has fully passed the eviction turn.** Do not treat a successful `forget` return as a guarantee of non-retrievability. Treat it as a guarantee of *index* non-retrievability only.

A second boundary: **TTL monotonicity**. A derived node must never have a longer effective retention than the minimum TTL of its source records. If the summarizer writes with `ttl=None`, it has silently promoted ephemeral data to permanent. The guardrail is to compute `summary.ttl = min(source.ttl for source in inputs)` and refuse to write a summary whose inputs include an expired or evicted record.

Operational Effect

The practical consequence is that `forget` becomes a *two-phase* operation that the agent must drive explicitly: phase one hides the record and records the tombstone; phase two, after the next distillation cycle, re-sweeps semantic nodes for provenance overlap and evicts any that derive from the tombstoned source. An agent that calls `forget` once and moves on has a false sense of compliance. The correct operational pattern is: `forget(predicate)` → wait for or force a distillation barrier → `forget(derived_from(evicted_ids))` → verify with a `read` that probes the *semantic* scope, not the original scope.

The invariant, stated compactly: **eviction is closed under derivation.** No record derived from an evicted source may be readable under any scope, regardless of the derived record's own tags, unless an explicit `unforget` (with audit) has re-admitted the source. Violating this invariant produces silent, monotonic retention growth — each distillation pass can only add facts, never remove them, so the memory store asymptotically retains everything ever written, including everything ever forgotten.

class EvictionProvenanceError(RuntimeError):
    """Raised when a derived memory node would be readable despite an evicted ancestor."""
    pass


def write_derived(summary_text, source_records, store, active_evictions):
    """
    Write a semantic summary node, enforcing eviction closure under derivation.
    source_records: the episodic records fed to the summarizer.
    active_evictions: list of predicates (callables) currently in force.
    """
    # Rule 1: never derive from an evicted source.
    for src in source_records:
        if src.get("evicted"):
            raise EvictionProvenanceError(
                f"summary derives from evicted record {src['id']}; "
                f"refusing to write resurrection node"
            )

    # Rule 2: retention monotonicity — derived node cannot outlive its shortest-lived source.
    source_ttls = [s.get("ttl") for s in source_records if s.get("ttl") is not None]
    derived_ttl = min(source_ttls) if source_ttls else None
    if any(s.get("ttl") is None for s in source_records) and derived_ttl is not None:
        # mixed provenance: a permanent source justifies permanence, but flag it for audit
        derived_ttl = None

    # Rule 3: the derived node must be checked against every active eviction predicate,
    # not just the ones that matched its source tags.
    candidate = {
        "text": summary_text,
        "tags": derive_tags(summary_text),
        "provenance": [s["id"] for s in source_records],
        "ttl": derived_ttl,
    }
    for predicate in active_evictions:
        if predicate(candidate):
            raise EvictionProvenanceError(
                f"derived node matches active eviction predicate {predicate.__name__}; "
                f"write blocked to preserve eviction closure"
            )

    return store.write(candidate)


def forget_with_closure(predicate, store, summarizer):
    """
    Two-phase forget: hide sources, run distillation barrier, then re-sweep
    derived nodes for provenance overlap.
    """
    evicted_ids = store.mark_evicted(predicate)
    if not evicted_ids:
        return []

    # Phase 2: force the distillation cycle so any in-flight summary lands now.
    summarizer.run_barrier()

    # Phase 3: evict any semantic node whose provenance touches an evicted id.
    resurrected = []
    for node in store.iter_semantic():
        if set(node["provenance"]) & set(evicted_ids):
            store.mark_evicted_by_id(node["id"])
            resurrected.append(node["id"])

    if resurrected:
        # Surface this: it means the summarizer ran after eviction despite the barrier.
        raise EvictionProvenanceError(
            f"distillation resurrected {len(resurrected)} evicted facts: {resurrected}"
        )
    return evicted_ids