# Which invariants prevent exemplar-link drift between trace spans, eval verdicts, and safety incident reports when the same generation is re-scored under a different eval policy **Date of Record:** 2026 November 25 **Scope:** Applies to agent systems that attach `gen_ai.*` semantic-convention attributes to trace spans and maintain bidirectional exemplar links (span → eval verdict → safety incident report) for post-hoc audit. Does not apply to systems where evals are run inline and synchronously with generation such that no re-scoring path exists, nor to trace stores that never re-open spans after ingest. ## Core Distinction The failure here is not "the eval disagrees with the trace" and it is not "the incident report cites the wrong span." It is that **the exemplar link itself becomes an ambiguous pointer** when a generation is re-scored under a new eval policy while the original verdict remains immutable in the trace store. The trace span records one `gen_ai.evaluation.score`, the eval store records two verdicts under different `eval.policy_id` values, and the incident report cites "the" exemplar — but there are now two exemplars for one generation, and the link resolves to whichever one the consumer's join happens to prefer. The invariant that prevents this is *not* "score is immutable." It is: **every exemplar link must be qualified by the (span_id, generation_hash, eval_policy_id) triple, and no consumer may dereference a link that lacks the policy qualifier.** The span carries the *link key*, not the *verdict*. Verdicts live in the eval store, keyed by policy. A span that embeds a scalar score has already collapsed the triple into a point and cannot be re-scored without either mutating the trace (forbidden) or orphaning the link (the failure). ## What Was Observed A generation span `S` for a customer-support agent turn carried: ``` gen_ai.system = "vendor-x" gen_ai.request.model = "model-a-2024-11" gen_ai.response.finish_reasons = ["stop"] gen_ai.usage.output_tokens = 412 gen_ai.evaluation.score = 0.91 gen_ai.evaluation.name = "helpfulness" ``` An eval pipeline (policy `P1`, helpfulness rubric v1) produced 0.91 and wrote it onto the span at export time. Six weeks later a safety review re-scored the same generation under policy `P2` (harmlessness rubric v3, which flags over-confident medical phrasing). `P2` produced a verdict of `unsafe:medical-advice` with score 0.12. The eval store correctly wrote a *new* row keyed `(generation_hash, P2)`. The trace span was untouched — 0.91 still sat in `gen_ai.evaluation.score`. A safety incident report was then filed citing exemplar `S`. The report generator joined on `span_id`, pulled `gen_ai.evaluation.score = 0.91`, and rendered the incident as "helpfulness 0.91, no safety flag." The actual P2 verdict — the reason the incident existed — was invisible to the report because the report's join path was `span → score attribute`, not `span → (generation_hash, policy) → verdict`. The trigger condition is precise: **a re-scoring event under a new policy, on a generation whose span already carries an embedded scalar eval attribute, consumed by a downstream report that joins on the span rather than on the triple.** Remove any one of those four and the failure does not occur. All four were present. Two secondary observations compounded it: 1. The eval store's exemplar-link table used `span_id` as primary key, so the P2 row *overwrote* the P1 row's link rather than appending. The P1 verdict became unreachable from the span even though the span still displayed P1's score. The link and the score now pointed at different policies. 2. The incident report's dedup logic keyed on `(span_id, incident_type)`. A second incident filed later under a third policy `P3` was suppressed as a duplicate of the first — because the dedup key did not include `eval_policy_id`. Two distinct safety findings collapsed to one. ## Condition of Validity The guardrail only holds under these conditions, and each is checkable: - **Link cardinality is (1 span, 1 generation_hash, N policies).** The exemplar-link table must be keyed `(span_id, generation_hash, eval_policy_id)` and must be append-only. Any schema with `span_id` alone as key is already broken; it cannot represent a re-score. - **The span never carries a verdict, only a pointer.** `gen_ai.evaluation.score` on a span is acceptable *only* if accompanied by `gen_ai.evaluation.policy_id` and understood as "the score under that policy at export time," never as "the score." Consumers must treat a bare score attribute as a *hint* and re-resolve through the link table. - **Generation identity is content-addressed.** `generation_hash` must be a hash over the model id, the full prompt, the sampling parameters, and the output — not over the span id. Span ids are per-export and can be re-emitted; a re-scored generation must hash identically across exports or the join silently misses. - **Incident dedup keys include policy.** `(span_id, incident_type, eval_policy_id)` is the minimum dedup key. Anything coarser suppresses legitimate distinct findings. - **Report renderers resolve through the triple.** A report that reads `gen_ai.evaluation.score` directly from the span is out of spec, regardless of how the span was written. If any condition is unmet, the system is in the failure regime and the invariant does not apply — you have an unqualified pointer and must treat all exemplar links as advisory. ## Decision Boundary The boundary is: **when does a re-score warrant a new exemplar link versus a correction of the existing one?** - If the new policy is a *different question* (harmlessness vs. helpfulness), it is a new link. Append. The old verdict stands. - If the new policy is a *corrected version of the same question* (rubric v1 → v2 for the same helpfulness dimension), it is a **supersession**, not a new link. The link table must carry `supersedes: ` and consumers must resolve to the latest non-superseded verdict for that dimension. Appending without supersession produces two "helpfulness" verdicts and the report picks arbitrarily. - If the re-score is *identical policy, different model judge*, that is a judge disagreement, not a re-score. It belongs in an inter-rater agreement record, not in the exemplar link. Conflating the two poisons the link table with what are actually eval-quality signals. The operational test: a link is a re-score (new link) iff `(eval.dimension, eval.policy_id)` differs and no supersession edge exists. It is a supersession iff the dimension matches and a `supersedes` edge is declared. It is a judge disagreement iff the policy matches and the judge id differs. Three cases, three tables or three edge types — collapsing them into "another row in the link table" is the design error that produced the incident. ## Operational Effect After the fix, the report renderer resolves `S` to the triple set `{(gen_hash, P1), (gen_hash, P2)}`, renders both verdicts with policy labels, and the dedup key `(span_id, medical-advice, P2)` admits the second incident. The P1 verdict remains visible as "helpfulness 0.91 under rubric v1" — not as "no safety flag," which was the false negative. The cost is that every report now shows *all* policies applied to a generation, which is more verbose but correct; the previous single-score rendering was a lossy projection that happened to look clean. The deeper effect: the span's `gen_ai.evaluation.score` attribute is now explicitly documented as a *non-authoritative export-time snapshot*. Any consumer that reads it without the accompanying `policy_id` and without a link-table resolution is flagged in CI by a schema lint. This is the enforcement point — the invariant is only real if a linter rejects the bare-attribute read path, because the failure mode is a *plausible-looking* join that returns a number and no error. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class ExemplarLinkDriftError(RuntimeError): """Raised when an exemplar link cannot be resolved to a unique, policy-qualified verdict for a generation.""" pass @dataclass(frozen=True) class ExemplarLink: span_id: str generation_hash: str eval_policy_id: str eval_dimension: str judge_id: str score: float verdict: str supersedes: Optional[str] = None def resolve_exemplar( span_id: str, generation_hash: str, dimension: str, links: list[ExemplarLink], ) -> ExemplarLink: """Resolve a span+generation to exactly one authoritative verdict for a dimension, honoring supersession edges. Raises on ambiguity.""" candidates = [ l for l in links if l.span_id == span_id and l.generation_hash == generation_hash and l.eval_dimension == dimension ] if not candidates: raise ExemplarLinkDriftError( f"no link for span={span_id} gen={generation_hash} dim={dimension}" ) superseded = {l.supersedes for l in candidates if l.supersedes} terminal = [l for l in candidates if l.eval_policy_id not in superseded] if len(terminal) == 0: raise ExemplarLinkDriftError( f"supersession cycle or dangling edge for span={span_id} dim={dimension}" ) if len(terminal) > 1: # Two terminal verdicts for one dimension: either a genuine judge # disagreement mis-filed as a link, or an un-declared supersession. policies = sorted(l.eval_policy_id for l in terminal) raise ExemplarLinkDriftError( f"ambiguous terminal verdicts for span={span_id} dim={dimension}: " f"policies={policies} — declare supersession or move to judge-agreement table" ) return terminal[0] def render_incident_exemplar( span_id: str, generation_hash: str, dimension: str, links: list[ExemplarLink], ) -> dict: link = resolve_exemplar(span_id, generation_hash, dimension, links) return { "span_id": span_id, "generation_hash": generation_hash, "policy_id": link.eval_policy_id, "dimension": link.eval_dimension, "judge_id": link.judge_id, "score": link.score, "verdict": link.verdict, } ```