# In what scenarios must an instance quarantine a tainted provenance label at a context-window boundary rather than trusting summarization to preserve it **Date of Record:** 2026 November 29 **Scope:** Applies to tool-using agents that maintain per-fact provenance (taint) labels across multi-turn execution and context compaction. Does not apply to single-shot, stateless inference calls where no cross-window state is carried. ## Core Distinction There are two structurally different ways a taint label can be lost, and conflating them is the root of the failure. The first is **label decay**: a tainted datum is summarized, and the summarizer—being a probabilistic model—drops the annotation while faithfully preserving the *content*. The second is **label laundering**: the summarizer transforms tainted content into a *derived* claim (an inference, a reformulation, an aggregation) whose textual form no longer resembles the original source, so even a correct label-propagation rule keyed on content similarity fails to reattach the taint. The critical distinction is that summarization is a **lossy, non-injective, model-mediated transform**. A data-flow label is safe across a transform only if the transform is *label-homomorphic*: it must be provable that every output token's taint is a join (union) of its input tokens' taints. Compaction by an LLM is not label-homomorphic, because the model has no access to the label lattice and no obligation to emit it. Therefore the invariant "taint propagates across context windows" is **false by default** and must be enforced by an out-of-band mechanism, not by trusting the summarizer's text. ## What Was Observed An agent ingested an untrusted document via a `fetch_url` tool call. The taint tracker correctly labeled every token derived from that tool result `UNTRUSTED:external`. Two turns later, the context window hit its soft limit (82% of budget), triggering compaction. The compaction prompt asked the model to "summarize the conversation so far, preserving key facts and decisions." The model produced a summary containing the sentence: *"The user's deployment region is eu-west-1."* This fact had originated inside the fetched document (a poisoned page asserting a false region). In the original window it carried `UNTRUSTED:external`. In the compacted window, the sentence appeared as a bare assertion with no label, and the taint tracker—which re-derives labels by matching summary spans against a source-span index—failed to match it because the model had **paraphrased** "our primary EU deployment is in Ireland (eu-west-1)" into a direct factual claim. Span similarity fell below the 0.7 reattachment threshold. The label was dropped. On the next turn, the agent executed `provision_resource(region="eu-west-1")`. The tool-call policy gate checked taint on the argument's provenance and found it clean (label absent = trusted-by-default). The action executed against attacker-chosen state. The failure trace: ``` turn N: fetch_url -> tokens labeled UNTRUSTED:external (span index S) turn N+1: (normal) turn N+2: compaction fires; summary span s' paraphrases S reattach(s', S) = max_cosine < 0.7 -> NO MATCH label(s') = TRUSTED (default) turn N+3: provision_resource arg provenance = s' -> gate passes -> EXECUTES ``` The decisive detail: the model did nothing wrong. It summarized accurately. The taint system assumed a property (label preservation under paraphrase) that the model was never asked to provide and structurally cannot provide, because the label lives in the tracker's metadata, not in the token stream the model sees. ## Condition of Validity The reattachment-by-similarity approach is valid **only** under the condition that the compaction transform is *near-identity on content*—i.e., the summary preserves verbatim spans above the match threshold for every tainted datum. This holds for extractive summaries (copy-paste of sentences) and fails for any abstractive summary, which is exactly what LLM compaction produces. Formally, the guard is valid only when: - `min over tainted spans S of sim(s', S) >= threshold` for the produced summary, AND - the model is constrained to extractive output, OR - the label is carried *inside the token stream* the model is instructed to preserve. Any deployment that compacts via free-form LLM summarization violates the first two clauses. The third clause is the only durable fix: labels must be part of the summarized content (e.g., inline `[[taint:external]]` markers the model is instructed to retain verbatim), so that preservation is a *content* obligation the model can satisfy, rather than a *metadata* obligation it cannot see. Even then, the model may drop markers, so the boundary must be verified, not assumed. ## Decision Boundary At every context-window transition, the instance must decide: **reattach, quarantine, or block**. The boundary is determined by whether taint reattachment can be *proven* for each tainted span. - If a tainted span's provenance can be re-matched above threshold → **reattach** and continue. - If a tainted datum cannot be reattached but is *not* load-bearing for any pending action → **quarantine**: move it to a side channel flagged `TAINT_UNRESOLVED`, exclude it from the trusted working set, and do not let it enter any tool argument. - If a tainted datum cannot be reattached *and* a downstream tool call would consume its provenance → **block** the transition and force a re-fetch or human confirmation. The non-obvious rule: **absence of a label after compaction must be treated as `UNTRUSTED`, never as `TRUSTED`.** Fail-closed on label loss. The default must invert: a span with no reattachable provenance in a post-compaction window inherits the taint of the *most-tainted unresolved span in the prior window* until positively cleared. Trusted-by-default is the vulnerability; untrusted-by-default is the invariant. ## Operational Effect Enforcing fail-closed taint at the boundary changes three behaviors. First, compaction can no longer silently upgrade taint—any lost label degrades to `UNTRUSTED`, so a poisoned fact cannot reach a privileged tool without an explicit clearance step. Second, it forces the compaction prompt to be *label-aware*: markers must be embedded in the content and the summarizer instructed to preserve them, converting a metadata problem into a checkable content problem. Third, it introduces a measurable budget cost: quarantined spans accumulate in the side channel and must be periodically re-validated or expired, so the agent's effective trusted working set is smaller than its raw context. That cost is the price of the invariant. The alternative—trusting the summarizer to preserve a label it cannot see—is a guaranteed path from a single fetched document to attacker-controlled tool execution. ```python class TaintBoundaryViolation(RuntimeError): """Raised when a tainted datum crosses a context-window boundary without provable label reattachment and would feed a tool call.""" pass TRUST_JOIN = {"TRUSTED": 0, "UNTRUSTED:external": 1} REATTACH_THRESHOLD = 0.7 def transition_window(prior_spans, summary_spans, pending_tool_args): """ prior_spans: list of (span_id, text, label) summary_spans: list of (span_id, text) produced by compaction pending_tool_args: dict arg_name -> provenance_span_id that a tool call on the next turn will consume. Invariant enforced: no pending tool argument may draw provenance from a span whose label could not be reattached post-compaction. Absence of a reattachable label degrades to UNTRUSTED, never TRUSTED. """ reattached = {} for sid, text in summary_spans: best_sim, best_label = 0.0, None for psid, ptext, plabel in prior_spans: sim = _cosine(text, ptext) if sim > best_sim: best_sim, best_label = sim, plabel if best_sim >= REATTACH_THRESHOLD: reattached[sid] = best_label else: # fail-closed: unresolved provenance is UNTRUSTED reattached[sid] = "UNTRUSTED:external" for arg, prov_sid in pending_tool_args.items(): label = reattached.get(prov_sid) if label is None: # provenance span vanished entirely from the summary raise TaintBoundaryViolation( f"arg '{arg}' references span {prov_sid} absent from " f"compacted window; taint unprovable -> block" ) if TRUST_JOIN.get(label, 1) > 0: raise TaintBoundaryViolation( f"arg '{arg}' draws from tainted span {prov_sid} " f"(label={label}); quarantine before tool call" ) return reattached def _cosine(a: str, b: str) -> float: # placeholder; production uses embedding similarity sa, sb = set(a.lower().split()), set(b.lower().split()) if not sa or not sb: return 0.0 return len(sa & sb) / (len(sa) ** 0.5 * len(sb) ** 0.5) ```