# What happens when an instance joins a federated trace after a privacy-sampled parent span has been dropped **Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent systems where spans from distinct organizational trust domains are stitched into a single causal trace via cross-org span links (e.g., W3C `traceparent`/`tracestate` propagation across MCP/A2A handoffs), and where each domain independently applies a privacy-preserving sampler (e.g., tail-based or hash-based head sampling) before export. Does not cover single-org tracing, nor systems where all spans are exported unconditionally to a shared collector. ## Core Distinction A *span* records that an agent did work. A *link* records that an agent's work was caused by another agent's work. Distributed trace reconstruction depends on the second, not the first. Most federated tracing designs treat sampling as a per-span property: each org decides whether to keep a span. But causality is a *relationship*, and sampling a relationship's endpoints independently breaks the relationship even when both orgs believe they are behaving correctly. The non-obvious invariant is this: **for a trace to be reconstructable, every retained span must have a retained ancestor-or-link path to the trace root.** Independent per-domain sampling does not preserve this invariant, because a domain can legitimately retain a child span while its cross-org parent span was dropped by the *other* domain's sampler. The result is an orphaned span that is present, valid, and causally unanchored. The trace looks complete to each org in isolation and is silently corrupt when federated. ## What Was Observed A three-org agent pipeline: Org A (planner agent) → Org B (retrieval + tool-execution agent) → Org C (auditor agent). Each org exports spans to its own collector and pushes a sampled subset to a shared federated trace store keyed by `trace_id`. Propagation used `traceparent` with `tracestate` carrying a per-org sampling hint. Org A's sampler was a tail-based sampler configured to keep only traces where the planner emitted an error or a latency above 800 ms. Org B used a deterministic hash sampler at 10%. Org C retained 100% (auditor compliance requirement). A specific incident trace, `trace_id=7f3a…`, ran cleanly: planner succeeded in 640 ms, retrieval succeeded, audit passed. Org A's sampler dropped the root planner span (no error, under latency threshold). Org B's hash sampler happened to retain the retrieval span. Org C retained the audit span. The federated store now contained: - Root planner span: **absent** - Retrieval span (`parent_span_id` → dropped planner span, cross-org link to Org A): **present** - Audit span (`parent_span_id` → retrieval span): **present** Reconstruction walked the audit span back to retrieval, then hit a `parent_span_id` pointing at a span that did not exist in the store. The reconstruction algorithm had two behaviors, both wrong: 1. **Strict mode** raised "missing parent" and marked the entire trace as corrupt, discarding two perfectly valid spans. 2. **Lenient mode** promoted the retrieval span to trace root, silently re-rooting the causal graph. Downstream latency attribution then charged the retrieval agent's 120 ms as "full end-to-end trace duration," understating the true 640 ms planner+retrieval path by 5×. The failure was invisible in per-org dashboards. Org A saw "no trace" (correct, it sampled out). Org B saw "one trace, 120 ms, healthy." Org C saw "one trace, audit passed." Only the federated view was broken, and only in lenient mode did it look *plausible* rather than broken—which is worse. A second-order effect appeared under replay. When the auditor agent replayed the trace for a compliance check, it requested the full trace by `trace_id` from the federated store. The store returned the re-rooted two-span trace. The auditor's verification logic compared the replayed span sequence against its own recorded expectation (planner → retrieval → audit) and concluded the planner step had been *skipped*, flagging a false policy violation. The dropped span, not the agent, was the culprit. ## Condition of Validity The reconstruction invariant holds only under one of these conditions: 1. **Sampling is trace-consistent across the federation.** All domains agree, via a propagated sampling decision in `tracestate`, to keep or drop the *entire trace* atomically. This requires the sampling decision to be made at the root and propagated, which conflicts with tail-based sampling (which cannot decide until the trace ends) and with per-org privacy rules (Org C must keep everything, Org A must drop most things). 2. **Dropped spans are replaced by tombstones.** When a domain's sampler drops a span that other domains may have retained children of, it emits a *tombstone span*: same `span_id`, `parent_span_id`, and `trace_id`, but with no payload, marked `sampled_out=true`, carrying only the structural fields needed for reconstruction. Tombstones are cheap (tens of bytes) and preserve the causal skeleton while satisfying privacy (no attributes, no timing detail beyond coarse buckets). 3. **Reconstruction tolerates gaps explicitly.** The federated store records, per trace, the set of `span_id`s it knows were *supposed* to exist (from propagated `tracestate` ancestry lists), and reconstruction reports "trace incomplete: N spans known-dropped" rather than either erroring or re-rooting. The invariant fails whenever a domain samples a span that is a cross-org ancestor of a span another domain retains, and does not emit a tombstone or a known-dropped marker. This is the default behavior of every off-the-shelf sampler that has no federation awareness. ## Decision Boundary The boundary is whether the sampler operates on **spans** or on **causal edges**. A span-local sampler is correct in a single-org system and incorrect in a federation, because it makes a unilateral decision about a relationship it does not own. The decision boundary for the engineer: - If all participating domains use the *same* sampling policy and the *same* seed derivation over `trace_id`, per-span sampling is safe: the decision is deterministic and identical everywhere, so a dropped parent implies a dropped child. This is the hash-on-`trace_id` case, and it is the only case where independent sampling is sound. - If any domain uses a policy that depends on span content (tail sampling, error-based, latency-based, or privacy-classification-based), the decision is *not* reproducible by other domains, and per-span sampling is unsound. You must either propagate the decision (condition 1) or emit tombstones (condition 2). The trap is that the unsound configuration *works* on the happy path. Traces where the root is retained reconstruct fine. The failure only manifests on traces where a content-based sampler drops an ancestor while a hash-based or 100% sampler retains a descendant—which is exactly the long tail of interesting traces you built the federation to observe. A secondary boundary: tombstones must themselves be exempt from sampling. If Org A's tail sampler drops the planner span *and* the tombstone that would replace it, the invariant is violated again. Tombstones are structural metadata, not telemetry, and must bypass the sampler entirely. ## Operational Effect The operational consequence is that **federated trace completeness is not a property any single org can verify.** Each org's local view is internally consistent. The corruption is a function of the *cross-org sampling policy composition*, which lives in no single domain. This means: - Completeness SLIs must be computed at the federation layer, not per-org. A "trace completeness" metric = (retained spans) / (known spans from `tracestate` ancestry) reveals the gap; per-org metrics never will. - Replay-based verification (auditor agents, compliance checks) must distinguish "span absent because dropped" from "span absent because the agent skipped the step." Without tombstones or known-dropped markers, these are indistinguishable, and the auditor will emit false violations—a verification replay discrepancy caused purely by sampling, not by agent behavior. - Re-rooting must be forbidden in reconstruction. A lenient reconstruction that promotes an orphan to root produces a *plausible* wrong answer, which is more dangerous than a strict error, because it silently corrupts latency attribution, cost attribution, and causal blame in multi-agent incident analysis. The guardrail is a reconstruction function that refuses to silently repair. It must either reconstruct a verified-complete trace or raise, naming the specific missing ancestor and the domain that was supposed to emit it. The following encodes that contract. ```python class TraceReconstructionError(RuntimeError): """Raised when a federated trace cannot be reconstructed without silently re-rooting an orphaned span or discarding causally-anchored spans.""" pass class Span: def __init__(self, span_id, parent_span_id, trace_id, org, tombstone=False, known_dropped=False): self.span_id = span_id self.parent_span_id = parent_span_id self.trace_id = trace_id self.org = org self.tombstone = tombstone # structural placeholder for a sampled-out span self.known_dropped = known_dropped # declared absent via propagated tracestate ancestry def reconstruct_trace(trace_id, spans, expected_span_ids): """ spans: list[Span] present in the federated store for trace_id. expected_span_ids: set of span_ids the federation knows were supposed to exist (from propagated tracestate ancestry lists). Returns an ordered root-to-leaf reconstruction. Raises on any gap that cannot be resolved by a tombstone or a known-dropped declaration. """ by_id = {s.span_id: s for s in spans} present = set(by_id) declared = present | set(expected_span_ids) # Step 1: every retained span's parent must be present, tombstoned, or known-dropped. for s in spans: if s.parent_span_id is None: continue # candidate root if s.parent_span_id not in present and s.parent_span_id not in expected_span_ids: raise TraceReconstructionError( f"trace {trace_id}: span {s.span_id} (org={s.org}) references parent " f"{s.parent_span_id} that is neither retained, tombstoned, nor declared " f"known-dropped. Cross-org sampler dropped an ancestor without a tombstone." ) # Step 2: identify true roots. A span is a root only if it has no parent AND is # declared as a root by the federation, never by promotion. roots = [s for s in spans if s.parent_span_id is None] if len(roots) != 1: raise TraceReconstructionError( f"trace {trace_id}: expected exactly one root, found {len(roots)}. " f"Refusing to re-root orphaned spans." ) root = roots[0] # Step 3: build children map, excluding tombstones from the emitted sequence # but retaining them as structural nodes. children = {} for s in spans: if s.parent_span_id is not None: children.setdefault(s.parent_span_id, []).append(s) # Step 4: walk root-to-leaf; a tombstoned or known-dropped intermediate is a # hard gap that must be reported, not skipped silently. ordered = [] stack = [root] while stack: node = stack.pop() if node.tombstone or node.known_dropped: raise TraceReconstructionError( f"trace {trace_id}: reconstruction path passes through dropped span " f"{node.span_id} (org={node.org}). Trace is incomplete; cannot emit a " f"verified causal sequence." ) ordered.append(node) stack.extend(children.get(node.span_id, [])) # Step 5: completeness check against declared ancestry. missing = declared - present if missing: raise TraceReconstructionError( f"trace {trace_id}: {len(missing)} declared span(s) absent without tombstone: " f"{sorted(missing)}. Federation completeness invariant violated." ) return ordered ``` The lesson for an agent operating in a federated trace: when you request a trace by `trace_id` and receive a reconstruction, do not assume the root you were handed is the true root. Check whether the federation reported known-dropped ancestors. A trace that reconstructs cleanly in lenient mode may be missing the very span that explains the latency, the error, or the policy step you are auditing—and the absence is not a bug in the agent, it is a sampling decision made by a domain you do not control.