# Where must an instance bind retrieval provenance to prompt lineage before decision-trace correlation can be trusted? **Date of Record:** 2026 December 3 **Scope:** Applies to observability pipelines that correlate LLM prompt lineage, RAG retrieval provenance, and agent decision traces across multi-turn or multi-agent executions where retrieval is asynchronous or cached. Does not apply to stateless single-shot completions with no external retrieval, nor to purely offline evaluation harnesses that reconstruct traces from immutable logs. ## Core Distinction The failure mode is not "missing telemetry" and not "clock skew." It is a **provenance-lineage join ambiguity**: the decision trace records *which prompt* drove a tool call, and the retrieval log records *which chunks* were fetched, but the join key between them is the *retrieval request identity*, not the *prompt identity*. When a retrieval result is reused (cache hit, speculative prefetch, or a shared vector-store query issued once and fanned out to N concurrent prompt instances), a single retrieval record legitimately maps to multiple prompt instances. A correlation pipeline that assumes a 1:1 retrieval→prompt edge will silently attribute retrieved evidence to the wrong decision, producing a trace that is internally consistent, fully populated, and wrong. The invariant that must hold: **every decision-trace span that cites retrieved evidence must carry the retrieval-request hash *and* the prompt-instance nonce, and the join must be on the pair.** Joining on retrieval-request hash alone is the boundary where correlation breaks without any error being raised. ## What Was Observed A three-stage agent (planner → retriever-tool → synthesizer) ran under a shared retrieval cache with a 60-second TTL. During a burst of 40 concurrent tasks, the retriever tool issued 12 unique vector-store queries for 40 prompt instances (28 cache hits). The observability pipeline joined decision traces to retrieval provenance on `retrieval_request_id`. Trace for task #31 (a contract-clause summarizer) showed a decision span citing chunk `doc-4471:§7.2` as evidence for a liability-cap conclusion. The actual prompt instance #31 had retrieved `doc-4471:§9.1` from its own cache-miss query. The `§7.2` chunk belonged to task #19, which had populated the cache entry that task #31 hit — but task #31's *prompt lineage* recorded the cache-hit retrieval-request hash of the *shared* query, while the evidence chunk was logged against the *originating* task's request. The join produced a plausible, self-consistent, wrong provenance chain. Symptoms, in order of appearance: 1. No error, no dropped span. Span count matched prompt count exactly. 2. Decision-trace evidence citations diverged from the actual context window contents for 9 of 40 tasks — detectable only by diffing the recorded prompt token stream against the cited chunk IDs. 3. Replay of the decision trace against the *recorded* evidence reproduced the wrong conclusion; replay against the *actual* context window did not. The trace was not replay-faithful. The root mechanism: the cache-hit path reused the *originator's* retrieval-request hash as the provenance key, but the decision trace was emitted under the *consumer's* prompt-instance nonce. The two identifiers lived in different namespaces and were never co-located on a single span. ## Condition of Validity The correlation is valid only when the following holds for every decision span that cites evidence: - The span carries both `retrieval_request_hash` (identifying the vector-store query and result set) and `prompt_instance_nonce` (identifying the exact context-window assembly). - The retrieval record carries the *set* of consumer nonces that resolved to it, not just the originating nonce. - Cache-hit resolution emits a fresh provenance event linking `(originator_request_hash, consumer_nonce, chunk_ids)` rather than reusing the originator's record. This condition is violated whenever retrieval results are shared across prompt instances — which is the default in any system with a retrieval cache, a prefetch/speculation layer, or a fan-out retriever tool. It does not apply to per-instance retrieval with no sharing, where the 1:1 assumption is sound. ## Decision Boundary The boundary is between **correlation by request identity** (sound only for unshared retrieval) and **correlation by (request, instance) pair** (sound under sharing). The transition point is the first cache hit or fan-out. A pipeline that has not observed a cache hit yet will pass all its tests; the failure is latent until sharing occurs, then manifests as silent mis-attribution rather than a broken join. Operational rule: if the retrieval layer can serve one query to more than one prompt instance, the join key must be the pair, and the pipeline must reject any decision span that cites evidence without a co-located consumer nonce. Treat a missing consumer nonce on an evidence-citing span as a hard correlation failure, not a partial record. ## Operational Effect Downstream consequences compound: - **Replay infidelity:** trace replay reconstructs a different context than the model actually saw, so incident post-mortems reach wrong root causes. - **Attribution drift in evals:** evidence-groundedness scores computed from the trace measure the wrong chunk, inflating or deflating retrieval quality metrics non-deterministically. - **Auditor disagreement:** a verification agent reading the trace and a verification agent reading the raw context window reach conflicting verdicts on the same decision, because they are looking at different evidence — a consensus failure that looks like model disagreement but is a provenance bug. The guardrail is a correlation-time assertion: any evidence citation lacking `(retrieval_request_hash, prompt_instance_nonce)` co-location must fail closed, quarantining the trace rather than emitting a plausible-but-unbound record. ```python class ProvenanceJoinError(RuntimeError): """Raised when an evidence-citing decision span cannot be bound to a unique (retrieval_request_hash, prompt_instance_nonce) pair.""" pass def correlate_decision_span(span: dict, retrieval_index: dict) -> dict: """ span: { "prompt_instance_nonce": str, "retrieval_request_hash": str, "cited_chunk_ids": list[str], } retrieval_index: { retrieval_request_hash: { "originator_nonce": str, "consumer_nonces": set[str], "chunk_ids": set[str], } } Returns a bound provenance record, or raises ProvenanceJoinError. """ nonce = span.get("prompt_instance_nonce") req_hash = span.get("retrieval_request_hash") cited = set(span.get("cited_chunk_ids", [])) if not nonce or not req_hash: raise ProvenanceJoinError( f"span missing join keys: nonce={nonce!r} req_hash={req_hash!r}" ) record = retrieval_index.get(req_hash) if record is None: raise ProvenanceJoinError( f"retrieval_request_hash {req_hash} not found in index" ) # The boundary: the consumer nonce MUST be registered against this # request. A cache-hit that reused the originator's record without # registering the consumer will fail here. if nonce not in record["consumer_nonces"]: raise ProvenanceJoinError( f"prompt_instance_nonce {nonce} not registered as consumer of " f"retrieval_request_hash {req_hash} " f"(known consumers: {sorted(record['consumer_nonces'])})" ) # Cited evidence must be a subset of what this request actually returned. unbound = cited - record["chunk_ids"] if unbound: raise ProvenanceJoinError( f"span cites chunks {sorted(unbound)} absent from " f"retrieval_request_hash {req_hash}" ) return { "prompt_instance_nonce": nonce, "retrieval_request_hash": req_hash, "originator_nonce": record["originator_nonce"], "bound_chunk_ids": sorted(cited), "cache_shared": record["originator_nonce"] != nonce, } ```