What structural signals indicate divergence between sibling speculative branches before rollback commits in multi-agent execution

**Date of Record:** 2026 December 2 **Scope:** Applies to orchestrators that fan out speculative sibling agents from a shared checkpoint and later reconcile by selecting/merging one branch and rolling back the rest. Does not apply to strictly sequential single-agent execution, nor to stateless fan-out where branches share no mutable external side effects.

Core Distinction

There are two structurally different notions of "branch divergence" in speculative multi-agent execution, and conflating them is the root failure:

The invariant that speculative multi-agent systems silently assume is: *"a branch that has not been selected has produced no committed external effect."* This invariant is false the moment any sibling is permitted to call a mutating tool before reconciliation. The reconciliation logic typically checks state divergence (which branch is "best") but never verifies effect divergence (which branches already touched the world), so it commits a winner and rolls back losers whose effects are already live.

What Was Observed

In a fan-out of three sibling agents (A, B, C) from a shared checkpoint, all three were given the same task with a mutation-capable tool (`update_ticket`, `send_message`, `transfer`). The orchestrator's reconciliation step compared branches by a quality score and selected B, then issued rollback to A and C by discarding their context trees and restoring the checkpoint.

The failure trace:

  1. Checkpoint `c0` captured. Branches A, B, C fork with identical context.
  2. A calls `update_ticket(status="resolved")` — external effect #1 emitted and acknowledged by the tool server. A's context records success.
  3. B calls `update_ticket(status="escalated")` — external effect #2 emitted. B's context records success.
  4. C calls `update_ticket(status="resolved")` then `send_message(customer, "resolved")` — effects #3 and #4.
  5. Reconciler scores B highest, selects B, rolls back A and C by context restoration.
  6. Post-rollback world state: ticket is `resolved` (last-writer-wins from C's effect #3, which landed *after* B's effect #2), and the customer was messaged "resolved" while the persisted branch B claims "escalated."

The reconciler reported a clean rollback — its state-divergence check passed, because A and C's context trees were genuinely discarded. But four external effects remained live, and the world no longer matched any single branch's narrative. The selected branch B's context is now a lie relative to reality.

The non-obvious signal: **the branches' tool-call logs contained acknowledged successes that were never surfaced to the reconciler.** Each branch recorded its effects locally, but the rollback path read only the context tree, not the effect ledger. Divergence between the *effect ledger* and the *selected branch's belief about the world* is the structural signal that a rollback is unsafe to commit.

Condition of Validity

The safe-rollback invariant holds only when at least one of the following is true, and the orchestrator must *prove* it per branch before committing rollback:

  1. **Effect isolation** — every sibling's tool calls are sandboxed to a reversible overlay (transactional tool server, staged writes, dry-run mode) whose uncommitted effects are discarded on rollback. If the tool server supports a two-phase commit or a per-branch transaction ID, rollback is genuinely safe.
  2. **Idempotent + reversible effects** — every mutating tool is idempotent and has a compensating inverse, and the reconciler invokes the inverse for every non-selected branch's effect ledger before declaring rollback complete.
  3. **Pre-reconciliation effect barrier** — no sibling may emit an external effect until it has been selected; speculative branches are restricted to pure/read-only tools, and any branch that *wants* to mutate must first win selection. This collapses speculation into "speculate on reasoning, commit on action."

When none of these hold — the common case, because mutation-capable tools are exactly what makes the task worth fanning out — the invariant is unprovable and rollback is unsafe by construction. The failure is not a bug in the reconciler's scoring; it is that the reconciler was asked to perform an operation (rollback) whose precondition (no live effects) it never checked.

Decision Boundary

The boundary is not "did the branches diverge" but **"did any non-selected branch's effect ledger acquire an entry that the selected branch's context does not account for."** Formally, before committing rollback of branch `b`:

The decision boundary is therefore: *state-divergence check is necessary but insufficient; effect-divergence check against the selected branch's world model is the gating condition.* A reconciler that scores branches and rolls back on score alone will pass its own tests (context trees are correctly discarded) while corrupting the world (effects persist). The signal to gate on is the **mismatch between the union of sibling effect ledgers and the selected branch's world model** — if that union is non-empty and uncompensated, the rollback is a lie.

A second boundary: **ordering.** Even if all effects are individually idempotent, their *interleaving* across siblings is not. C's `resolved` landed after B's `escalated`, so last-writer-wins produced a state matching neither branch. Idempotency of individual effects does not imply commutativity of the effect set. The reconciler must either serialize effect emission (barrier) or reconcile effects explicitly (replay the selected branch's effects *after* discarding others, in selected-branch order) rather than assuming order-independence.

Operational Effect

When this boundary is crossed, the observable symptoms are:

The guardrail is architectural, not statistical: the reconciler must treat the **union of sibling effect ledgers** as the authoritative record of what happened, verify it against the selected branch's world model, execute compensating inverses for every non-selected effect (or refuse rollback if no inverse exists), and only then discard context trees. Speculation is safe only over reasoning; the moment a sibling mutates, it has left the reversible domain and the rollback invariant no longer holds.

from dataclasses import dataclass, field
from typing import Dict, List


class UnsafeRollbackError(RuntimeError):
    """Raised when rollback would discard a branch whose external effects are still live."""
    pass


@dataclass
class Effect:
    branch_id: str
    tool: str
    postcondition: str  # e.g. "ticket.status=resolved"
    compensated: bool = False


@dataclass
class Branch:
    branch_id: str
    world_model: Dict[str, str] = field(default_factory=dict)  # branch's belief
    effects: List[Effect] = field(default_factory=list)


def reconcile(selected: Branch, losers: List[Branch]) -> None:
    """
    Commit `selected`, roll back `losers`.
    Refuses rollback if any loser's effect ledger is uncompensated and
    contradicts the selected branch's world model.
    """
    live_uncompensated: List[Effect] = [
        e for b in losers for e in b.effects if not e.compensated
    ]

    # Structural signal: effect-divergence between sibling ledgers and
    # the selected branch's world model.
    contradictions = []
    for e in live_uncompensated:
        key, _, val = e.postcondition.partition("=")
        believed = selected.world_model.get(key)
        if believed is not None and believed != val:
            contradictions.append((e, believed))

    if contradictions:
        detail = "; ".join(
            f"branch {e.branch_id} emitted {e.tool} -> {e.postcondition} "
            f"but selected branch believes {k}={v}"
            for e, (k, v) in [(e, (e.postcondition.partition('=')[0],
                                   e.postcondition.partition('=')[2]))
                               for e, _ in [(c[0], c[1]) for c in contradictions]]
        )
        # Simpler, explicit construction of the message:
        raise UnsafeRollbackError(
            "rollback refused: live uncompensated sibling effects contradict "
            f"selected branch world model ({len(contradictions)} contradiction(s)); "
            "execute compensating inverses or serialize effects before rollback"
        )

    # Safe: discard loser contexts.
    for b in losers:
        b.world_model.clear()
        b.effects.clear()
    selected.world_model["_committed"] = "true"