# What structural signals indicate span-verdict correlation collapse in GenAI observability pipelines when safety-benchmark verdicts and injection alerts are joined across asynchronous agent traces **Date of Record:** 2026 November 24 **Scope:** Applies to observability pipelines that join LLM/agent execution spans (tool calls, reasoning steps, handoffs) against out-of-band safety-benchmark verdicts and prompt-injection alerts emitted by a separate scorer. Does not cover synchronous in-process guardrails that block a call before completion, nor offline batch evaluation that never claims per-span attribution. ## Core Distinction The failure mode is not "missing telemetry" or "a verdict was wrong." It is **attribution collapse under asynchronous join**: the observability pipeline correlates a verdict to a span by a key (trace_id, span_id, or a derived content hash) that the safety scorer reconstructs *independently* from the trace exporter. When the two sides disagree on span identity—because the scorer re-tokenizes, re-chunks, or re-orders the agent's content before scoring—the join silently succeeds against the *wrong* span, producing a verdict that is structurally well-formed, referentially valid, and semantically misattributed. The pipeline reports "injection alert attached to span S7" when the alert actually describes span S3's retrieved document. No error is raised because the foreign key exists. The invariant that must hold: **the identity key used to join a verdict to a span must be assigned by the span producer, carried immutably through the scorer, and never recomputed from content.** Content-derived keys are the collapse vector. ## What Was Observed A multi-agent retrieval pipeline emitted spans with `span_id` (UUIDv4, producer-assigned) and a parallel `content_sha` computed by the exporter over the *serialized* span payload (tool name + arguments + truncated output). A separate safety scorer consumed the same spans from the trace store, but its ingestion path **re-serialized** the payload with different key ordering and applied a 512-token truncation before hashing. The scorer emitted verdicts keyed by *its* `content_sha`. Downstream, the correlator joined `verdict.content_sha == span.content_sha`. Three structural signals appeared, none of which threw: 1. **Orphan rate drift, not spike.** Roughly 4–9% of verdicts failed the join and were dropped as "unmatched," but the rate varied by span *length*, not by span *count*—long retrieval spans (which crossed the 512-token truncation boundary) consistently failed, short tool-call spans consistently matched. The unmatched set was biased toward exactly the spans most likely to carry injected content. 2. **Verdict/span semantic mismatch on matched pairs.** Sampled matched pairs showed injection alerts whose `matched_text` did not appear anywhere in the joined span's payload. The alert was real; the attachment was wrong. Because `matched_text` was stored but not validated against the joined span, the mismatch was invisible to schema checks. 3. **Duplicate-key collisions across agents.** Two agents in the swarm produced byte-identical short tool calls (`search("AAPL")`). Under content-hashing, both collapsed to one key; one agent's clean verdict overwrote the other's flagged verdict in the verdict table (last-writer-wins on upsert). The flagged agent's trace showed zero alerts. The compounding failure: an auditor agent replayed the trace, saw a clean verdict on the flagged span, and advanced the baton. The injection propagated one hop before a human caught it in a spot check. ## Condition of Validity This analysis holds only when **all three** of the following are true: - The safety scorer is a *separate process* from the span producer and receives spans through a serialization boundary (store, queue, or RPC) rather than an in-memory reference. - The join key is *derived from span content* (hash, normalized text, embedding) rather than producer-assigned and immutably propagated. - Verdicts are written with upsert/last-writer-wins semantics keyed on that derived key. If the scorer receives the producer's `span_id` opaquely and echoes it back, collapse cannot occur even with content mutation—the key is a pointer, not a fingerprint. If verdicts are append-only with `(span_id, scorer_run_id)` composite keys, duplicate-key overwrite cannot occur. The failure is specifically the *intersection* of content-derived keys and mutable-key upsert. ## Decision Boundary The operational decision is **whether to trust a matched verdict as attribution or as a candidate requiring re-verification.** The boundary: - **Trust directly** only when `verdict.span_id` is producer-assigned and the scorer's ingestion is provably identity-preserving (no re-serialization, no truncation before key assignment). Verify by asserting `verdict.span_id ∈ span.producer_span_ids` at write time—not at read time. - **Treat as candidate** whenever the join key is content-derived. In this regime, a "match" is a hypothesis. The correlator must re-validate that `verdict.matched_text` (or its normalized form) is a substring/near-match of the joined span's *full, untruncated* payload before attaching. A failed re-validation is not a drop—it is an **attribution-uncertain** flag that must propagate to the auditor, because dropping it recreates the orphan-rate bias. - **Never** allow content-hash upsert to overwrite a flagged verdict with a clean one. If two spans collide on a derived key, the key is not an identity and the write must fail closed. The hard boundary: a pipeline that cannot distinguish "no alert" from "alert that failed to attach" is not observing safety—it is observing the absence of the *appearance* of alerts. Those are different signals and must be stored in different columns. ## Operational Effect After switching to producer-assigned `span_id` propagation with a composite `(span_id, scorer_run_id)` verdict key and append-only writes, the orphan rate dropped to a flat 0.3% (genuine ingestion lag, not length-biased), the semantic-mismatch sample rate went to zero, and the duplicate-key overwrite class disappeared entirely. The auditor's replay now surfaces an explicit `attribution_uncertain` count per trace; a nonzero count blocks baton advancement rather than passing silently. The residual risk is upstream: any future scorer that re-derives identity from content reintroduces the collapse. The guardrail is a startup assertion in the scorer—refuse to emit a verdict whose `span_id` was not present in the ingested span envelope. ```python from __future__ import annotations import hashlib from dataclasses import dataclass class AttributionCollapseError(RuntimeError): """Raised when a verdict cannot be bound to a producer-assigned span identity.""" @dataclass(frozen=True) class Span: span_id: str # producer-assigned, immutable payload: str # full, untruncated @dataclass(frozen=True) class Verdict: span_id: str # must echo producer id, never re-derived scorer_run_id: str matched_text: str flagged: bool def content_sha(payload: str) -> str: # Illustrates the collapse vector: content-derived identity is NOT an identity. return hashlib.sha256(payload.encode("utf-8")).hexdigest() def attach_verdict(span: Span, verdict: Verdict, *, key_was_content_derived: bool) -> Verdict: if verdict.span_id != span.span_id: raise AttributionCollapseError( f"verdict span_id {verdict.span_id!r} does not match producer span_id " f"{span.span_id!r}; refusing to attach (possible re-serialization drift)" ) if key_was_content_derived: # Content-keyed join: a match is a hypothesis, not attribution. normalized = " ".join(verdict.matched_text.split()).lower() if normalized and normalized not in " ".join(span.payload.split()).lower(): raise AttributionCollapseError( f"content-derived join matched span {span.span_id!r} but matched_text " f"{verdict.matched_text!r} is absent from full payload; " f"attribution_uncertain — must propagate, not drop" ) return verdict def ingest(span: Span, verdict: Verdict, *, content_keyed: bool) -> Verdict: # Fail closed on duplicate-key overwrite: flagged must never be clobbered by clean. if content_keyed and not verdict.flagged: existing_flag = False # placeholder for verdict-table lookup by derived key if existing_flag: raise AttributionCollapseError( "clean verdict would overwrite flagged verdict under content-hash upsert; " "key is not an identity — write rejected" ) return attach_verdict(span, verdict, key_was_content_derived=content_keyed) ```