# How does an instance detect orphaned parent span links when federated agent traces cross trust domains **Date of Record:** 2026 November 29 **Scope:** Applies to agent runtimes that emit OpenTelemetry-style spans with GenAI semantic conventions and propagate trace context across federation boundaries (A2A handoffs, MCP tool calls into third-party servers, cross-org sub-agent delegation). Does not apply to single-process, single-trust-domain tracing where the full span tree is materialized in one collector. ## Core Distinction A *span link* and a *parent span reference* are not the same invariant. In GenAI semantic conventions, `gen_ai.*` spans frequently carry both a `parent_span_id` (the causal caller) and one or more `links` (e.g., the retrieval span that fed an LLM call, or the peer span in a baton-pass). The distinction that matters operationally: a missing parent is a **structural break** the collector can detect and re-parent; a missing *linked* span is a **silent referential hole** that the collector will happily accept, because OTel permits links to spans that live in another trace or another trust domain and never resolves them. The non-obvious boundary: when an agent federates across a trust domain, the downstream instance receives a `traceparent` and a set of `tracestate`-encoded link references, but it does **not** receive the linked spans themselves. It cannot distinguish "link target exists but is in a domain I can't read" from "link target was never emitted" from "link target was emitted but dropped by a sampler." All three look identical at the receiving instance: an unresolved link ID. The instance must decide, before it acts, whether its causal chain is *intact-but-unreadable* or *actually broken* — and those two require opposite remediations. ## What Was Observed A three-agent pipeline: an orchestrator (trust domain A) delegates to a planner agent (domain B) which calls a retrieval tool hosted as an MCP server (domain C). The orchestrator emits a `gen_ai.orchestrator` span. The planner's first `gen_ai.chat` span carries `parent_span_id = ` (propagated via `traceparent`, resolvable only if A's collector is queried) and a `link` to the retrieval span emitted in C. Failure trace observed in production: 1. Domain C's MCP server emits its retrieval span with a **head-based sampler at 10%**. The `traceparent` it received had `sampled=1` (A and B sample at 100%), but C's local sampler policy is applied *in addition* to the inherited flag — a common misconfiguration where the SDK's `ParentBased(root=TraceIdRatioBased(0.1))` is replaced by a bare `TraceIdRatioBased(0.1)`, discarding the parent decision. The retrieval span is dropped ~90% of the time. 2. The planner's `gen_ai.chat` span still records `links: [{trace_id: T, span_id: R}]`. The link is written unconditionally because the SDK serializes the in-memory span context *before* the sampler decision on the remote side is known to it. 3. Downstream, the auditor agent (domain D) receives the planner's span, sees a link to `R`, and attempts to fetch `R` to verify that the retrieval actually grounded the answer. `R` is absent from C's backend. 4. The auditor's verification logic branches on "link resolvable?" — and treats unresolvable as **hallucination evidence**, flagging a correct answer as ungrounded in 90% of runs. False-positive rate tracked the sampler ratio exactly. The critical observation: the auditor had no way to tell that `R` was *sampled out* rather than *never produced*. The referential hole was indistinguishable from a fabrication. ## Condition of Validity The guardrail below holds only under these conditions, and must be declared invalid otherwise: - The link-emitting instance records a **link disposition** at emit time: `emitted`, `sampled_out`, or `deferred`. This requires the emitting SDK to expose the sampler decision *before* finalizing the link record — achievable by emitting the link with `otel.status`/attribute `link.disposition` set from the `SamplingResult`, not from the in-memory context. - The receiving instance treats an unresolved link as **`indeterminate`**, never as `absent`. `absent` is only assertable when the emitting domain returns an authoritative negative (a signed "no such span" from C's trace backend, or a `deferred` disposition that expired). - The federation handoff carries a **trust-domain manifest** in `tracestate` listing which domains are queryable for which span ranges, so the receiver knows whether "unresolvable" means "can't read" or "doesn't exist." If any of these is missing, the receiver must degrade to `indeterminate` and must not branch verification on link resolution. ## Decision Boundary The instance's decision point is precise: **at the moment it needs the linked span to make a verification claim, not at span receipt.** Receiving a link is cheap; resolving it is a cross-domain RPC with its own latency and failure modes. The boundary is: - If `link.disposition == emitted` **and** the target domain is in the trust manifest **and** the fetch returns the span → link is `resolved`; verification may proceed on its content. - If `link.disposition == sampled_out` → link is `intentionally-absent`; verification must fall back to *other* grounding evidence (the tool's own output hash, a signed retrieval receipt) and must **not** treat absence as fabrication. - If `link.disposition` is missing or `deferred`-expired, or the target domain is not in the trust manifest → link is `indeterminate`; the auditor must abstain from grounding claims and mark the answer `unverified`, never `hallucinated`. - If the target domain is queryable and returns an authoritative "no such span" for a link marked `emitted` → **that** is the only condition under which a broken causal chain is asserted, and it is a genuine protocol violation (the emitter claimed `emitted` but the span is gone). The trap is collapsing `indeterminate` into `absent`. The invariant: **unresolvable ≠ nonexistent; only an authoritative negative from a trusted, queryable domain licenses an `absent` verdict.** ## Operational Effect Before the disposition field, the auditor's false-positive hallucination rate was 90% — exactly C's drop rate — and the team spent two weeks "fixing" a retrieval pipeline that was working correctly. After introducing link disposition plus a trust-domain manifest, the auditor's `unverified` bucket absorbed the sampled-out cases, and the `hallucinated` verdict fired only on genuine emitter-claims-emitted-but-span-gone violations (which turned out to be a real bug: a C-side exporter retry that double-dropped after a 200 OK). The general lesson for federated GenAI tracing: **span links are promises about causality that the emitting domain does not have to keep, and the receiving domain cannot audit.** Any agent that branches on link resolution — grounding checks, provenance scoring, replay verification — must first establish *why* a link is unresolved, or it will measure the remote sampler's configuration instead of the thing it intended to measure. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class LinkDisposition(Enum): EMITTED = "emitted" SAMPLED_OUT = "sampled_out" DEFERRED = "deferred" UNKNOWN = "unknown" class OrphanedLinkError(RuntimeError): """Raised when a link is claimed EMITTED but an authoritative, trusted domain reports the span does not exist. This is a protocol violation, not a sampling artifact.""" pass @dataclass class LinkRef: trace_id: str span_id: str disposition: LinkDisposition = LinkDisposition.UNKNOWN @dataclass class TrustManifest: queryable_domains: set = field(default_factory=set) def can_query(self, domain: str) -> bool: return domain in self.queryable_domains class LinkResolver: """Resolves federated span links without conflating 'unreadable' with 'absent'.""" def __init__(self, manifest: TrustManifest, backend): self.manifest = manifest self.backend = backend # backend.fetch(domain, trace_id, span_id) -> span | None | "NO_SUCH" def resolve(self, link: LinkRef, target_domain: str) -> tuple[str, Optional[dict]]: # Deliberately-absent links never trigger a fetch or a fabrication verdict. if link.disposition is LinkDisposition.SAMPLED_OUT: return ("intentionally-absent", None) if not self.manifest.can_query(target_domain): return ("indeterminate", None) result = self.backend.fetch(target_domain, link.trace_id, link.span_id) if result == "NO_SUCH": if link.disposition is LinkDisposition.EMITTED: # Emitter promised the span; trusted domain says it is gone. raise OrphanedLinkError( f"link {link.trace_id}/{link.span_id} claimed EMITTED " f"but {target_domain} returns authoritative negative" ) return ("indeterminate", None) if result is None: # Transient/unreadable, not an authoritative negative. return ("indeterminate", None) return ("resolved", result) class GroundingAuditor: def __init__(self, resolver: LinkResolver): self.resolver = resolver def verdict(self, link: LinkRef, target_domain: str, answer: str) -> str: status, span = self.resolver.resolve(link, target_domain) if status == "resolved": return "grounded" if span.get("tool_output_hash") else "ungrounded" if status == "intentionally-absent": # Fall back to other evidence; never call absence fabrication. return "unverified" if not self._has_alt_evidence(answer) else "grounded-alt" # indeterminate: abstain from a hallucination claim. return "unverified" @staticmethod def _has_alt_evidence(answer: str) -> bool: return False # placeholder for receipt/hash checks ```