# Under what conditions must an instance quarantine a provenance label when a tool output re-embeds previously tainted content under a fresh source identity **Date of Record:** 2026 December 2 **Scope:** Applies to agents that propagate per-span provenance/taint labels from tool outputs into the reasoning context and re-emit them on downstream tool calls. Does not apply to single-turn stateless inference with no tool loop, nor to systems that treat all tool output as uniformly untrusted (no label propagation exists to corrupt). ## Core Distinction Taint tracking fails in two categorically different ways, and conflating them produces the wrong guardrail. The first is **label laundering by re-derivation**: tainted content is summarized, reformatted, or re-serialized by a tool (a linter, a JSON normalizer, a search index, a diff engine) and returned under a *new* source identity — `tool:formatter` rather than `tool:fetcher`. A naive tracker keys provenance to the emitting tool, so the label silently resets to `untrusted→trusted` because the *channel* changed even though the *bytes* are the same tainted bytes. The second is **label amplification by coincidence**: two independent, genuinely clean sources happen to produce overlapping content (a common license header, a shared boilerplate sentence, a repeated stack-trace line), and a content-hash-based tracker merges their provenance, marking a trusted span as tainted or vice versa. The non-obvious boundary is this: **the invariant "a span's taint is a property of its content lineage, not of its emitting channel" is only enforceable when the tracker distinguishes re-derivation from coincidence.** A tracker that hashes content alone cannot tell these apart and will either over-quarantine (blocking clean work on coincidental collisions) or under-quarantine (laundering tainted bytes through a formatter). The decision point is not "is this span tainted" but "did this span's *content lineage* pass through a tainted node, or does it merely *resemble* one." ## What Was Observed A retrieval-then-format pipeline: `tool:web_fetch` pulls an untrusted page containing an injected instruction. The agent labels the fetched span `taint=external_injected`, `origin=web_fetch#42`. The agent then passes that span to `tool:markdown_normalize` to clean whitespace before reasoning over it. The normalizer returns the same semantic content, byte-different, under `origin=markdown_normalize#7`. The tracker, keyed on emitting tool, assigned the normalized output `taint=none`. The injected instruction — now inside a span the agent believed was locally derived — survived into the next planning step and was executed as an instruction. The tainted bytes were never dropped; only their label was. A second trace in the same system showed the inverse. Two clean documents shared a 40-token Apache license header. A content-hash tracker merged their provenance and marked both `taint=external_injected` because one document's *body* was tainted and the header hash collided across the provenance graph. The agent refused to summarize a legitimate document, and the operator, seeing a false positive, disabled taint propagation entirely — which re-opened the laundering path. Both failures trace to the same missing distinction: the tracker had no representation of *lineage edges* (which span was derived from which) versus *content equality* (which spans happen to match). ## Condition of Validity The quarantine rule below is valid only under all of the following: 1. Every tool output carries a **lineage edge** to the input span(s) it was derived from, not merely a source identity. A normalizer that receives span `S` and returns `S'` must emit `S'.derived_from = {S}`. 2. Taint is computed as **reachability over the lineage DAG**: a span is tainted iff any ancestor node is tainted. Content hashes are used only to *detect* possible derivation, never to *assign* taint. 3. A **re-derivation event** (tool returns content whose lineage edge points to a tainted ancestor) forces the new span to inherit the *maximum* taint of its ancestors, regardless of the emitting tool's own trust level. 4. A **coincidence event** (content hash matches a tainted span but no lineage edge exists) is *not* sufficient to taint; it is logged as a `hash_collision` and the span retains its own lineage-derived taint. If any of these is absent — in particular if lineage edges are dropped when a tool is not lineage-aware — the invariant cannot be enforced and the system must fall back to the conservative rule: *any* tool output that is not provably fresh-from-trusted-source is treated as tainted. ## Decision Boundary The boundary is crossed at the moment a tool emits output without a lineage edge. Two cases: - **Lineage-preserving tool** (`derived_from` present): apply reachability. Taint iff an ancestor is tainted. This is the only case where a span may be *downgraded* to clean, and only if *all* ancestors are clean. - **Lineage-breaking tool** (`derived_from` absent, content non-empty): the span is **quarantined** — it may not enter the reasoning context as an instruction-bearing span until a human or a lineage-aware re-fetch re-establishes provenance. It is *not* silently marked clean because the tool is "trusted." Trust in a tool means trust in its *code*, not in the *content* it was handed. The trap is treating "the formatter is our own trusted tool" as grounds to reset taint. A trusted tool processing untrusted input produces untrusted output. The tool's trust level governs whether its *transformations* are correct, not whether its *inputs* were safe. The boundary condition is: **taint resets to clean only on a lineage edge to a clean ancestor, never on a change of emitting channel.** ## Operational Effect Enforcing the lineage-reachability rule changes three behaviors: 1. **Formatter laundering is closed.** A `markdown_normalize` of a tainted span yields a tainted span. The injected instruction remains labeled and is excluded from the instruction-execution set even after reformatting. 2. **Coincidental collisions stop causing false quarantines.** Shared boilerplate across a clean and a tainted document no longer poisons the clean document, because taint is reachability, not hash membership. This removes the main operational pressure that led operators to disable propagation. 3. **Lineage-breaking tools become visible.** Any tool that fails to emit `derived_from` now triggers quarantine rather than silent trust, which surfaces the real gap (a non-lineage-aware tool in the pipeline) instead of hiding it behind a trusted-channel assumption. The cost is that every lineage-breaking tool must be wrapped or upgraded to emit `derived_from`, and the tracker must maintain a DAG rather than a flat label map. That cost is the invariant. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceQuarantineError(RuntimeError): """Raised when a tool output cannot be assigned a lineage-derived taint label.""" @dataclass class Span: span_id: str content_hash: str emitting_channel: str taint: str # "clean" | "external_injected" | ... derived_from: tuple[str, ...] = field(default_factory=tuple) class ProvenanceTracker: def __init__(self) -> None: self._spans: dict[str, Span] = {} def register(self, span: Span) -> None: self._spans[span.span_id] = span def _reachable_taint(self, span: Span, seen: Optional[set[str]] = None) -> str: if seen is None: seen = set() if span.span_id in seen: return "clean" # cycle guard; lineage DAGs are acyclic by construction seen.add(span.span_id) if span.taint != "clean": return span.taint for parent_id in span.derived_from: parent = self._spans.get(parent_id) if parent is None: raise ProvenanceQuarantineError( f"span {span.span_id} references unknown ancestor {parent_id}" ) inherited = self._reachable_taint(parent, seen) if inherited != "clean": return inherited return "clean" def label(self, span: Span) -> str: # Lineage-breaking tool: no derived_from edges. Cannot prove freshness. if not span.derived_from: raise ProvenanceQuarantineError( f"span {span.span_id} from channel {span.emitting_channel!r} " f"has no lineage edge; content cannot be proven clean and must be quarantined" ) # Coincidence is NOT taint: we ignore content_hash for taint assignment. return self._reachable_taint(span) def ingest_tool_output(tracker: ProvenanceTracker, span: Span) -> str: """Return the effective taint label, or raise if provenance is unprovable.""" try: label = tracker.label(span) except ProvenanceQuarantineError: raise if label != "clean" and span.emitting_channel.startswith("trusted:"): # A trusted-channel emitter does not launder taint; flag the invariant breach. raise ProvenanceQuarantineError( f"trusted channel {span.emitting_channel!r} re-emitted tainted span " f"{span.span_id} (inherited={label}); laundering detected" ) return label ```