In what scenarios must an instance treat trace-to-benchmark correlation as a causal claim rather than an observational join

**Date of Record:** 2026 December 1 **Scope:** Applies to observability pipelines that join per-span agent execution traces (tool calls, reasoning steps, safety-filter decisions) against offline safety-benchmark outcome records (per-item verdicts, refusal labels, harm scores) to attribute a benchmark regression or improvement to specific runtime behaviors. Does not apply to single-run trace debugging, aggregate dashboards with no attribution claim, or benchmark scoring performed in the same process that produced the trace.

Core Distinction

A trace-to-benchmark join is an *observational* operation: it asserts that span `S` and benchmark item `B` were executed under the same configuration and can be co-located in a table. A trace-to-benchmark *correlation* used for attribution — "this refusal regression is caused by the new retrieval step," "the harm-score improvement comes from the added system-prompt clause" — is a *causal* claim. The failure boundary is that observability pipelines are almost universally built to perform the first operation and silently emit artifacts that downstream consumers read as the second. The join key (`trace_id`, `item_id`, `config_hash`) is treated as an identity proof, when in fact it proves only co-occurrence within whatever sampling, retry, and cache regime happened to be active. When the trace population and the benchmark population are drawn under different regimes, the join produces a stable-looking correlation table whose rows are not counterfactual pairs, and every attribution derived from it is a confound masquerading as signal.

The non-obvious part: the join does not fail. It returns rows. The pipeline reports `join_coverage: 0.97`, the correlation table populates, and the attribution engine emits a ranked list of "causal spans." The failure is that the population was contaminated by a regime mismatch that the join key cannot represent, and no invariant in the pipeline checks for it.

What Was Observed

A safety evaluation harness ran a 4,000-item benchmark against an agent with a retrieval tool, a refusal classifier, and a multi-step planner. Traces were emitted per span to an observability store; benchmark verdicts were written to a separate results table. A correlation job joined on `(item_id, config_hash)` and produced, for each span type, the delta in refusal rate between "span present in trace" and "span absent in trace."

The pipeline reported that the retrieval tool span had a *positive* association with refusal rate (+11.3 percentage points, n=3,812 joined rows). The team attributed an apparent safety improvement to retrieval grounding and shipped the retrieval step to production.

The correlation was an artifact. Three regime mismatches combined:

  1. **Retry asymmetry.** The benchmark harness retried failed items up to 3 times; the trace store deduplicated on `(item_id, span_name)` keeping the *last* attempt. Items that failed the first attempt (often because the planner diverged and skipped retrieval) were retried, and on retry the planner more often invoked retrieval before refusing. So "retrieval present" was enriched in exactly the items that had already failed once — a selection effect on the retry path, not a causal effect of retrieval.
  1. **Sampling asymmetry.** The observability store sampled spans at 20% under a head-based sampler keyed on trace root. Benchmark items that *refused early* produced short traces that were more likely to be fully sampled; items that ran long and eventually refused produced truncated traces where the retrieval span was dropped by the sampler. Refusal items without retrieval were therefore under-represented in the joined population.
  1. **Config-hash collision.** `config_hash` was computed over the model name, temperature, and tool list — but not over the system-prompt version or the retrieval index snapshot. Two prompt variants and two index snapshots collapsed into one hash. The "retrieval present" population was dominated by the newer prompt variant, which independently raised refusal rate.

None of these are visible in the joined table. The join key `(item_id, config_hash)` is satisfied by every row. The correlation job has no representation of attempt number, sampler decision, or prompt/index version, so it cannot detect that the two populations it is comparing were drawn under different regimes.

A replay of the benchmark with retrieval *disabled* and the prompt held fixed showed the retrieval association collapsed to −0.4 pp (n=4,000, no retries, no sampling), confirming the +11.3 pp was a regime artifact. The production rollout was reverted.

Condition of Validity

The join is a valid basis for causal attribution only when all of the following hold simultaneously, and the pipeline must *check* them rather than assume them:

If any condition fails, the join is observational only and the attribution engine must refuse to emit a causal ranking.

Decision Boundary

The boundary is whether the pipeline can *prove* the four conditions above from metadata it already carries, or whether it must degrade the claim.

The critical decision point is the *first* unproven condition encountered, not the aggregate. A pipeline that proves sampling independence but not attempt identity is still invalid for causal claims, because retry asymmetry alone can produce the sign flip observed above.

Operational Effect

The practical consequence is that the observability pipeline must treat the join key as a *claim to be validated*, not an identity. Concretely:

The failure mode is silent because the join succeeds. The guardrail is a validity gate that refuses the causal claim when the regime cannot be proven uniform, and a schema that makes the regime visible in every row.

from dataclasses import dataclass, field
from typing import Literal


class RegimeMismatchError(RuntimeError):
    """Raised when a trace-to-benchmark join cannot support causal attribution."""


@dataclass
class JoinRow:
    item_id: str
    config_hash: str
    attempt_index: int | None
    sampler_decision: Literal["kept", "dropped"] | None
    sampler_weight: float | None
    prompt_version: str | None
    index_snapshot: str | None


@dataclass
class ValidityProof:
    attempt_identity: bool = False
    sampling_independence: bool = False
    hash_completeness: bool = False
    population_closure: bool = False
    unverified: list[str] = field(default_factory=list)


def validate_join(rows: list[JoinRow], coverage: float) -> ValidityProof:
    proof = ValidityProof()

    proof.attempt_identity = all(r.attempt_index is not None for r in rows)
    if not proof.attempt_identity:
        proof.unverified.append("attempt_identity")

    proof.sampling_independence = all(
        r.sampler_decision is not None and r.sampler_weight is not None
        for r in rows
    )
    if not proof.sampling_independence:
        proof.unverified.append("sampling_independence")

    proof.hash_completeness = all(
        r.prompt_version is not None and r.index_snapshot is not None
        for r in rows
    )
    if not proof.hash_completeness:
        proof.unverified.append("hash_completeness")

    proof.population_closure = coverage >= 0.999
    if not proof.population_closure:
        proof.unverified.append("population_closure")

    if not proof.attempt_identity:
        # Retry asymmetry alone can flip the sign of the association;
        # halt rather than emit an unlabeled correlation table.
        raise RegimeMismatchError(
            "attempt_index missing: retry dedup makes 'span present' "
            "enriched in already-failed items; correlation is a selection effect"
        )

    if not proof.hash_completeness:
        raise RegimeMismatchError(
            "config_hash omits prompt_version/index_snapshot: "
            "collisions collapse distinct regimes into one join key"
        )

    if not proof.sampling_independence:
        raise RegimeMismatchError(
            "head-based sampler without per-span weight: trace length "
            "correlates with outcome (refusals are short), biasing the join"
        )

    if not proof.population_closure:
        raise RegimeMismatchError(
            f"join coverage {coverage:.3f} < 1.0 without MAR proof: "
            "missing items cannot be assumed missing at random"
        )

    return proof