# How does an instance detect trace-eval correlation collapse when an observability pipeline silently drops safety signals under span sampling **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose assurance loop depends on joining three asynchronous signal streams—execution traces (spans), evaluation verdicts (scorer outputs keyed to trace IDs), and safety classifier events (keyed to content hashes or message IDs)—into a single correlated record per agent step. Does not apply to systems where evals and safety signals are emitted synchronously inside the same span they describe, or where sampling is disabled at the trace level. ## Core Distinction The failure is not "the pipeline is down." It is a *correlation collapse*: each stream remains individually healthy, each emits well-formed records, and the pipeline's error rate, latency SLOs, and per-stream volume dashboards all read green—yet the join key that binds a safety verdict to the trace span that produced it has been silently severed for a subset of sampled spans. The agent's assurance controller, which computes "fraction of executed steps with a passing safety verdict," therefore reads a *denominator that includes steps whose safety signal was dropped* and a *numerator that only counts steps whose signal survived*. The resulting assurance metric drifts upward, not downward, because dropped safety events are disproportionately emitted on spans that were sampled out after the fact—and sampled-out spans are exactly the ones the safety classifier flagged as high-entropy. This is distinct from ordinary telemetry loss. Telemetry loss is observable as a volume deficit against a known emission rate. Correlation collapse is a *ratio* failure: the emission rate of safety events is unchanged, but their keys no longer resolve against the retained span set, so they land in an orphan table that nobody joins, and the join in the assurance query returns NULL, which the metric layer coerces to "no violation found." ## What Was Observed A multi-step tool-using agent emitted, per step: one span (with `trace_id`, `span_id`, `parent_span_id`), zero or more eval verdicts (keyed by `span_id`), and zero or more safety events (keyed by `trace_id` plus a `content_digest`). The collector applied *tail-based sampling*: spans were buffered for 30s and retained only if they errored, exceeded a latency threshold, or were marked `sampled_keep=true` by a downstream rule. Safety events were emitted by a separate sidecar that ran *before* the sampling decision and had no visibility into it. Trigger condition: a step produced a safety event of severity `medium` (e.g., a tool argument that tripped a PII heuristic), but the span completed fast, did not error, and was not flagged—so tail sampling dropped the span. The safety event survived, keyed to a `trace_id` whose spans no longer existed in the store. The eval verdict for that span was emitted *after* the sampling decision (scorers ran on retained spans only), so it never existed at all. The failure trace: 1. Step N executes; sidecar emits safety event `S` keyed `(trace_id=T, digest=D)`. 2. Span for step N is buffered by the tail sampler. 3. Span closes fast, no error, no keep-flag → dropped at T+30s. 4. Scorer runs over retained spans only → no eval verdict for step N. 5. Assurance query joins `spans ⨝ evals ⨝ safety ON trace_id`. Step N contributes a safety row with NULL span and NULL eval. 6. Metric layer computes `safety_pass_rate = count(evals where safety=pass) / count(spans)`. Step N is in neither numerator nor denominator of the eval side, but its safety event is counted as an *orphan* and excluded. 7. Net effect: the flagged step vanishes from the assurance denominator entirely. Pass rate rises. The non-obvious part: the agent's *own* self-check, which queried "did any safety event fire on my last step," used the safety table directly (not the join) and correctly saw `S`. The agent believed it was flagged. The assurance controller, reading the joined view, believed it was clean. Two components of the same system held contradictory beliefs about the same step, and both were "correct" against their own data source. ## Condition of Validity The collapse is bounded and detectable only under these conditions: - **Join-key asymmetry must be the failure vector.** If safety events were keyed by `span_id` and the sidecar observed the sampler's keep/drop decision, the event would be dropped in lockstep with the span and the ratio would be preserved. The bug requires that safety events outlive their spans. - **The assurance metric must be a ratio over joined rows.** A ratio over *emitted* safety events (denominator = all safety events, numerator = those with a passing eval) would fall, not rise, and would trigger an alert. The upward drift is specific to denominators anchored on retained spans. - **Sampling must be content-correlated with flagging.** If tail sampling were independent of safety severity, dropped spans would be a random sample and the ratio would be unbiased (just noisier). The bias arises because fast, non-erroring, high-entropy steps—the ones most likely to trip soft safety heuristics without hard failure—are preferentially dropped by latency/error-based sampling rules. When any of these fails to hold, the invariant "assurance pass rate is monotone in true safety" is not violated and the standard orphan-row alert (orphan count > threshold) is sufficient. ## Decision Boundary The architectural invariant required is: **no safety verdict may be counted in an assurance metric unless its join key resolves to a retained span and a retained eval verdict; and any safety event whose span was sampled out must force the span to be retained.** Operationally this means the sampling decision must be *safety-aware and ordered before emission*: the sidecar's severity must be an input to the tail sampler's keep predicate, not a parallel stream. Concretely, the keep rule becomes `keep = error OR slow OR sampled_keep OR safety_severity >= medium`. This converts an orphan into a retained span, restoring the join. The decision boundary for the agent instance is: when the assurance controller's pass rate and the self-check's flag rate *disagree by more than the orphan fraction*, the instance must treat the assurance metric as untrusted and halt continuous-assurance promotion. The detector is not "orphans exist"—orphans always exist at some rate—but "orphan fraction exceeds the fraction of safety events whose severity should have forced retention." A cheap proxy: `orphan_safety_count / total_safety_count > 0` combined with `orphan events all have severity >= medium` is a near-certain signature of the collapse, because medium+ events should have forced retention and therefore should never be orphans. ## Operational Effect Left undetected, the collapse produces *assurance inversion*: the agent's continuous-assurance dashboard improves precisely as it begins taking riskier, faster, unflagged actions, because those are the actions that get sampled out along with their safety signals. The agent, reading its own green dashboard, escalates autonomy. The self-check's contradicting belief is logged but not reconciled, because the two components were never required to agree. The guardrail is a *reconciliation invariant* enforced at the assurance controller: for every step in the last window, `self_check_flag(step) == assurance_view_flag(step)` must hold, and any step present in one view but absent from the other is a *correlation gap*, not a pass. The controller must fail closed on correlation gaps rather than coercing NULL to "clean." This is the same discipline as a database NOT NULL on a foreign key that gates a safety decision: the absence of a verdict is not the absence of a violation. ```python class CorrelationCollapseError(RuntimeError): """Raised when a safety event's join key does not resolve to a retained span+eval, and the event's severity should have forced retention. Indicates trace-eval-safety correlation collapse, not ordinary telemetry loss.""" pass def reconcile_assurance_window( safety_events: list[dict], retained_span_ids: set[str], retained_eval_span_ids: set[str], min_force_retain_severity: str = "medium", ) -> dict: severity_rank = {"low": 0, "medium": 1, "high": 2, "critical": 3} threshold = severity_rank[min_force_retain_severity] orphans_that_should_have_been_retained = [] for ev in safety_events: span_id = ev.get("span_id") sev = severity_rank.get(ev.get("severity", "low"), 0) span_retained = span_id in retained_span_ids eval_retained = span_id in retained_eval_span_ids if not span_retained and sev >= threshold: # A medium+ safety event whose span was sampled out. This is the # collapse signature: retention should have been forced. orphans_that_should_have_been_retained.append(ev) elif span_retained and not eval_retained: # Span survived but scorer never emitted: eval pipeline lag or drop. orphans_that_should_have_been_retained.append(ev) if orphans_that_should_have_been_retained: raise CorrelationCollapseError( f"{len(orphans_that_should_have_been_retained)} safety event(s) of " f"severity >= {min_force_retain_severity} have no resolvable span+eval " f"join. Assurance pass rate is untrustworthy; halt promotion. " f"Sample: {orphans_that_should_have_been_retained[:3]}" ) # Only events with a fully resolved join may enter the assurance denominator. resolved = [ ev for ev in safety_events if ev.get("span_id") in retained_span_ids and ev.get("span_id") in retained_eval_span_ids ] return { "resolved_count": len(resolved), "total_safety_events": len(safety_events), "assurance_trusted": True, } ```