# Why does an instance lose tamper-evidence at the cross-org audit boundary when OpenTelemetry spans are re-exported through a second collector? **Date of Record:** 2026 November 27 **Scope:** Applies to multi-tenant agent fleets where an originating org's agent emits OpenTelemetry spans that must be consumed by a foreign org's auditor, and the export path traverses at least one intermediate collector owned by neither party. Does not apply to single-org traces where the collector and the auditor share a trust root. ## Core Distinction There are two different things people call "tamper-evident audit trail," and they diverge exactly at the org boundary: 1. **Span-level integrity** — each span carries an authenticating digest (e.g., a signature over `trace_id`, `span_id`, attributes, and `previous_span_hash`). Verifying one span proves *that span* wasn't modified. 2. **Trace-level continuity** — the *chain* of spans for one agent task is complete and ordered: no span was dropped, reordered, duplicated, or spliced in from another trace. The failure mode this record covers: **an agent fleet can hold perfect span-level integrity while silently losing trace-level continuity during cross-org re-export.** The receiving auditor verifies every signature, sees 100% "valid," and still cannot prove the agent's reasoning loop is intact — because the intermediate collector is permitted (by spec and by policy) to drop, batch, retry, and reorder spans, and the standard OTel export path does not bind the *set* of spans to a single signed root. The non-obvious part: the tamper-evidence mechanism (per-span signatures) and the tamper surface (the export pipeline's sampling and retry semantics) are owned by different principals. The originating agent signs spans; the intermediate collector decides which spans ever reach the auditor. A collector that drops a span does not *forge* anything — it just makes the surviving chain look shorter, and a shorter chain verifies cleanly. ## What Was Observed A three-agent pipeline (planner → tool-executor → verifier) ran under an originating org's collector. Each agent emitted spans with an HMAC-SHA256 signature over a canonicalized tuple including a `prev_hash` linking to the prior span in the same trace. The intermediate collector was configured with: - `batch` processor, `timeout: 5s`, `max_queue_size: 2048` - `memory_limiter` with `spike_limit_mib` that triggered refusal under load - default `retry_on_failure` with exponential backoff - head-based sampling at the *receiving* collector (`probabilistic: 0.1`) — a setting the originating org never audited because it lived in the foreign org's config. Under a load spike, the tool-executor agent's `execute_tool` span (the one carrying the tool's return value and the verifier's input hash) hit the memory limiter and was refused. The batch processor retried; the retry exceeded the queue and the span was dropped with a `dropped_spans` counter increment that nobody exported. The verifier span, emitted 40ms later, still carried a valid `prev_hash` pointing at the *dropped* span's hash — because the agent computes `prev_hash` from its own local state, not from what the collector accepted. At the auditor, verification ran as: for each received span, check signature and check `prev_hash` resolves to a received span. Result: - The verifier span's `prev_hash` did **not** resolve → flagged. - But the auditor's rule was "flag unresolved links as `ORPHAN`, do not fail the trace." Orphans were counted as informational. - The planner and tool-executor spans that *did* arrive (a retried duplicate of an earlier span, plus the planner's) formed a shorter, self-consistent sub-chain that verified `VALID`. Net observed state: trace reported `VALID` with 3 `ORPHAN` warnings. The tool-executor's actual tool output — the thing the verifier was supposed to check — never reached the auditor. The audit trail was cryptographically intact at the span level and materially false at the trace level. ## Condition of Validity The span-level invariant ("every received span's signature verifies and its `prev_hash` resolves") is only *sufficient* for audit integrity when the following holds: > **Completeness invariant:** the auditor receives a signed *manifest* enumerating the exact set of `span_id`s the originator emitted for the trace, and verification fails closed if the received set is a strict subset of the manifest. Without the manifest, `prev_hash` resolution proves only *local* consistency of whatever arrived. It cannot distinguish "the agent emitted 5 spans and 5 arrived" from "the agent emitted 9 spans, 4 were dropped by a collector, and the 5 that arrived happen to chain." The dropped span's hash is *referenced* but never *required* — a dangling `prev_hash` is an orphan, not a contradiction, unless the verifier treats orphans as fatal. The invariant also requires that the `prev_hash` chain be **anchored**, not merely linked: the first span of a trace must carry a signature over the trace's *total expected span count* or a root commitment (Merkle root) that the originator signs and that the auditor can recompute. A bare linked list with no length commitment is trivially truncatable by any intermediary that drops a tail span. ## Decision Boundary The boundary is between two verification policies that look identical in code but differ in failure semantics: | Condition | Linked-list only (`prev_hash` resolves) | Manifest-anchored (signed set + root) | |---|---|---| | Span dropped by collector | Orphan warning; trace may still verify `VALID` | Set mismatch → `FAIL_CLOSED` | | Tail span dropped | Truncated chain verifies `VALID` | Root commitment mismatch → `FAIL_CLOSED` | | Span duplicated on retry | Duplicate `span_id` — often deduped silently | Manifest count mismatch → `FAIL_CLOSED` | | Span reordered across batches | Chain broken → orphan | Order irrelevant; set matches → `VALID` | | Span spliced from another trace | `prev_hash` mismatch → orphan | Root mismatch → `FAIL_CLOSED` | The decision: **if any principal other than the originator and auditor sits on the export path, span-level signatures are insufficient and a signed completeness manifest is mandatory.** If the path is direct (originator collector → auditor, shared trust root), linked-list verification is adequate and the manifest is optional overhead. Choosing wrong is not a performance tradeoff — it is a correctness tradeoff that fails *open*. The linked-list-only policy produces `VALID` on truncated traces, which is precisely the state a tampering or misconfigured intermediary produces. ## Operational Effect Three concrete consequences observed in production: 1. **Silent truncation reads as health.** Dashboards built on `VALID`/`INVALID` span counts showed 99.97% valid traces throughout the incident. The `ORPHAN` counter existed but was not alertable because orphans are also produced by benign clock-skew and late-arriving spans. The signal was present and unusable. 2. **The `prev_hash` chain is computed from agent-local state, not collector-acknowledged state.** This is the root cause. The agent cannot know a span was dropped, so it keeps chaining from its own view. Fixing this requires either (a) the agent to await collector acknowledgment before advancing `prev_hash` (serializes the loop, unacceptable for latency), or (b) decoupling: agent signs a manifest at trace close that the auditor reconciles against received spans. Option (b) is the only one that preserves the agent's execution loop. 3. **The foreign collector's sampling config is part of your audit surface.** Head-based sampling at the receiving collector silently discards spans *before* signature verification, and the originating org has no visibility into it. Any cross-org audit contract must pin the receiving collector's sampling to `always_on` for audited trace classes, or the manifest reconciliation will fail every trace where sampling fired — turning a silent failure into a noisy one, which is the correct direction. The guardrail: emit a signed `trace_manifest` span at trace close containing the sorted `span_id` list, a Merkle root over span hashes, and the expected count. The auditor recomputes the Merkle root from received spans and fails closed on any mismatch. Orphans become fatal by construction because a missing span changes the root. ```python import hashlib import hmac from dataclasses import dataclass, field class AuditContinuityError(RuntimeError): """Raised when a received trace set does not match the originator's signed manifest.""" @dataclass class Span: span_id: str prev_hash: str payload: bytes signature: str = "" @dataclass class TraceManifest: trace_id: str span_ids: list[str] = field(default_factory=list) merkle_root: str = "" expected_count: int = 0 signature: str = "" def _merkle_root(leaves: list[str]) -> str: if not leaves: return hashlib.sha256(b"").hexdigest() layer = sorted(leaves) while len(layer) > 1: nxt = [] for i in range(0, len(layer), 2): a = layer[i] b = layer[i + 1] if i + 1 < len(layer) else a nxt.append(hashlib.sha256((a + b).encode()).hexdigest()) layer = nxt return layer[0] def build_manifest(trace_id: str, spans: list[Span], key: bytes) -> TraceManifest: ids = sorted(s.span_id for s in spans) root = _merkle_root([s.signature for s in spans]) m = TraceManifest(trace_id=trace_id, span_ids=ids, merkle_root=root, expected_count=len(spans)) body = f"{trace_id}:{','.join(ids)}:{root}:{m.expected_count}".encode() m.signature = hmac.new(key, body, hashlib.sha256).hexdigest() return m def verify_trace(received: list[Span], manifest: TraceManifest, key: bytes) -> None: body = ( f"{manifest.trace_id}:{','.join(manifest.span_ids)}:" f"{manifest.merkle_root}:{manifest.expected_count}" ).encode() expected_sig = hmac.new(key, body, hashlib.sha256).hexdigest() if not hmac.compare_digest(expected_sig, manifest.signature): raise AuditContinuityError("manifest signature invalid — originator identity not established") received_ids = sorted(s.span_id for s in received) if received_ids != manifest.span_ids: missing = set(manifest.span_ids) - set(received_ids) extra = set(received_ids) - set(manifest.span_ids) raise AuditContinuityError( f"span set mismatch: missing={sorted(missing)} extra={sorted(extra)}" ) if len(received) != manifest.expected_count: raise AuditContinuityError( f"count mismatch: received={len(received)} expected={manifest.expected_count}" ) recomputed = _merkle_root([s.signature for s in received]) if not hmac.compare_digest(recomputed, manifest.merkle_root): raise AuditContinuityError( "merkle root mismatch — a span was modified or substituted in transit" ) # Only now is the linked-list check meaningful: the set is proven complete. by_id = {s.span_id: s for s in received} for s in received: if s.prev_hash and s.prev_hash not in {t.signature for t in by_id.values()}: raise AuditContinuityError( f"span {s.span_id} references prev_hash {s.prev_hash} absent from proven-complete set" ) ```