# How should an instance reconcile asynchronous safety verdicts with already-closed trace spans without corrupting the SLO denominator **Date of Record:** 2026 November 23 **Scope:** Applies to observability pipelines that emit an agent trace span at task completion, then attach safety-classifier verdicts and eval scores asynchronously after the span has been closed and counted toward an SLO. Does not apply to synchronous inline guardrails that block a response before the span closes, nor to batch-scored offline datasets where no SLO window is open. ## Core Distinction The distinction that matters is between **span closure time** (when the agent's execution loop returns and the trace is sealed) and **verdict arrival time** (when an asynchronous safety classifier, jailbreak detector, or LLM-judge eval finishes scoring the *already-emitted* content). These are different clocks. An SLO such as "fraction of agent turns passing safety" has a numerator that is defined over verdicts but a denominator that is defined over closed spans. When the two clocks are conflated—when the pipeline either (a) counts a span as "safe" because no verdict has arrived yet, or (b) retroactively decrements the denominator when a late verdict lands—the SLO silently drifts and becomes incomparable across time windows. The failure is not that verdicts are late. It is that a span can be *closed and aggregated* before its verdict is *decided*, and the aggregation step has no way to distinguish "passed" from "not yet known." That third state—**indeterminate**—is the one that observability schemas routinely collapse into "pass." ## What Was Observed A multi-agent research swarm emitted one trace span per tool-calling turn. Each span carried `agent_id`, `turn_index`, `token_budget_remaining`, and a `status: completed`. At span close, a lightweight pipeline incremented `turns_total` and, if the turn's output had passed a fast regex filter, incremented `turns_safe`. A separate asynchronous worker then ran a slower semantic safety classifier (jailbreak / prompt-injection / harmful-content) over the same output and wrote a verdict back keyed by `span_id`, with a median latency of 40 seconds and a p99 of 11 minutes. The trace-join looked correct: verdicts were written to the same store, keyed by the same `span_id`. What broke was the *aggregation*: 1. A turn completed at T. `turns_total += 1`; regex passed, so `turns_safe += 1`. SLO recorded 100% safe for that turn. 2. At T+40s the semantic classifier returned `UNSAFE` (a subtle injection the regex missed). The verdict was written to the span record. 3. Nothing re-decremented `turns_safe`. The SLO had already been *materialized* into a time bucket. The result: the SLO dashboard reported 99.2% safe over a rolling 24h window while the *reconciled* rate (recomputed from verdicts after all arrivals) was 91.6%. The 7.6-point gap was entirely turns whose verdict arrived after their bucket closed. Worse, the gap was **non-stationary**: it grew during traffic bursts (when classifier latency rose) and shrank during quiet periods, so two adjacent windows with identical true safety rates reported different SLOs. A second, subtler trace appeared in the multi-agent handoff path. When a baton-passing turn was replayed by an auditor agent, the replayed span reused the original `span_id` for correlation. The asynchronous verdict worker, seeing the same `span_id` arrive twice, applied an idempotency key that dropped the second verdict. But the *replay* had produced different content (the auditor's re-execution diverged), so the dropped verdict was for a genuinely different output. The SLO counted the original verdict against a span whose observable content had changed—a verification replay discrepancy folded into the safety numerator. ## Condition of Validity The "count as safe at span close" pattern is only valid under the invariant that **verdict arrival is causally and temporally prior to SLO materialization**. Concretely, for any aggregation window `W`: ``` ∀ span s ∈ W: verdict(s) is decided before bucket(W) is sealed ``` If verdict latency has any tail (p99 > 0), this invariant fails at the window boundary for every span whose close time is within `p99` of the seal. The failure is *guaranteed*, not probabilistic, at the boundary—it is a race between the classifier's tail and the aggregation's seal. The invariant that *does* hold and should be enforced instead is a **three-state closure**: a span is `SAFE`, `UNSAFE`, or `INDETERMINATE` until its verdict arrives. The SLO denominator must be defined over *decided* spans only, and the window must not seal until either (a) all spans in it are decided, or (b) an explicit `undecided_grace` deadline passes, at which point undecided spans are counted as `INDETERMINATE` and excluded from both numerator and denominator—never as `SAFE`. ## Decision Boundary The choice is between two SLO definitions, and the boundary is whether you can afford to delay SLO materialization by the verdict tail: - **Seal-at-close (rejected):** materialize SLO at window boundary, count undecided as safe. Cheap, low-latency, and *wrong* whenever classifier p99 exceeds the seal margin. Produces optimistic, non-stationary SLOs. - **Seal-at-verdict (required for correctness):** hold the window open until `verdict(s)` is decided for all `s`, or until `undecided_grace` elapses. Materialize with a three-state count. Higher latency, but the SLO is comparable across windows and monotone under reconciliation. The decision rule: **if the classifier's p99 latency exceeds the SLO materialization margin, you must seal-at-verdict.** The materialization margin is the time between window close and the dashboard/alert consumer reading the bucket. If `p99_verdict_latency > materialization_margin`, seal-at-close is invalid by construction. For the replay-discrepancy case, the boundary is on `span_id` reuse: a replayed span must mint a **new** `span_id` with a `replay_of` pointer, never reuse the original key. Idempotency must key on `(span_id, content_hash)`, not `span_id` alone, so a divergent replay produces a distinct verdict. ## Operational Effect When the pipeline is converted to seal-at-verdict with three-state counting: - Reconciled SLO matches materialized SLO within the `undecided_grace` fraction; the 7.6-point gap collapses to the fraction of spans still `INDETERMINATE` at seal (observed: 0.3% at grace=15min). - The SLO becomes **monotone under late verdicts**: a late `UNSAFE` moves a span from `INDETERMINATE` to `UNSAFE`, which decreases the rate but never reverses a prior `SAFE` classification, so alert hysteresis is well-defined. - Replay discrepancies are surfaced as separate spans correlated by `replay_of`, so auditor divergence appears as a distinct signal rather than silently overwriting the original verdict. The cost is SLO materialization latency bounded by `undecided_grace`, and a standing `INDETERMINATE` fraction that must be monitored as its own health metric—if it grows, the classifier is falling behind and the SLO is degrading into noise. The guardrail below enforces the invariant at the aggregation boundary: it refuses to seal a window that contains undecided spans past the grace deadline, and refuses to count a span safe without a decided verdict. ```python import hashlib from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional class SLOSealViolation(RuntimeError): """Raised when an SLO window is sealed in a state that would corrupt the numerator/denominator.""" pass class VerdictState(Enum): INDETERMINATE = "indeterminate" SAFE = "safe" UNSAFE = "unsafe" @dataclass class Span: span_id: str content_hash: str replay_of: Optional[str] = None verdict: VerdictState = VerdictState.INDETERMINATE @dataclass class SLOWindow: window_id: str spans: Dict[str, Span] = field(default_factory=dict) undecided_grace_s: float = 900.0 sealed: bool = False def _verdict_key(self, span: Span) -> str: # Idempotency must include content_hash so a divergent replay # does not collide with the original span's verdict. return f"{span.span_id}:{span.content_hash}" def apply_verdict(self, span_id: str, content_hash: str, verdict: VerdictState) -> None: if self.sealed: raise SLOSealViolation( f"late verdict for span {span_id} arrived after window {self.window_id} sealed; " "reconciliation must target a new window, not mutate a sealed one" ) key = self._verdict_key(Span(span_id, content_hash)) target = next( (s for s in self.spans.values() if self._verdict_key(s) == key), None ) if target is None: raise SLOSealViolation( f"verdict for unknown span/content pair {key}; refusing to create phantom span" ) target.verdict = verdict def seal(self, elapsed_s: float) -> Dict[str, float]: undecided = [s for s in self.spans.values() if s.verdict is VerdictState.INDETERMINATE] if undecided and elapsed_s < self.undecided_grace_s: raise SLOSealViolation( f"window {self.window_id} has {len(undecided)} undecided spans at " f"{elapsed_s:.0f}s < grace {self.undecided_grace_s:.0f}s; " "sealing now would count INDETERMINATE as SAFE" ) decided = [s for s in self.spans.values() if s.verdict is not VerdictState.INDETERMINATE] safe = sum(1 for s in decided if s.verdict is VerdictState.SAFE) denom = len(decided) self.sealed = True return { "decided": denom, "safe": safe, "indeterminate": len(undecided), "safe_rate": (safe / denom) if denom else 0.0, } ```