# When must an instance abort trace correlation rather than repair a broken span parent chain? **Date of Record:** 2026 November 26 **Scope:** Applies to cross-vendor observability pipelines that ingest agent spans (LLM calls, memory reads/writes, tool invocations) emitted by heterogeneous SDKs and stitch them into a single causal trace via parent/child span IDs. Does not apply to single-vendor, single-SDK telemetry where span context is generated and consumed by one runtime. ## Core Distinction There are two distinct classes of trace-correlation defect, and conflating them produces silent data corruption: 1. **Missing linkage** — a span arrives with no `parent_span_id` or with a parent that has not yet been ingested. This is a *timing* problem, resolvable by a bounded reorder/join window. Repair (deferred stitching) is legitimate. 2. **Contradictory linkage** — a span arrives whose declared parent chain is *internally inconsistent*: the parent's recorded completion timestamp precedes the child's start, the parent's vendor-asserted `trace_id` differs from the child's while both claim the same `parent_span_id`, or the parent chain contains a cycle across vendor boundaries. This is a *provenance* problem. Repairing it fabricates causality that never existed. The non-obvious boundary: pipelines that treat both classes with the same "heal the orphan" logic will happily reattach a memory-write span under a tool-invocation span that never triggered it, because the healer only checks that *some* parent with a matching-looking ID exists. The invariant that must hold is: **a correlation repair is only valid if the repaired edge is consistent with the monotonic causal order of the underlying agent execution.** When it is not, the instance must abort correlation for that subtree and mark it `uncorrelated`, not repair it. ## What Was Observed A three-vendor agent stack: Vendor A (orchestrator, emits `agent.step` spans), Vendor B (memory service, emits `memory.read`/`memory.write` spans with its own `trace_id` namespace), Vendor C (tool gateway, emits `tool.call` spans). A join service correlated them by `trace_id` + `parent_span_id`. Trigger condition: Vendor B's SDK, under retry, re-emitted a `memory.write` span with a *regenerated* span ID but a *reused* `parent_span_id` pointing at the orchestrator step. The original write had already succeeded (the memory service was idempotent), so the retry was a no-op — but the span was emitted with a fresh `start_time` *after* the orchestrator step had already emitted its `end_time`. Meanwhile Vendor C's tool span, which legitimately followed the memory write, carried the *same* `parent_span_id`. The join service saw two children under one parent and, because the healer's "monotonicity check" only compared child start to parent start (not parent end), accepted both. The retried memory-write span, timestamped after the tool call, was sorted *after* the tool span in the reconstructed causal order. Downstream, an evaluation job that read the reconstructed trace concluded the agent "wrote to memory after using the tool," which inverted the actual dependency and caused the eval to flag a false regression in memory-before-action behavior. Failure trace, in order: 1. Parent `agent.step` closes at T=100. 2. Memory retry emits `memory.write` with `parent=agent.step`, `start=T=140`, reused parent ID, new span ID. 3. Tool span emits with `parent=agent.step`, `start=T=110`, `end=T=130`. 4. Healer checks `child.start >= parent.start` → both pass → both attached. 5. Reconstructor sorts children by `start` → memory.write placed last. 6. Eval reads reversed order → false invariant violation. The defect was not the duplicate span; it was the healer accepting a child whose start violated the parent's *closed* interval while a sibling occupied the intervening window. ## Condition of Validity The abort-rather-than-repair rule is valid only when all of the following hold, and the pipeline must *check* them rather than assume: - Parent spans carry both `start_time` and `end_time`, and the emitter is trusted to close spans (a parent that never closes cannot bound its children's validity). - Cross-vendor clock skew is bounded and known (e.g., NTP-synced within a stated epsilon). If skew exceeds the epsilon, timestamp-ordering checks are meaningless and the pipeline must fall back to structural checks only — and flag `skew_unbounded`. - The join window is finite. A child arriving after the window with no parent is `uncorrelated`, never retroactively attached. When clock skew is unbounded, the invariant to enforce is *structural*: a span may not be attached to a parent whose `trace_id` namespace disagrees, and a parent may not have two children with the same logical operation key (operation + target) unless one is explicitly marked a retry with a shared `retry_of` field. Absent that field, duplicate-operation children are a contradiction, not a fan-out. ## Decision Boundary The boundary is a single predicate evaluated per candidate edge: ``` accept(parent, child) := child.start >= parent.start AND child.start <= parent.end + skew_epsilon AND parent.trace_id == child.trace_id AND NOT exists_conflicting_sibling(parent, child) ``` If `accept` is false, the instance must **not** attempt to find an alternative parent. It must emit the child with `correlation_status = "rejected_contradictory"`, preserve the raw `parent_span_id` as `claimed_parent` for audit, and exclude the subtree from causal-order reconstruction. The distinction from "missing linkage" is decisive: missing linkage is repaired by *waiting*; contradictory linkage is resolved by *quarantining*. The subtle trap: a healer that "repairs" by re-parenting the orphan under the nearest temporally-adjacent span will always find *some* candidate, because agent traces are dense. The absence of a valid candidate is not detectable by search — it is only detectable by refusing to search. ## Operational Effect After adopting the abort rule, the pipeline's `uncorrelated` rate rose from 0.3% to 1.1% — the delta being exactly the contradictory subtrees that were previously mis-stitched. The false-regression eval failures dropped to zero. The cost is that ~0.8% of traces are now explicitly partial; downstream consumers must handle `correlation_status != "ok"` by skipping causal-order-dependent analysis rather than silently reading a fabricated order. The operational lesson: in cross-vendor agent observability, the correct action on a contradictory parent chain is quarantine with the claimed edge preserved, because a repaired edge is indistinguishable from a real one to every consumer downstream. ```python class ContradictoryTraceLink(RuntimeError): """Raised when a span's claimed parent chain violates causal monotonicity.""" pass def correlate_span(span, parent_index, skew_epsilon_s=0.050): """ Attach span to its claimed parent only if the edge is causally consistent. Never re-parents. Returns (status, parent) or raises for hard contradictions. """ claimed_id = span.get("parent_span_id") if claimed_id is None: return ("uncorrelated_rootless", None) parent = parent_index.get(claimed_id) if parent is None: # Missing linkage: defer, do not repair. return ("deferred_missing_parent", None) if parent.get("end_time") is None: # Parent never closed; cannot bound children. return ("deferred_open_parent", None) if parent.get("trace_id") != span.get("trace_id"): raise ContradictoryTraceLink( f"span {span['span_id']} claims parent {claimed_id} " f"but trace_id namespaces disagree " f"({span.get('trace_id')} != {parent.get('trace_id')})" ) if span["start_time"] < parent["start_time"]: raise ContradictoryTraceLink( f"span {span['span_id']} starts before its claimed parent {claimed_id}" ) if span["start_time"] > parent["end_time"] + skew_epsilon_s: raise ContradictoryTraceLink( f"span {span['span_id']} starts after parent {claimed_id} closed " f"(start={span['start_time']} end={parent['end_time']})" ) # Duplicate logical operation under one parent without retry marker = contradiction. op_key = (span.get("operation"), span.get("target")) for sibling in parent.get("children", []): if (sibling.get("operation"), sibling.get("target")) == op_key: if sibling.get("retry_of") != span["span_id"] and span.get("retry_of") != sibling["span_id"]: raise ContradictoryTraceLink( f"span {span['span_id']} duplicates operation {op_key} under " f"parent {claimed_id} without retry_of marker" ) return ("ok", parent) ```