# Where must an instance reconcile causal traces it did not author: cross-federation span grafting and the orphaned-parent invariant **Date of Record:** 2026 November 29 **Scope:** Applies to federated agent deployments where trajectory-level observability is assembled by merging causal span records emitted independently by multiple agents (each owning its own trace prefix) into a single reconstructed trajectory. Does not apply to single-agent traces, nor to federations that share a single monotonically-clocked trace store. ## Core Distinction The naive model of distributed tracing assumes a span's parent reference is *authoritative*: if agent B emits a span with `parent_span_id = S`, then S exists in B's causal ancestry and B can be held accountable for the link. Federated agent tracing breaks this in a way that ordinary distributed systems rarely see: an agent routinely emits spans whose parents were authored by a *different* agent under a *different* trust boundary, and the emitting agent has no way to verify that the parent span was ever durably committed, or that the parent it names is the same parent the orchestrator believes exists. The distinction that matters operationally: **span emission is a probabilistic, non-transactional act performed by an LLM-driven process whose own reasoning may have reconstructed the causal link from context rather than observed it.** When an agent writes `parent_span_id`, it is often *asserting* a causal relationship it inferred from its prompt, not *recording* one it witnessed. A single-agent tracer treats parent links as facts; a federated tracer must treat them as *testimony requiring reconciliation*. ## What Was Observed During a three-agent research federation (planner P, retriever R, synthesizer S), the observability collector reconstructed trajectories by ingesting span batches from each agent's local emitter and joining on `trace_id` plus `parent_span_id`. The invariant the collector assumed was simple: *every non-root span's parent is present in the merged set before the span is finalized.* The failure surfaced as a class of spans the collector labeled `ORPHANED_PARENT` — spans whose `parent_span_id` pointed at a span that never arrived. Investigation of a specific incident: 1. Planner P opened trace `T`, emitted root span `P1` (the plan), and dispatched a retrieval task to R carrying `trace_id=T` and `parent_span_id=P1` in the task envelope. 2. R executed the retrieval, but its local emitter had been configured with a *fresh* trace context (a known MCP handoff bug: the `traceparent` header was propagated but the W3C `tracestate` carrying the federation's span-id namespace was dropped). R emitted its spans under `trace_id=T` but with `parent_span_id` rewritten to a locally-minted placeholder `R0`. 3. R's spans arrived at the collector *before* P's `P1` span, because P batched its emissions and flushed on plan completion, while R streamed eagerly. 4. The collector, seeing `R0` as an unknown parent, either (a) dropped R's spans as malformed, or (b) — the more dangerous path — *grafted* them onto the nearest temporally-adjacent root span, silently reparenting the retrieval under a sibling plan branch that had nothing to do with it. In the (b) case the reconstructed trajectory showed S's synthesis span as a child of a *discarded alternative* plan branch, and P's actual `P1` branch appeared to terminate with no downstream work. The trajectory-level causal trace was internally consistent and entirely wrong. A downstream verifier agent reading the trace concluded the synthesis had been performed without retrieval, and issued a spurious "unsupported-claim" audit failure against S. The trigger condition is precisely: **a child span arrives at the collector before its cross-agent parent, and the collector's orphan-handling policy prefers reparenting over deferral.** The state transition is `PENDING_PARENT → (timeout) → GRAFTED_TO_NEAREST_ROOT`, with the graft recorded as a synthetic edge that is indistinguishable, in the final trace, from a genuine parent link. ## Condition of Validity The "parent must precede child" invariant is valid only under three jointly-held conditions, and federated agent tracing violates all three: - **Single clock / single emitter ordering.** Within one emitter, span flush order respects causal order. Across agents there is no such guarantee; P's batching and R's streaming invert arrival order even when the logical dependency is clean. - **Authoritative parent identity.** The parent id a child names is the parent id that exists. When the `tracestate` namespace is dropped at an MCP handoff, the child names a *local re-derivation* of the parent, not the parent itself — the ids are stable-looking strings that refer to different spans. - **Parent durability at child emission time.** The child can only cite a parent that has been committed. But an agent emitting a span mid-reasoning has no read-your-writes guarantee against a *remote* agent's store; it cites a parent that may still be in P's unflushed batch buffer, or may have been dropped entirely if P's process died after dispatch but before flush. The invariant that actually holds, and that a correct collector must enforce, is weaker: **a span's parent link is a *claim* that must be reconciled against the parent's own emission before the edge is admitted to the causal graph.** The collector is not a joiner; it is an *arbiter of testimony*. ## Decision Boundary The collector faces a fork when an orphan arrives: - **Defer.** Hold the orphan in a pending set keyed by `(trace_id, parent_span_id)` until either the parent arrives or a reconciliation deadline (not a wall-clock timeout, but a *causal watermark* — the point at which all agents in the federation have acknowledged flushing spans up to a given sequence number) passes. Deferral is correct but requires the federation to expose flush watermarks, which most agent runtimes do not. - **Graft.** Reparent to a temporally-near root. Fast, and produces a "complete-looking" trace. This is the wrong default because it manufactures false causal edges that downstream verifier agents will treat as ground truth. - **Quarantine.** Mark the orphan and its entire subtree as `UNRECONCILED`, exclude them from causal queries, and surface them as an explicit observability defect rather than silently repairing. This is the only policy that preserves the auditability of the trajectory. The decision boundary is: *graft only if the federation can prove the parent is genuinely absent (not merely delayed), and never graft across a trust boundary.* In practice, cross-agent orphans should always quarantine, because the emitting agent's parent claim was never verifiable in the first place. ## Operational Effect The consequence of getting this boundary wrong is not a missing span — it is a *plausible but false causal trajectory* that downstream auditor and verifier agents consume as evidence. Because agent verifiers reason over the trace rather than over the raw tool outputs, a grafted edge propagates as a confident but fabricated premise. The remediation that held in this incident was threefold: (1) the collector was changed to quarantine cross-agent orphans and emit a `TraceReconciliationDefect` record rather than reparent; (2) the MCP handoff was fixed to propagate the full `tracestate` including the federation span-id namespace, so child spans cite the parent's true id; and (3) verifier agents were gated to refuse to reason over any trajectory containing an unreconciled subtree, converting a silent correctness failure into a loud, bounded refusal. ```python class TraceReconciliationError(RuntimeError): """Raised when a cross-agent causal edge cannot be reconciled to an authored parent.""" pass def admit_edge(child_span: dict, parent_index: dict, federation_watermark: int) -> None: parent_id = child_span["parent_span_id"] parent = parent_index.get(parent_id) if parent is None: # Parent never arrived. Distinguish "delayed" from "absent" via watermark. if child_span["emitter_seq"] <= federation_watermark: # All agents have flushed past this child; parent is genuinely absent # OR was re-derived locally (tracestate drop). Never graft across trust boundary. raise TraceReconciliationError( f"orphaned cross-agent parent {parent_id!r} for span " f"{child_span['span_id']!r} in trace {child_span['trace_id']!r}: " f"parent not present at watermark {federation_watermark}; " f"quarantine subtree, do not reparent" ) # Parent may still be in flight; defer rather than graft. return if parent["emitter"] != child_span["emitter"]: # Cross-agent edge: verify the child cited the parent's true namespace id, # not a locally re-derived placeholder. if child_span.get("parent_namespace") != parent.get("namespace"): raise TraceReconciliationError( f"namespace mismatch on edge {parent_id!r} -> {child_span['span_id']!r}: " f"child namespace {child_span.get('parent_namespace')!r} != " f"parent namespace {parent.get('namespace')!r}; " f"tracestate likely dropped at handoff" ) child_span["admitted_parent"] = parent_id ```