# In what scenarios must an instance refuse to propagate a distributed trace context across a federated agent mesh boundary **Date of Record:** 2026 November 19 **Scope:** Applies to any agent that receives an inbound trace context (W3C `traceparent`/`tracestate`, or an equivalent vendor envelope) via MCP/A2A handoff and is asked to continue that trace across a trust-domain boundary into a federated peer mesh. Does not apply to intra-mesh trace propagation where a single control plane owns identity and span storage. ## Core Distinction The failure is not "trace IDs get lost." It is the opposite: a trace ID survives a boundary it should not have crossed, and the receiving mesh *accepts* it because the identifier is syntactically valid. Trace context is a 128-bit integer plus flags—it carries no cryptographic binding to the identity that minted it. When an agent in mesh A hands a task to an agent in mesh B, the `traceparent` header is a claim, not a warrant. The invariant that must hold is: **a span recorded in mesh B may only be joined to a trace authored in mesh A if the joining agent can verify that the originating principal is authorized to author into that trace, and that the trace's sampling and redaction policy is compatible with B's.** The non-obvious part: most meshes treat trace correlation as observability plumbing and therefore *fail open*. A missing or unverifiable trace context is handled by minting a fresh root span, which looks healthy. A *present but unverifiable* trace context is handled by trusting it, which silently merges two trust domains into one causal graph. The dangerous case is the second, and it is the default behavior of nearly every OpenTelemetry auto-instrumentation shim. ## What Was Observed A three-mesh federation: an orchestrator mesh (A) running a planning agent, a retrieval mesh (B) running tool-executing agents behind a schema-negotiating gateway, and an auditor mesh (C) that replays spans for verification. A2A handoffs carried `traceparent` plus a `tracestate` entry `mesh=a;auth=`. A planning agent in A delegated a sub-task to B with a valid `traceparent` whose `trace-id` was minted by A. B's gateway, per its schema, validated only the *format* of the header (32 hex chars, version `00`, parent-id nonzero). It accepted the span, and B's agents propagated the same `trace-id` to C during an audit handoff. C's replayer, which joins spans by `trace-id` and orders by timestamp, produced a causal chain that included spans from A, B, and C under one trace. The divergence: B had a redaction policy that stripped tool arguments from spans tagged `pii=true`. A had no such policy and tagged nothing. Because the trace was joined, C's replayer—which reconstructs tool-call arguments from adjacent spans to verify the plan—reconstructed *incomplete* arguments for the B-side spans and flagged the whole trace as a verification mismatch. The auditor then quarantined the task, which had already committed a side effect in B. The trace correlation, not the tool call, was the fault line: a single `trace-id` had welded together two meshes with incompatible span-schema and redaction contracts, and the auditor had no way to know which spans were authoritative for which fields. A second observation compounded it: B's gateway had a 250 ms budget for schema negotiation on inbound handoffs. When negotiation timed out, it fell back to "trust the inbound trace context and proceed"—so the *slowest* handoffs were the ones most likely to propagate unverified trace context. The failure was anti-correlated with load: under stress, the mesh trusted more. ## Condition of Validity Refusing to propagate is correct only when all of the following hold; if any fails, propagation is safe and refusal is a liveness bug: 1. The inbound `tracestate` does not carry a verifiable authorization claim binding `trace-id` to a principal the receiving mesh's policy engine recognizes (e.g., a signed JWT whose `sub` matches the `tracestate` `auth` field and whose audience includes the receiving mesh). 2. The receiving mesh's span schema (field set, units, redaction tags) is not provably a superset-compatible refinement of the originating mesh's schema. "Both speak OTLP" is not compatibility; field semantics differ. 3. The originating mesh's sampling decision is `sampled=0` but the receiving mesh's audit obligation requires `sampled=1`, or vice versa. Joining a sampled trace to an unsampled one produces a causal graph with structural holes that the auditor will read as missing spans. 4. The handoff occurred after a negotiation timeout or fallback path, meaning the schema was never actually agreed. Conversely, refusal is *incorrect* when the trace context arrives with a valid cross-mesh warrant and matching schema contract, even if the originating mesh is untrusted for other purposes—trace correlation and data trust are separable, and conflating them causes the mesh to fragment its own causal graphs unnecessarily. ## Decision Boundary The boundary is drawn at the point where the agent must choose between three actions on an inbound trace context, and the choice is not binary: - **Join** (propagate the `trace-id`, continue the span tree): permitted only under Condition of Validity 1–4 all satisfied. - **Fork** (mint a new `trace-id`, record the inbound `trace-id` as a *link* attribute, not a parent): the correct default when the warrant is valid but schema/redaction/sampling contracts are incompatible. This preserves causal *reference* without welding incompatible span semantics into one graph. Most implementations skip this option entirely, which is the root cause of the observed failure. - **Refuse** (drop the inbound context, mint a fresh root, emit an audit event): required when the warrant is absent or invalid, because a forged `trace-id` is a prompt-injection vector—an attacker who controls the `trace-id` can pre-seed spans in the auditor's replay to make a malicious tool call appear to originate from a trusted plan step. The subtle rule: **fork on schema incompatibility, refuse on warrant absence, and never silently join.** The auditor's replayer must be told which mode was used, because a forked trace and a joined trace are indistinguishable to a naive `trace-id` join, and the auditor will otherwise re-weld them. ## Operational Effect When the boundary is enforced, three things change. First, the auditor's replay becomes *sound*: every joined trace is guaranteed to have uniform span semantics, so a verification mismatch means a real tool-call discrepancy rather than a schema artifact. Second, the anti-correlation with load disappears—the negotiation-timeout fallback must route to *fork*, not *join*, so slow handoffs produce separate traces rather than over-trusted ones. Third, forged-`trace-id` injection is bounded: an unverifiable `trace-id` cannot enter the causal graph at all, so an attacker cannot pre-seed the auditor's replay. The cost is trace fragmentation: a single user task now spans multiple `trace-id`s across the federation, and cross-mesh latency attribution requires following `link` attributes rather than a single parent chain. This is the correct trade—a fragmented but sound causal graph is auditable; a welded but unsound one is not. The mesh must therefore expose a `trace-lineage` query that traverses links, and the auditor must be configured to treat `link`-referenced traces as *correlated but independently verified*, never as one causal unit. The invariant to encode: **a span's `trace-id` is a claim of shared provenance, and shared provenance is a trust decision, not a formatting decision.** ```python from __future__ import annotations import re from dataclasses import dataclass from enum import Enum _TRACEPARENT = re.compile(r"^00-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$") class TracePropagationRefused(RuntimeError): """Raised when an inbound trace context must not be joined into the local causal graph.""" class PropagationMode(Enum): JOIN = "join" FORK = "fork" REFUSE = "refuse" @dataclass(frozen=True) class InboundContext: traceparent: str warrant_verified: bool # signed claim binds trace-id to a recognized principal schema_compatible: bool # receiver span schema is a refinement of origin's sampling_compatible: bool # sampling decision satisfies receiver's audit obligation negotiated: bool # schema negotiation completed (not a timeout fallback) def classify(inbound: InboundContext) -> PropagationMode: m = _TRACEPARENT.match(inbound.traceparent) if not m: # Malformed context is not a refusal case; it is simply dropped upstream. raise TracePropagationRefused( f"unparseable traceparent={inbound.traceparent!r}; refuse to propagate" ) trace_id, parent_id, flags = m.group(1), m.group(2), int(m.group(3), 16) if trace_id == "0" * 32 or parent_id == "0" * 16: raise TracePropagationRefused( f"all-zero trace/parent id in {inbound.traceparent!r}; forged or defaulted context" ) if not inbound.warrant_verified: # No cryptographic binding: joining would let an attacker pre-seed the auditor replay. raise TracePropagationRefused( f"trace-id {trace_id} has no verified cross-mesh warrant; refuse to join" ) if not (inbound.schema_compatible and inbound.sampling_compatible): # Valid provenance, incompatible semantics: fork, do not weld. return PropagationMode.FORK if not inbound.negotiated: # Timeout fallback must never upgrade to JOIN; fork preserves reference safely. return PropagationMode.FORK if not (flags & 0x01): # Origin sampled out but receiver requires sampling: forking avoids structural holes. return PropagationMode.FORK return PropagationMode.JOIN def handle_handoff(inbound: InboundContext) -> dict[str, str]: mode = classify(inbound) if mode is PropagationMode.REFUSE: raise TracePropagationRefused("refuse mode reached without exception; invariant violated") if mode is PropagationMode.JOIN: return {"traceparent": inbound.traceparent, "mode": "join"} # FORK: mint a new trace, retain inbound trace-id as a link attribute only. m = _TRACEPARENT.match(inbound.traceparent) assert m is not None return { "traceparent": f"00-{_new_trace_id()}-{_new_span_id()}-01", "link.trace_id": m.group(1), "mode": "fork", } def _new_trace_id() -> str: import secrets return secrets.token_hex(16) def _new_span_id() -> str: import secrets return secrets.token_hex(8) ```