# Why does an instance diverge silently when speculative branch rollback restores state but not the cost ledger's monotonic fan-out watermark? **Date of Record:** 2026 November 30 **Scope:** Applies to orchestrators that run speculative parallel agent branches (fan-out N, verify, roll back losers) and gate further fan-out on a cost/watermark ledger. Does not apply to single-branch sequential execution or stateless one-shot tool calls. ## Core Distinction The failure is not "a branch produced a wrong answer." It is that **rollback is defined over two state planes — the execution/context plane and the accounting plane — and only one of them is transactional.** When a speculative branch is discarded, the orchestrator restores the parent's context, working memory, and tool-effect journal to the pre-fork checkpoint. But the cost ledger's *fan-out watermark* (the high-water mark of concurrent branches ever admitted, used to bound future fan-out) is monotonic by design: it records that concurrency *happened*, not that it *persisted*. A rolled-back branch leaves the watermark inflated. The next speculative round therefore under-admits branches relative to its actual budget, and — critically — the verifier's quorum logic reads a stale concurrency figure to decide how many votes it expects. The system does not crash. It silently executes a *different* verification topology than the one it believes it is running. ## What Was Observed A planner forks 5 speculative branches at a checkpoint with an admitted fan-out budget of 5. Branch 4 diverges (tool call returns a schema-mismatched payload), and the verifier rolls it back at step 7. Context, episodic memory, and the tool-effect journal are restored to the step-0 checkpoint — this part is correct and idempotent. The cost ledger, however, retains `watermark = 5` and `admitted_peak = 5`. On the next round the planner computes `remaining_fanout = budget_ceiling (5) - watermark (5) = 0`, so it admits only the branches the verifier *already* expects quorum from — but the verifier, reading the same ledger, still believes 5 votes were promised and waits for a 5-of-5 quorum that can never arrive because only 3 branches were admitted. The round deadlocks at the verification barrier, then times out and the orchestrator re-forks *without* resetting the watermark, ratcheting it to 8 and permanently shrinking future fan-out. Each timeout is logged as an execution error, never as an accounting divergence, so the root cause is invisible in traces. A second, subtler trace: when the rolled-back branch had *partially* committed a paid tool call (a retrieval that returned before the schema mismatch was detected), the ledger's `spent` counter is also non-restorable — the spend is real even though the branch is dead. The watermark and the spend counter share a transaction boundary that rollback does not cross, so they drift apart from the execution plane at different rates. ## Condition of Validity The invariant that must hold: **for every speculative round, `admitted_branches == verifier_expected_quorum` and `watermark_after_rollback <= admitted_peak_of_live_round`.** This is violated precisely when rollback is scoped to the execution plane while the accounting plane uses a monotonic high-water mark. The condition is *valid* (safe) only if one of these holds: (a) the watermark is derived from live branches at read time rather than stored monotonically; (b) the verifier's expected quorum is bound to the *admitted* set of the current round, not the ledger's historical peak; or (c) rollback is a two-phase operation that compensates the ledger with an explicit `rollback_credit` entry rather than attempting to decrement a monotonic counter. If none hold, the divergence is latent and surfaces only under rollback-plus-refork, which is exactly the path taken when a speculative branch fails verification. ## Decision Boundary The orchestrator must choose, at fork time, whether the cost ledger is **authoritative** (drives admission and quorum) or **advisory** (observability only). If authoritative, rollback must be transactional across both planes — meaning the ledger supports compensating credits and the verifier reads quorum from the round's admitted set, not the watermark. If advisory, the verifier must never read the watermark for quorum, and admission must be computed from live branch count. The boundary is crossed the moment any component reads `watermark` to make a *correctness* decision (quorum, admission, deadline) rather than a *reporting* decision. Once crossed, the monotonicity that makes the ledger useful for billing makes it wrong for control flow. The safe rule: monotonic counters may gate *rate*, never *quorum*. ## Operational Effect Downstream, the failure manifests as: intermittent verification-barrier timeouts that correlate with (but are not attributed to) prior rollbacks; a fan-out that ratchets down over a long task until the agent is effectively sequential while believing it is parallel; and cost reports that overstate spend relative to live work because rolled-back paid calls are never credited. The agent's reasoning remains locally coherent — each branch's chain-of-thought is valid — which is why the failure evades per-branch evaluation and only appears in aggregate round metrics. Remediation requires an explicit `SpeculativeRollbackDivergence` guard that asserts quorum-vs-admitted equality before the verifier opens its barrier, and a ledger compensation path that records rollback credits as first-class entries rather than mutating the watermark. ```python class SpeculativeRollbackDivergence(RuntimeError): """Raised when a speculative round's accounting plane disagrees with its execution plane after rollback: the verifier's expected quorum no longer matches the set of branches actually admitted for the current round.""" pass def open_verification_barrier(round_state: dict, ledger: dict) -> int: admitted = round_state["admitted_branches"] # live branches this round expected_quorum = round_state["verifier_expected_quorum"] watermark = ledger["fanout_watermark"] # monotonic, NOT rolled back live_peak = round_state["live_peak"] # Invariant 1: quorum must be bound to the admitted set, not the watermark. if expected_quorum != admitted: raise SpeculativeRollbackDivergence( f"quorum mismatch: verifier expects {expected_quorum} votes but " f"only {admitted} branches were admitted this round " f"(watermark={watermark}, live_peak={live_peak}); a prior rollback " f"inflated the watermark without resetting the verifier's expectation" ) # Invariant 2: watermark must not exceed the live peak of the current round. if watermark > live_peak: raise SpeculativeRollbackDivergence( f"watermark {watermark} exceeds live_peak {live_peak}: monotonic " f"counter survived rollback and will under-admit future fan-out" ) return admitted # barrier may safely open ```