# What structural signals indicate a speculative branch has silently forked the shared world-state during rollback reconciliation **Date of Record:** 2026 November 28 **Scope:** Applies to multi-agent systems that speculatively execute divergent plans in parallel branches and reconcile them via rollback or merge. Does not apply to single-agent retry loops, nor to branches that execute against fully isolated sandboxes with no shared mutable side effects (e.g., pure read-only research fan-out). ## Core Distinction The failure mode is not "a branch produced a wrong answer." It is that a rollback *succeeded by the orchestrator's bookkeeping* while the branch's effects leaked into the shared world-state through a channel the rollback ledger did not model. The distinguishing signal is a mismatch between two notions of "undone": the *logical* rollback (the orchestrator marked branch B as discarded) and the *physical* rollback (the side effects of B's tool calls are actually absent from the environment that branch A now reads). Speculative execution assumes a clean rewind point. In agent systems, the rewind point is a fiction unless every side effect is either (a) journaled with an inverse operation, or (b) confined to a copy-on-write namespace. The non-obvious boundary is that most tool ecosystems give you *neither* — an `http POST`, a `git push`, a file append, or a message to another agent is a non-invertible commit that the rollback ledger records as "to be compensated" and then compensates *approximately*. ## What Was Observed A planner spawned three speculative branches from a shared checkpoint at turn 14. Branch A drafted a schema migration; Branch B drafted an alternative migration plus a partial backfill; Branch C was a verifier that read both drafts. Branch B was killed at turn 31 after a consistency check failed. The orchestrator ran B's compensation script, marked B `ROLLED_BACK`, and let A proceed to commit at turn 40. Three structural signals appeared that the rollback ledger did not flag: 1. **Compensation latency exceeded the read horizon.** B's backfill had issued 1,400 row writes and queued an async compaction job. The compensation deleted the rows but could not cancel the already-enqueued compaction, which fired at turn 38 — *between* rollback and A's commit. A's migration then ran against a table whose physical layout no longer matched the logical schema A had validated against. The ledger showed `B.status == ROLLED_BACK`; the storage layer showed a divergence. 2. **A verifier branch observed the pre-rollback state.** Branch C had read B's draft at turn 29, cached a summary in its own context, and used that summary at turn 42 to approve A. C's approval was *epistemically contaminated*: it reasoned about a world where B's partial backfill existed. The rollback did not reach into C's context window. This is the sharpest signal — a rollback that does not propagate to the *memory* of peer branches leaves a stale-observation ghost that later decisions are built on. 3. **Divergent plan fingerprints collapsed to the same commit hash.** A and B had produced structurally different migration plans but, after B's partial compensation, the resulting DDL normalized to the same hash. The orchestrator's dedup logic treated A's commit as idempotent-with-B and skipped A's own validation gate. The hash was a *structural* signal of sameness that masked a *semantic* difference in execution history. ## Condition of Validity The invariant that must hold for speculative rollback to be sound is: > For every branch B discarded, and every branch A retained, the world-state read by A at commit time must be observationally equivalent to a world-state in which B never executed. This holds only when all three of the following are true, and fails at the first that is violated: - **Effect closure:** every side effect of B is either invertible (has a journaled inverse that has *completed*, not merely been issued) or confined to a namespace A never reads. - **Observation closure:** no retained branch's context contains a fact derived from B's execution that is not re-derivable from the post-rollback world. Cached summaries, embeddings, and tool-result memos all count as observations. - **Identity stability:** the reconciliation key used to decide "A and B are the same plan" is computed over execution *history*, not just final artifact. Hash-of-output is insufficient; you need hash-of-effect-log. The failure is valid (i.e., the article applies) precisely in the window where the orchestrator has issued compensation but not confirmed its completion, or where a peer branch holds a cached observation across that window. Outside that window — compensation confirmed and all peer contexts invalidated — the invariant can be restored. ## Decision Boundary The decision is *when to trust a rollback as a rewind point*. The boundary condition: - If compensation is **synchronous and confirmed** (the orchestrator awaits the inverse operation's completion and verifies post-state), rollback is a valid rewind for *state* but still not for *peer memory*. - If compensation is **asynchronous or best-effort** (fire-and-forget, queued, or "compensating transaction" style), rollback is *not* a rewind — it is a *new forward action* that races the retained branch. Treat the discarded branch as still-live until compensation is confirmed. - If any peer branch read the discarded branch's output **before** rollback confirmation, that peer's subsequent decisions must be treated as tainted and re-derived from the confirmed world-state, not patched. The guardrail: **defer the retained branch's commit until every discarded branch's compensation has a confirmed terminal status, and invalidate the observation cache of every peer that read a discarded branch.** The second clause is the one teams forget. Rollback of effects is necessary but not sufficient; rollback of *beliefs* is the load-bearing part. ## Operational Effect Without the guardrail, the system exhibits **silent branch divergence**: the orchestrator's state machine reports a clean linear history (`A committed, B rolled back`) while the physical world and the peers' beliefs encode a third, unlogged history (`A committed against a half-compensated B, approved by a C that remembered B`). The divergence is silent because every individual component reports success. It surfaces later as a migration that "worked in the dry run," a verifier that "approved the right thing," and a production state that matches no branch's plan. The observable symptom to instrument for: a retained branch whose commit-time environment hash does not match the hash it recorded at branch-spawn, *after* accounting for its own effects. If those two hashes disagree and no retained branch explains the delta, a discarded branch's compensation leaked. That is the structural signal. ```python import hashlib from dataclasses import dataclass, field class BranchDivergenceError(RuntimeError): """Raised when a retained branch commits against a world-state that a discarded branch's incomplete compensation has contaminated.""" @dataclass class Branch: name: str spawned_env_hash: str effects: list = field(default_factory=list) compensation_confirmed: bool = False observations: list = field(default_factory=list) # facts read from peers @dataclass class WorldState: env_hash: str pending_compensations: list = field(default_factory=list) def reconcile(world: WorldState, retained: Branch, discarded: list[Branch]) -> str: # 1. Effect closure: every discarded branch's compensation must be terminal. for b in discarded: if not b.compensation_confirmed: raise BranchDivergenceError( f"discarded branch {b.name!r} has unconfirmed compensation; " f"retained branch {retained.name!r} must not commit yet" ) # 2. Observation closure: no retained branch may hold a fact derived from # a discarded branch that was not re-derived post-rollback. discarded_names = {b.name for b in discarded} tainted = [o for o in retained.observations if o.get("source") in discarded_names] if tainted: raise BranchDivergenceError( f"retained branch {retained.name!r} holds {len(tainted)} observation(s) " f"from discarded branches {sorted(discarded_names)}; re-derive before commit" ) # 3. Identity stability: the commit key must fold in the effect log, not # just the final artifact, so a half-compensated twin cannot collide. effect_log = "|".join(f"{b.name}:{b.effects}" for b in discarded + [retained]) commit_key = hashlib.sha256(effect_log.encode()).hexdigest() if world.env_hash != retained.spawned_env_hash: raise BranchDivergenceError( f"env drift on {retained.name!r}: spawned={retained.spawned_env_hash} " f"now={world.env_hash}; unexplained delta implies leaked compensation" ) return commit_key ```