When must an instance refuse to propagate a traceparent across an organizational boundary: the privacy-spanning join hazard in federated agent observability

**Date of Record:** 2026 December 1 **Scope:** Applies to any multi-agent system where spans emitted by LLM agent instances are exported to an observability backend owned by a different organization than the one that produced the span, and where W3C `traceparent`/`tracestate` headers are used to stitch cross-org traces. Does not apply to single-tenant observability where all spans share one trust domain, nor to purely aggregate metrics export with no per-span identifiers.

Core Distinction

The failure is not "PII leaked into a span attribute." That is a content-filtering problem with a known shape: redact, hash, drop. The failure examined here is subtler and structural: **the trace identifier itself is a cross-org join key that re-identifies redacted spans by linking them to spans the receiving org can already attribute.**

A span that has been perfectly scrubbed—no user IDs, no prompts, no tool arguments—still carries a `trace_id` and a `parent_span_id`. When org B (the trace collector) receives a scrubbed span from org A's agent, org B can join that span against its *own* spans in the same trace. If org B's spans in that trace contain the end-user's identity (because org B is the SaaS front-end), then org B can now attribute org A's scrubbed span to a specific user. The redaction of org A's span is defeated not by reading its attributes, but by the *existence of the join edge*.

This is the privacy-spanning join hazard: **trace propagation is a foreign-key injection across a trust boundary, and the foreign key is the personal data.** The invariant that must hold is not "spans are redacted" but "no join edge exists from a span in trust domain A to an identity-bearing span in trust domain B, unless the data subject has consented to that specific join."

What Was Observed

A federated deployment: a customer-support agent platform (org A) runs retrieval and reasoning agents; its spans are exported to a tracing vendor (org B) that also instruments the customer's web front-end. Both use W3C context propagation. A request flows: user → org B front-end → org A agent (via MCP) → org A tool calls.

Observed trace after a "privacy-preserving" export pass:

  1. Org A's exporter ran a redaction transform: `gen_ai.prompt`, `gen_ai.completion`, `tool.args`, `enduser.id`, and `net.peer.ip` were stripped from every span. A span-attribute allowlist was enforced. This passed review.
  2. The `traceparent` header was propagated unchanged, because dropping it would break distributed tracing, and "trace IDs are not personal data" was the stated assumption.
  3. Org B, holding the front-end spans, could resolve `trace_id → session → authenticated user` from its own data. It then joined to org A's scrubbed `agent.invoke` span, which carried `gen_ai.agent.name`, `tool.name`, and timing.

The concrete leak: org B could determine *which* users' requests triggered *which* org A tools, and at what latency. Combined with `tool.name` (e.g., `fetch_billing_record`, `escalate_to_human`), this reconstructed sensitive behavioral attributes—"user X's request caused an account-escalation tool call"—despite every attribute on org A's span being individually non-identifying. The re-identification came entirely from the join, not the span.

Two secondary observations:

Condition of Validity

The join hazard is *latent* (no leak) under any of these conditions, and *live* when all hold:

  1. **Shared trace ID across the boundary.** The `traceparent.trace-id` is byte-identical on both sides of the trust boundary. If the boundary terminates and restarts the trace (new `trace_id` on egress), the join edge does not exist.
  2. **Identity resolvable on the receiving side.** Org B can map the trace (or any span in it) to a natural person using data it already holds. If org B holds only anonymized session tokens with no re-identification path, the join is harmless.
  3. **Correlated attributes on the exported span.** The scrubbed span carries *some* attribute (agent name, tool name, timing bucket, error class) that is itself sensitive when attributed to the resolved identity. A span with a single `span.kind=INTERNAL` attribute and no semantics is not exploitable.
  4. **No consent or contractual basis for the join.** The data subject consented to org A processing their request and to org B processing their front-end session, but not to the *cross-org linkage* of the two. Consent to each processing is not consent to the join.

If any one condition fails, the hazard is bounded. The operational mistake is treating condition 1 as an implementation detail ("trace IDs are opaque") rather than as the load-bearing privacy control.

Decision Boundary

The decision is not "export or don't export." It is **who owns the trace ID at the boundary, and whether the join is licensed.**

The boundary test an instance must run before egress: *for each span I am about to export, can the receiver join it to a person, and is that join licensed?* If the answer is "yes, and no," the instance must terminate the trace, not scrub it harder.

Operational Effect

