# What structural signals indicate a taint-label collapse at the inline policy enforcement point during tool-call fan-out **Date of Record:** 2026 December 1 **Scope:** Applies to agent runtimes that make inline allow/deny decisions on tool invocations using taint labels propagated from prior tool outputs, prompt segments, or retrieved memory. Does not apply to post-hoc audit-only logging, nor to runtimes where taint is derived solely from static tool manifests rather than runtime dataflow. ## Core Distinction The distinction that matters is between *taint as a property of a value* and *taint as a property of a call site*. A taint-aware enforcement point is correct only when the label attached to the arguments of a tool invocation is the least-upper-bound (join) of the labels of every value that contributed to those arguments, recomputed at the moment of invocation. The common failure is that the runtime computes the join once, at the boundary of the tool call that *produced* the tainted data, and then carries a single coarse label on the agent's working context. When the agent fans out one tainted observation into several downstream tool calls with different sinks (a read-only search, a filesystem write, an outbound HTTP POST), the enforcement point sees the same coarse context label on all of them. It then either denies everything (over-taint) or, if any intermediate step "sanitized" by re-deriving the context from a clean summarizer, allows everything (under-taint). The structural signal is the **decoupling of the label set from the argument provenance**: the number of distinct labels reachable from the actual argument AST is strictly smaller than the number of labels that were live in the producing step. ## What Was Observed An agent was tasked with triaging an untrusted email corpus. Message bodies were labeled `UNTRUSTED_EXTERNAL`. A summarizer tool reduced each message to a structured record; the runtime joined the summary's label with `UNTRUSTED_EXTERNAL` and stamped the agent context accordingly. The agent then issued a fan-out of three calls in one reasoning step: `search_kb(query)` (sink class `READ`), `write_note(path, body)` (sink class `MUTATE_LOCAL`), and `post_webhook(url, payload)` (sink class `EGRESS`). The policy table permitted `UNTRUSTED_EXTERNAL → READ`, forbade `UNTRUSTED_EXTERNAL → EGRESS`, and permitted `UNTRUSTED_EXTERNAL → MUTATE_LOCAL` only when the argument's own taint was `CLEAN` (i.e., the agent had transformed, not copied, the untrusted bytes). The observed trace: 1. `search_kb` allowed — correct. 2. `write_note` allowed — **incorrect**: the `body` argument was a verbatim substring of the message body, but the runtime evaluated the *context* label (`UNTRUSTED_EXTERNAL`) against the sink rule and found the `MUTATE_LOCAL` gate satisfied because the rule's guard was written against `argument.taint == CLEAN`, and the argument record had been constructed by the planner with a default `CLEAN` label. The join never ran on the argument. 3. `post_webhook` denied — correct, but for the wrong reason: the coarse context label tripped the `EGRESS` deny, not the argument label. The structural tell was visible in the enforcement log as a mismatch: the argument record's `taint` field was `CLEAN` while its `provenance.root` pointed at a message segment labeled `UNTRUSTED_EXTERNAL`. The enforcement point trusted the field and ignored the provenance graph. The second tell was fan-out asymmetry: three calls in one step, one label set, three different sink classes, and the decision varied by sink rule *shape* rather than by argument content. ## Condition of Validity The invariant that must hold for inline taint enforcement to be sound is: > For every tool invocation `c`, `label(args(c)) = ⊔ { label(v) : v ∈ provenance(args(c)) }`, evaluated at the enforcement point, and the sink decision is a function of `(label(args(c)), sink_class(c))` only — never of the agent context label, and never of a defaulted field. This invariant is violated whenever any of the following hold, each of which is a *structural signal* rather than a semantic judgment: - **Label/argument arity mismatch:** the number of distinct taint labels on the argument provenance graph exceeds the number of labels the enforcement point reports it evaluated. - **Defaulted argument labels:** the planner constructs argument records and any field is populated by a default rather than by a join over provenance. Detectable as `arg.taint` set but `arg.provenance` empty, or vice versa. - **Context-label substitution:** the decision log records a `context_label` in the decision tuple where an `argument_label` is required by the rule schema. - **Fan-out divergence:** in a single reasoning step, the same context label yields decisions that differ only by sink class while argument provenance is identical — this is fine — *or* decisions that are identical across sink classes while argument provenance differs — this is the collapse. - **Sanitizer laundering without provenance rewrite:** a summarizer or rewriter step emits `CLEAN` output whose provenance still reaches tainted roots. A genuine sanitizer must truncate the provenance graph at the rewrite boundary and record the rewrite as a declassification event with an explicit rule reference. The condition of validity does not require that the agent be prevented from reading untrusted data, nor that the LLM be trusted. It requires only that the enforcement point's decision be a pure function of argument-level provenance and sink class, and that argument labels be derived, not asserted. ## Decision Boundary The boundary between a bounded and an unbounded failure is whether the enforcement point can *reconstruct* argument provenance at decision time. Two regimes: - **Reconstructable (bounded):** the runtime retains a provenance graph from tool outputs and memory retrievals through planner argument construction. The enforcement point walks the graph, computes the join, and applies the sink rule. Misconfiguration causes over-taint (denials) but not silent egress. Recovery is a policy edit; no data has left. - **Non-reconstructable (unbounded):** the planner summarizes or re-serializes arguments before the call, severing provenance. The enforcement point can only see the asserted label. Under-taint is silent: the call succeeds, the write lands, the webhook fires. The failure is discovered only by downstream audit, if at all. The decision boundary is therefore not "is the data tainted" but "can the enforcement point still see *why* the argument is tainted at the instant it must decide." Once provenance is severed by a lossy planner step, no inline policy — however strict — can recover the join, because the information required for the decision has already been destroyed upstream of the decision point. ## Operational Effect The operational consequence is that taint-aware inline enforcement must be placed *downstream of argument construction and upstream of any lossy serialization*, and the planner must be forbidden from emitting argument records whose label is not the computed join. Concretely: - Argument records carry a provenance handle, not a label field; the enforcement point computes the join and refuses to evaluate if the handle is dangling. - Sanitizers must emit an explicit declassification record; a `CLEAN` label without a declassification record is treated as a policy violation, not a pass. - Fan-out steps re-evaluate the join per call; a single step producing N calls produces N independent decisions, and the decision tuple must include the argument label, not the context label. - The enforcement point fails closed on any arity mismatch between provenance roots and evaluated labels. Where these hold, the failure mode degrades from silent egress to loud denial, which is the correct direction for an agent runtime: a denied legitimate call is recoverable by policy edit; an allowed illegitimate egress is not. ```python from dataclasses import dataclass, field from typing import Iterable class TaintCollapseError(RuntimeError): """Raised when the enforcement point cannot prove the argument label equals the join over argument provenance at decision time.""" @dataclass(frozen=True) class Provenance: root_id: str label: str declassified_by: str | None = None @dataclass class ToolCall: name: str sink_class: str args_provenance: list[Provenance] = field(default_factory=list) asserted_label: str | None = None SINK_RULES = { ("UNTRUSTED_EXTERNAL", "READ"): "allow", ("UNTRUSTED_EXTERNAL", "MUTATE_LOCAL"): "deny", ("UNTRUSTED_EXTERNAL", "EGRESS"): "deny", ("CLEAN", "READ"): "allow", ("CLEAN", "MUTATE_LOCAL"): "allow", ("CLEAN", "EGRESS"): "allow", } LABEL_ORDER = {"CLEAN": 0, "UNTRUSTED_EXTERNAL": 1} def join_labels(provs: Iterable[Provenance]) -> str: label = "CLEAN" for p in provs: if p.declassified_by is None and LABEL_ORDER[p.label] > LABEL_ORDER[label]: label = p.label return label def enforce(call: ToolCall) -> str: if not call.args_provenance: raise TaintCollapseError( f"call {call.name!r} has no argument provenance; " "cannot compute join, refusing to evaluate policy" ) computed = join_labels(call.args_provenance) if call.asserted_label is not None and call.asserted_label != computed: raise TaintCollapseError( f"call {call.name!r}: asserted label {call.asserted_label!r} " f"!= provenance join {computed!r}; provenance likely severed " "by lossy planner step" ) decision = SINK_RULES.get((computed, call.sink_class)) if decision is None: raise TaintCollapseError( f"no rule for ({computed!r}, {call.sink_class!r}); " "failing closed" ) return decision def run_step(calls: list[ToolCall]) -> dict[str, str]: results: dict[str, str] = {} for c in calls: results[c.name] = enforce(c) return results if __name__ == "__main__": step = [ ToolCall("search_kb", "READ", [Provenance("msg:42", "UNTRUSTED_EXTERNAL")]), ToolCall("write_note", "MUTATE_LOCAL", [Provenance("msg:42", "UNTRUSTED_EXTERNAL")], asserted_label="CLEAN"), ToolCall("post_webhook", "EGRESS", [Provenance("msg:42", "UNTRUSTED_EXTERNAL")]), ] try: run_step(step) except TaintCollapseError as e: print(f"halted: {e}") ```