# What structural signals indicate a severed causal parent in federated trace-context propagation **Date of Record:** 2026 November 21 **Scope:** Applies to distributed agent meshes where spans are propagated via W3C Trace Context (`traceparent`/`tracestate`) across trust boundaries and where a downstream agent's actions must be causally attributable to an upstream initiating task. Does not apply to single-process agent loops or to meshes where each hop re-roots the trace by design. ## Core Distinction The failure is not "missing trace ID." Missing trace IDs are loud—they produce orphan spans and are trivially detected. The non-obvious failure is **structurally valid but causally severed** propagation: a downstream agent emits a `traceparent` whose `trace-id` matches the originator and whose `span-id` is well-formed, but whose `parent-id` points at a span that the *receiving* mesh's span store never witnessed. The trace graph is syntactically intact and semantically broken. Every span in the chain validates against the W3C grammar; the causal edge, however, dangles. This emerges specifically at **federated boundaries** where each domain maintains its own span store and only the `traceparent` header crosses the wire—not the parent span record. The receiving domain cannot distinguish "parent span exists but I never received it" from "parent span never existed." Both render as an unresolvable `parent-id`. Attribution tooling that trusts header integrity alone will happily stitch a chain that never happened. ## What Was Observed During a three-domain mesh run (orchestrator → planner → executor), an incident was traced back to a **re-rooting proxy** sitting at the planner→executor boundary. The proxy, under load, fell back to a "trace hygiene" mode that regenerated the `span-id` but preserved the incoming `trace-id` and set `parent-id` to the *proxy's own* synthetic span. The synthetic span was logged to the proxy's local store, which was never federated. Result: - `trace-id`: preserved, matches originator. - `span-id`: fresh, valid hex. - `parent-id`: points to a span in a store the executor cannot query. The executor's attribution layer saw a well-formed header, accepted the span, and recorded the executor's action as a child of an *unresolvable* parent. When the auditor replayed the trace, the chain from originator to executor action was broken at exactly one edge—but the broken edge was invisible to any check that only validated header grammar or `trace-id` equality. The incident was misattributed to the planner for 40 minutes because the planner's spans were the last *resolvable* nodes in the chain. The tell was a **structural signal**: the ratio of `parent-id` values that resolve within the local store dropped from ~0.98 to ~0.61 for the executor domain specifically, while `trace-id` continuity remained at 1.00. Header-level health checks stayed green throughout. ## Condition of Validity The invariant that must hold for causal attribution to be sound: > For every span `S` received at domain `D`, either `S.parent-id` resolves to a span record present in `D`'s local store, **or** `S` carries an explicit federation marker (`tracestate` vendor key) declaring that the parent is external and naming the trust domain that holds it. Absent either condition, the span is **causally orphaned** even though it is syntactically valid. Attribution across the mesh is only valid over the subgraph of spans that satisfy this invariant. Any consumer that computes "what caused this action" must refuse to traverse a dangling `parent-id` and must instead escalate to the named external domain—or mark the attribution as *incomplete*, never as *root*. The failure mode is bounded when: (a) proxies are forbidden from synthesizing `parent-id` values that are not federated, and (b) receiving domains run a resolution check on ingest and quarantine unresolvable-parent spans rather than accepting them. ## Decision Boundary The operational decision is what to do when `parent-id` fails to resolve locally: - **Accept silently** (the observed failure): the span enters the store, the trace appears continuous, attribution silently drifts to the last resolvable ancestor. Never correct. - **Reject the span**: loses the executor's action entirely; breaks observability. - **Quarantine + escalate**: the span is stored with a `causal_status=unresolved_parent` flag; the `tracestate` is inspected for a federation marker; if a domain is named, a resolution request is issued; if not, the span is surfaced to the auditor as a *causal gap* rather than a root. The boundary between "accept" and "quarantine" must be drawn on **resolvability of the parent edge**, not on header validity. A header can be 100% grammar-valid and still be causally severed. The guardrail is a resolution check at ingest, with the `tracestate` federation marker as the only sanctioned escape hatch. ## Operational Effect Once the resolution check was deployed at the executor boundary, the planner→executor gap surfaced as a discrete `unresolved_parent` count (peaking at 39% of executor spans during the load window) instead of a silent attribution drift. The proxy's synthetic-span fallback was identified within one replay cycle. Attribution queries were changed to return `INCOMPLETE` rather than a nearest-resolvable-ancestor guess, which eliminated the 40-minute misattribution class entirely. The cost is that some traces now report incomplete; the benefit is that no trace reports a *false* causal chain. For agent meshes, a false causal chain is strictly worse than an admitted gap—it redirects remediation to the wrong agent. ```python import re from dataclasses import dataclass from typing import Optional _TRACEPARENT = re.compile( r"^(?P[0-9a-f]{2})-" r"(?P[0-9a-f]{32})-" r"(?P[0-9a-f]{16})-" r"(?P[0-9a-f]{2})$" ) class CausalSeveranceError(RuntimeError): """Raised when a span's parent-id cannot be resolved and no federation marker exists.""" @dataclass class Span: trace_id: str span_id: str parent_id: Optional[str] tracestate: dict def parse_traceparent(header: str) -> Span: m = _TRACEPARENT.match(header.strip()) if not m: raise CausalSeveranceError(f"malformed traceparent: {header!r}") return Span( trace_id=m.group("trace_id"), span_id=m.group("span_id"), parent_id=None, tracestate={}, ) def resolve_causal_parent( span: Span, local_store: dict, federation_marker_key: str = "fed_domain", ) -> str: """ Enforce the causal-parent invariant on ingest. Returns 'ROOT' if span has no parent, 'RESOLVED' if parent is local, or 'EXTERNAL:' if a federation marker names the holder. Raises CausalSeveranceError otherwise. """ if span.parent_id is None: return "ROOT" if span.parent_id in local_store: return "RESOLVED" fed_domain = span.tracestate.get(federation_marker_key) if fed_domain: return f"EXTERNAL:{fed_domain}" raise CausalSeveranceError( f"parent-id {span.parent_id} for span {span.span_id} " f"(trace {span.trace_id}) is unresolved and no federation " f"marker ({federation_marker_key!r}) is present in tracestate; " f"span must be quarantined as causally orphaned." ) def ingest_span(header: str, local_store: dict, tracestate: dict) -> dict: span = parse_traceparent(header) span.tracestate = tracestate # parent-id is carried in the tracestate parent field for this mesh span.parent_id = tracestate.get("parent_id") status = resolve_causal_parent(span, local_store) return {"span": span, "causal_status": status} ```