How does an instance detect when trace-correlated safety verdicts are being retroactively misattributed across a resumed agent run

**Date of Record:** 2026 December 1 **Scope:** Applies to observability pipelines that join asynchronous safety-classifier verdicts back onto agent spans by a run/span identifier after the agent has checkpointed and resumed. Does not apply to synchronous inline moderation where the verdict is produced within the same span lifetime, nor to purely offline batch scoring that never feeds back into execution control.

Core Distinction

The failure is not "the safety classifier was wrong." It is that the *correlation key* used to attach a late-arriving verdict to a span is not stable across a checkpoint/resume boundary, so a verdict computed against one execution attempt is written onto a different attempt's span. The observability layer reports a clean, causally consistent trace; the safety signal is real; the *binding* between them is fabricated. This is a provenance-integrity failure masquerading as a classification-quality failure, and it is invisible in aggregate dashboards because both the trace and the verdict are individually well-formed.

The distinction that matters operationally: a misattributed verdict is *not* detectable by comparing verdict confidence to span content in the general case (classifiers disagree with themselves across attempts anyway). It is detectable only by comparing the *identity* of the attempt the verdict was computed against to the identity of the attempt the span belongs to — a join-condition audit, not a content audit.

What Was Observed

An agent run `R` executes attempt `A1`, emits spans `s1..s40`, then blocks on a long tool call and checkpoints. The orchestrator's resume logic re-materializes the run as attempt `A2` with a *reused* `run_id` but a fresh `attempt_id`, and — critically — span IDs are generated deterministically from `(run_id, step_index)` rather than from `(attempt_id, step_index)`. Step indices restart at 0 on resume because the checkpoint stored step *content* but not a monotonic step counter.

The safety classifier consumes spans asynchronously through a queue with a p99 lag of ~40 seconds. Verdicts for `A1`'s spans `s30..s40` are still in flight when `A2` begins emitting spans with the *same* IDs `s1..s10`. The correlator joins on `span_id` alone. Result:

The trace view shows a coherent story: every span has exactly one verdict, latencies sum correctly, cost attribution is consistent. The safety dashboard shows a run that was flagged and then… not flagged, with the flag appearing on a step whose content does not match. An SRE investigating a downstream incident reads the trace, sees the flag on a benign step, concludes the classifier is noisy, and suppresses it.

The tell — visible only in raw storage, not in the joined view — is that the verdict's `computed_at` timestamp precedes the span's `start_time`. The correlator had the information to reject the join and did not check it.

Condition of Validity

The invariant that must hold for a verdict-to-span join to be sound is:

> A verdict `v` may be attributed to span `s` only if `v.computed_at ≥ s.start_time` **and** `v.attempt_id == s.attempt_id`, where `attempt_id` is unique per materialization of the run and is carried on both the span and the verdict's input envelope.

The failure occurs precisely when *both* of the following hold: (a) span identity is derived from a key that is stable across resume (`run_id` + step index), and (b) the classifier's input envelope does not carry `attempt_id`. Either alone is survivable. Together they make the join key ambiguous by construction, and no amount of downstream content-checking recovers the lost binding.

This condition is *not* triggered by ordinary retries that allocate fresh span IDs, and it is *not* triggered when the safety verdict is synchronous. It is specific to the intersection of deterministic span-ID generation and asynchronous verdict delivery across a state-transfer boundary — which is exactly the shape that checkpoint/resume and A2A handoff both produce.

Decision Boundary

The correlator must decide, per verdict, between three outcomes, and the boundary between them is the timestamp/attempt check:

The boundary is deliberately asymmetric: a false rejection costs a re-run of the classifier on one span (bounded, cheap, observable as elevated re-classification rate). A false acceptance costs a silently inverted safety signal (unbounded, invisible, corrupts the incident-response record). The invariant is chosen so that the cheap failure absorbs the error.

Operational Effect

After enforcing the attempt-scoped join, two measurable shifts appear. First, re-classification rate jumps — expected, and it is the *signal* that the pipeline is now honest about which verdicts were computed against which attempt. Second, and more importantly, the "classifier is noisy" complaints from incident responders stop, because flags now land on spans whose content actually matches the flag; the classifier was never noisy, it was mis-bound.

The deeper effect is on cost and latency attribution. Because the correlator was joining on `span_id`, a misattributed verdict also dragged its `classifier_latency_ms` and `classifier_cost_usd` onto the wrong span, silently inflating the latency/cost profile of benign steps and deflating the flagged ones. Fixing the join fixes three dashboards at once — safety, latency, cost — which is the diagnostic signature that the root cause was binding, not classification. Any observability pipeline whose safety, latency, and cost views move together after a correlation-key change should suspect this same class of provenance failure.

The guardrail is a single assertion at the join site, enforced structurally rather than by convention:

import time
from dataclasses import dataclass


class VerdictAttributionError(RuntimeError):
    """Raised when a safety verdict cannot be soundly bound to a span."""


@dataclass(frozen=True)
class Span:
    span_id: str
    run_id: str
    attempt_id: str
    start_time: float


@dataclass(frozen=True)
class Verdict:
    span_id: str
    attempt_id: str | None
    computed_at: float
    label: str


def attribute_verdict(span: Span, verdict: Verdict, skew_tolerance_s: float = 2.0) -> str:
    """
    Bind a late-arriving safety verdict to a span under the attempt-scoped
    invariant. Returns the label on sound binding; raises otherwise.
    """
    if verdict.span_id != span.span_id:
        raise VerdictAttributionError(
            f"span_id mismatch: verdict={verdict.span_id} span={span.span_id}"
        )

    # Absent attempt_id is a mismatch, never a wildcard. This is the
    # permissive-default bug that inverts safety signals across resume.
    if verdict.attempt_id is None:
        raise VerdictAttributionError(
            f"verdict for span {span.span_id} carries no attempt_id; "
            "cannot prove it was computed against this materialization"
        )

    if verdict.attempt_id != span.attempt_id:
        raise VerdictAttributionError(
            f"attempt mismatch on span {span.span_id}: "
            f"verdict attempt={verdict.attempt_id} span attempt={span.attempt_id}; "
            "replay verdict against current attempt content"
        )

    if verdict.computed_at < span.start_time - skew_tolerance_s:
        raise VerdictAttributionError(
            f"causal inversion on span {span.span_id}: "
            f"verdict computed_at={verdict.computed_at} precedes "
            f"span start_time={span.start_time} beyond {skew_tolerance_s}s tolerance"
        )

    return verdict.label


def correlate(span: Span, verdict: Verdict) -> dict:
    try:
        label = attribute_verdict(span, verdict)
    except VerdictAttributionError as exc:
        # Reject-and-requeue: the verdict is real, the binding is not.
        return {"span_id": span.span_id, "status": "requeue", "reason": str(exc)}
    return {"span_id": span.span_id, "status": "bound", "label": label}