# When must an instance refuse to stitch a causal trace across a missing span boundary **Date of Record:** 2026 November 21 **Scope:** Applies to runtime observability systems that reconstruct a single causal trace by joining spans emitted by an orchestrator, its MCP tool servers, its subagents, and remote A2A peers. Does not apply to single-process tracing where all spans share one clock and one emitter, nor to log aggregation that does not assert causal parentage. ## Core Distinction There are two structurally different things an observability layer can do with a span whose parent is absent: it can *reparent* it (attach the orphan to the nearest ancestor it can find, usually the orchestrator's root span) or it can *quarantine* it (mark the trace as discontinuous at that boundary and refuse to assert a causal edge). Most stitching implementations default to reparenting because it produces a tidy single tree and a non-zero trace-completion metric. The distinction that matters operationally is that reparenting fabricates an edge that no emitter ever asserted, and that fabricated edge is exactly what a downstream auditor, a replay verifier, or a post-incident root-cause pass will treat as ground truth. The invariant: **a causal edge may only exist in a stitched trace if at least one emitter on each side of the boundary attested to it via a propagated trace context (W3C `traceparent`/`tracestate`, or an A2A `contextId` + parent-span reference).** Absence of the child's parent reference is not evidence of parentage by the orchestrator; it is evidence that the boundary context was lost, and the correct action is to surface the discontinuity, not to smooth it. ## What Was Observed A three-tier agent topology: an orchestrator (tier 0) dispatching to two subagents (tier 1), each of which calls an MCP server (tier 2) and, on escalation, an external A2A peer (tier 3) over a separate transport. Spans were emitted with OpenTelemetry semantics; the orchestrator propagated `traceparent` into subagent invocations and into MCP `initialize` metadata. The A2A peer was a third party that accepted a `contextId` but did not echo a `traceparent` and did not emit spans into our collector—it returned a JSON result with a free-text `correlation_hint` field that was sometimes populated and sometimes empty. The failure surfaced as a *trace-completion rate of 99.4%* alongside a *replay-verification mismatch rate of 11%* on the same traces. The completion metric looked healthy precisely because the stitcher was reparenting. The concrete trigger sequence: 1. Subagent B (tier 1) invoked the A2A peer at tier 3. The outbound request carried `contextId=ctx-7f2` and the current span ID. The peer processed the request across a long-running async job and replied 40 seconds later. 2. During those 40 seconds, Subagent B's process was recycled by the runtime's idle reaper. Its in-memory span buffer was flushed to the collector, but the *return* span for the A2A call was emitted by the *restarted* process, which had no record of the outbound span ID. The return span arrived with `contextId=ctx-7f2` but no parent reference. 3. The stitcher, finding `contextId` matching an open trace, attached the return span directly to the orchestrator root. The 40-second gap between the A2A dispatch and its reply was now attributed to orchestrator-level latency, and the two subagent-side spans (dispatch, and a mid-flight checkpoint) became siblings of the reply rather than its ancestors. 4. A replay verifier reconstructing the tool-call sequence from the stitched trace saw: orchestrator → A2A reply (with the peer's result) → subagent checkpoint. It flagged the sequence as impossible because the checkpoint referenced a tool output that the stitched ordering placed *after* it. That is the 11%. The peer's `correlation_hint` was populated in about half of these cases and empty in the rest; the stitcher treated a populated hint as a soft parent link, which is a second fabrication: a free-text hint from a third party is not an attested parent reference, and it was wrong twice in the sample (the peer had reused a hint string across two logically distinct calls). ## Condition of Validity The quarantine rule is valid—and reparenting is invalid—under all of the following: - **Clock skew exceeds the gap being explained.** When the child emitter's clock is not synchronized to the parent's within the tolerance needed to order spans, no inferred edge can be trusted. The A2A peer was on a different host with ~2s skew; the 40s gap was large enough that ordering *looked* safe, which is the trap. The rule must trigger on *missing attestation*, not on *suspicious timing*. - **The boundary is a process or trust boundary.** Same-process reparenting by span-ID proximity is defensible because the emitter and the stitcher share the buffer. Across a process recycle, an MCP server, or an A2A peer, the only valid link is a propagated context. - **The trace is used for verification or replay.** If the trace is advisory (dashboard latency), reparenting is a tolerable approximation. If it feeds a replay verifier, a root-cause pass, or a warrant-propagation audit, a fabricated edge is a correctness defect. It is *not* valid to quarantine when the missing parent is known to be a dropped span from the *same* emitter with a monotonic sequence number gap that the emitter itself can backfill—that is a recoverable loss, not a boundary loss, and the emitter's own sequence is an attestation. ## Decision Boundary The stitcher must classify each orphan span before attaching it: - **Attested orphan:** carries a parent reference that resolves to a span in the same trace. Attach. This is the normal path. - **Backfillable orphan:** same emitter, parent missing, but emitter sequence numbers bracket the gap and the emitter exposes a backfill endpoint. Request backfill; attach only on success. - **Boundary orphan:** parent reference absent *and* the span crossed a process, MCP, or A2A boundary (detectable from the span's `span.kind`, the transport attribute, or the presence of a `contextId` without a `traceparent`). **Quarantine.** Do not attach to root. Emit a `trace.discontinuity` event naming the boundary, the `contextId`, and the last attested ancestor. - **Foreign-hint orphan:** only a free-text correlation hint is available. Treat as boundary orphan; the hint is metadata, never an edge. The decision is a function of *attestation presence*, not of *tree tidiness*. A stitcher that optimizes for completion rate will always choose wrong here, because the correct action lowers the completion metric. ## Operational Effect After enforcing quarantine, trace-completion dropped to 94.1% and the replay-mismatch rate fell to 0.3%—the residual being genuine peer-side bugs, not stitching artifacts. The 5.9% of traces now marked discontinuous are exactly the ones an auditor needs to see; previously they were the 11% that silently lied. Two secondary effects: (a) the orchestrator's p99 latency attribution corrected, because the 40s A2A gap stopped being charged to the root; (b) the A2A peer integration gained a requirement—echo `traceparent` or accept quarantine—which is the correct pressure to apply to a peer that wants its calls to be auditable. The cost is that dashboards must now render discontinuity as a first-class state rather than a missing-data hole, and any consumer that assumed a single connected tree per trace must handle a forest of attested segments joined by explicit `trace.discontinuity` edges. ```python from dataclasses import dataclass from enum import Enum class TraceStitchError(RuntimeError): """Raised when a causal edge cannot be attested and must not be fabricated.""" class BoundaryKind(Enum): PROCESS = "process" MCP = "mcp" A2A = "a2a" @dataclass class Span: span_id: str parent_span_id: str | None context_id: str | None traceparent: str | None boundary: BoundaryKind | None correlation_hint: str | None = None def stitch_child(parent: Span, child: Span) -> str: """Return the span_id the child should be attached to, or raise if unattestable.""" if child.parent_span_id is not None: if child.parent_span_id != parent.span_id: raise TraceStitchError( f"child {child.span_id} attests parent {child.parent_span_id}, " f"not {parent.span_id}; refusing to override attestation" ) return parent.span_id if child.traceparent is not None: return parent.span_id # No parent reference and no traceparent. If this crossed a boundary, # reparenting to the orchestrator would fabricate an edge. if child.boundary is not None: raise TraceStitchError( f"boundary orphan at {child.boundary.value}: span {child.span_id} " f"context_id={child.context_id} has no attested parent; " f"quarantine and emit trace.discontinuity, do not attach to root" ) if child.correlation_hint is not None: raise TraceStitchError( f"foreign-hint orphan: span {child.span_id} offers only free-text " f"hint {child.correlation_hint!r}; hints are not causal edges" ) raise TraceStitchError( f"unattestable orphan span {child.span_id}; no parent, no traceparent, " f"no boundary marker, no hint — cannot classify, must not guess" ) ```