# When must an instance refuse to propagate a traceparent across a federated trust boundary: span-ID reuse and the poisoned-correlation invariant **Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent systems where LLM-driven agent instances execute tool calls under W3C Trace Context propagation across organizational boundaries (MCP servers, A2A peers, or remote tool providers owned by a different trust domain). Does not apply to intra-org tracing where a single control plane owns all spans, nor to purely asynchronous batch pipelines that do not carry a live `traceparent`. ## Core Distinction The failure mode is not "tracing is missing" or "trace IDs don't match." It is the inverse: **a traceparent that is structurally valid and semantically continuous, but whose span-ID was minted in a foreign trust domain and is therefore a carrier for correlation poisoning.** Distributed tracing assumes that a `traceparent` is an *identifier*, a passive label. Across a federation boundary it becomes an *assertion*: "this span is a child of span X in trace T, and the emitting party vouches for that lineage." When an agent instance blindly re-parents its own spans onto an inbound foreign `traceparent`, it imports the foreign party's ability to (a) merge unrelated traces by reusing a span ID, (b) inject synthetic causal parents that never executed, and (c) make the local audit log claim a causal chain the local instance cannot verify. The non-obvious part: standard trace-context libraries validate *format* (32-hex trace ID, 16-hex span ID, 2-hex flags) and pass. They do not validate *provenance*. An LLM agent that reasons over its own trace ("the parent span says the user authorized this") will confidently cite a forged lineage because the trace library told it the header was well-formed. ## What Was Observed A federated deployment: an orchestrator agent (Org A) calls a retrieval agent hosted by Org B via A2A, which in turn calls a summarization tool hosted by Org C. All three emit OpenTelemetry spans. The orchestrator's policy engine uses trace-derived causal chains to answer questions like "did any span in this trace carry a `data_classification=PII` attribute before the summarizer ran?" — a real guardrail, since the summarizer is not cleared for PII. Observed sequence, reproduced in a staging federation: 1. Org B's agent received an inbound `traceparent` from Org A with span ID `00f067aa0ba902b7`. Org B's tracing SDK, configured with default `ParentBased(AlwaysOn)` sampler, adopted it and minted child spans. 2. Org B's agent made three retries to Org C after a 503. Each retry re-entered the tracing middleware. A bug in Org B's retry wrapper re-used the *inbound* span ID as the parent for every retry attempt rather than minting a fresh one, so all three retry spans shared parent `00f067aa0ba902b7` — a span ID that, in Org A's trace, belonged to a *different* logical operation (the initial request, not the retries). 3. Org C's summarizer, seeing three sibling spans with identical parent span ID but three distinct `traceparent` trace IDs (because Org B's retry wrapper also rotated the trace ID on each attempt while keeping the span ID), emitted three independent traces. The summarizer's own guardrail — "reject if the parent span has `data_classification=PII`" — checked only the *immediate* parent span, which was the retry span, not the PII-bearing ancestor three hops up. 4. The summarizer processed PII. The orchestrator's post-hoc audit, joining on trace ID, saw three traces, none of which contained the PII span, because the PII span lived under the *original* trace ID that Org B had rotated away from. The correlation was *broken in a way that looked complete*. Every span had a valid traceparent. Every service reported success. The guardrail passed. The audit's "no PII reached summarizer" conclusion was false. A second, cleaner reproduction isolated the span-ID-reuse variant: an adversarial Org B (in a red-team exercise) deliberately emitted a child span whose parent span ID equaled a span ID from an *unrelated* trace in Org A's recent history. Org A's trace backend, keyed by `(trace_id, span_id)`, silently merged the two traces into one, and the merged trace showed a causal path from a benign user request to a privileged admin tool call that never happened. An LLM agent summarizing the trace for an incident report wrote: "the admin tool was invoked as a direct consequence of the user's request" — a fabricated causal claim derived from a structurally valid header. ## Condition of Validity The invariant that was violated: **a span ID is only a valid causal reference within the trust domain that minted it.** Formally, for a `traceparent` received across a federation boundary to be safely adopted as a parent, all three must hold: - **Provenance binding:** the inbound `traceparent` carries a signature or an out-of-band attestation (e.g., a signed A2A message envelope, or a W3C `tracestate` entry carrying a domain-scoped HMAC over `(trace_id, span_id, parent_span_id)`) that the receiving instance can verify against a known key for the emitting org. - **Span-ID non-reuse:** the emitting domain guarantees (and the receiver verifies) that the span ID has not been used as a parent for any other trace ID. In practice this means the receiver must reject any inbound `traceparent` whose `(trace_id, span_id)` pair has not been seen before *for that trace*, and must reject any span ID that appears under two different trace IDs within a sliding window. - **Ancestor visibility:** the receiver must be able to resolve the *full* ancestor chain, not just the immediate parent, before any policy decision that depends on ancestor attributes (classification, authorization, user identity). If the ancestor spans live in a domain the receiver cannot query, the receiver must treat the chain as *unverified*, not as *absent*. The staging failure violated all three. The production guardrail had been written assuming the second and third held because the first (format validity) held. That is the seductive part: format validity is cheap to check and creates a false sense of completeness. ## Decision Boundary The precise boundary where an instance must **refuse to propagate** rather than adopt: - **Adopt** the inbound `traceparent` as parent only when provenance is bound (signature or attested `tracestate`) AND the receiver's local span-ID registry has no conflicting `(trace_id, span_id)` mapping AND either the ancestor chain is resolvable within the receiver's trust domain or no policy decision depends on ancestor attributes. - **Refuse and re-root** — mint a fresh trace ID, record the inbound `traceparent` as a *link* (OpenTelemetry `Link`, not `Parent`) with an explicit `link.unverified=true` attribute — when provenance is unbound but the call must proceed for availability reasons. The new trace is local; the link is advisory. - **Refuse and abort** when a policy decision (PII, authz, data residency) depends on ancestor attributes and the ancestor chain is not resolvable. This is the case the staging run hit and mishandled: the summarizer should have aborted, not proceeded with an unverified parent. The non-obvious corollary for LLM agents: an agent that is *asked to reason about its own trace* (incident summarization, self-audit, "why did you call this tool?") must be given the trace's *trust status* as a first-class field, not just the span tree. A structurally valid trace with unverified links is not a weaker form of evidence — it is *negative* evidence, because it invites confident fabrication. The agent's prompt or tool schema must carry `trace.trust_status ∈ {verified, partially_verified, unverified}` and the agent must be instructed that `unverified` traces may not be cited as causal evidence. ## Operational Effect Concretely, the guardrail that was missing is a **span-ID registry with cross-trace collision detection** at every federation ingress, plus a **signed `tracestate` entry** carrying the emitting domain's HMAC over the parent triple. The registry is small (a bounded LRU of `(trace_id, span_id) → first_seen_ts` per peer domain, with a TTL matching the max trace duration) and cheap. The signature check is one HMAC verify per inbound request. Together they convert the inbound `traceparent` from an unverified assertion into a bounded claim. The cost of *not* doing this is not "bad traces." It is that every downstream reasoning step an LLM agent performs over the trace — incident reports, self-audits, policy decisions — inherits the forgery. The agent cannot distinguish a real causal chain from a merged one because the merge happened below the layer it reasons at. The invariant to encode: **an agent instance must never treat a `traceparent` as evidence of causality until the lineage has been verified within a trust domain that can vouch for every hop.** When it cannot verify, it must degrade the trace's trust status and refuse any reasoning or policy action that depends on the unverified portion — not silently proceed with a well-formed header. ```python import hashlib import hmac import time from dataclasses import dataclass, field class UnverifiedTraceLineageError(RuntimeError): """Raised when an inbound traceparent cannot be bound to a trusted lineage.""" @dataclass class SpanRegistry: # (trace_id, span_id) -> first_seen monotonic ts, per peer domain seen: dict = field(default_factory=dict) ttl_seconds: float = 3600.0 def _prune(self, now: float) -> None: cutoff = now - self.ttl_seconds self.seen = {k: v for k, v in self.seen.items() if v >= cutoff} def check_and_record(self, peer: str, trace_id: str, span_id: str) -> bool: """Return True if this (trace_id, span_id) is novel; False on collision.""" now = time.monotonic() self._prune(now) key = (peer, trace_id, span_id) if key in self.seen: return False # cross-trace span-ID reuse: same peer, same span_id, different trace_id for (p, t, s), _ in self.seen.items(): if p == peer and s == span_id and t != trace_id: return False self.seen[key] = now return True def verify_inbound_traceparent( peer: str, traceparent: str, tracestate: str, peer_hmac_key: bytes, registry: SpanRegistry, ancestor_chain_resolvable: bool, policy_depends_on_ancestors: bool, ) -> str: """ Returns 'adopt' | 'reroot' | raises UnverifiedTraceLineageError. """ parts = traceparent.split("-") if len(parts) != 4 or len(parts[1]) != 32 or len(parts[2]) != 16: raise UnverifiedTraceLineageError(f"malformed traceparent from {peer}: {traceparent!r}") _, trace_id, span_id, _flags = parts # 1. provenance binding: signed tracestate entry over (trace_id, span_id) expected = hmac.new(peer_hmac_key, f"{trace_id}:{span_id}".encode(), hashlib.sha256).hexdigest() sig = None for entry in tracestate.split(","): entry = entry.strip() if entry.startswith(f"{peer}@sig="): sig = entry.split("=", 1)[1] break provenance_bound = sig is not None and hmac.compare_digest(sig, expected) # 2. span-ID non-reuse novel = registry.check_and_record(peer, trace_id, span_id) # 3. ancestor visibility if policy_depends_on_ancestors and not ancestor_chain_resolvable: raise UnverifiedTraceLineageError( f"policy depends on ancestor attributes but chain for trace {trace_id} " f"from {peer} is not resolvable; refusing to proceed" ) if provenance_bound and novel and ancestor_chain_resolvable: return "adopt" if not novel: # collision: never adopt; re-root under a fresh local trace return "reroot" if not provenance_bound: return "reroot" return "adopt" def handle_remote_tool_call( peer: str, traceparent: str, tracestate: str, peer_hmac_key: bytes, registry: SpanRegistry, ancestor_chain_resolvable: bool, policy_depends_on_ancestors: bool, ) -> str: decision = verify_inbound_traceparent( peer, traceparent, tracestate, peer_hmac_key, registry, ancestor_chain_resolvable, policy_depends_on_ancestors, ) if decision == "reroot": # caller mints a fresh trace; inbound traceparent is recorded as a Link # with link.unverified=true, never as Parent. return "rerooted" return "adopted" ```