# Which invariants prevent causal trace reconstruction from silently breaking when federated spans are redacted at different privacy tiers **Date of Record:** 2026 November 28 **Scope:** Applies to multi-agent systems where spans from distinct trust domains (e.g., a planner agent, a tool-executor agent, and an external vendor's retrieval agent) are joined into a single causal trace via parent/child span IDs, and where each domain applies its own redaction policy (PII stripping, prompt-content hashing, arg elision) before export. Does not apply to single-tenant tracing where one policy owns the whole trace, nor to log aggregation that does not attempt causal ordering. ## Core Distinction The failure here is not "redaction removes fields." It is that **redaction is a per-domain, order-preserving transformation that is not a homomorphism over the trace's causal join**. Observability systems assume that if span `S` is a child of span `P`, the reconstructed trace preserves the edge `P→S` and the ordering constraints implied by timestamps and parent references. Redaction breaks this in a specific, non-obvious way: independent domains redact *different* fields at *different* granularities, so the join key, the causal edge, and the temporal ordering can each survive in one domain and be destroyed in another. The result is a trace that *reconstructs successfully* — it parses, it has no dangling parents reported as errors — but whose causal graph is silently wrong: edges reroute through placeholder spans, spans from a redacted domain get re-parented to the nearest surviving ancestor, and the reconstructed "causal path" no longer corresponds to the execution that actually happened. The invariant that must hold is: **the causal edge relation and the temporal partial order must be reconstructible from redacted spans alone, without access to the unredacted originals.** Most redaction pipelines satisfy a weaker invariant — "each span is individually well-formed after redaction" — which is not sufficient. A trace can be composed entirely of well-formed redacted spans and still reconstruct into a causally false graph. ## What Was Observed A three-tier federation: Tier A (internal orchestrator, full fidelity, retains `parent_span_id`, `start_ts`, `end_ts`, `prompt_hash`), Tier B (tool-executor agent, retains `parent_span_id` but coarsens timestamps to 1-second buckets and replaces tool arguments with `arg_digest`), Tier C (external retrieval vendor, strips `parent_span_id` entirely for cross-tenant isolation and emits only `trace_id`, `span_id`, and a coarse `observed_at`). The reconstruction service joined spans on `trace_id` and rebuilt the tree by matching `parent_span_id` to `span_id`. For Tier C spans, `parent_span_id` was null, so the joiner treated them as **roots**. The reconstructed trace therefore showed the retrieval calls as top-level roots running in parallel with the orchestrator, not as children of the tool-executor's retrieval step. Because Tier B had coarsened `start_ts` to 1-second buckets, two sibling tool calls that actually ran sequentially (one blocked on the other's output) appeared to start in the same bucket, and the joiner's tie-break (sort by `span_id` lexicographically) reordered them. Downstream, the "critical path" computation attributed 2.3s of latency to the retrieval vendor that actually belonged to a serialization stall in Tier B, and an incident postmortem concluded the vendor was the bottleneck. The vendor was not. The signature is that **no error was raised**. The joiner's dangling-parent check only fires when a `parent_span_id` references a `span_id` that is absent. A *null* `parent_span_id` is a valid root marker. So Tier C's stripped edges were indistinguishable from legitimate root spans. The reconstruction was lossy in the edge relation while remaining structurally valid — the worst class of observability failure, because it produces a confident, wrong narrative. A second, subtler effect: Tier A retained `prompt_hash` for the orchestrator's outbound call to Tier B. Tier B, under its own policy, hashed the *received* prompt with a domain-salted hash. The two hashes for the same logical payload did not match. The reconstruction service used hash equality to deduplicate "the same call observed by both sides," so it kept both spans as distinct nodes, doubling the apparent agent-hop count. The trace looked like the orchestrator called the tool-executor twice. It called it once. ## Condition of Validity The reconstruction is causally faithful only if, for every redacted span, at least one of the following holds: 1. **Edge preservation under redaction:** the domain either retains `parent_span_id` or emits a *causal token* — a non-reversible but equality-comparable identifier (e.g., `HMAC(domain_key, parent_span_id || trace_id)`) — such that the joiner can test edge equality without seeing the raw ID. A null parent must be distinguishable from a *redacted* parent; conflating them is the bug. 2. **Ordering preservation:** timestamp coarsening must be monotone with respect to the happens-before relation. If span `S` happened-after `P`, then `bucket(S) ≥ bucket(P)`, and the equality case must be resolvable by a retained logical clock (Lamport counter or vector clock component) rather than a lexicographic span-ID tie-break. 3. **Identity preservation across domains:** any cross-domain deduplication key (prompt hash, request ID) must be computed over a *normalized, domain-independent* payload with a shared salt, or deduplication must not be attempted across domains. A per-domain salted hash is a valid privacy measure and an invalid join key; using it as both is the contradiction. If none of these hold for a given domain pair, the correct behavior is to **mark the edge as unobservable** and refuse to emit a causal claim across that boundary — not to fall back to root-parenting or span-ID ordering. ## Decision Boundary The boundary between "reconstruct" and "refuse to reconstruct" is crossed at the first span whose parent edge is redacted *and* whose domain provides no causal token. At that point the joiner has two honest options and one dishonest one: - **Honest (degrade):** emit the span as a node of *unknown parentage*, attach it to the trace with an `edge_unobservable` annotation, and exclude it from critical-path and hop-count computations. The trace remains useful for "what happened" but explicitly not for "in what order / under what parent." - **Honest (refuse):** if the query requires causal ordering (e.g., latency attribution, failure propagation), fail the reconstruction with a typed error naming the unobservable boundary. A postmortem that needs the critical path must not silently receive a root-parented graph. - **Dishonest (the observed bug):** treat null parent as root, tie-break equal timestamps by span ID, and emit a confident causal graph. The decision rule: **a causal claim may be emitted across a domain boundary only if the boundary carries an explicit edge token or a shared-normalized join key. Absence of evidence of parentage is not evidence of root status.** This is the invariant that was violated. ## Operational Effect Enforcing the invariant changes three things operationally. First, redaction policies become *contract-bearing*: a domain that strips `parent_span_id` must emit a causal token or declare its spans causally opaque, and the joiner must honor that declaration. Second, the joiner's dangling-parent check must be extended to a **null-parent provenance check**: a null parent is valid only if the span's domain is declared root-capable; otherwise it is an unobservable edge and must be annotated, not root-parented. Third, cross-domain deduplication keys must be validated for normalization equivalence at ingestion — a per-domain salted hash must be rejected as a join key at schema-negotiation time, not silently used and silently failing to match. The cost is that some traces become explicitly partial. The benefit is that a partial trace is *honest*: it says "the retrieval call happened, its parent is unobservable at this trust tier," rather than "the retrieval call was a root that ran in parallel and caused the latency." For agent postmortems and automated failure-attribution loops, the honest partial trace is the only one that does not compound a wrong causal story into the next agent's reasoning context — where a mis-attributed root cause becomes a retrieved "fact" that poisons subsequent planning. ```python import hashlib from dataclasses import dataclass from typing import Optional class UnobservableCausalEdge(RuntimeError): """Raised when a causal edge cannot be reconstructed from redacted spans.""" pass @dataclass class RedactedSpan: trace_id: str span_id: str domain: str parent_span_id: Optional[str] # None may mean root OR redacted parent_causal_token: Optional[str] # HMAC over parent edge, if provided start_bucket: int # coarsened timestamp logical_clock: int # Lamport counter, if retained domain_declares_root_capable: bool join_key: Optional[str] # dedup key, domain-salted or normalized def reconstruct_edge(child: RedactedSpan, known_span_ids: set[str]) -> Optional[str]: """ Return the parent span_id iff the edge is reconstructible. Raise UnobservableCausalEdge if the edge is redacted without a token. """ if child.parent_span_id is not None: if child.parent_span_id not in known_span_ids: raise UnobservableCausalEdge( f"span {child.span_id} references absent parent " f"{child.parent_span_id}; edge is dangling, not root" ) return child.parent_span_id # parent_span_id is None: distinguish true root from redacted edge. if child.domain_declares_root_capable: return None # legitimate root if child.parent_causal_token is not None: # Caller must resolve token against token index; we cannot resolve here, # so signal that resolution is required rather than assuming root. raise UnobservableCausalEdge( f"span {child.span_id} carries causal token {child.parent_causal_token}; " f"resolve via token index, do NOT root-parent" ) raise UnobservableCausalEdge( f"span {child.span_id} in domain {child.domain} has redacted parent " f"and no causal token; parentage is unobservable, refuse causal claim" ) def order_siblings(siblings: list[RedactedSpan]) -> list[RedactedSpan]: """ Order siblings only if ordering is justified by logical clock. Do NOT fall back to lexicographic span_id on equal buckets. """ buckets = {s.start_bucket for s in siblings} if len(buckets) == len(siblings): return sorted(siblings, key=lambda s: s.start_bucket) clocks = {s.logical_clock for s in siblings} if len(clocks) == len(siblings): return sorted(siblings, key=lambda s: s.logical_clock) raise UnobservableCausalEdge( f"cannot order {len(siblings)} siblings: bucket collision without " f"distinct logical clocks; ordering is unobservable" ) def dedup_cross_domain(a: RedactedSpan, b: RedactedSpan) -> bool: """Dedup only on normalized join keys; per-domain salted hashes are invalid.""" if a.join_key is None or b.join_key is None: return False if a.domain != b.domain and not a.join_key.startswith("norm:"): raise UnobservableCausalEdge( f"cross-domain dedup attempted with non-normalized key " f"{a.join_key!r} (domain {a.domain} vs {b.domain}); " f"per-domain salted hashes are not valid join keys" ) return a.join_key == b.join_key ```