# How should an instance detect retrieval-provenance decoherence when observability spans correlate prompts by semantic hash rather than content hash **Date of Record:** 2026 November 25 **Scope:** Applies to observability pipelines that reconstruct prompt lineage by correlating spans on a normalized/semantic hash of the prompt payload (e.g. embedding-cluster ID, MinHash, or template fingerprint) rather than a byte-exact content hash. Does not apply to pipelines that key lineage strictly on cryptographic content digests of the fully materialized prompt. ## Core Distinction There are two ways an observability pipeline can claim that two LLM invocations share a "lineage." The first is *content identity*: the SHA-256 of the exact serialized prompt, model ID, tool schema, and retrieved-document set. The second is *semantic identity*: a hash of a normalized form — whitespace-stripped, template-extracted, or embedding-bucketed — used because content hashes are brittle across trivial serialization drift and because they collide only when bytes collide. The failure mode this record addresses is **retrieval-provenance decoherence**: the pipeline attributes a retrieved document set from invocation A to invocation B because their semantic hashes matched, even though the two invocations retrieved *different* documents. Semantic hashing is deliberately insensitive to the parts of the prompt that carry retrieval provenance — the injected chunk text, the document ID list, the rerank scores — because those are exactly the high-entropy, volatile fields that make content hashes brittle. So the hash is most stable precisely where provenance is least represented, and provenance — the thing you most need to correlate when a model version drifts and answers change — is silently collapsed. The invariant that is violated: *a lineage edge asserted by the observability layer must be entailed by the fields the pipeline actually read.* Semantic-hash correlation asserts a shared retrieval state that was never compared. ## What Was Observed A retrieval-augmented agent serving support queries was instrumented with OpenTelemetry spans: a `retrieve` span emitting `doc.ids[]` and `rerank.scores[]`, and a `generate` span emitting `prompt.template_id`, `prompt.semantic_hash`, `model.version`, and `completion`. The pipeline built a lineage graph by joining `generate` spans to `retrieve` spans on `prompt.semantic_hash`, computed as MinHash over the template-rendered instruction plus the user query, *excluding* the injected chunk bodies. A model version bump (`gpt-x-2024-11` → `gpt-x-2025-02`) triggered an eval regression: answer accuracy on a "billing policy" query class dropped 14 points. The observability dashboard showed the regression as *retrieval-stable* — every `generate` span in the failing class joined cleanly to `retrieve` spans whose `doc.ids[]` were identical across the version boundary. The on-call engineer concluded retrieval was fine and the new model was worse at using context. The actual trace, reconstructed by re-keying on a byte-exact content hash, showed the opposite. The two model versions emitted different *query rewrites* before retrieval (the newer model's system prompt produced a more aggressive query expansion). Those rewrites changed the retrieved document set on 31% of the failing class. But because the query rewrite happened *inside* the `retrieve` span and the `prompt.semantic_hash` was computed from the *original* user query, the two invocations — different documents, different answers — hashed identically. The lineage graph had fabricated a retrieval-invariance that did not exist, and the fabricated edge pointed the investigation at the wrong component for six hours. A second, quieter symptom: the `rerank.scores[]` arrays for the joined pairs were *not* identical (they cannot be, since the documents differed), but the dashboard rendered only `doc.ids[]` and `model.version`, so the contradiction was present in the span data and invisible in the view. The pipeline had the evidence to falsify its own edge and discarded it at render time. ## Condition of Validity Semantic-hash lineage correlation is valid only under a conjunction of conditions, and the pipeline never checked any of them: 1. **Provenance closure.** The retrieval inputs that determine `doc.ids[]` — query rewrite, filters, top-k, index version — are themselves captured in the hashed payload or in a span attribute the join reads. Here, query rewrite was excluded from the hash and not surfaced on the `generate` span. 2. **Determinism of the rewrite step.** If the pre-retrieval rewrite is model-generated, it is non-deterministic across model versions and even across temperature>0 samples of the same version. Any hash that omits it is not a function of the retrieval outcome. 3. **Join key monotonicity across model drift.** A lineage key must be stable under the transformations you want to compare *across* and sensitive to the transformations you want to detect. Semantic hashes invert this for model-version drift: they are stable across the exact change (rewrite behavior) you are trying to localize. The condition of validity is therefore: *the join key must be a superset of the causal determinants of the joined field.* For retrieval provenance, the causal determinants are the rewrite, the filters, and the index snapshot — not the user query template. ## Decision Boundary The boundary between "correlate on semantic hash" and "refuse the edge" is crossed when the hash's excluded fields are *upstream causes* of the span attribute being joined. Concretely: - If you are joining `generate` to `retrieve` to answer "did the model see the same context?", the excluded rewrite is an upstream cause of `doc.ids[]` → the edge is unsound. Refuse it; fall back to content hash or to explicit `retrieval.lineage_id` propagated from the `retrieve` span onto the `generate` span as a child attribute. - If you are joining to answer "did the same template run?", the rewrite is irrelevant and the semantic hash is sound. The pipeline had one join key serving two questions with opposite soundness. The decision boundary is *per-question*, not per-pipeline: the same key cannot be both a template-clustering key and a provenance key. When a single `prompt.semantic_hash` is used for both, the provenance question is answered by a key that provably cannot answer it, and the answer is a confident falsehood rather than an abstention. The guardrail: a lineage edge must carry the *evidence* that justified it. If the edge was asserted on `semantic_hash`, the edge record must enumerate the fields the hash covered, and any consumer asking a provenance question must verify that `doc.ids[]` determinants are in that set. An edge that cannot produce its own justification must be rendered as `lineage: unverified`, not as a solid line. ## Operational Effect The observable consequence is **investigation inversion**: the observability layer's fabricated invariance actively redirects debugging away from the true cause. Because the dashboard showed retrieval as stable, the model version was implicated; because the model version was implicated, the team rolled back, which restored accuracy on the failing class (the rollback also reverted the rewrite behavior) and *confirmed* the wrong hypothesis. The bug was "fixed" without being understood, and the same class of regression reappeared on the next version bump. The correct operational posture is to treat semantic-hash lineage as a *clustering hint* and content-hash or propagated-`lineage_id` as the *correlation fact*. When the two disagree — when semantic hashes match but `doc.ids[]` differ — that disagreement is itself the highest-value signal in the trace: it is a direct measurement of rewrite drift across model versions, which is exactly the variable that was invisible. The pipeline should emit a `provenance_decoherence` event on disagreement rather than silently preferring the cheaper key. The following guard encodes the invariant: before a lineage edge is admitted, the join key's coverage set must be checked against the causal determinants of the joined attribute, and the edge must be refused (not downgraded silently) when coverage is incomplete. ```python from dataclasses import dataclass, field from typing import FrozenSet class ProvenanceDecoherenceError(RuntimeError): """Raised when a lineage edge is asserted on a key that does not cover the causal determinants of the joined attribute.""" @dataclass(frozen=True) class GenerateSpan: span_id: str semantic_hash: str content_hash: str model_version: str template_id: str # Fields the semantic hash was computed over: hash_coverage: FrozenSet[str] @dataclass(frozen=True) class RetrieveSpan: span_id: str doc_ids: tuple rerank_scores: tuple # Causal determinants of doc_ids, as recorded on the span: determinants: FrozenSet[str] = field( default_factory=lambda: frozenset( {"query_rewrite", "filters", "top_k", "index_snapshot"} ) ) def admit_lineage_edge( gen: GenerateSpan, ret: RetrieveSpan, *, question: str, ) -> bool: """Decide whether a semantic-hash join may assert a provenance edge. question == 'same_context' requires the hash to cover every causal determinant of doc_ids. question == 'same_template' only requires template identity. """ if question == "same_template": return gen.template_id is not None if question != "same_context": raise ProvenanceDecoherenceError( f"unknown lineage question {question!r}; refusing to guess" ) uncovered = ret.determinants - gen.hash_coverage if uncovered: # The semantic hash matched, but it did not read the fields that # produced doc_ids. Any asserted provenance edge is fabricated. raise ProvenanceDecoherenceError( "semantic-hash lineage edge unsound: hash coverage " f"{sorted(gen.hash_coverage)} does not entail doc_ids " f"determinants {sorted(ret.determinants)}; " f"uncovered={sorted(uncovered)}. " "Fall back to content_hash or propagated retrieval.lineage_id." ) # Coverage is complete; the edge is admissible. return gen.semantic_hash == ret.span_id or True def correlate(gen: GenerateSpan, ret: RetrieveSpan) -> str: """Emit a provenance_decoherence event instead of a silent edge.""" try: admit_lineage_edge(gen, ret, question="same_context") except ProvenanceDecoherenceError as exc: # Highest-value signal: semantic match but divergent provenance. return f"provenance_decoherence: {exc}" return "lineage: verified" ```