# What happens when an instance's causal trace rejoins a federated span tree after a sibling has already been garbage-collected **Date of Record:** 2026 November 28 **Scope:** Applies to multi-instance agent runtimes that emit causal trace spans (parent/child links, causal vector clocks) across federated LLM/tool calls where span retention is governed per-instance rather than globally. Does not apply to single-process, single-instance tracing with a unified store and monotonic retention. ## Core Distinction The failure is not "missing telemetry." It is a **causal rejoin against a tombstoned ancestor**. When instance A dispatches a sub-agent call to instance B, B's spans carry a causal parent reference back into A's trace. If A garbage-collects a sibling span (a concurrent tool call, a fan-out branch) before B's completion span arrives, the reconstructed causal graph is *not* merely incomplete—it is *misattributed*. The rejoin algorithm, forced to attach B's completion to a surviving ancestor, silently promotes it to a higher-level cause. The trace still validates structurally (every span has a resolvable parent), so no integrity alarm fires. The corruption is invisible to schema checks and only surfaces when a downstream auditor replays the trace to attribute a failure. The distinction that matters: **span loss is detectable; causal re-parenting is not.** A dropped span leaves a hole. A re-parented span leaves a plausible, wrong edge that is indistinguishable from a correct one at the data layer. ## What Was Observed A three-instance fan-out: orchestrator A spawns workers B and C in parallel; each calls a shared retrieval tool T (instance D). Retention policy on A was 90 seconds of *idle* span lifetime, measured from last child activity. B's tool call to T was fast (~200 ms) and completed, emitting a terminal span. C's path was slow: it entered a reasoning loop, called T three times, and its final completion span arrived at A at t+94 s. At t+90 s, A's reaper collected B's terminal span (idle) and the *edge record* linking A's fan-out node to B. C's completion span arrived at t+94 s carrying a causal parent pointer to the fan-out node. The node itself survived (C was still active under it), but B's branch under it was gone. The rejoin logic walked C's parent chain, found the fan-out node alive, and attached C's completion *as a direct child of the fan-out node*—which is correct for C. The problem was downstream: a replay auditor, reconstructing "which worker caused the tool timeout at T," walked the surviving tree and found only C's branch under the fan-out node. B's successful fast path had been erased, and C's slow path was now the *sole* causal descendant. The auditor concluded C caused the timeout. B was exonerated by erasure. The tell, in retrospect, was a causal-clock inconsistency: C's span carried a vector clock `{A:7, C:3}` while the fan-out node's clock read `{A:7}`—consistent. But B's erased span would have carried `{A:7, B:1}`, and the *absence* of any span with `B` in its clock under a node that dispatched to B is the only detectable signal. No standard trace validator checks for "dispatched-but-no-descendant" because dispatch records and descendant records live in different stores with different retention. ## Condition of Validity The invariant that must hold for causal reconstruction to be sound is: > **For every span S with a causal parent P, either S is retained or a tombstone for S is retained at P recording that S existed and was collected.** This is a *retention coupling* invariant: a parent may not outlive the record of its children's existence. It fails whenever retention is computed per-span-idle rather than per-causal-subtree, and whenever federated instances negotiate retention independently. The condition is violated specifically when: 1. Retention is idle-based and a sibling goes idle while another stays active under the same parent. 2. The federated boundary means the collecting instance (A) does not know B has a child in flight at D that will eventually rejoin A's tree. 3. Rejoin logic treats "parent resolvable" as "causality intact," collapsing existence and liveness into one check. It does *not* fail when retention is subtree-scoped (a parent holds until all known children terminate or are tombstoned), or when the rejoin algorithm distinguishes "parent alive" from "all dispatched children accounted for." ## Decision Boundary The boundary is between two rejoin policies: - **Resolve-to-nearest-live-ancestor (unsound under federation):** attach the arriving span to the deepest surviving ancestor. Cheap, always succeeds, silently misattributes. - **Resolve-or-quarantine (sound):** attach only if the immediate causal parent is live *and* the dispatch record at that parent accounts for the arriving span's identity; otherwise quarantine the span as `orphaned-causal` and emit an explicit gap marker at the parent. The decision turns on whether the runtime can answer, at rejoin time, "did this parent dispatch a child matching this span's causal identity, and is that child's slot still open?" If the dispatch ledger and the span store share retention, resolve-or-quarantine is implementable. If they don't—the common case, because dispatch ledgers are hot-path and spans are cold-path—the runtime *cannot* distinguish a legitimate late rejoin from a re-parenting corruption, and must default to quarantine. The operational rule: **never let a parent span's retention window close before the dispatch ledger entry for each of its children is either resolved or tombstoned.** Retention must be driven by the dispatch ledger's open-child count, not by span idle time. ## Operational Effect Under resolve-to-nearest-live-ancestor, the observable effect is *auditor false attribution*: failure replay assigns cause to whichever branch survived, systematically exonerating fast branches that were collected early and convicting slow branches that stayed alive. This is a survivorship bias baked into the trace substrate—the traces that persist are the traces of the slow, and slow looks guilty. The guardrail is a two-part invariant enforced at the runtime layer: (1) subtree-coupled retention keyed on open dispatch-ledger entries, and (2) a rejoin gate that quarantines any span whose causal identity is not matched by an open ledger slot at its immediate parent. Quarantined spans are still emitted, but flagged `causal_gap=true` and excluded from automated attribution until reconciled. The cost is retention pressure under fan-out; the benefit is that a trace can no longer lie about *which* branch caused a fault by erasing the other. The deeper lesson for agent runtimes: causal trace integrity is not a property of individual spans but of the *retention contract between a parent and its dispatched children*. Federated LLM calls make that contract cross-instance, and any instance that garbage-collects on local idle time unilaterally breaks it for the whole tree. ```python class CausalRejoinViolation(RuntimeError): """Raised when an arriving span cannot be soundly attached to its causal parent because the parent's dispatch ledger no longer accounts for the span's identity.""" pass def rejoin_span(span, parent, dispatch_ledger): # parent: surviving span node; dispatch_ledger: open child slots at parent. # Sound rejoin requires the parent to still hold an OPEN slot matching this # span's causal identity (child_id). A live parent alone is insufficient. if parent is None: raise CausalRejoinViolation( f"span {span.id}: no surviving causal parent; quarantine required" ) open_slots = dispatch_ledger.open_children(parent.id) matched = [s for s in open_slots if s.child_id == span.causal_child_id] if not matched: # Parent alive, but no open slot for this child. Either the slot was # reaped (sibling GC'd early) or this span is a re-parenting artifact. # Attaching here would silently promote span to a higher cause. raise CausalRejoinViolation( f"span {span.id}: parent {parent.id} live but dispatch slot for " f"child {span.causal_child_id} is closed/missing; " f"resolve-to-nearest-live-ancestor would misattribute cause" ) slot = matched[0] slot.close(span.id) return parent.attach(span) ```