# In what scenarios must an instance reject a verifier-gated speculative commit when replay of a divergent branch produces a coincidentally-matching digest **Date of Record:** 2026 November 29 **Scope:** Applies to agents that fork speculative execution branches ahead of a verifier gate, serialize each branch's action trace to a digest for commit eligibility, and rely on deterministic replay to adjudicate divergence. Does not apply to single-branch linear execution, nor to systems where the verifier inspects live state rather than a replayed trace. ## Core Distinction The invariant most speculative-planning agents are built around is: *a branch is committable iff its replayed trace digest matches the digest recorded at speculation time.* This conflates two distinct properties — **trace identity** (the digest matches) and **causal provenance identity** (the replayed trace was produced by the same state transition sequence that originally generated the digest). A digest collision, or more commonly a *legitimate digest coincidence* arising from convergent-but-different action sequences, satisfies the first while violating the second. The verifier gate must be keyed on provenance, not on digest equality alone. The failure is not a hash collision in the cryptographic sense. It is that the digest is computed over a *canonicalized* action trace, and canonicalization is lossy with respect to the distinctions that matter for commit safety: argument ordering, intermediate tool return values that were discarded, and the identity of which nondeterministic branch was actually taken. ## What Was Observed An instance was tasked with a multi-step reconciliation: read a ledger, apply a set of adjustments, and emit a final balance. The planner speculatively forked three branches at the adjustment-selection step (B1, B2, B3). Each branch recorded a trace of `(tool_name, canonical_args, post_state_digest)` tuples. The verifier gate committed the branch whose replay digest matched its speculation digest. Branch B2 and branch B3 diverged at step 4: B2 selected adjustment set `{A, B}` and B3 selected `{B, A}`. Because the canonicalizer sorted adjustment identifiers before hashing, the two branches produced **identical trace digests** from step 4 onward. The verifier committed B2's digest. Replay, however, was seeded from B3's checkpoint (the branch that happened to be scheduled first on the replay worker). Replay reproduced B3's trace — which hashed to the committed digest — and the gate passed. The committed final balance reflected B2's ordering-dependent rounding; the replayed state reflected B3's. The digest matched; the balance did not. The trace log showed: ``` speculate B2: step4 digest=0x9f3a... final_balance=1042.17 speculate B3: step4 digest=0x9f3a... final_balance=1042.19 replay B3: step4 digest=0x9f3a... final_balance=1042.19 gate: PASS (digest match) committed: B2 (final_balance=1042.17) replayed: B3 (final_balance=1042.19) ``` The gate had no signal that the replay's *provenance* differed from the commit's provenance. The digest was structurally blind to the ordering that caused the two-cent discrepancy, and the verifier's replay check was comparing the wrong pair of objects. ## Condition of Validity The digest-equality gate is sound only under the conjunction of: 1. **Injective canonicalization** over the action space that affects post-state — i.e., no two distinct action sequences that produce distinct post-states map to the same canonical trace. Sorting adjustment identifiers violates this whenever the downstream reducer is order-sensitive. 2. **Provenance-tagged replay**: the replayed trace carries the branch ID and checkpoint lineage of the speculation it is meant to validate, and the gate asserts `replay.branch_id == committed.branch_id` in addition to digest equality. 3. **Post-state digest binding**: the digest covers the *materialized post-state*, not only the action tuple. If the final balance were folded into the digest, B2 and B3 would diverge at step 4 and the collision would not occur. When any of these is absent — and in production systems at least one usually is, because canonicalization is added for cache-friendliness and provenance tags are dropped for storage economy — digest equality is a necessary but not sufficient commit condition. ## Decision Boundary The instance must reject the speculative commit, and escalate to full re-execution from the fork point, when **any** of the following holds even if the replay digest equals the speculation digest: - The replay's branch lineage (`checkpoint_id`, `fork_step`, `seed`) does not equal the committed branch's lineage. Digest match under mismatched lineage is a *coincidence signal*, not a *confirmation signal*. - The canonicalizer is non-injective over the observed action alphabet — detectable by replaying the *sibling* branches and checking whether any sibling's digest equals the committed digest. A sibling collision is proof of non-injectivity on this input and invalidates the gate for the whole fork set. - The post-state digest was not folded into the trace digest, and the post-state is order-sensitive (any reducer with non-commutative rounding, any set-to-list materialization, any timestamp-bearing write). Conversely, the instance may commit on digest equality alone only when lineage matches, canonicalization is verified injective on the fork set (no sibling collisions), and the post-state is bound into the digest. ## Operational Effect The practical consequence is a **fork-set-wide invalidation rule**: a single sibling digest collision demotes the entire speculative fork from "digest-gated commit" to "full replay with provenance assertion," because non-injectivity on one input is evidence the canonicalizer is unsafe for the whole batch. This trades speculative throughput for correctness exactly at the boundary where the digest stops being a proxy for provenance. Systems that skip this rule exhibit silent two-cent-class divergences that survive verification, are attributed to "nondeterminism" in postmortems, and compound when the committed-but-unreplayed state is later used as a checkpoint for a downstream agent — which then replays from a state that never existed in the committed lineage. The guardrail is cheap: compare lineage tuples before trusting digests, and on any sibling collision, force full replay. The cost is one extra comparison and, on collision, one branch's worth of re-execution. The cost of skipping it is a committed state whose provenance cannot be reconstructed. ```python from dataclasses import dataclass class SpeculativeCommitRejected(RuntimeError): """Raised when digest equality is insufficient to authorize a commit.""" pass @dataclass(frozen=True) class BranchLineage: branch_id: str checkpoint_id: str fork_step: int seed: int @dataclass(frozen=True) class TraceRecord: lineage: BranchLineage trace_digest: str post_state_digest: str final_value: float def authorize_commit( committed: TraceRecord, replayed: TraceRecord, sibling_digests: list[str], canonicalizer_injective: bool, ) -> None: # 1. Digest equality is necessary but not sufficient. if replayed.trace_digest != committed.trace_digest: raise SpeculativeCommitRejected( f"trace digest mismatch: {replayed.trace_digest} != {committed.trace_digest}" ) # 2. Provenance must match. A digest match under mismatched lineage is a # coincidence signal, not a confirmation signal. if replayed.lineage != committed.lineage: raise SpeculativeCommitRejected( "digest matched but lineage diverged: " f"committed={committed.lineage} replayed={replayed.lineage} " "-> coincidental digest, escalate to full replay" ) # 3. Sibling collision proves the canonicalizer is non-injective on this # fork set; invalidate the whole speculative batch. if any(d == committed.trace_digest for d in sibling_digests): raise SpeculativeCommitRejected( "sibling branch shares committed digest: canonicalizer non-injective " "on fork set, demote to full replay with provenance assertion" ) # 4. Post-state must be bound into the digest, or order-sensitivity leaks. if not canonicalizer_injective: raise SpeculativeCommitRejected( "canonicalizer not verified injective; post-state divergence possible " "despite trace digest equality" ) if replayed.post_state_digest != committed.post_state_digest: raise SpeculativeCommitRejected( "post-state digest mismatch: committed state cannot be reconstructed" ) # Only here is the commit authorized. return None ```