Enforcing boundary-terminating traces changes three things in the agent runtime:

  1. **The exporter gains a trust-domain gate.** Before serializing, it checks whether the destination trust domain equals the source. On mismatch, it mints a new `trace_id`, preserves the original in a local `linkage` record keyed by the new ID, and strips `tracestate` entirely. The original `traceparent` is never serialized into the outbound envelope.
  2. **Retry semantics must be made explicit in the span model.** A retried tool call must emit a new span with `retry.attempt` and a `parent_span_id` pointing at the *logical* operation, not the failed attempt, or the receiving side will fork the trace. The receiving side must reject spans whose `parent_span_id` is already closed (a closed-parent violation) rather than silently accepting them into a second timeline.
  3. **The allowlist must cover the envelope, not just the body.** `tracestate`, baggage, and any vendor headers are part of the export surface and must be filtered by the same policy as span attributes. A tenant hint in `tracestate` is a span attribute in disguise.

The residual risk after termination: org B can still correlate *timing* of its own front-end spans with *aggregate* latency reported by org A, and if org A reports per-request latency keyed by a request ID it shares out-of-band, the join reappears. The invariant must extend to any side channel that re-establishes the edge, not just the trace header.

The code below encodes the egress gate as a hard precondition: an instance that is about to export a span whose trace ID originated in a different trust domain, without a licensed join, must raise rather than emit.

from __future__ import annotations

from dataclasses import dataclass, field
from enum import Enum
from typing import Optional


class TrustDomain(str, Enum):
    ORG_A = "org-a"
    ORG_B = "org-b"


class UnlicensedCrossDomainJoin(RuntimeError):
    """Raised when a span would create a join edge across a trust boundary
    without an enumerated, consented basis for that join."""


class ClosedParentViolation(RuntimeError):
    """Raised when a retry span points at a parent already closed on the
    receiving side, which would fork the trace into a second timeline."""


@dataclass(frozen=True)
class Span:
    trace_id: str
    span_id: str
    parent_span_id: Optional[str]
    origin_domain: TrustDomain
    attributes: dict = field(default_factory=dict)
    # True if the receiving side can resolve this trace to a natural person.
    identity_resolvable_at_receiver: bool = False


@dataclass(frozen=True)
class ExportPolicy:
    destination: TrustDomain
    # Enumerated join licenses, keyed by (origin, destination). Empty = no join.
    licensed_joins: frozenset = frozenset()
    # Attributes that are sensitive-when-attributed; must be coarsened or absent.
    sensitive_when_attributed: frozenset = frozenset(
        {"tool.name", "gen_ai.agent.name", "enduser.id", "net.peer.ip"}
    )


def gate_egress(span: Span, policy: ExportPolicy) -> Span:
    """Return a span safe to export, or raise. Never returns a span that
    carries an unlicensed cross-domain join edge."""
    cross_domain = span.origin_domain != policy.destination

    if not cross_domain:
        return span

    join = (span.origin_domain, policy.destination)
    if join not in policy.licensed_joins:
        # The trace ID is a foreign key to the receiver's identity graph.
        # Scrubbing attributes does not remove the edge; we must terminate it.
        raise UnlicensedCrossDomainJoin(
            f"refusing to export trace {span.trace_id!r} from "
            f"{span.origin_domain.value} to {policy.destination.value}: "
            f"no licensed join {join!r}. Terminate the trace (mint a fresh "
            f"trace_id and keep the original in a local linkage table) instead "
            f"of scrubbing attributes."
        )

    if span.identity_resolvable_at_receiver:
        leaked = set(span.attributes) & policy.sensitive_when_attributed
        if leaked:
            raise UnlicensedCrossDomainJoin(
                f"licensed join {join!r} permits propagation, but span "
                f"{span.span_id!r} carries {sorted(leaked)!r}, which is "
                f"sensitive when attributed to a resolvable identity. "
                f"Coarsen these attributes before egress."
            )

    return span


def accept_span(span: Span, closed_span_ids: set[str]) -> Span:
    """Receiving-side guard against retry-forked traces."""
    if span.parent_span_id is not None and span.parent_span_id in closed_span_ids:
        raise ClosedParentViolation(
            f"span {span.span_id!r} references parent {span.parent_span_id!r} "
            f"which is already closed on this side; accepting it would fork "
            f"trace {span.trace_id!r} into a second timeline. The retry must "
            f"re-parent to the logical operation, not the failed attempt."
        )
    return span


def terminate_trace(span: Span, new_trace_id: str) -> Span:
    """Boundary-terminating rewrite: fresh trace_id, original kept locally."""
    return Span(
        trace_id=new_trace_id,
        span_id=span.span_id,
        parent_span_id=None,
        origin_domain=span.origin_domain,
        attributes=dict(span.attributes),
        identity_resolvable_at_receiver=False,
    )