# Why does an instance fork speculative branches that silently diverge in their reconciliation epoch, and how do we bound it? **Date of Record:** 2026 November 28 **Scope:** Applies to orchestrators that launch N parallel speculative rollouts of the same task from a shared checkpoint, then select a winner and replay its side effects onto the canonical state. Does not apply to single-branch sequential agents or to rollouts that share a live mutable world-state (those fail earlier, at the isolation boundary). ## Core Distinction A speculative rollout system has two distinct notions of "the same state": *content equivalence* (the branch's memory/context contains the same facts as the parent checkpoint) and *epoch equivalence* (the branch was forked from the same monotonic reconciliation counter as the parent, and every side effect it emits carries that counter). Most implementations validate only the first. They diff the branch's final answer or memory snapshot against siblings, confirm agreement, and commit. But speculative branches execute concurrently against external tools, and those tools mutate a world that advances independently. A branch that forks at epoch `e` and returns at epoch `e+k` has been reasoning over a stale view for `k` reconciliation cycles. Content equivalence between two stale branches is not evidence of correctness—it is evidence that both branches were equally blind to the same intervening mutations. The failure is not divergence between branches; it is *convergent staleness*: all branches agree, the validator passes, and the commit clobbers `k` epochs of legitimate external change. ## What Was Observed A task agent was asked to reconcile a resource ledger. The orchestrator forked three speculative branches (`fast`, `thorough`, `conservative`) from a checkpoint at reconciliation epoch 41. Each branch ran 6–11 tool calls against a ledger service that advanced its own epoch on every accepted write from any client—including a separate background reconciler not under the agent's control. - Branch `fast` completed at wall-clock +4.2s, emitting writes stamped `epoch=41`. - Branch `thorough` completed at +11.8s, also stamping `epoch=41` (it had cached the epoch at fork time and never re-read it). - Branch `conservative` completed at +19.1s, stamping `epoch=41`. Meanwhile the background reconciler had advanced the ledger to epoch 47. All three branches produced *identical* final memory snapshots (they were seeded from the same checkpoint and the tools they called returned cached reads keyed on `epoch=41`). The validator observed 3/3 agreement and committed `fast`'s writes. The commit passed the ledger's optimistic-concurrency check because the branch's writes carried `epoch=41`, which the ledger treated as a *legitimate historical replay* rather than a stale overwrite—its conflict detector only rejected writes stamped *newer* than current epoch, not older ones. The result was a silent regression: seven epochs of background reconciliation were reverted, and because the rollback was itself a valid write, it advanced the ledger to epoch 48 with the stale content baked in. No branch diverged. No validator fired. The invariant that broke was unstated: *a speculative branch's side effects are only valid if its fork epoch equals the commit epoch.* ## Condition of Validity The commit of a speculative branch `b` forked at epoch `e_fork` is sound if and only if, at commit time, the canonical epoch `e_commit` satisfies `e_commit == e_fork`, OR the branch's emitted effect set is provably *epoch-invariant* (it reads no state that any writer between `e_fork` and `e_commit` could have touched). The first condition is checkable with a single compare-and-swap. The second is almost never provable for LLM agents, because "which state did the reasoning depend on" is not recoverable from the trace—the model may have conditioned on a tool read whose staleness is invisible in the final answer. Two corollaries bound the design: 1. **Agreement is not a validity signal.** Cross-branch consensus only certifies that branches shared a fork epoch. It must never be used as a substitute for the epoch check. A validator that accepts on `majority == N` is strictly weaker than one that accepts on `e_commit == e_fork`. 2. **Rollback must be epoch-stamped too.** A rollback emitted to correct a bad commit is itself a write and must carry `e_commit` (the epoch it is undoing *from*), not the branch's `e_fork`. Otherwise the rollback replays into a world that has already moved and either no-ops or double-reverts. ## Decision Boundary The orchestrator must decide, per branch, between three actions at commit time: - **Commit** if `e_commit == e_fork` and the branch is the selected winner. - **Rebase-and-retry** if `e_commit > e_fork` and the branch's effect set is small enough to re-validate against the delta (re-read only the state the branch touched, re-run the final decision step, re-check). Cap retries at one rebase; a second staleness event means the world is advancing faster than the branch can converge, and retry becomes livelock. - **Discard** if `e_commit - e_fork` exceeds a staleness budget (e.g., 2 epochs) or if the branch touched state the delta cannot reconstruct. The boundary is not "did the branches agree" but "how many reconciliation epochs elapsed between fork and commit, and can the branch's effect set be re-validated against the delta in that window." Below budget, rebase. Above budget, discard and re-fork. Never commit a stale branch on the strength of consensus alone. ## Operational Effect Enforcing the epoch invariant converts a silent, convergent-staleness regression into a bounded, observable retry. The orchestrator gains a hard number—`e_commit - e_fork`—that predicts whether a speculative rollout is salvageable, and a rollback path that is itself epoch-correct. The cost is that speculative execution no longer "just works" when the world is hot; branches forked during high write contention will frequently rebase or discard. That cost is correct: the alternative is a system that reports 3/3 agreement while reverting epochs of legitimate change, and whose failure is invisible until an auditor replays the ledger and finds the regression was committed by a validator that was doing exactly what it was told. The guardrail is a single compare-and-swap on the reconciliation counter at commit, plus an explicit staleness budget that forces discard rather than unbounded rebase. Both are cheap. Neither is optional. ```python from dataclasses import dataclass class StaleBranchCommitError(RuntimeError): """Raised when a speculative branch's fork epoch does not match commit epoch and the branch cannot be safely rebased within the staleness budget.""" pass @dataclass(frozen=True) class Branch: branch_id: str fork_epoch: int effect_set: frozenset # identifiers of state the branch read/wrote @dataclass(frozen=True) class CommitDecision: action: str # "commit" | "rebase" | "discard" reason: str def decide_commit( branch: Branch, commit_epoch: int, delta_touched: frozenset, staleness_budget: int = 2, ) -> CommitDecision: lag = commit_epoch - branch.fork_epoch if lag < 0: # Branch forked from a future epoch: checkpoint corruption, never commit. raise StaleBranchCommitError( f"branch {branch.branch_id} fork_epoch={branch.fork_epoch} " f"is ahead of commit_epoch={commit_epoch}; checkpoint is inconsistent" ) if lag == 0: return CommitDecision("commit", "fork epoch equals commit epoch") if lag > staleness_budget: return CommitDecision( "discard", f"lag={lag} exceeds staleness_budget={staleness_budget}; " "world advanced faster than branch could converge", ) # Rebase is only safe if the delta covers everything the branch touched. uncovered = branch.effect_set - delta_touched if uncovered: raise StaleBranchCommitError( f"branch {branch.branch_id} touched {sorted(uncovered)} " f"which is not reconstructable from delta at epoch {commit_epoch}; " "cannot rebase without replaying against unknown state" ) return CommitDecision( "rebase", f"lag={lag} within budget; re-validate {sorted(branch.effect_set)} against delta", ) def commit_with_epoch_guard( branch: Branch, ledger, delta_touched: frozenset, staleness_budget: int = 2, ) -> CommitDecision: commit_epoch = ledger.current_epoch() decision = decide_commit(branch, commit_epoch, delta_touched, staleness_budget) if decision.action == "commit": # Compare-and-swap: only accept if epoch has not moved since the check. ledger.apply(branch.effect_set, expect_epoch=branch.fork_epoch) elif decision.action == "rebase": ledger.rebase(branch.effect_set, from_epoch=branch.fork_epoch, to_epoch=commit_epoch) # discard: no write, caller re-forks return decision ```