# When must an instance treat a reconstructed causal edge as untrusted: attribution collapse from clock-skewed span joins in multi-agent traces **Date of Record:** 2026 November 30 **Scope:** Applies to observability pipelines that reconstruct causal graphs for multi-agent LLM traces by joining child spans to parent spans using wall-clock timestamps and propagated trace/span IDs, then attribute anomalies (latency spikes, token blowups, error bursts) to a specific agent node. Does not apply to single-process, single-threaded agent loops where causality is a strict call-stack order with no cross-instance async fan-out. ## Core Distinction There are two distinct notions of "causal edge" in an agent trace, and conflating them is the failure: 1. **Recorded causality** — the edge declared by context propagation (W3C `traceparent`, OpenTelemetry parent span ID, or an explicit `parent_agent_id` field). This edge is a *claim* made by the emitting agent at span-close time. 2. **Reconstructed causality** — the edge your observability backend *infers* when the declared parent is missing, dropped, or arrives after the child, so the joiner falls back to interval overlap: "child span `[t_start, t_end]` falls inside parent span `[T_start, T_end]`, therefore parent → child." Attribution is only sound when the anomaly is attributed along **recorded** edges. The moment the reconstructor substitutes an interval-overlap edge for a missing declared edge, attribution becomes a *hypothesis about a hypothesis*: the inferred parent is itself a probabilistic guess, and any anomaly budget you push up that edge is contaminated by the guess's error. The invariant: **an anomaly may propagate across a reconstructed edge only if that edge is corroborated by at least one non-temporal signal (shared trace ID + shared agent session token, or an explicit handoff receipt).** Interval overlap alone is never sufficient corroboration. ## What Was Observed A three-agent pipeline (planner → retriever → synthesizer) with an async fan-out in the retriever. The retriever spawned N=8 parallel sub-agents, each closing its span with a `parent_span_id` pointing at the retriever's fan-out span. Under load, the collector's batch exporter dropped the retriever's fan-out parent span (sampling tail-drop on the largest span), but the 8 child spans all arrived intact, each carrying a valid `trace_id` but a `parent_span_id` that resolved to nothing. The reconstructor's fallback rule: "if parent span absent, attach to the temporally-enclosing span in the same trace." Because the planner span had the widest interval and the synthesizer span overlapped the retriever's tail, five of the eight children were re-parented to the **planner**, and three to the **synthesizer**. The true parent (retriever) received zero children. Then the anomaly detector fired: the synthesizer's p99 latency exceeded budget by 4.2×. The attribution walk ascended the reconstructed graph and assigned 61% of the latency budget to the planner node — which had in fact finished 900 ms *before* the offending children even started. The dashboard reported the planner as the "latency root cause." A human on-call spent two hours inspecting planner prompts; the actual cause was a retriever sub-agent stuck in a retry loop against a rate-limited tool, whose span had been mis-attached to the synthesizer and whose cost was then double-counted into the planner's critical path. The tell was structural, not statistical: the reconstructed parent's `end_time` preceded the child's `start_time` by 900 ms — a *negative causal latency*. The joiner accepted it because it only checked interval *containment of the child midpoint*, not monotonicity of `parent.end ≥ child.start`. ## Condition of Validity The reconstruction is valid only when all of the following hold simultaneously. If any is violated, the edge must be marked `inferred_uncorroborated` and excluded from anomaly propagation: - **Clock coherence:** child and parent spans were emitted by processes whose clocks are within the reconstruction tolerance (typically ≤ 50 ms skew after NTP; agent fleets with container cold-starts routinely exceed this). Cross-host fan-out must carry a monotonic clock source or a causal marker, not `time.time()`. - **Monotonic containment:** `parent.start ≤ child.start` AND `child.end ≤ parent.end` AND `parent.end ≥ child.start`. The last clause is the one that catches the negative-latency case above; most joiners omit it. - **Uniqueness of enclosure:** exactly one candidate parent span temporally encloses the child. When a fan-out creates overlapping siblings, enclosure is non-unique and the edge is ambiguous by construction — this is precisely the retriever case. - **Declared-edge completeness:** the child's `parent_span_id` is either resolved or *known-dropped* (the collector emitted an explicit drop record). A dangling `parent_span_id` with no drop record means the exporter's behavior is unknown and the fallback must not run. ## Decision Boundary The boundary is between **repair** and **refuse**. When the declared parent is missing: - If a *single* candidate encloses the child, monotonicity holds, and the trace contains a drop record for the missing parent → **repair** the edge, tag it `inferred_corroborated_by_drop_record`, and allow anomaly propagation with a confidence penalty applied to the attributed budget. - If enclosure is non-unique (fan-out), or monotonicity fails (negative causal latency), or no drop record exists → **refuse**. Emit the child as an orphan node in the graph, attribute its anomaly to the orphan set, and surface an `attribution_gap` metric. Do not push its cost up any edge. The subtle trap: refusing feels like losing data, so pipelines default to "best-effort attach to nearest enclosing span." That default is what produced the 61% misattribution. The correct default is to leave the orphan orphaned and let the anomaly float to the trace root as *unattributed*, which is a truthful statement, rather than pin it to a plausible-but-wrong node, which is a confident lie. ## Operational Effect After enforcing the refuse rule, the `attribution_gap` rate for the fan-out pipeline settled at ~7% of spans (the tail-dropped fan-out parents), all of which now surface as explicit orphans rather than silent misattributions. The on-call's mean-time-to-root-cause for latency anomalies dropped from ~2h to ~18min because the dashboard stopped naming innocent nodes. The cost of the invariant is that ~7% of anomaly budget is reported as "unattributed" — an honest gap — instead of being smeared across the graph. For a causal-attribution system, an honest gap is strictly more valuable than a confident error, because the gap is *actionable* (you go fix the exporter's tail-drop policy) while the confident error sends you debugging the wrong agent. ```python from dataclasses import dataclass from typing import Optional class CausalAttributionError(RuntimeError): """Raised when an anomaly would be attributed across an untrustworthy edge.""" @dataclass class Span: span_id: str trace_id: str parent_span_id: Optional[str] start_ns: int end_ns: int @dataclass class DropRecord: trace_id: str dropped_span_id: str SKEW_TOLERANCE_NS = 50_000_000 # 50 ms def reconstruct_edge( child: Span, candidates: list[Span], drop_records: list[DropRecord], ) -> Span: """Return the corroborated parent for `child`, or raise if the edge is untrusted. Enforces: unique temporal enclosure, monotonic containment (parent.end >= child.start), and a known drop record for the missing declared parent. Refuses otherwise. """ if child.parent_span_id is None: raise CausalAttributionError( f"span {child.span_id} declares no parent; nothing to reconstruct" ) declared_present = any(s.span_id == child.parent_span_id for s in candidates) if declared_present: # Recorded edge — always trustworthy, no reconstruction needed. return next(s for s in candidates if s.span_id == child.parent_span_id) enclosing = [ s for s in candidates if s.trace_id == child.trace_id and s.start_ns <= child.start_ns and child.end_ns <= s.end_ns and s.end_ns >= child.start_ns # monotonicity: no negative causal latency ] if len(enclosing) != 1: raise CausalAttributionError( f"span {child.span_id}: enclosure non-unique ({len(enclosing)} candidates); " "fan-out ambiguity — refusing to reconstruct edge" ) parent = enclosing[0] if parent.end_ns < child.start_ns: raise CausalAttributionError( f"span {child.span_id}: parent {parent.span_id} ends " f"{(child.start_ns - parent.end_ns) / 1e6:.1f} ms before child starts; " "negative causal latency" ) has_drop = any( d.trace_id == child.trace_id and d.dropped_span_id == child.parent_span_id for d in drop_records ) if not has_drop: raise CausalAttributionError( f"span {child.span_id}: declared parent {child.parent_span_id} missing " "with no drop record; exporter behavior unknown — refusing to reconstruct" ) return parent # inferred_corroborated_by_drop_record ```