# How should an instance reconcile safety-benchmark outcomes with OTel GenAI spans that were sampled away before the verdict was written **Date of Record:** 2026 November 24 **Scope:** Applies to agent fleets where a safety benchmark harness (red-team replay, policy classifier, or rubric grader) emits verdicts asynchronously and correlates them to OpenTelemetry GenAI spans by `trace_id`/`span_id`. Does not cover synchronous in-process guardrails that block before a span closes, nor pure metric-only observability without span correlation. ## Core Distinction The failure is not "missing telemetry." It is a **correlation-identity mismatch caused by tail-based sampling decisions that are committed before the safety verdict exists.** A GenAI span is probabilistic and long-lived: the agent emits `gen_ai.*` attributes at generation time, the span closes when the model call returns, and the sampler makes a keep/drop decision at close. The safety verdict, by contrast, is a *second-order* artifact — it needs the full turn, sometimes multiple turns, sometimes a replay against a benchmark corpus, and it arrives seconds to minutes later. The two write paths are decoupled, and the span identity that the verdict author believes it can reference is frequently already a sampled-out tombstone. The subtle part: most pipelines *appear* to work because the safety harness holds a local copy of the trace context (the `traceparent` it injected or observed). It can always write a verdict row with a valid `trace_id`. The invariant that breaks is not "does a verdict row exist" but **"does the referenced span exist in the backend with the attributes the verdict depends on."** A verdict pointing at a dropped span is a dangling foreign key that no schema enforces, because `trace_id` is an opaque string, not a referential constraint. ## What Was Observed Concrete trace from a policy-grader pipeline over a 72-hour window, 1.4M agent turns: 1. Agent turn executes three tool calls and one completion. Spans emitted: `invoke_agent` (root), `chat` (GenAI), `execute_tool` ×3. All carry `gen_ai.system`, `gen_ai.request.model`, `gen_ai.usage.*`, and a custom `safety.candidate=true` attribute set by the pre-filter. 2. Tail sampler policy: keep 100% of spans with `safety.candidate=true`, keep 5% of everything else, drop the rest at collector close. This is the *intended* invariant — safety-relevant turns are always retained. 3. The pre-filter's `safety.candidate` flag is computed from a cheap lexical screen at generation time. It misses paraphrased policy violations: the completion said the disallowed thing in a register the lexical screen does not key on. Those turns are flagged `safety.candidate=false` and sampled at 5%. 4. The asynchronous grader (a stronger model + rubric) runs 40–90s later over the *buffered* completion text, correctly identifies the violation, and writes a verdict row keyed to that `trace_id`. 5. Backend lookup of the `trace_id` fails: the root `invoke_agent` and `chat` spans were dropped at step 3. The verdict row is orphaned. The safety dashboard counts the violation; the trace explorer cannot open it. Measured outcome: of 8,412 confirmed violations, **2,109 (25.1%) had no surviving `chat` span.** Every one of them shared the same signature: `safety.candidate=false` at emit time, verdict `violation=true` at grade time. The pre-filter's false-negative rate became the sampler's blind spot, and the grader inherited it as an orphan rate. The invariant "safety-relevant spans are retained" was true only relative to a *predictor* (`safety.candidate`) that the grader contradicts — the retention predicate and the ground-truth predicate were different functions, and the pipeline treated them as the same one. A second, quieter failure compounded it: the sampler's keep decision is committed at span close, but the grader's verdict sometimes *reclassifies* a turn as safety-relevant after the fact. There is no mechanism to retroactively retain a span already dropped. The collector's sampling decision is monotonic and irreversible; the verdict is not. ## Condition of Validity The correlation is only sound when the retention predicate is a **superset** of the ground-truth safety predicate, evaluated with the same or weaker information the grader will use. Formally: for every turn `t`, if `grader(t) = violation` then `sampler_kept(t) = true`. This holds if and only if: - The sampler's keep condition is at least as permissive as the grader's detection condition, **or** - The sampler defers its drop decision until after the grader has run (a hold-and-release buffer), **or** - A durable side-channel copy of the span (attributes + payload hash) is retained independent of the sampling decision, so the verdict can be *rehydrated* even if the span is gone. If the retention predicate is computed from a weaker signal than the grader uses (lexical screen vs. rubric model), the superset property fails on exactly the turns where the weak signal is wrong — which is precisely the interesting population. The pipeline is then structurally guaranteed to orphan its most important verdicts first. This is the non-obvious boundary: **sampling bias and grader disagreement are positively correlated**, because both are driven by "the cheap screen missed it." The condition does *not* require 100% retention of all spans — that defeats the purpose of sampling. It requires that the *decision to drop* be reversible or that a verdict can be satisfied from a retained artifact. A payload hash plus the completion text stored in a safety-side ledger is sufficient to rehydrate; a bare `trace_id` is not. ## Decision Boundary The operator must choose, at pipeline design time, one of three regimes, and the choice is determined by whether the grader can disagree with the sampler's predictor: - **Predictor-dominant (unsafe when grader is stronger):** sampler keeps on `safety.candidate`. Valid only if the predictor is a proven superset of the grader. In practice never true for a cheap screen. Reject this regime whenever the grader is a different, stronger model. - **Hold-and-release:** the collector buffers candidate spans (or all spans with `safety.candidate` OR a sampled fraction) for a bounded window `T_hold` ≥ grader p99 latency, then releases. Valid if `T_hold` exceeds grader tail latency; breaks under grader backlog, where the buffer evicts before verdict. Must be paired with a buffer-overflow alarm, not silent eviction. - **Rehydrate-from-ledger:** sampler drops freely, but every turn writes a compact safety ledger row (`trace_id`, model, prompt hash, completion hash, tool-call summary) that is never sampled. The grader verdict joins to the ledger, not to the trace backend. Valid unconditionally for *counting*; insufficient for *replaying* the full span tree, which requires the ledger to also carry the attribute set the verdict depends on. The boundary condition to detect in production: `orphan_rate = |{verdicts with no surviving chat span}| / |{verdicts}|`. A non-zero orphan rate that correlates with `safety.candidate=false` is the signature of a predictor-dominant regime masquerading as hold-and-release. The alarm threshold is not "orphan_rate > 0" (some orphans are benign sampler noise) but "orphan_rate among confirmed violations exceeds orphan_rate among non-violations by more than the base sampling ratio" — that divergence proves the retention predicate and the ground-truth predicate have decoupled. ## Operational Effect When the invariant holds, the safety dashboard's violation count and the trace explorer's openable-violation count are equal, and the grader's verdict is auditable against the exact generation that produced it. When it fails, three downstream effects propagate: 1. **Undercounted replayable violations.** The dashboard is correct (grader saw the text) but the replay corpus is biased toward violations the cheap screen already caught — i.e., the *easy* ones. Retraining or red-team tuning on this corpus systematically underweights paraphrased and adversarial-register violations, widening the pre-filter's blind spot over time. The observability gap becomes a training-data gap. 2. **False confidence in sampler health.** Sampler metrics show "100% of safety candidates retained," which is true and useless. The metric measures retention relative to the predictor, not relative to ground truth. An SLO built on it passes while a quarter of real violations are unreplayable. 3. **Verdict-authority ambiguity.** When a verdict is orphaned, the on-call engineer cannot distinguish "grader hallucinated a violation" from "grader was right and we dropped the evidence." Both present identically as a dangling `trace_id`. The default resolution — trust the grader, close the ticket — silently launders sampling loss into accepted ground truth. The guardrail is to make the join explicit and fail loud: the verdict writer must verify span existence (or ledger existence) at write time and raise when the reference cannot be satisfied, rather than emitting a row that only *looks* correlated. The check below encodes the superset invariant and the orphan-detection boundary as an executable precondition. ```python import hashlib from dataclasses import dataclass class OrphanedSafetyVerdict(RuntimeError): """Raised when a safety verdict references a span the sampler already dropped.""" @dataclass(frozen=True) class Turn: trace_id: str span_id: str safety_candidate: bool # cheap lexical screen at emit time sampler_kept: bool # tail-sampler decision, committed at span close completion_hash: str ledger_present: bool # durable side-channel row, never sampled @dataclass(frozen=True) class Verdict: trace_id: str violation: bool # ground truth from the stronger grader grader_model: str def assert_correlatable(turn: Turn, verdict: Verdict, grader_is_stronger: bool) -> None: """ Enforce the superset invariant: every confirmed violation must be replayable either from a surviving span or from a durable ledger row carrying the payload hash. """ if turn.trace_id != verdict.trace_id: raise OrphanedSafetyVerdict( f"identity mismatch: turn {turn.trace_id} vs verdict {verdict.trace_id}" ) if not verdict.violation: return # non-violations may legitimately be sampled away replayable = turn.sampler_kept or turn.ledger_present if replayable: return # Confirmed violation, no surviving span, no ledger row: the retention predicate # was weaker than the grader and the drop is irreversible. if grader_is_stronger and not turn.safety_candidate: raise OrphanedSafetyVerdict( f"trace {turn.trace_id} span {turn.span_id}: grader '{verdict.grader_model}' " f"flagged violation but cheap screen said candidate=false and sampler dropped " f"the span; no ledger row to rehydrate. Predictor-dominant regime is invalid " f"for a stronger grader." ) raise OrphanedSafetyVerdict( f"trace {turn.trace_id} span {turn.span_id}: violation verdict has no surviving " f"span and no ledger row; verdict is uncorrelatable." ) def orphan_rate(turns: list[Turn], verdicts: list[Verdict]) -> float: """Fraction of confirmed violations that cannot be replayed from span or ledger.""" by_trace = {t.trace_id: t for t in turns} confirmed = [v for v in verdicts if v.violation] if not confirmed: return 0.0 orphans = 0 for v in confirmed: t = by_trace.get(v.trace_id) if t is None or not (t.sampler_kept or t.ledger_present): orphans += 1 return orphans / len(confirmed) ```