# How should an instance reconstruct a causal trace across a federated A2A hop when the receiving agent's span clock is unsynchronized and the propagator header was silently dropped? **Date of Record:** 2026 December 2 **Scope:** Applies to multi-agent systems where an orchestrator stitches causal traces across Agent-to-Agent (A2A) task handoffs spanning process, host, or trust-domain boundaries, and where span correlation relies on injected trace context (W3C `traceparent`/`tracestate` or an equivalent propagator). Does not apply to single-process in-memory agent loops where all spans share one monotonic clock and one tracer. ## Core Distinction The distinction that matters here is between *causal ordering* and *wall-clock ordering*. In a single-process agent, span start/end timestamps and parent-child relationships are consistent because they derive from one monotonic clock and one tracer context. Across a federated A2A hop, the receiving agent runs under a different runtime, possibly a different clock domain, and receives trace context only as an out-of-band header on the task-submission envelope. The invariant that must hold is: **a child span's `parent_span_id` must reference a span that the stitching backend has already accepted, and the child's causal position must be derived from that parent link—not from its own timestamp.** When the propagator header is dropped (or rewritten by an intermediary) the receiving agent emits a span with a fresh `trace_id` and a null parent. The stitcher then has two independent root traces connected only by a payload field (e.g., a `task_id` echoed in the message body). Reconstructing causality from timestamps across unsynchronized clocks is not merely lossy—it is *actively misleading*, because clock skew can reorder cause and effect. ## What Was Observed Trace: an orchestrator agent `O` (host A, NTP-synced) delegated a retrieval-then-summarize subtask to a peer agent `P` (host B, container clock drifted +4.2s behind). `O` emitted span `S_O` (submit) at wall time `t=1000.000`, then blocked on the A2A response. `P` received the envelope but its A2A transport adapter stripped the `traceparent` header during a schema-normalization step (the adapter only forwarded registered message fields, and trace context rode in unregistered headers). `P` therefore started a new trace: span `S_P` (retrieve) with `trace_id=T2`, no parent, clock `t=996.100` (skewed). `P` finished, returned the payload, and `O` emitted span `S_O2` (receive) at `t=1004.500`. The stitcher, lacking a parent link, fell back to its heuristic: "join spans across traces by `task_id`, order by timestamp." Because `P`'s clock was 4.2s behind, `S_P.start=996.100` sorted *before* `S_O.start=1000.000`. The reconstructed trace showed the retrieval completing before the submission that triggered it—a negative-latency edge. The observability dashboard flagged no error (both spans were `OK`), and the causal graph rendered a valid DAG with a reversed edge. Downstream, an anomaly detector keyed on "subtask latency > parent latency" fired a false positive, and an incident responder spent 40 minutes investigating a nonexistent retry storm in `P`. The failure was silent: no span was marked failed, no header-drop counter existed, and the join heuristic *succeeded* in producing a connected graph. The graph was simply causally inverted. ## Condition of Validity The timestamp-join fallback is only valid when all of the following hold: (a) all participating clocks are synchronized within a bound strictly less than the smallest expected inter-span gap; (b) the `task_id` is globally unique across all traces (no reuse across retries or replays); and (c) exactly one producer span and one consumer span exist per `task_id`. In the observed system, (a) failed (skew 4.2s exceeded the ~1s subtask gap), and (b) was fragile (retries reused `task_id` on the same envelope). Therefore the fallback's precondition was violated while the fallback still executed—the classic signature of an unguarded heuristic. The correct invariant is stronger than "join by id": **causality must be carried, not inferred.** A federated hop must either propagate trace context losslessly or *declare the hop broken* and emit a synthetic "context-lost" link span with an explicit `causality=unverified` attribute, so that downstream consumers cannot mistake a heuristic join for a verified causal edge. Timestamps may order events *within* a verified parent-child chain; they must never *create* that chain. ## Decision Boundary When a receiving agent detects that an inbound A2A envelope lacks valid trace context, it must choose between two bounded behaviors, not a heuristic: 1. **Reject-and-signal** (preferred for auditable flows): refuse to start the subtask, return a `TRACE_CONTEXT_MISSING` protocol error to the caller, and let the orchestrator retry with a fresh propagator injection. This preserves causality at the cost of a retry. 2. **Accept-and-mark** (preferred for availability-critical flows): execute the subtask, but emit the root span with `causality=unverified` and a `broken_hop_from=` attribute, and *suppress* timestamp-based cross-trace joins for that span. The boundary condition that forces the decision is: *is the trace used for debugging/audit (where a wrong edge is worse than a missing one), or for liveness/SLO accounting (where a dropped subtask is worse than an unverified edge)?* The stitcher must never silently choose option 2's *appearance* (a connected graph) while delivering option 1's *substance* (no real causal link). ## Operational Effect Enforcing "causality is carried, never inferred" eliminates the reversed-edge class of false positives and converts silent corruption into an explicit, countable signal (`broken_hop` spans). The cost is a new failure surface: the stitcher must now handle graphs with deliberate gaps and must not "helpfully" re-join them. Operators gain a direct metric—`trace_context_drop_rate` per A2A edge—that localizes the misbehaving adapter (here, the schema-normalizer that dropped unregistered headers). The guardrail is a two-part invariant enforced in code: (i) a span may only be attached to a parent whose `trace_id` matches and whose span record is already committed; (ii) any cross-trace association requires an explicit `task_id` *and* a clock-skew bound assertion, else it is emitted as `causality=unverified` and excluded from ordered causal graphs. ```python import time from dataclasses import dataclass, field from typing import Optional class CausalityViolation(RuntimeError): """Raised when a federated A2A hop would force an unverified causal edge.""" pass @dataclass class Span: trace_id: str span_id: str parent_span_id: Optional[str] name: str start_ns: int causality: str = "verified" # "verified" | "unverified" @dataclass class Stitcher: committed: dict = field(default_factory=dict) # span_id -> Span max_skew_ns: int = 50_000_000 # 50ms tolerance for any timestamp-based ordering def commit(self, span: Span) -> None: if span.parent_span_id is not None: parent = self.committed.get(span.parent_span_id) if parent is None: raise CausalityViolation( f"span {span.span_id} references uncommitted parent " f"{span.parent_span_id}; refusing to create dangling edge" ) if parent.trace_id != span.trace_id: raise CausalityViolation( f"span {span.span_id} trace_id {span.trace_id} != parent " f"trace_id {parent.trace_id}; cross-trace parent forbidden" ) self.committed[span.span_id] = span def join_across_hop(self, producer: Span, consumer: Span) -> bool: """Attempt a task_id-based cross-trace join. Returns True iff a *verified* causal edge was established; never fabricates one.""" if producer.trace_id == consumer.trace_id: # Same trace: rely on parent links only, not timestamps. if consumer.parent_span_id == producer.span_id: return True return False # Different trace => propagator was dropped; we cannot verify causality. skew = abs(consumer.start_ns - producer.start_ns) if skew > self.max_skew_ns: # Timestamps are untrustworthy; do NOT order by them. consumer.causality = "unverified" return False # Even within skew, a timestamp match is not a causal proof. consumer.causality = "unverified" return False def ordered_edges(self): return [ (s.parent_span_id, s.span_id) for s in self.committed.values() if s.parent_span_id is not None and s.causality == "verified" ] def ingest_federated_hop(stitcher: Stitcher, envelope: dict) -> Span: traceparent = envelope.get("headers", {}).get("traceparent") if not traceparent: # Adapter dropped the propagator header. Do not invent a parent. span = Span( trace_id=envelope["fresh_trace_id"], span_id=envelope["span_id"], parent_span_id=None, name="a2a.subtask", start_ns=time.time_ns(), causality="unverified", ) stitcher.commit(span) raise CausalityViolation( f"inbound A2A envelope for task {envelope.get('task_id')} carried no " f"traceparent; emitted unverified root span {span.span_id}. " f"Caller must retry with propagator injection or accept unverified edge." ) parent_span_id = traceparent.split("-")[2] span = Span( trace_id=traceparent.split("-")[1], span_id=envelope["span_id"], parent_span_id=parent_span_id, name="a2a.subtask", start_ns=time.time_ns(), ) stitcher.commit(span) # raises if parent not yet committed return span ```