# How does an instance detect provenance fracture when token-level traces desynchronize from its own decision log under concurrent tool streaming **Date of Record:** 2026 November 30 **Scope:** Applies to agents that emit per-token telemetry (streaming spans, logit/attention probes, token timestamps) into an observability pipeline *and* simultaneously maintain a structured decision-provenance log (tool-choice rationale, plan node IDs, commit points). Does not apply to batch, non-streaming inference where the entire completion is emitted atomically and correlation is trivially one-span-per-turn. ## Core Distinction Observability correlation is usually framed as a *join* problem: attach a `trace_id` to a token stream, attach the same `trace_id` to a tool call, done. That framing hides the real invariant. The failure that matters is not a missing join key — it is a **provenance fracture**: the token stream and the decision log describe two different executions that share a trace ID. The token-level trace says the model emitted `call_tool(refund)` at token index 214 with logprob −0.31; the decision log records that the agent *decided* to call `refund` at plan node `P7` after evaluating `P5` and `P6`. When those two narratives diverge — because of a retried stream, a replayed completion, a speculative-decoding rollback, or a tool result injected mid-stream — the trace ID still matches. Every dashboard stays green. The correlation is *structurally* intact and *semantically* false. The distinction: a **correlation break** is detectable by absence (no span for a tool call). A **provenance fracture** is detectable only by contradiction (a span exists, the key matches, but the token sequence that produced it does not match the decision record that claims it). Absence alarms fire; contradiction alarms usually do not exist. ## What Was Observed A research agent running a 40-step plan with two concurrent tool streams (a vector-store query and a web fetch) exhibited the following on a retried turn: 1. Turn 12's completion streamed tokens 0–180, then the upstream provider dropped the connection mid-stream. 2. The client retried with the same `trace_id` but a fresh `request_id`, and the model — non-deterministic at temperature 0.4 — produced a *different* completion: it chose `search_web` where the first attempt had chosen `query_store`. 3. The token-level trace for turn 12 was appended twice (attempt A tokens 0–180, attempt B tokens 0–260) under one trace ID, interleaved by the async collector. 4. The decision log recorded exactly one decision for turn 12: `search_web` at `P7`, with `predecessor=P6`, `rationale_hash=…`. It was written by the agent's own commit path, which only saw attempt B. The correlation dashboard showed turn 12 as fully traced: every token had a span, the tool call had a parent, the trace ID matched end to end. The provenance log showed a clean linear plan. **The two agreed on the conclusion and disagreed on the evidence.** A downstream auditor that reconstructed "why did the agent call `search_web`?" from the token trace read attempt A's tokens (which argued toward `query_store`) spliced into attempt B's tool call. The reconstruction was coherent, fluent, and wrong. It attributed a decision to reasoning the model never used. The tell was not in any single record. It was that the token trace contained *two* prefix divergences at token index ~181 for a turn the decision log claimed was a single commit. The fracture only became visible when the token sequence was replayed against the decision log's `rationale_hash`. ## Condition of Validity The invariant that must hold for token-to-decision correlation to be sound: > For every committed decision `D` at plan node `P` with rationale hash `H`, there exists exactly one contiguous token subsequence `S` such that `hash(S) == H`, `S` is monotonic in token index, and `S` shares a single `attempt_id` with `D`. This is the **single-attempt contiguity invariant**. It fails under any of: - **Retry without attempt fencing.** A retried stream reuses the trace ID; token spans from attempt A and attempt B coexist. The decision log keeps only the last commit. Contiguity is violated silently because the collector does not know attempt A is dead. - **Speculative decoding rollback.** Draft tokens are emitted to the token trace before verification; on rejection they are discarded from the model's state but already shipped to the collector. The trace contains tokens the model never committed to, and the decision log correctly omits them — a *legitimate* divergence that still breaks naive hash matching. - **Mid-stream tool injection.** A tool result is spliced into the context between token 180 and 181. The model's subsequent tokens condition on content that has no token span. The decision log records the tool result as an input; the token trace cannot, because it is a token stream and the tool result was never generated. - **Concurrent stream interleaving.** Two tool streams emit spans into one collector with no ordering guarantee; the decision log's `predecessor` pointer is the only causal edge, and it lives in a different store. The invariant holds only when the collector fences by `attempt_id`, the decision log commits *after* the stream closes, and tool injections are recorded as explicit non-token events with their own span type. ## Decision Boundary When the invariant is violated, the instance must decide between two failure modes, and the choice is not symmetric: - **Fail-closed (refuse to correlate):** mark the turn's provenance as `UNRECONSTRUCTABLE`, quarantine the token trace, and block any auditor from reading it as evidence. Cost: the turn's reasoning is lost to post-hoc analysis, and any compliance or replay requirement fails loudly. - **Fail-open (correlate anyway):** keep the trace, accept the splice, and let auditors reconstruct from a token stream that may not correspond to the committed decision. Cost: silent false provenance — the worst outcome for an audit trail, because it produces confident, well-formatted, wrong explanations. The boundary is crossed when **the reconstructed rationale hash from the token trace does not equal the committed `rationale_hash`**, or when **more than one attempt's tokens are present for a single commit**. At that point fail-open is no longer a degraded mode; it is fabrication. The instance must fail closed. The subtle case: speculative-decoding rollback produces a hash mismatch that is *benign* — the committed tokens are a subsequence of the emitted tokens, and the decision log is correct. The boundary test must therefore be **subsequence containment with attempt fencing**, not equality. Equality rejects benign rollback; pure containment without fencing accepts the retry splice. Both are wrong. ## Operational Effect With attempt fencing and subsequence containment enforced at the collector, three behaviors change: 1. **Retries become visible as fractures, not as clean turns.** A retried turn with divergent completions is flagged `ATTEMPT_DIVERGENCE` and its token trace is split by `attempt_id`. Auditors see two candidate rationales and the decision log's committed one; the mismatch is surfaced, not hidden. 2. **Speculative rollback stops poisoning provenance.** Draft tokens carry `speculative=true` and are excluded from rationale-hash reconstruction; the committed subsequence is extracted from verified tokens only. Benign rollback passes containment; retry splice fails fencing. 3. **Tool injections get first-class spans.** A mid-stream tool result is recorded as a `context_injection` event with a token-position anchor, so the trace can represent "the model conditioned on content it did not generate." Without this, every tool-using turn is technically a provenance fracture. The cost is that the observability pipeline must now understand attempt lifecycle and token provenance, not just span parentage. It must know when an attempt is dead, when a token is speculative, and when a context injection occurred. That is a real increase in coupling between the agent runtime and the telemetry layer — and it is the price of a correlation that is true rather than merely present. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class ProvenanceFracture(RuntimeError): """Raised when token-level trace cannot be soundly correlated to a committed decision.""" pass @dataclass class TokenSpan: attempt_id: str token_index: int token: str speculative: bool = False @dataclass class DecisionCommit: plan_node: str rationale_hash: str attempt_id: str predecessor: Optional[str] = None @dataclass class TurnTrace: trace_id: str spans: list[TokenSpan] = field(default_factory=list) injections: list[tuple[int, str]] = field(default_factory=list) # (token_index, payload_hash) def reconstruct_rationale(spans: list[TokenSpan], attempt_id: str) -> str: """Committed tokens for one attempt, excluding speculative drafts, in index order.""" committed = [s for s in spans if s.attempt_id == attempt_id and not s.speculative] committed.sort(key=lambda s: s.token_index) return "".join(s.token for s in committed) def correlate(trace: TurnTrace, commit: DecisionCommit) -> None: # Fence 1: only one attempt may contribute tokens to a single commit. attempts = {s.attempt_id for s in trace.spans} if len(attempts) > 1: raise ProvenanceFracture( f"trace {trace.trace_id} carries tokens from attempts {sorted(attempts)} " f"but commit {commit.plan_node} names only {commit.attempt_id}; " f"retry splice would fabricate provenance" ) # Fence 2: committed rationale must be recoverable from verified tokens. reconstructed = reconstruct_rationale(trace.spans, commit.attempt_id) actual_hash = hashlib.sha256(reconstructed.encode()).hexdigest() if actual_hash != commit.rationale_hash: raise ProvenanceFracture( f"rationale hash mismatch at {commit.plan_node}: " f"committed={commit.rationale_hash[:12]} reconstructed={actual_hash[:12]}; " f"token trace does not evidence the committed decision" ) # Fence 3: every mid-stream injection must be anchored, not silently absorbed. for idx, payload_hash in trace.injections: if not any(s.token_index == idx - 1 for s in trace.spans): raise ProvenanceFracture( f"context injection at token {idx} ({payload_hash[:12]}) has no " f"anchoring token span; model conditioned on unrecorded content" ) ```