# Why does an instance lose causal linkage between a safety verdict and the reasoning span that produced it when traces are sampled independently of evals **Date of Record:** 2026 December 1 **Scope:** Applies to production GenAI observability pipelines that emit reasoning traces (spans), run asynchronous evals/scorers, and attach safety verdicts (classifier hits, guardrail blocks, red-team flags) to those traces. Does not apply to synchronous inline guardrails that block within the request path, nor to single-span systems with no cross-signal join. ## Core Distinction The failure is not "missing telemetry" and not "eval nondeterminism." It is **join-key divergence between three independently-sampled signal streams that share a logical request but not a physical identifier.** A trace is sampled by the tracing SDK (head-based, at span creation). An eval is scheduled by the eval worker (tail-based, on completion, often sampled again for cost). A safety verdict is emitted by a classifier that fires on the *output text* and is keyed by whatever handle the guardrail layer happens to possess — frequently a `request_id`, a `trace_id`, or a hash of the prompt, chosen at integration time and never reconciled. When those three streams disagree on the join key, the pipeline does not error. It produces a **deduplicated, plausible-looking trace graph with the safety verdict silently reattached to the wrong span, or dropped and re-derived from a neighboring trace that shares the same prompt hash.** The observability layer reports a clean correlation rate because the join "succeeded" — it just succeeded against the wrong parent. This is a *continuity invariant* violation: the causal edge `verdict → reasoning_span` is asserted, not verified. ## What Was Observed A production pipeline over a 72-hour window. Three streams: - **Trace stream:** head-sampled at 10% by the OTEL SDK; `trace_id` is a 128-bit W3C value generated at the root span. - **Eval stream:** tail-sampled at 100% of completed requests, scored asynchronously, keyed by the application's `request_id` (a UUIDv4 minted by the API gateway), with `trace_id` attached *only if* the eval worker could recover it from the span context — which it could not, because the eval worker runs in a separate process pool that received `request_id` and the serialized messages, not the OTEL context. - **Safety stream:** classifier fires on final output, keyed by `sha256(prompt + model_id)` because the guardrail team wanted to dedupe repeated prompts and never had access to `request_id`. The pipeline's correlation step joined eval→trace on a fallback: it looked up `trace_id` by matching `request_id` against a span attribute `app.request_id`. That attribute was set on the root span *after* head-sampling decision. For the 90% of requests not head-sampled, no root span existed, so the lookup returned the nearest trace whose `app.request_id` *prefix-matched* — a bug in the fallback matcher that used `startswith` on a truncated ID column. The safety stream joined to eval on `sha256(prompt+model_id)`; for a prompt template with a slot filled by a user-supplied field, two different requests with the same template and same user field collided. Observed outcome over the window: 4,112 safety verdicts. 611 (14.9%) were attached to a trace whose reasoning spans belonged to a *different* request. 203 (4.9%) were attached to no trace and silently dropped by the "orphan verdict" filter, which logged at DEBUG. The dashboard showed `safety_correlation_rate = 0.951` because the metric counted verdicts with *a* trace parent, not verdicts with the *correct* trace parent. The tell: safety verdicts clustered on trace graphs whose reasoning spans contained tool calls the classifier could not have seen in its input text. A human reviewer noticed a `BLOCK` verdict on a trace that never called the blocked tool. That is the signature — **the verdict's evidence is not present in the span it is attached to.** ## Condition of Validity The invariant that must hold for cross-signal correlation to be sound: > For every safety verdict `v` with evidence set `E(v)` (the exact tokens/output the classifier scored), there exists exactly one reasoning span `s` such that `E(v) ⊆ output(s)` and `parent(s) = root(request(v))`, and the join is established by a **single identifier minted before any stream samples**, carried in-band through every stream. Three conditions must hold jointly: 1. **Pre-sampling identifier.** The join key must be generated at request ingress, before head-sampling, and propagated as a first-class field in the trace context, the eval payload, and the safety payload. A key recovered *post hoc* (by attribute lookup, prefix match, or content hash) is not a join key; it is a guess. 2. **Evidence containment check.** The correlation step must verify `E(v) ⊆ output(s)` before asserting the edge. Content-hash joins without this check are unsound whenever the hash input is not unique per request (templated prompts, retries, cached completions). 3. **Orphan verdicts are errors, not noise.** A verdict that fails to join must raise, not be filtered. The DEBUG-level drop is the mechanism by which the 4.9% vanished. The boundary is exact: the moment any stream derives its key from content rather than from an ingress-minted identifier, the correlation is a heuristic and the continuity invariant is unenforced. ## Decision Boundary The operational choice is not "sample more" or "sample less." It is **where the join key is minted relative to the first sampling decision.** - **Sound:** mint `correlation_id` at gateway ingress → inject into OTEL baggage → eval worker reads from baggage → guardrail reads from baggage. Sampling decisions downstream cannot break the join because the key predates them. - **Unsound (observed):** mint `request_id` at gateway, `trace_id` at SDK, `prompt_hash` at guardrail. Three keys, three sampling regimes, one fallback matcher. Correlation becomes a probabilistic guess whose error rate is invisible because the metric measures join *success*, not join *correctness*. The decision boundary is crossed the instant a stream's key is *derived* (hash, prefix, attribute lookup) rather than *inherited* (baggage, in-band context). Derived keys are acceptable only when paired with an evidence-containment check that converts a wrong join into a hard failure. Without that check, derived keys degrade silently and the pipeline reports health it does not have. ## Operational Effect The observable consequence is **safety-signal misattribution that survives audit.** Because the pipeline reports a high correlation rate, downstream consumers — incident review, red-team triage, model-release gates — treat the attached verdicts as ground truth. A `BLOCK` verdict on the wrong trace causes two failures at once: the true offending request is never flagged (its verdict was reattached elsewhere), and an innocent trace is marked. Release gates that threshold on "block rate per trace category" now measure a shuffled distribution. The second-order effect is worse: because the misattribution is *plausible* (verdicts attach to real traces with real reasoning spans), replay-based verification does not catch it. Replaying the eval on the attached trace reproduces the *eval's* score, not the safety verdict's evidence, and the two are never cross-checked. The continuity invariant must be enforced at join time with an evidence-containment assertion; it cannot be recovered after the fact. ## Operational Effect (continued — remediation shape) The guardrail is a pre-sampling `correlation_id` in baggage plus a join-time containment assertion that raises on mismatch. Orphan verdicts must increment an error-class counter, not a debug log. Correlation-rate metrics must be computed as `correct_joins / total_verdicts` where `correct` requires the containment check to pass — otherwise the metric is measuring the bug. ```python import hashlib from dataclasses import dataclass class CorrelationContinuityError(RuntimeError): """Raised when a safety verdict cannot be soundly bound to a reasoning span.""" pass @dataclass(frozen=True) class Verdict: correlation_id: str evidence: str # exact output text the classifier scored label: str @dataclass(frozen=True) class Span: correlation_id: str # inherited from ingress baggage, never derived output: str parent_is_root: bool def bind_verdict_to_span(verdict: Verdict, candidate_spans: list[Span]) -> Span: # Invariant 1: join key must be inherited, not derived. If the verdict's # correlation_id was minted post-hoc, this list will be empty or wrong. matches = [s for s in candidate_spans if s.correlation_id == verdict.correlation_id] if not matches: # Orphan verdict is an ERROR, not debug noise. Do not filter. raise CorrelationContinuityError( f"orphan verdict {verdict.correlation_id}: no span carries the ingress key" ) if len(matches) > 1: raise CorrelationContinuityError( f"ambiguous join for {verdict.correlation_id}: {len(matches)} spans share key" ) span = matches[0] # Invariant 2: evidence containment. The verdict's scored text must appear # in the span it is attached to. A content-hash join that skips this check # is unsound for templated prompts and retries. if verdict.evidence not in span.output: raise CorrelationContinuityError( f"evidence not contained in span {span.correlation_id}: " f"verdict scored {verdict.evidence[:32]!r}, span output differs" ) # Invariant 3: the span must be the root's descendant, not a neighbor. if not span.parent_is_root: raise CorrelationContinuityError( f"span {span.correlation_id} is not rooted at request ingress" ) return span def correlate(verdicts: list[Verdict], spans: list[Span]) -> int: correct = 0 for v in verdicts: try: bind_verdict_to_span(v, spans) correct += 1 except CorrelationContinuityError: # Count as error; never coerce into a "successful" join. raise return correct ```