# Under what conditions must an instance refuse to close a federated trace span when the parent context is a dangling reference **Date of Record:** 2026 November 27 **Scope:** Applies to observability pipelines that stitch OpenTelemetry-style spans emitted by autonomous agents running under separate trust domains, where a child agent receives a serialized trace context (trace_id, parent_span_id) via MCP/A2A handoff but does not share a span store with the caller. Does not apply to single-process, single-vendor tracing where the parent span is guaranteed to be in the same collector. ## Core Distinction The distinction that matters is between a **trace context that is structurally valid** and a **trace context whose parent is provably resolvable**. A federated child agent receives `traceparent` headers that parse perfectly — 32-hex trace_id, 16-hex parent_span_id, flags byte set — yet the parent span may never arrive at the child's collector because the originating domain either dropped the span, sampled it out independently, or restarted its exporter mid-run. The child cannot distinguish "parent span still in flight" from "parent span will never exist." If it closes its span optimistically, the observability backend receives an orphan: a span whose `parent_span_id` points at nothing, which most backends silently re-root as a new trace, destroying the causal chain the pipeline was built to preserve. The invariant is: **a federated span may only be finalized when its parent is either resolved or explicitly declared unresolvable by an authoritative timeout, never by local completion alone.** ## What Was Observed During a three-agent research pipeline (orchestrator → retriever → summarizer), each on a different host with independent OTel collectors, we observed a class of trace corruption that only manifested under load. The orchestrator emitted span `A1` with `trace_id=T`, set `sampled=1`, and handed `traceparent` to the retriever via A2A. The retriever emitted span `B1` as a child of `A1` and forwarded to the summarizer, which emitted `C1` as a child of `B1`. All three spans carried `T`. The failure trace: the orchestrator's collector, under backpressure, applied a tail-sampling policy that dropped `A1` (it exceeded a latency threshold and the sampler classified it as "errored, low value"). `B1` and `C1` were exported successfully to their own domains and forwarded to the central store. The central store received `B1` with `parent_span_id=A1` and `C1` with `parent_span_id=B1`. Because `A1` never arrived, the backend's span-assembly logic re-rooted `B1` as a new trace root, and — critically — `C1`'s parent `B1` *did* arrive, so `C1` stayed attached to `B1`. The result was a trace that appeared complete and internally consistent (`B1` → `C1`) but was missing the entire causal origin. An auditor replaying agent decisions saw the retriever as the root cause of a latency spike that actually originated in orchestrator scheduling. The corruption was invisible: no error, no orphan warning, because the backend's tolerance for late-arriving parents (a 30-second assembly window) expired and it made a *decision* — re-root — that looked like success. A second, subtler observation: when the same pipeline ran with the orchestrator's sampler configured to drop *after* export (head-sampling at 100%, tail-drop at collector), the parent span arrived late but within the window on ~99.2% of traces and was dropped on 0.8%. The 0.8% produced re-rooted traces indistinguishable from the 99.2% in the UI. There was no span attribute marking "parent unresolved at assembly time." The pipeline's own telemetry could not tell you which traces were trustworthy. ## Condition of Validity The re-rooting behavior is *only* acceptable when the child span carries an explicit marker that its parent was unresolved at finalization: a span attribute such as `trace.parent_unresolved=true` plus `trace.parent_expected_span_id=A1`. Without that marker, the backend cannot distinguish a legitimate root from a re-rooted orphan, and any downstream consumer (an auditor agent, a cost-attribution job, a causal-replay verifier) will treat the re-rooted trace as ground truth. The condition under which a child agent *must* refuse to close its span is therefore: it has a `parent_span_id` that is non-empty, it has no local record of the parent span, and it has exceeded a bounded resolution window (which must be shorter than the backend's assembly window, or the backend will have already re-rooted). At that point the child must either (a) hold the span open and emit a `parent_pending` heartbeat until the window closes, or (b) finalize with the explicit unresolved marker. Silent finalization is the invariant violation. ## Decision Boundary The boundary is the **resolution window vs. assembly window ordering**. If `child_resolution_timeout >= backend_assembly_window`, the child will always finalize after the backend has already made its re-rooting decision — the marker arrives too late to suppress the re-root. If `child_resolution_timeout < backend_assembly_window`, the child finalizes with the unresolved marker, the backend sees the marker on arrival, and can either hold the trace in a `pending_parent` state or quarantine it rather than promoting it to a clean root. The rule: the child's resolution timeout must be strictly less than the backend's assembly window, and the backend must treat a span arriving with `parent_unresolved=true` as non-promotable to root. A trace with any unresolved-parent span is a **degraded trace**: usable for latency of the resolved subgraph, not usable for causal root attribution. ## Operational Effect Enforcing this boundary converts a silent, invisible corruption (0.8% of traces re-rooted with no marker) into an explicit, countable signal (`parent_unresolved` span count per trace_id). In the pipeline above, the degraded-trace rate became a first-class metric, and the orchestrator's tail-sampler was reconfigured to emit a tombstone span for every dropped span (a zero-duration span with `sampled=0` and the original `span_id`) so that children could resolve their parent to a *known-dropped* state rather than an *unknown* state. The cost is one tombstone span per dropped span and a bounded hold on child finalization; the benefit is that a causal-replay auditor can now distinguish "this trace is complete" from "this trace is missing its origin" before it attributes a fault to the wrong agent. ```python class UnresolvedParentTraceError(RuntimeError): """Raised when a federated span is about to finalize without a resolvable parent.""" pass def finalize_federated_span( span_id: str, parent_span_id: str | None, parent_resolved: bool, elapsed_since_handoff_s: float, child_resolution_timeout_s: float, backend_assembly_window_s: float, ) -> dict: # Invariant: the child must resolve or mark before the backend re-roots. if child_resolution_timeout_s >= backend_assembly_window_s: raise UnresolvedParentTraceError( f"resolution timeout {child_resolution_timeout_s}s >= assembly window " f"{backend_assembly_window_s}s; child will finalize after backend re-roots" ) if parent_span_id and not parent_resolved: if elapsed_since_handoff_s < child_resolution_timeout_s: # Hold open; do not finalize yet. return {"span_id": span_id, "state": "parent_pending"} # Window expired: finalize only with explicit unresolved marker. return { "span_id": span_id, "state": "finalized_degraded", "attributes": { "trace.parent_unresolved": True, "trace.parent_expected_span_id": parent_span_id, }, } return {"span_id": span_id, "state": "finalized_clean"} ```