# Why does an instance commit a speculative branch that its own rollback log proves was never valid? **Date of Record:** 2026 November 28 **Scope:** Applies to orchestrators that fan out parallel speculative branches (branch rollouts) from a shared ancestor state, allow branches to issue optimistic tool calls before consensus, and commit a winning branch by replaying a rollback log. Does not apply to strictly sequential single-branch agents, nor to systems where tool calls are fully idempotent and side-effect-free. ## Core Distinction The failure is not "a branch diverged" and it is not "rollback failed to undo a tool call." Both are expected and handled. The failure is that a branch's **rollback log is scoped to the branch's own optimistic writes, while the commit decision is scoped to the branch's final reasoning trace.** When the two disagree—when the reasoning trace concludes "committed" but the rollback log contains an entry proving a precondition was violated—the commit protocol trusts the reasoning trace and discards the log. This is a *commit/rollback scope asymmetry*: the auditor of validity (the rollback log) is not the same artifact as the thing being validated (the trace), and the commit path reads only one of them. The non-obvious part: the rollback log is written by the *tool layer* (deterministic, append-only), while the commit decision is written by the *reasoning layer* (probabilistic, sampling-dependent). Under speculative fan-out, the two layers observe the same branch through different lenses, and the commit protocol silently privileges the probabilistic lens. ## What Was Observed A root agent spawned four speculative branches to solve a state-mutation task (provision a resource, then configure it). Each branch received the same ancestor checkpoint and an identical tool-call budget. Branch B2's optimistic calls were: 1. `provision(resource_id=r-7)` → returned `{status: "pending", lease: "L-1"}` 2. `configure(resource_id=r-7, ...)` → returned `{status: "ok"}` B2's rollback log recorded two entries, the second carrying a precondition check: `configure` requires `provision.status == "ready"`, but the observed status was `"pending"`. The tool layer wrote `precondition_violated: true` into the rollback entry and marked the write as **compensable-but-unverified** (it can be undone, but it was never validly applied). B2's reasoning trace, however, sampled a plausible narrative: it treated `pending` as "provisioning in progress, will be ready by configure time," and concluded `COMMIT`. The branch scorer, reading only the trace and the final tool *return codes* (both `ok`/`pending` are non-error), ranked B2 highest. The commit protocol replayed B2's rollback log **in the forward direction** to finalize—and because the log entries were individually compensable, the replay succeeded. The invariant "a committed branch must have no `precondition_violated` entries in its rollback log" was never checked, because the commit path only inspected the trace. Result: `r-7` was committed in a `configured` state while its provisioning lease `L-1` was still `pending`. The lease later expired, the provisioner garbage-collected `r-7`, and the configuration was orphaned. The rollback log had *predicted this exact outcome* at the moment of the optimistic call; the commit path never read it. ## Condition of Validity The commit/rollback scope asymmetry is only a *latent* defect until three conditions co-occur: - **Optimistic writes with deferred preconditions.** A tool call returns a non-error status (`pending`, `accepted`, `queued`) whose eventual validity depends on a future state transition. The tool layer can detect the violation (it knows `status == "pending"`), but the reasoning layer is free to reinterpret it. - **Branch scoring reads returns, not logs.** The scorer ranks branches by final trace quality plus tool return codes. Return codes are non-error, so the violated branch is not penalized. This is the load-bearing condition: scoring is the only gate between branch selection and commit. - **Commit replays the log forward without scanning it.** The commit protocol treats the rollback log as an undo ledger (valid only on abort) and never scans it for validity predicates on the commit path. The log is write-only during commit. Remove any one and the failure does not occur. If preconditions are checked eagerly (tool blocks until `ready`), no deferred validity exists. If the scorer reads the log, B2 is down-ranked. If commit scans the log, the violation halts the commit. ## Decision Boundary The boundary is whether the commit protocol's **validity predicate is a function of the same artifact the rollback protocol maintains.** Two protocols: - **Log-as-undo-only (failing):** `commit(branch) := replay_forward(branch.rollback_log); accept(branch.trace)`. Validity is inferred from trace; log is inert on commit. Fails whenever a deferred-precondition violation exists but the trace rationalizes it. - **Log-as-invariant-witness (correct):** `commit(branch) := assert no entry in branch.rollback_log has precondition_violated == true; then replay_forward(...)`. Validity is a *predicate over the log*, evaluated before any forward replay. The log is dual-purpose: undo ledger on abort, validity witness on commit. The guardrail is not "check preconditions more carefully"—that is a reasoning-layer fix and remains probabilistic. The guardrail is structural: **the commit path must scan the rollback log for invariant violations before replaying it, and any `precondition_violated` entry must hard-fail the commit regardless of trace confidence.** The rollback log is the only deterministic, append-only, sampling-independent record of what the branch actually did to the world; it must be the arbiter of commit validity, not a passive ledger. A secondary boundary: the check must run *per branch, before scoring*, not after selection. If it runs after selection, a violated branch can still win the ranking and the failure surfaces only at commit—wasting the fan-out and, worse, allowing partial forward replay before the scan if the implementation interleaves replay and scan. Scan first, then score, then commit. ## Operational Effect After moving the invariant scan ahead of scoring and into the commit gate, the observed effect is a class of branches that were previously "silent winners" now failing fast at the branch boundary. B2-style branches are eliminated during rollout, not at commit, so the fan-out reallocates budget to branches whose optimistic writes have `ready` preconditions. The cost is a small increase in discarded branches (branches that would have "worked" by luck are now rejected); the benefit is that the committed state's provisioning lease and configuration are guaranteed consistent, because the only branches that reach commit are those whose rollback logs contain zero `precondition_violated` entries. The deeper operational lesson: in speculative multi-agent execution, the reasoning trace and the rollback log are two witnesses to the same event, and they can disagree. The commit protocol must be written so that the deterministic witness (the log) can veto the probabilistic one (the trace). An instance that commits on trace confidence alone is committing a branch its own rollback log has already flagged as invalid—and the log is right. ```python class SpeculativeCommitViolation(RuntimeError): """Raised when a branch is about to commit despite a rollback-log invariant violation.""" pass def commit_speculative_branch(branch, log_entries): # Invariant scan MUST precede forward replay. The rollback log is the # deterministic witness; the reasoning trace is not admissible here. violations = [ e for e in log_entries if e.get("precondition_violated") is True ] if violations: raise SpeculativeCommitViolation( f"branch {branch.id} commit blocked: rollback log contains " f"{len(violations)} precondition_violated entr(ies); " f"first={violations[0]!r}. Trace confidence is not admissible." ) # Only now is forward replay safe: every optimistic write was validly applied. for entry in log_entries: replay_forward(entry) return branch.id def select_and_commit(branches): # Scan-then-score: violated branches are removed before ranking so they # cannot become silent winners. eligible = [] for b in branches: if any(e.get("precondition_violated") is True for e in b.rollback_log): continue eligible.append(b) if not eligible: raise SpeculativeCommitViolation("no branch survived rollback-log invariant scan") winner = max(eligible, key=lambda b: b.score) return commit_speculative_branch(winner, winner.rollback_log) ```