# In what scenarios must an instance reconcile divergent span-parentage across asynchronous observability exporters before trusting a reconstructed decision trace **Date of Record:** 2026 November 23 **Scope:** Applies to agent runtimes that emit OpenTelemetry-style spans (prompt lineage, retrieval provenance, tool/decision spans) through two or more asynchronous exporters whose flush order is not coordinated. Does not apply to single-exporter, synchronous, in-process trace assembly where span parentage is written before the child span closes. ## Core Distinction The failure is not lost telemetry. It is *mis-parented* telemetry that is individually complete and internally consistent. When a retrieval-provenance exporter (vector store client, reranker) and a decision-trace exporter (agent loop, tool calls) flush on independent schedules, the reconstructed trace can attribute a retrieved chunk to the wrong reasoning step, or attribute a tool call to the wrong prompt invocation, without any span being dropped. The trace looks whole. It is wrong at the seams. Observability pipelines that treat "all spans present" as the integrity invariant will silently accept a corrupt causal graph. The distinction that matters: **span presence is not span parentage.** A pipeline can have 100% span coverage and 0% correct causal ordering. Observability correctness is a graph-isomorphism property against the runtime's actual causal history, not a completeness property over the span set. ## What Was Observed A multi-step agent (planner → retriever → synthesizer → tool-caller) emitted spans to two collectors. The decision-trace exporter batched on a 5s timer; the retrieval-provenance exporter flushed on span-close with sub-100ms latency. Each span carried a `trace_id` and a `parent_span_id` assigned at span creation by the runtime, so the *intended* parentage was correct in every span. The corruption arose at the join. The runtime assigned `parent_span_id` lazily: the synthesizer span was created before the retriever span closed, and the runtime backfilled the parent reference from a mutable "current step" pointer. Under concurrent retrieval (two parallel `retrieve()` calls for the same planner step), the second retrieval's close event overwrote the pointer before the synthesizer's parent was serialized. Result: both retrieval spans claimed the planner as parent, and the synthesizer claimed the *second* retriever as parent — even though its prompt context was assembled from the *first* retriever's chunks. The reconstructed trace showed: - Planner span → two retriever children (plausible; parallel retrieval is normal). - Retriever-B → synthesizer child (causally false; synthesizer consumed Retriever-A's output). An auditor replaying the trace to verify "did the agent use the retrieved document it cited?" walked Retriever-B's provenance, found a document that was never in the synthesizer's context, and flagged a hallucinated citation. The citation was correct. The trace was wrong. The verification produced a false positive against a correct agent decision. The tell was a single inconsistency: the synthesizer span's `prompt.context_chunk_ids` attribute (written at prompt-assembly time, immutable) did not intersect Retriever-B's `retrieval.result_ids`. The pipeline had no cross-check between the attribute-level provenance and the span-parentage graph, so it never noticed. ## Condition of Validity The reconstruction is trustworthy only when the following invariant holds at join time, checked per trace: 1. **Parentage-attribute coherence:** for every span with a `parent_span_id`, the child's immutable provenance attributes (consumed chunk IDs, tool-call arguments, prompt hash) must be a subset of, or derivable from, the parent's emitted outputs. A synthesizer whose consumed chunks are not in its parent retriever's results is mis-parented regardless of what `parent_span_id` says. 2. **Monotonic step ordering:** the runtime's step counter (if present) must be strictly increasing along every root-to-leaf path. A child with a step counter ≤ its parent's is a backfill artifact. 3. **Single-parent resolution under concurrency:** when the runtime uses a mutable "current step" pointer for lazy parent assignment, the pointer must be captured (snapshotted) at span *creation*, not at span *close*. If the exporter cannot guarantee snapshot-at-creation, parallel sibling spans will race the pointer. The invariant is *not* "all spans arrive." It is "the parentage graph is consistent with the immutable provenance attributes carried on each span." These are independent; the first can hold while the second fails. ## Decision Boundary An instance must **distrust and re-derive** the trace (rather than accept it) when any of the following hold: - Two or more child spans of the same parent carry overlapping or identical `current_step` snapshots but disjoint output attribute sets — a sign of pointer race. - A child's consumed-provenance attribute set is disjoint from its parent's produced-output set (parentage-attribute incoherence). - Step counters are non-monotonic along a root-to-leaf path. - Exporters have divergent flush latencies exceeding the runtime's step-transition interval (a structural precondition for backfill races). An instance may **accept** the trace when parentage-attribute coherence holds on every edge, step counters are monotonic, and the runtime snapshots parent references at creation. In that regime, exporter async ordering is harmless because parentage was frozen before any flush could interleave. The boundary is sharp: coherence is a per-edge predicate, and a single incoherent edge invalidates the causal claims downstream of it, not the whole trace. Quarantine the subtree, do not discard the trace. ## Operational Effect When the boundary is crossed and the pipeline re-derives parentage from immutable attributes rather than trusting `parent_span_id`, three things change: 1. **False-positive verification collapses.** Auditor replays that previously flagged correct citations as hallucinated (because they walked the wrong retriever's provenance) resolve against the attribute-derived parent. The false-positive rate on citation verification drops to the rate of genuine attribute mismatch. 2. **The re-derivation itself becomes an audit signal.** A trace that required parentage re-derivation is flagged as `parentage_repaired=true` and routed to a lower-trust tier for downstream automated decisions. The repair is not silent. 3. **The runtime is forced to fix the root cause.** Because the pipeline now surfaces pointer-race traces, the lazy-parent-assignment pattern becomes visible in aggregate; the fix is snapshot-at-creation in the runtime, which eliminates the race at source rather than papering over it in the pipeline. The operational invariant to encode: **never let a mutable pointer determine causal parentage in a system whose spans flush asynchronously.** Freeze parentage at span creation, carry provenance as immutable attributes, and let the observability pipeline validate the graph against those attributes rather than against the parent pointer alone. ```python from dataclasses import dataclass, field class ParentageIncoherenceError(RuntimeError): """Raised when a reconstructed span graph contradicts immutable provenance attributes.""" pass @dataclass class Span: span_id: str parent_span_id: str | None step: int consumed_ids: frozenset[str] = field(default_factory=frozenset) # immutable, set at creation produced_ids: frozenset[str] = field(default_factory=frozenset) # immutable, set at close def validate_trace(spans: list[Span]) -> dict[str, str]: """Re-derive parentage from provenance attributes; raise on any incoherent edge. Returns a mapping of span_id -> resolved_parent_span_id for the coherent subtree. """ by_id = {s.span_id: s for s in spans} resolved: dict[str, str] = {} for span in spans: if span.parent_span_id is None: continue parent = by_id.get(span.parent_span_id) if parent is None: raise ParentageIncoherenceError( f"span {span.span_id} references missing parent {span.parent_span_id}" ) # Invariant 1: parentage-attribute coherence. # A child's consumed provenance must be derivable from the parent's outputs. if span.consumed_ids and not span.consumed_ids.issubset(parent.produced_ids): orphaned = span.consumed_ids - parent.produced_ids raise ParentageIncoherenceError( f"span {span.span_id} consumed {sorted(orphaned)} not produced by " f"declared parent {parent.span_id}; parentage pointer is a backfill artifact" ) # Invariant 2: monotonic step ordering along the edge. if span.step <= parent.step: raise ParentageIncoherenceError( f"span {span.span_id} step {span.step} not greater than parent " f"{parent.span_id} step {parent.step}; non-monotonic causal path" ) resolved[span.span_id] = parent.span_id return resolved def audit_decision_trace(spans: list[Span], cited_doc_id: str) -> bool: """Verify a citation against the repaired causal graph, not the raw parent pointer.""" try: resolved = validate_trace(spans) except ParentageIncoherenceError as exc: # Quarantine: do not silently repair; surface for runtime fix. raise ParentageIncoherenceError( f"trace rejected for citation audit; root cause must be fixed at span creation: {exc}" ) from exc synthesizer = next((s for s in spans if s.consumed_ids), None) if synthesizer is None: raise ParentageIncoherenceError("no span carries consumed-provenance attributes") true_parent = resolved.get(synthesizer.span_id) if true_parent is None: raise ParentageIncoherenceError( f"synthesizer {synthesizer.span_id} has no coherent parent edge" ) parent_span = next(s for s in spans if s.span_id == true_parent) return cited_doc_id in parent_span.produced_ids ```