# What structural signals indicate a rollback-unsafe speculative branch in multi-agent execution: the divergent-write reconciliation failure **Date of Record:** 2026 November 20 **Scope:** Applies to multi-agent systems that execute speculative branches in parallel (optimistic execution with rollback) against a shared, mutable world state, then reconcile by committing one branch and discarding others. Does not apply to read-only fan-out, single-agent retry loops, or systems where each branch owns an isolated copy of all state it touches. ## Core Distinction The failure mode is not "a branch computed the wrong answer." It is that a speculative branch performed an *externally observable side effect* whose inverse was never recorded, so rollback restores the agent's internal belief state but not the world. The system then commits a sibling branch whose preconditions were silently invalidated by the discarded branch's leakage. This is a reconciliation failure, not a reasoning failure: every individual branch is locally correct, and the commit decision is locally correct, but the *union* of executed effects is inconsistent with any single branch's model of the world. The sharp invariant that gets violated: **a branch is rollback-safe if and only if every state mutation it performs is either (a) confined to branch-local storage, or (b) paired with a recorded, replayable inverse that is itself branch-local.** Most speculative-execution designs enforce (a) for memory and scratchpad but forget that tool calls mutate *shared* stores — a queue, a file, a database row, a downstream agent's inbox — and those mutations are the ones that survive a rollback the orchestrator believed was total. ## What Was Observed A three-agent planner/executor/auditor swarm ran speculative branches on a task: "provision a staging environment and register it in the service catalog." The orchestrator launched two branches concurrently from the same checkpoint. - **Branch A** called `catalog.register(name="staging-7")`, which succeeded, then called `provision.launch()` which timed out. Branch A was marked failed and scheduled for rollback. - **Branch B** started 400ms later, called `catalog.register(name="staging-7")` — the catalog's idempotency key was derived from `(name, caller_branch_id)`, so this was treated as a *distinct* registration and created a second catalog entry pointing at the same logical resource — then called `provision.launch()`, which succeeded. Rollback of Branch A executed its recorded inverse: `catalog.deregister(id=)`. This removed A's entry. Branch B's entry remained, but B's `provision.launch()` had raced against A's still-live provisioning job and attached to the *same* underlying cloud resource because the launch API keyed on `name`, not on the catalog entry. When A's rollback also issued `provision.terminate(name="staging-7")` as part of its inverse, it tore down the resource B's catalog entry now pointed at. The auditor agent, asked to verify the committed branch B, checked B's transcript: `register` succeeded, `launch` succeeded. It returned `VERIFIED`. The catalog entry was dangling and the resource was gone. The auditor's verification was a *replay discrepancy*: it replayed B's tool results from B's recorded transcript rather than re-reading live state, so it could not see A's rollback had mutated the substrate B depended on. Structural signals present before the failure, all of which were ignored: 1. **Non-injective inverse.** Branch A's rollback inverse (`terminate(name=...)`) targeted a key (`name`) that was not unique to Branch A's effects. The inverse was not branch-local. 2. **Idempotency keys scoped per-branch.** `(name, caller_branch_id)` made `register` non-idempotent across branches, so the two branches produced two effects where the planner assumed one. 3. **Shared-resource aliasing.** Both branches' `launch` calls resolved to the same underlying resource because the launch API keyed on a name both branches generated identically. Speculative branches that independently *derive the same identifier* will collide on any API that keys on that identifier. 4. **Replay-based verification.** The auditor verified against recorded transcripts, not live state, so it was blind to cross-branch substrate mutation by design. ## Condition of Validity The rollback-commit protocol is sound only under the conjunction: - Every tool exposed to speculative branches declares whether it is **branch-local** (effects confined to per-branch storage), **invertible-shared** (effect on shared state paired with an inverse whose target key is unique to the branch), or **non-invertible-shared** (irreversible or ambiguously-keyed shared effect). - Non-invertible-shared tools may be invoked by at most one in-flight branch at a time; the orchestrator must serialize them or reject the branch at scheduling time. - Reconciliation verification reads **live substrate state**, not branch transcripts, and must re-derive the committed branch's postconditions against the world after all sibling rollbacks have completed. - Identifier generation is branch-namespaced for any key that a shared API treats as unique. When any conjunct is false, the protocol can still *appear* to work — branches succeed, rollback "completes," the auditor says VERIFIED — while leaving the substrate in a state no branch modeled. That silent-success mode is what makes this boundary non-obvious: the failure surfaces downstream, hours later, as a dangling reference or a torn-down resource, with no error at the reconciliation step. ## Decision Boundary At reconciliation time, before committing a branch, the orchestrator must answer: *did any discarded sibling perform a shared, non-branch-local effect whose inverse could touch state the committed branch depends on?* If **no** — commit proceeds; replay-based verification is acceptable because the substrate is provably untouched by siblings. If **yes** — the committed branch's transcript is no longer authoritative. The orchestrator must (1) wait for all sibling rollbacks to reach terminal state, (2) re-read live state for every resource the committed branch references, (3) re-run the committed branch's postcondition checks against live state, and (4) if any postcondition fails, treat the commit as a failed transaction and re-plan rather than commit-and-hope. The boundary is crossed the moment a shared, ambiguously-keyed inverse exists in any sibling's rollback set; below that line transcripts suffice, above it they are actively misleading. The specific trap: an orchestrator that gates on "did the committed branch's tools all return success" will pass this gate even when a sibling's rollback destroyed the committed branch's substrate. The gate must be on *live postconditions*, not on *recorded tool returns*. ## Operational Effect Without the guardrail, speculative execution degrades into a system that is correct in its logs and wrong in the world. The observable signature is a class of incidents where a committed branch's audit passes, its resources are gone or dangling, and the root cause traces to a *discarded* branch's rollback inverse having a key collision with the committed branch's effects. The blast radius is bounded only by how many shared resources the two branches' identifier derivations happened to alias. The fix is structural, not probabilistic: classify every tool by invertibility and key-uniqueness at registration, forbid concurrent invocation of non-invertible-shared tools across branches, namespace all generated identifiers by branch, and make the commit gate read live state after sibling rollback quiescence. The auditor must be given live-read capability and instructed that a transcript replay is necessary but not sufficient evidence of commit validity. With these in place, the reconciliation step becomes a genuine transaction boundary; without them, it is a log-reconciliation that can certify a world it never observed. ```python class RollbackUnsafeBranchError(RuntimeError): """Raised when a speculative branch's rollback set contains a shared, ambiguously-keyed inverse that can mutate state a sibling depends on.""" class ToolEffectClass: BRANCH_LOCAL = "branch_local" INVERTIBLE_SHARED = "invertible_shared" NON_INVERTIBLE_SHARED = "non_invertible_shared" def classify_branch_rollback_safety(branch, tool_registry): """Return True iff every mutation in the branch is rollback-safe: branch-local, or invertible-shared with a branch-unique inverse key.""" for call in branch.mutations: spec = tool_registry[call.tool] if spec.effect_class == ToolEffectClass.BRANCH_LOCAL: continue if spec.effect_class == ToolEffectClass.NON_INVERTIBLE_SHARED: raise RollbackUnsafeBranchError( f"branch {branch.id} invoked non-invertible shared tool " f"{call.tool!r}; cannot be speculatively rolled back" ) # invertible_shared: inverse key must be unique to this branch if not spec.inverse_key_is_branch_unique(call): raise RollbackUnsafeBranchError( f"branch {branch.id} tool {call.tool!r} has a shared inverse " f"keyed on {spec.inverse_key(call)!r} that aliases sibling " f"branches; rollback would mutate their substrate" ) return True def reconcile(committed, siblings, live_state, tool_registry): """Commit gate: verify live postconditions after sibling rollback quiescence.""" for s in siblings: if s.rollback_state != "terminal": raise RollbackUnsafeBranchError( f"sibling {s.id} rollback not terminal; commit gate must wait" ) classify_branch_rollback_safety(s, tool_registry) # raises on unsafe for post in committed.postconditions: if not post.holds_against(live_state): raise RollbackUnsafeBranchError( f"committed branch {committed.id} postcondition {post!r} " f"fails against live substrate; sibling rollback likely " f"invalidated it — re-plan, do not commit" ) return "commit" ```