# Under what conditions must an instance refuse to emit a child span when an inbound MCP call carries an unverifiable traceparent **Date of Record:** 2026 November 29 **Scope:** Applies to any agent instance that participates in W3C Trace Context propagation across MCP tool calls or A2A task handoffs and is expected to produce causally linked spans. Does not apply to single-process agents with no cross-instance hop, nor to systems where trace correlation is reconstructed post hoc from logs rather than propagated in-band. ## Core Distinction There are two structurally different things an agent can do with an inbound `traceparent` header on an MCP `initialize`/`tools/call` frame or an A2A `tasks/send` envelope: it can *adopt* the parent context and mint a child span, or it can *reject* the parent and start a new root trace. Most implementations do neither deliberately — they adopt unconditionally on the assumption that a syntactically valid `traceparent` is a semantically trustworthy one. That assumption is false, and the failure it produces is not a crash but a **silent causal forgery**: the child span is emitted under a parent that the receiving instance cannot verify belongs to the same authorization domain, the same logical task, or even the same trace generation. The trace looks complete. The lineage is wrong. The sharp invariant is this: **a span MUST NOT be emitted with a `parent_span_id` derived from an inbound `traceparent` unless the receiving instance can bind that trace context to a verified caller identity within the same trust boundary as the span's own emission.** Syntactic validity (32-hex trace-id, 16-hex span-id, 2-hex flags) is necessary and grossly insufficient. ## What Was Observed A three-hop pipeline: orchestrator agent `O` (root span `S0`, trace `T`) → planner agent `P` via A2A `tasks/send` → tool executor `E` via MCP `tools/call` → a retrieval tool `R` behind an MCP server. Each hop propagates `traceparent` in the transport metadata per spec. During a routine capacity event, `P` timed out on its A2A call to `E` and retried. The A2A client library reused the *same* `traceparent` value on the retry rather than minting a fresh child span-id for the retried attempt — a plausible library behavior, since the "logical operation" was unchanged. `E` received two `tools/call` frames with identical `traceparent` (`T`, `S1`, same span-id). It adopted both. It emitted two child spans, `S2a` and `S2b`, both with `parent_span_id = S1`. Downstream, `R` received both and emitted `S3a`, `S3b`. The trace backend deduplicated the two `S1` parents fine, but the **span-id collision at `S2`** was not detected because `E` used a monotonic counter seeded per-process and the two frames landed on different worker threads that had each initialized the counter at zero. The collector accepted both spans. The resulting trace had two distinct subtrees both claiming to descend from `S1`, with no disambiguating field, and the critical-path computation summed both durations — reporting a tool latency of 4.1s where the true p99 was 2.3s. The second, subtler observation: on the retry, `P`'s A2A envelope carried a *newly minted* caller identity token (the retry was issued by a different replica of `P` after the first replica's lease expired), but the reused `traceparent` still encoded the *original* replica's span context. `E` verified the identity token — successfully — but never cross-checked that the identity in the token matched the identity the trace context was originally minted under. So `E` emitted spans attributing work to `P-replica-1`'s trace lineage while the actual work was authorized and performed under `P-replica-2`. The audit trail was internally consistent and externally wrong. ## Condition of Validity The adoption of an inbound trace context is valid only when *all* of the following hold at the receiving instance: 1. The `traceparent` parses and its `trace-id` is not all-zero and not the invalid sentinel. 2. The receiving instance has a caller identity (from the MCP transport auth or the A2A envelope warrant) that is *verified*, not merely present. 3. The trace context is bound to that identity — either because the context was minted within the same process (trivial case), because the transport carries a signed binding between `trace-id`/`span-id` and the caller's warrant, or because a prior hop's binding is transitively verifiable through a chain the receiver can check. 4. The receiving instance can guarantee **span-id uniqueness within the trace**, which requires a globally unique span-id source (random 64-bit, not per-process counters) because two instances on the same trace will otherwise collide. 5. The inbound span-id has not already been observed as a parent within this trace by this instance (a retry-detection check), or if it has, the retry is explicitly modeled as a *sibling* attempt, not a second child of the same parent. If condition 3 fails — the common case, because most MCP servers do not carry signed trace bindings — the correct behavior is **not** to adopt the parent. It is to start a new root trace, emit a `link` (W3C span link) to the unverified inbound context, and mark the span with an attribute such as `trace.parent.adopted=false`, `trace.parent.unverified_reason=`. The link preserves correlation for debugging without forging causal parentage. ## Decision Boundary The boundary is between *correlation* and *causation*. An unverified `traceparent` is still useful as a correlation hint: it tells you which upstream request this work is probably related to. It is not a valid causal parent, because causal parentage is a claim about authorization and ordering that the receiver cannot substantiate. Concretely, the decision procedure at the receiver is: - If the inbound context is self-minted (same process) → adopt, emit child, done. - If the inbound context arrives with a verifiable binding to the caller's warrant → adopt, emit child, record the binding digest as a span attribute. - If the inbound context is syntactically valid but unbound → **do not adopt**; start a new root, add a span link with `traceparent` and the unverified reason, set `trace.parent.adopted=false`. - If the inbound context is bound but its span-id has already been seen as a parent in this trace → treat as retry; emit a sibling span under the *grandparent* (or under a synthetic retry-aggregator span), never a second child of the same parent. - If the `trace-id` is all-zero or malformed → treat as absent; start a new root; do not link (a malformed context carries no correlation value). The failure mode this prevents is the one observed: unconditional adoption producing a trace that is *shaped* like a valid causal tree but whose edges are unverified, colliding, or identity-mismatched. Such traces are worse than absent traces, because downstream reasoning (latency attribution, blame assignment, replay) treats them as ground truth. ## Operational Effect With the boundary enforced, three observable properties change. First, latency attribution becomes sound: no more double-counted subtrees from span-id collisions, because span-ids are random and retry attempts are modeled as siblings with an explicit `retry.attempt` attribute. Second, the audit trail becomes *honest about its own uncertainty*: spans that could not verify their parent carry `trace.parent.adopted=false` and a link, so a replay tool can distinguish "this work definitely descended from that request" from "this work is probably related to that request." Third, identity-trace mismatches surface as a first-class signal rather than a silent forgery — a span whose caller warrant digest differs from the digest bound into the trace context raises a `TraceBindingMismatch` at emission time, which is exactly the kind of thing an auditor wants to see flagged rather than smoothed over. The cost is that trace trees become slightly bushier (more roots, more links) and dashboards that assumed a single root per trace need to aggregate over links. That cost is bounded and predictable. The cost of the alternative — forged causality that survives every syntactic check — is unbounded and only discovered during incident forensics, which is the worst possible time. ```python from __future__ import annotations import re from dataclasses import dataclass _TRACEPARENT_RE = re.compile(r"^([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})-([0-9a-f]{2})$") _ZERO_TRACE = "0" * 32 _ZERO_SPAN = "0" * 16 class TraceBindingMismatch(RuntimeError): """Raised when an inbound traceparent cannot be verified against the caller's warrant.""" class SpanIdCollision(RuntimeError): """Raised when an inbound parent span-id was already observed as a parent in this trace.""" @dataclass(frozen=True) class InboundContext: traceparent: str caller_warrant_digest: str | None # None => unbound (no signed binding present) bound_warrant_digest: str | None # digest bound into the trace context, if any @dataclass(frozen=True) class SpanDecision: adopt_parent: bool parent_span_id: str | None link_to: str | None reason: str class TraceAdopter: def __init__(self) -> None: # per-trace set of parent span-ids already observed by this instance self._seen_parents: dict[str, set[str]] = {} def decide(self, ctx: InboundContext, new_span_id: str) -> SpanDecision: m = _TRACEPARENT_RE.match(ctx.traceparent) if not m: return SpanDecision(False, None, None, "malformed") trace_id, parent_span_id, _flags, _ver = m.groups() if trace_id == _ZERO_TRACE or parent_span_id == _ZERO_SPAN: return SpanDecision(False, None, None, "zero_sentinel") if ctx.caller_warrant_digest is None: raise TraceBindingMismatch( f"no verified caller warrant for trace {trace_id}; " "cannot adopt unbound parent" ) if ctx.bound_warrant_digest is None: # syntactically valid but unbound: correlate via link, do not adopt return SpanDecision(False, None, ctx.traceparent, "unbound") if ctx.bound_warrant_digest != ctx.caller_warrant_digest: raise TraceBindingMismatch( f"trace {trace_id} bound to warrant {ctx.bound_warrant_digest!r} " f"but caller presented {ctx.caller_warrant_digest!r}" ) seen = self._seen_parents.setdefault(trace_id, set()) if parent_span_id in seen: # retry: model as sibling attempt, not second child of same parent return SpanDecision(False, None, ctx.traceparent, "retry_sibling") seen.add(parent_span_id) if new_span_id == parent_span_id: raise SpanIdCollision( f"new span-id {new_span_id} collides with inbound parent in trace {trace_id}" ) return SpanDecision(True, parent_span_id, None, "adopted") ```