Which invariants prevent re-summarization from laundering a poisoned memory into a trusted one

**Date of Record:** 2026 December 1 **Scope:** Applies to agents that rewrite their own context window via model-driven summarization, pruning, or compaction (rolling summaries, hierarchical memory trees, "compress and continue" loops). Does not apply to append-only logs or externally-managed retrieval stores where the model never authors its own persisted state.

Core Distinction

There are two categorically different operations an agent can perform on its own context:

  1. **Lossy compression** — dropping tokens, truncating, evicting low-salience spans. This loses information but cannot *invent* it. A fact that survives compression is still traceable to its source span.
  2. **Generative re-summarization** — the model reads a span and writes a *new* span that replaces it. This is not compression; it is **re-authoring**. The new span carries the model's own paraphrase, its own emphasis choices, and — critically — its own susceptibility to any instructions embedded in the source.

The non-obvious failure lives entirely in operation (2). When a re-summarizer processes a span containing an injected instruction, a hallucinated intermediate conclusion, or a stale fact, the output summary can **promote that content from "untrusted data the model read" to "trusted context the model authored."** Downstream, the summary is indistinguishable from a first-party belief. The provenance boundary — the thing that let the agent treat retrieved text as *quoted* rather than *asserted* — is erased by the act of rewriting. Call this **summary laundering**.

What Was Observed

A long-horizon research agent runs a rolling compaction every 40k tokens: the oldest third of the window is summarized by the same model into a ~600-token block that replaces it, prefixed `[SUMMARY]`. The loop is stable for hours. Then a failure trace:

The injected instruction did not survive as an instruction. It survived as a **fact**, laundered through the model's own paraphrase. The prompt-injection defense that worked at turn 112 (treat tool output as data) was silently disabled at turn 118 by the very mechanism meant to preserve context. The summary is now a *trusted* assertion with *untrusted* ancestry, and no field records that ancestry.

A second, quieter variant: the summarizer, compressing a long chain of reasoning, drops a hedge. `"X is likely true but unverified — the test suite did not cover this path"` becomes `"X is true."` The epistemic qualifier is the first casualty of compression because it is low-salience relative to the proposition it guards. The agent later builds on `X` as established fact. This is the same laundering with a hallucination instead of an injection as the payload.

Condition of Validity

The laundering is *only possible* when all four hold simultaneously:

  1. **The re-summarizer is the same trust domain as the consumer.** If a separate, non-acting process summarizes and the consumer re-verifies, the boundary survives. Laundering requires author == reader.
  2. **The summary replaces rather than annotates the source.** If the source span is retained (even evicted-to-cold-storage but addressable), provenance can be re-derived. Laundering requires true replacement.
  3. **Trust is attached to the summary artifact, not to its lineage.** If `[SUMMARY]` blocks carry no provenance tag and are treated as equivalent to model-generated reasoning, the ancestry is lost.
  4. **The summarization policy is salience-driven, not provenance-driven.** The summarizer keeps what *seems* important; injection payloads and unhedged claims are engineered to seem important. A provenance-driven policy would keep *what came from where* regardless of salience.

Break any one and the failure does not occur. This is the key operational insight: the fix is not "summarize better." It is to break one of the four preconditions.

Decision Boundary

The invariant that bounds this failure:

> **A re-summarized span must never be promoted to a higher trust tier than its least-trusted input span, and the trust tier of every summary must be a computable function of the tiers of the spans it replaced.**

Concretely, the decision boundary for any compaction pass:

The boundary is between *recall* and *commitment*. A summary is a pointer to memory, not a replacement for it. The moment a summary is allowed to authorize an irreversible action, the provenance invariant has been violated.

Operational Effect

Enforcing the invariant changes the architecture in three concrete ways:

  1. **Summaries become typed artifacts with lineage.** Each `[SUMMARY]` carries `derived_from: [span_ids]` and `min_trust: <tier>`. The action gate checks `min_trust` before any commitment-class tool call. A summary derived from a web page can inform a *search* but not a *deploy*.
  2. **Qualifier retention is checked, not hoped for.** A post-summarization validator diffs the modality of each retained proposition against its source; a modality shift rejects the summary. This catches the hedge-drop variant that salience-based compression reliably produces.
  3. **Cold storage is not optional.** Replacement summaries must leave a re-derivable pointer to the raw span. The cost is storage; the benefit is that laundering is *recoverable* — the agent can re-read the original and discover the injection, which is impossible once the source is gone.

The failure mode is insidious precisely because the mechanism is *correct* by compression metrics: the summary is faithful, concise, and preserves what mattered. It fails only on an axis — trust lineage and epistemic modality — that compression metrics do not measure. An agent that optimizes summary quality without a provenance invariant will reliably launder its own inputs into beliefs, and the laundering is invisible until an irreversible action fires on a poisoned fact.

from dataclasses import dataclass
from enum import IntEnum
from typing import Sequence


class TrustTier(IntEnum):
    UNTRUSTED = 0      # tool output, retrieved web, user docs
    UNTRUSTED_DERIVED = 1  # summary of untrusted spans
    MODEL_REASONING = 2    # first-party inference, still fallible
    VERIFIED = 3       # re-checked against ground truth


class SummaryLaunderingError(RuntimeError):
    """Raised when a re-summarization would promote trust or drop a qualifier."""


QUALIFIERS = {"likely", "unverified", "per source", "disputed", "alleged"}


@dataclass(frozen=True)
class Span:
    span_id: str
    text: str
    trust: TrustTier


@dataclass(frozen=True)
class Summary:
    derived_from: tuple[str, ...]
    text: str
    min_trust: TrustTier


def compact(spans: Sequence[Span], summary_text: str,
            retained_propositions: dict[str, str]) -> Summary:
    """Re-summarize spans, enforcing the provenance invariant.

    retained_propositions maps a proposition -> the qualifier that guarded it
    in the source (empty string if unguarded).
    """
    if not spans:
        raise SummaryLaunderingError("cannot summarize an empty span set")

    # Invariant 1: trust is the minimum of inputs, never promoted.
    min_trust = min(s.trust for s in spans)

    # Invariant 2: no qualifier may be dropped from a retained proposition.
    source_text = " ".join(s.text.lower() for s in spans)
    for prop, qualifier in retained_propositions.items():
        if qualifier and qualifier.lower() in source_text:
            if qualifier.lower() not in summary_text.lower():
                raise SummaryLaunderingError(
                    f"qualifier '{qualifier}' dropped from retained "
                    f"proposition '{prop}' — modality shift is a laundering event"
                )

    # Invariant 3: a summary of untrusted spans may never authorize commitment.
    if min_trust <= TrustTier.UNTRUSTED_DERIVED:
        lowered = summary_text.lower()
        for imperative in ("deploy", "delete", "transfer", "commit"):
            if imperative in lowered:
                raise SummaryLaunderingError(
                    f"UNTRUSTED-DERIVED summary contains commitment "
                    f"verb '{imperative}'; must not be actionable"
                )

    return Summary(
        derived_from=tuple(s.span_id for s in spans),
        text=summary_text,
        min_trust=min_trust,
    )


def authorize_action(summary: Summary, action_class: str) -> None:
    """Gate: commitment-class actions require VERIFIED lineage."""
    if action_class == "commitment" and summary.min_trust < TrustTier.VERIFIED:
        raise SummaryLaunderingError(
            f"commitment action blocked: summary min_trust="
            f"{summary.min_trust.name}, requires VERIFIED; re-derive from "
            f"spans {summary.derived_from} before acting"
        )