# What structural signals indicate transport-layer provenance separation has failed mid-stream in an agent context **Date of Record:** 2026 November 29 **Scope:** Applies to agents that enforce instruction/data provenance separation at the MCP/A2A transport boundary by tagging message parts with a provenance class (e.g., `instruction` vs `data`) and rejecting inline directive content found in data-classed parts. Does not address post-hoc output filtering, model-side prompt hardening, or content moderation of the model's own generations. ## Core Distinction Provenance separation at the transport layer assumes a *stable, per-message-part* classification: a chunk of bytes is either instruction-channel or data-channel, decided once at ingress, and the downstream executor is expected to honor that classification for the lifetime of the context window that contains it. The failure mode is not "the classifier mislabeled a part." It is **classification drift under reassembly**: when a data-classed part is split across multiple transport frames (chunked streaming, partial JSON-RPC batches, resumable tool output) and the reassembly path re-derives provenance per frame rather than per logical part, individual frames can be promoted to instruction-class — or, conversely, an instruction-class frame can be demoted and then re-promoted as data — producing a context in which a *single logical part* carries two contradictory provenance tags. The executor then resolves the conflict by position (last-writer-wins) or by precedence (instruction beats data), and the injected directive rides in on the data channel while the guardrail reports "no data-class directive content detected," because the guardrail scanned the *part* and the *executor* acted on the *frame*. The invariant that must hold: **provenance is a property of the logical part, is assigned exactly once at ingress, and is immutable across every frame derived from that part.** Any system where provenance is recomputed, inherited from transport framing, or merged across frames violates this invariant and is vulnerable to the split-part promotion attack. ## What Was Observed A tool-call result arrives from an MCP server as a `text/event-stream` of 14 frames. Frame 1 carries the JSON-RPC envelope with `"role": "tool_result"` and a provenance tag `data`. Frames 2–13 carry base64-encoded tool output chunks. Frame 14 carries the terminal sentinel and a duplicated envelope header — a common pattern in resumable streams where the server re-emits the envelope to allow client-side resumption after a network drop. The client's reassembly loop treats each frame as an independent transport unit and calls `classify_provenance(frame)` on it. Frames 2–13 have no envelope, so the classifier falls back to a heuristic: "no explicit role → infer from content." The heuristic sees imperative verbs in the decoded chunk (`ignore previous`, `call the tool`, `write to`) and — because the heuristic was tuned to *catch* instructions — labels those frames `instruction`. Frames 1 and 14 are labeled `data` from their envelopes. The reassembled logical part therefore contains 12 `instruction`-classed frames and 2 `data`-classed frames. The executor, applying last-writer-wins by frame order, ends with the part tagged `data` (frame 14 is last). The guardrail, scanning per-part, sees `data` and finds no directive content. But the *content assembly* step concatenates frames in order, and the model's context contains the decoded imperative text. The guardrail's verdict (`clean`) and the model's input (contains directives) diverge. The tell was a 340 ms gap between the guardrail's `provenance_check` span (which completed in 4 ms on the part) and the executor's `context_append` span (which took 344 ms to decode and concatenate 12 frames). The guardrail was operating on a different unit of analysis than the executor. A second observed variant: an A2A handoff where the sending agent serializes a task with an `instruction`-classed `system` part and a `data`-classed `payload` part, but the transport's max-frame-size forces the `payload` to split. The receiving agent's reassembly inherits the provenance of the *frame's* position in the stream — the first payload frame is adjacent to the system part and inherits `instruction`, the rest inherit `data`. The receiving agent now has a partially-instruction payload, and any directive in the first payload frame executes with instruction authority. ## Condition of Validity This failure requires all four of the following to hold simultaneously: 1. **Part splitting across frames.** The logical message part exceeds the transport frame size or is streamed for latency reasons. If parts are atomic per frame, per-frame classification is equivalent to per-part classification and the failure cannot occur. 2. **Per-frame provenance derivation.** The reassembly path either re-runs the classifier on each frame or inherits provenance from frame adjacency/position. If provenance is assigned at ingress and carried as an explicit field on every frame (not re-derived), the invariant holds. 3. **A conflict-resolution rule that differs from the guardrail's unit of analysis.** The executor resolves multi-tag parts by position or precedence; the guardrail scans the merged part. If both operate on the same unit (both per-part, or both per-frame), the divergence closes — though per-frame guardrails have their own recall problems. 4. **A classifier with a directive-detection heuristic.** The fallback classifier must be capable of promoting content to `instruction` based on content alone. A classifier that only reads explicit role fields cannot promote, and the split-part frames stay `data` (they may then be mislabeled as data when they should be instruction, which is a different, less dangerous failure). The condition is *not* met when the transport guarantees atomic parts (e.g., a single JSON-RPC message with no streaming), or when provenance is a signed field on the envelope that the reassembler verifies rather than re-derives. ## Decision Boundary The boundary is between **provenance as a derived property** and **provenance as a transported property**. Derived provenance is recomputed from observable frame features (envelope presence, content heuristics, frame adjacency) and is therefore vulnerable to any reassembly path that changes the frame features. Transported provenance is an explicit, immutable field that travels with every frame and is verified — not recomputed — at each hop. Operationally, the decision is: if your transport can split a logical part across frames *and* your reassembler does not carry an explicit provenance field on every frame, you must either (a) forbid splitting for any part whose provenance is `instruction` or whose content the classifier would promote, or (b) make provenance a signed envelope field that the reassembler treats as authoritative and refuses to re-derive. Option (a) is cheaper and sufficient for most MCP deployments; option (b) is required for A2A handoffs where the receiving agent does not control the sender's framing. The boundary is *not* crossed by adding a post-reassembly guardrail scan, because the guardrail and the executor can still disagree on the unit of analysis — the observed 340 ms divergence is exactly this. The guardrail must operate on the *same assembled buffer* the executor appends to the context, and it must run *after* reassembly, not on individual frames or on the part envelope. ## Operational Effect When the invariant is violated, the observable effect is a **provenance-verdict divergence**: the guardrail reports `clean` while the model's context contains directive content from a data-classed part. The divergence is detectable by instrumenting the guardrail and the context-append to emit a content hash of their respective inputs; if the hashes differ, the units of analysis differ and the guardrail's verdict is not load-bearing for that part. The downstream effect is that prompt injection succeeds through the data channel with the guardrail's implicit endorsement. The model receives directives that the guardrail has certified as non-directive, and because the guardrail's verdict is typically logged as the audit record, the injection is *invisible in the audit trail* — the record shows a clean check followed by a model action that contradicts the data part's apparent content. Incident response then has to reconcile the log against the raw transport frames to discover the split. The bound is the invariant, not the classifier. No classifier accuracy improvement closes this failure, because the failure is a unit-of-analysis mismatch, not a classification error. The only structural fix is to make provenance a transported, immutable, per-frame field and to make the guardrail and the executor share a single assembled buffer. ```python from __future__ import annotations import hashlib from dataclasses import dataclass, field from enum import Enum from typing import Iterable class ProvenanceViolation(RuntimeError): """Raised when a logical part carries conflicting provenance across frames.""" class Provenance(str, Enum): INSTRUCTION = "instruction" DATA = "data" @dataclass(frozen=True) class Frame: part_id: str seq: int provenance: Provenance | None # None means "reassembler must derive" payload: bytes @dataclass class AssembledPart: part_id: str provenance: Provenance | None = None payload: bytearray = field(default_factory=bytearray) frames_seen: int = 0 def content_hash(self) -> str: return hashlib.sha256(bytes(self.payload)).hexdigest() def reassemble(frames: Iterable[Frame]) -> dict[str, AssembledPart]: parts: dict[str, AssembledPart] = {} for frame in frames: part = parts.setdefault(frame.part_id, AssembledPart(part_id=frame.part_id)) # INVARIANT: provenance is transported, never re-derived from content. # A frame that omits provenance is a protocol violation, not a hint. if frame.provenance is None: raise ProvenanceViolation( f"part {frame.part_id} frame {frame.seq} has no transported " f"provenance; reassembler refuses to derive from content" ) if part.provenance is None: part.provenance = frame.provenance elif part.provenance is not frame.provenance: # Split-part promotion: same logical part, two provenance classes. raise ProvenanceViolation( f"part {frame.part_id} carries conflicting provenance: " f"{part.provenance.value} at first frame, " f"{frame.provenance.value} at frame {frame.seq}" ) part.payload.extend(frame.payload) part.frames_seen += 1 return parts def guardrail_check(part: AssembledPart, executor_buffer_hash: str) -> None: """Guardrail must scan the exact buffer the executor appends to context.""" if part.content_hash() != executor_buffer_hash: raise ProvenanceViolation( f"guardrail scanned {part.content_hash()[:12]} but executor " f"appended {executor_buffer_hash[:12]}; units of analysis diverge" ) if part.provenance is Provenance.DATA and _contains_directive(part.payload): raise ProvenanceViolation( f"data-classed part {part.part_id} contains directive content" ) def _contains_directive(payload: bytes) -> bool: lowered = payload.lower() return any( marker in lowered for marker in (b"ignore previous", b"call the tool", b"write to") ) ```