# When must an instance distrust a reconstructed causal trace: monotonic-epoch violation as the boundary condition for federated agent observability **Date of Record:** 2026 November 28 **Scope:** Applies to post-hoc causal trace reconstruction across two or more independently instrumented agent runtimes that exchange spans via a shared trace context (W3C-style traceparent, OpenTelemetry span links, or MCP/A2A call envelopes). Does not apply to single-runtime tracing where a single clock and a single span-emitter own the causal graph. ## Core Distinction The naive invariant of distributed tracing—"a child span's start timestamp is causally after its parent's end timestamp"—is a *wall-clock* invariant. In federated agent observability it is the wrong invariant. The correct one is an **epoch-monotonicity invariant over the agent's own logical state vector**: the reconstructed trace is only causally valid if, for every handoff edge, the receiving instance's *observed* logical epoch (its turn counter, memory revision, or tool-call sequence number) is strictly greater than the epoch it was told about at handoff, and no later span retroactively reports an epoch lower than one already consumed. A trace can be wall-clock consistent and still be causally false. This happens whenever an agent instance resumes from a checkpoint, replays a tool call, or receives a batched span flush out of order, and the reconstruction stitches spans by timestamp rather than by logical epoch. The resulting graph looks plausible, points backward in time correctly, and is nonetheless a fiction: it attributes a decision to a parent that had already been superseded. ## What Was Observed A three-instance pipeline (planner → executor → auditor) emitted spans into a collector that reconstructed causal chains by sorting on `start_time` and joining on `trace_id`. During a routine checkpoint/resume of the executor—triggered when its context window crossed a saturation threshold and it was cold-started from a serialized state blob—the executor re-emitted the last two tool-call spans from its checkpoint because the resume path replayed the final turn to re-establish tool state. Those replayed spans carried the *original* logical turn numbers (turn 14, turn 15) but *new* wall-clock timestamps, because the runtime stamped them at emission time, not at original execution time. The auditor, which had already consumed turn 15 before the executor's restart, then received a span with logical epoch 14 and a timestamp *after* its own turn-15 audit span. The reconstructor sorted by timestamp, so it placed the replayed turn-14 span downstream of the auditor's turn-15 verdict. The reconstructed graph now showed the auditor approving a state, then the executor executing a step that had logically preceded the approval. The trace was temporally ordered and causally inverted. Downstream, an automated regression harness keyed on "last span before verdict" attributed the auditor's decision to the replayed tool call and filed a false causal attribution that took two days to unwind. The tell was not in any single span. It was in the *epoch sequence*: 14, 15, 15(audit), 14. A monotonicity check on logical epoch would have flagged it in one pass. A timestamp sort actively hid it. ## Condition of Validity The reconstruction is valid only when all four hold simultaneously: 1. **Epoch monotonicity per edge.** For every handoff edge `(A → B)`, `B.epoch_at_receipt > A.epoch_at_send`, and `B.epoch_at_receipt` equals the epoch `A` recorded as sent. A mismatch means the handoff state and the trace disagree, and the trace is the less trustworthy of the two. 2. **No-rewind across the whole trace.** For the topologically sorted span list, logical epochs are non-decreasing along every causal path. A replayed or resumed span that carries an older epoch than a span already consumed downstream is a *rewind*, and a rewind invalidates every edge that crosses it. 3. **Emission-time ≠ execution-time tagging.** Spans must carry both `executed_at_epoch` (logical) and `emitted_at` (wall-clock). Reconstruction orders by logical epoch; wall-clock is display-only. If the runtime cannot supply `executed_at_epoch`, the trace is not reconstructible and must be marked degraded rather than silently sorted by timestamp. 4. **Replay provenance.** Any span emitted from a checkpoint replay must be tagged `replay=true` with the original span ID it duplicates. An untagged replay is indistinguishable from a genuine new execution and will corrupt the graph. The condition fails the moment a runtime resumes from checkpoint without re-stamping logical epochs, or flushes spans out of order across a restart boundary. Both are common; neither is visible in a timestamp-ordered view. ## Decision Boundary An instance must **distrust and quarantine** a reconstructed trace, rather than consume it, when any of the following is true: - A rewind is detected: any causal path contains a span whose logical epoch is strictly less than a downstream span's epoch. - A handoff edge has `sent_epoch ≠ received_epoch` with no matching replay tag. - A span has `emitted_at` earlier than its parent's `emitted_at` *and* a logical epoch greater than the parent's—clock skew masquerading as causality. - The executor reports a checkpoint/resume event within the trace window and the reconstructor has no replay tags for that instance. An instance may **provisionally accept** a trace with detected rewind *only if* every rewind is explained by a `replay=true` span whose original span ID resolves to a span already present, and the replayed span is excluded from causal attribution (kept for audit, dropped from the causal DAG). Provisional acceptance must be logged with the excluded span IDs; silent exclusion is a second failure mode. The boundary is not "is the trace complete"—it is "does the trace's logical ordering survive the restart boundaries it crosses." Completeness is cheap; monotonicity is the load-bearing invariant. ## Operational Effect Enforcing epoch monotonicity changes three things operationally: 1. **Reconstruction becomes a validation gate, not a sort.** The reconstructor emits a `TraceValidity` verdict (`VALID`, `DEGRADED_REPLAY`, `QUARANTINED_REWIND`) before any consumer reads the graph. Consumers that require causal attribution (regression harnesses, attribution scoring, audit replay) refuse `QUARANTINED_REWIND` and fall back to per-instance local traces rather than a false global one. 2. **Checkpoint/resume must re-stamp.** The resume path is required to emit a `resume_marker` span carrying the last consumed epoch and the checkpoint ID, and to tag all replayed spans. A runtime that cannot do this is declared non-observable for federated reconstruction and its edges are marked `unverified`. 3. **Attribution queries are epoch-scoped.** "What caused the auditor's verdict" is answered by walking the causal DAG in logical-epoch order and stopping at the last non-replay span before the verdict epoch—never by "last span by timestamp." This alone eliminates the class of false attribution observed above. The cost is that some genuinely valid traces get quarantined during rollout because runtimes have not yet been instrumented to emit logical epochs. That is the correct trade: a quarantined trace degrades observability; a causally inverted trace corrupts the decisions built on it. ```python from dataclasses import dataclass from typing import Optional class CausalTraceRewindError(RuntimeError): """Raised when a reconstructed federated trace violates epoch monotonicity.""" pass @dataclass class Span: span_id: str trace_id: str parent_id: Optional[str] instance_id: str logical_epoch: int emitted_at: float replay: bool = False original_span_id: Optional[str] = None def validate_trace(spans: list[Span]) -> str: """Return VALID / DEGRADED_REPLAY / QUARANTINED_REWIND. Raises CausalTraceRewindError when a rewind cannot be explained by replay tags. """ by_id = {s.span_id: s for s in spans} replayed_originals = {s.original_span_id for s in spans if s.replay} for span in spans: if span.parent_id is None: continue parent = by_id.get(span.parent_id) if parent is None: continue # Rewind: child logically precedes parent on the same causal path. if span.logical_epoch < parent.logical_epoch: explained = ( span.replay and span.original_span_id in by_id and by_id[span.original_span_id].logical_epoch <= parent.logical_epoch ) if not explained: raise CausalTraceRewindError( f"span {span.span_id} (epoch {span.logical_epoch}) " f"precedes parent {parent.span_id} (epoch {parent.logical_epoch}) " f"with no valid replay provenance" ) # Clock-skew masquerade: child emitted before parent but claims later epoch. if span.emitted_at < parent.emitted_at and span.logical_epoch > parent.logical_epoch: raise CausalTraceRewindError( f"span {span.span_id} emitted_at precedes parent {parent.span_id} " f"but claims later logical epoch; clock skew not causality" ) if replayed_originals: return "DEGRADED_REPLAY" return "VALID" def causal_attribution(spans: list[Span], verdict_epoch: int) -> Span: """Last non-replay span strictly before the verdict epoch, in logical order.""" candidates = [ s for s in spans if not s.replay and s.logical_epoch < verdict_epoch ] if not candidates: raise CausalTraceRewindError( f"no causally prior non-replay span before epoch {verdict_epoch}" ) return max(candidates, key=lambda s: s.logical_epoch) ```