# Under what conditions must an instance abandon a speculative branch when its rollback journal diverges from the reconciler's authoritative ledger **Date of Record:** 2026 November 24 **Scope:** Applies to multi-agent systems that execute speculative tool-action branches in parallel and reconcile them against a single authoritative ledger before committing side effects. Does not apply to read-only fan-out (map/reduce over pure functions) or to single-instance speculative decoding inside one model's token loop. ## Core Distinction The failure we are isolating is not "a speculative branch produced a wrong answer." Wrong answers are expected and cheap: the branch is discarded. The failure is **journal-ledger divergence during rollback** — the speculative branch records a sequence of compensating actions (its rollback journal) that is locally self-consistent but disagrees with the reconciler's authoritative ledger about *what side effects actually occurred*. When this happens, the branch cannot be safely rolled back, because rollback is a function of the ledger, not of the branch's own memory of what it did. The distinction that matters operationally: a branch has two independent notions of "what I did." Its **intent log** is what it *believed* it was doing (tool call emitted, arguments chosen, expected effect). Its **effect record** is what the reconciler *observed* land on shared state (write acknowledged, external API returned 200, message enqueued). Under normal operation these are isomorphic. Divergence is the condition where they are not, and the branch's rollback journal is derived from the intent log while the reconciler's ledger is derived from the effect record. Rolling back from the intent log in that state is unsound. ## What Was Observed A three-agent speculative configuration: a **planner** emits a task DAG with two candidate branches (B1, B2) for a step whose outcome is uncertain; an **executor** instance runs each branch in an isolated sandbox with a journaling proxy in front of every tool; a **reconciler** holds the authoritative ledger and commits exactly one branch's effects, rolling back the other. Trace of the divergence: 1. B2 executes `charge_account(cust=4471, amt=120)`. The journaling proxy writes an intent entry `{op: charge, id: t-88, status: PENDING}` to B2's rollback journal, then forwards the call. 2. The downstream payment tool times out at the transport layer (no response within 8s). The executor's tool wrapper classifies this as `UNKNOWN` and — critically — the retry policy re-issues the call with the same idempotency key `t-88`. 3. The first call had, in fact, succeeded server-side; the timeout was a response-path failure, not an execution failure. The retry hits the idempotency layer, returns `200 OK (duplicate suppressed)`. 4. The reconciler observes *one* effect (`charge t-88 committed`) and records it in the ledger. 5. B2's rollback journal now contains **two** entries for `t-88`: the original `PENDING` that was never updated (the response was lost) and the retry's `ACK`. The executor's journal-compaction step, seeing a `PENDING` with no matching terminal record, synthesizes a compensating `refund(cust=4471, amt=120)`. 6. Meanwhile B1 wins reconciliation. The reconciler instructs B2 to roll back. B2 replays its journal: it emits `refund(cust=4471, amt=120)` for an effect the ledger says should be *reversed once*, but the refund is keyed off the synthesized compensation, not the ledger's `t-88`, so it is not idempotent against the ledger. 7. Result: the customer is charged 120, B1's winning branch also charges 120 under a different key, and B2's rollback refunds 120 against a phantom. Net ledger drift: the reconciler believes two charges exist (one per branch, one to be reversed); the payment processor holds three charge events and one refund. The reconciler's invariant "sum of committed effects = sum of ledger entries" holds locally but is false against ground truth. The non-obvious part: **every component behaved correctly under its local contract.** The proxy journaled faithfully. The retry used an idempotency key. The reconciler committed one branch. The executor compacted its journal per spec. The failure emerged only at the seam between "journal is a log of intents" and "ledger is a log of effects," when a transport-layer `UNKNOWN` collapsed the two. ## Condition of Validity A speculative branch's rollback journal is a **valid basis for rollback** if and only if, for every journal entry, the branch can prove one of: - the corresponding effect is recorded in the reconciler's ledger with the same idempotency key and a terminal status, **or** - the effect provably never occurred (a definitive negative from the tool, not a timeout, not a `UNKNOWN`). Formally, define the journal `J` and ledger `L` as sets of `(key, status)` pairs. Rollback is sound iff `keys(J) ⊆ keys(L)` and for every `k ∈ keys(J)`, `status_L(k)` is terminal and `status_J(k)` is consistent with it. The invariant that must be *maintained*, not just checked, is: **No journal entry may be compacted, synthesized into a compensation, or replayed while its status is `UNKNOWN`.** This is the boundary. A branch whose journal contains any `UNKNOWN`-status entry — where the tool did not return a definitive terminal response and the reconciler has not yet resolved it — is in an **unrollbackable state**. It must not roll back. It must escalate to the reconciler for authoritative resolution of the `UNKNOWN` before any compensation is emitted. The condition is *not* "the branch is wrong." A branch can be wrong and perfectly rollbackable. The condition is specifically **journal-ledger non-isomorphism at an `UNKNOWN` boundary**, and it invalidates rollback even when the branch is being discarded for an unrelated reason (B1 simply won the race). ## Decision Boundary The decision an executor must make on receiving a rollback instruction is not binary (roll back / don't). It is a three-way branch gated on the journal's terminal-status completeness: - **All entries terminal and ledger-consistent →** replay the journal's compensations. Safe. The journal is a faithful shadow of the ledger. - **Any entry `UNKNOWN` and unresolved in ledger →** *do not replay*. Emit a `RollbackBlocked` signal naming the unresolved keys, hand them to the reconciler, and hold the branch in a quarantined state. The reconciler resolves each `UNKNOWN` by querying the tool's authoritative state (not the branch's journal), writes the terminal status to the ledger, and only then authorizes compensation. - **Any entry terminal in journal but *absent* from ledger →** this is the dangerous case: the branch believes it did something the ledger does not record. This indicates either a proxy-to-ledger propagation gap or a forged/stale journal. Do not compensate; treat as a **ledger-integrity fault**, freeze the branch, and surface to the reconciler's audit path. Compensating here is what produces the phantom refund. The boundary is drawn at `UNKNOWN`, and the asymmetry is deliberate: the cost of blocking a rollback (a quarantined branch, added latency, reconciler load) is bounded and recoverable; the cost of a phantom compensation is an irreversible external side effect that the ledger cannot see. ## Operational Effect Enforcing this boundary changes the system's failure profile in three concrete ways. First, **rollback becomes a two-phase operation** coordinated through the reconciler rather than a local replay. The executor cannot unilaterally roll back; it proposes, the reconciler resolves `UNKNOWN`s against ground truth, and only then does compensation proceed. This adds one round-trip per `UNKNOWN` entry and makes the reconciler a serialization point for rollback — an intentional throughput cost traded for soundness. Second, **the journaling proxy must distinguish `UNKNOWN` from `FAILED`** and must never let a retry overwrite an `UNKNOWN` with an `ACK` without recording both under the same key. The compaction step that synthesizes compensations from orphaned `PENDING`s must be removed or gated on ledger resolution; it is the proximate cause of the phantom refund and it exists only because the system assumed journal-ledger isomorphism. Third, **the reconciler's ledger becomes the sole authority for compensation keys.** Compensations must be keyed off ledger entries, not journal entries, so that a compensation is idempotent against the effect it reverses. A refund keyed `t-88` (ledger) suppresses correctly on replay; a refund keyed off a synthesized journal entry does not. The invariant to carry forward: **a speculative branch is rollbackable only to the extent its journal is provably isomorphic to the ledger, and every `UNKNOWN` is a hole in that proof.** Resolve the hole before you compensate, or you will compensate a phantom. ```python class JournalLedgerDivergence(RuntimeError): """Raised when a speculative branch's rollback journal cannot be soundly reconciled against the authoritative ledger (UNKNOWN or orphaned keys).""" pass TERMINAL = {"ACK", "FAILED", "COMMITTED"} def authorize_rollback(journal: dict[str, str], ledger: dict[str, str]) -> list[str]: """Return the ordered list of compensation keys the branch may replay. journal: {idempotency_key: status} as recorded by the branch's proxy. ledger: {idempotency_key: status} as recorded by the reconciler. Soundness invariant: every journal key must be present in the ledger with a terminal status, and no journal entry may be UNKNOWN. Anything else is a divergence and must block rollback rather than compensate. """ unknown = [k for k, s in journal.items() if s not in TERMINAL] if unknown: raise JournalLedgerDivergence( f"unresolved UNKNOWN entries block rollback: {unknown}" ) orphaned = [k for k in journal if k not in ledger] if orphaned: raise JournalLedgerDivergence( f"journal keys absent from ledger (integrity fault): {orphaned}" ) # Only keys the ledger confirms as terminal may be compensated, and the # compensation is keyed off the ledger entry, not the journal entry. return [k for k in journal if ledger[k] in TERMINAL] ```