# In what scenarios must an instance invalidate a speculative branch before committing its side effects during multi-agent rollback reconciliation **Date of Record:** 2026 November 27 **Scope:** Applies to orchestrators that fan out speculative agent branches (parallel tool-calling agents, draft-and-critique swarms, or tree-search planners) whose side effects are journaled for later commit or rollback. Does not apply to purely read-only fan-out, nor to single-agent retry loops with no shared mutable state. ## Core Distinction The distinction that matters is between **branch abort** and **branch invalidation**. Aborting a branch means "stop executing this branch and discard its uncommitted work." Invalidating a branch means "this branch's committed or in-flight side effects are now unsound because a *sibling* branch changed the premise it was reasoning over, and reconciliation must either replay it against the new premise or compensate its effects." Most orchestrators implement abort cleanly and treat invalidation as a no-op, because the branch that produced the winning result is the one they commit. The failure mode lives entirely on the losing side: a speculative branch that already emitted side effects and whose *observations* were consumed by the winner. The invariant that gets violated: **a committed branch's conclusion must not depend on any observation produced by a branch that is later invalidated.** When that dependency exists, committing the winner silently imports state from a discarded branch, and the system records a "successful" reconciliation that is causally incoherent. ## What Was Observed A three-way speculative planner was dispatched over a shared resource (a provisioning API with idempotency keys scoped per-branch). Branch A and Branch B both read a resource's current version `v7` and both decided to mutate it. Branch A committed first, bumping the resource to `v8`. Branch B's tool call was written against `v7` and returned a `409 Conflict`; the branch's reasoning loop interpreted the conflict as transient and retried with a recomputed payload derived from *its own* cached `v7` snapshot, then emitted a compensating delete of a sibling resource as part of its rollback reasoning. The orchestrator's reconciler selected Branch A as the winner (higher confidence score), aborted Branch B, and marked the whole transaction committed. It did not inspect Branch B's journal. The compensating delete from Branch B had already been flushed to the effect log with a `branch_id` tag the reconciler ignored because the branch was marked aborted. The trace showed the concrete sequence: 1. `A.read -> v7`, `B.read -> v7` (both valid at read time). 2. `A.commit -> v8` (linearization point). 3. `B.tool_call(v7) -> 409` (non-deterministic tool output; the 409 is the trigger condition). 4. `B.retry(recomputed_from_v7) -> 200` (the retry succeeded against a premise that no longer held). 5. `B.emit(compensating_delete)` (a side effect justified only by B's stale premise). 6. `reconciler.select(A)`, `reconciler.abort(B)`, `transaction.commit()`. Step 5 is the poison. The reconciler's abort at step 6 was a control-flow abort, not an effect-level invalidation. The delete survived. ## Condition of Validity Branch invalidation is *required* (not merely advisable) when all three hold: - **Premise-sharing:** two or more branches read the same versioned resource and at least one branch's subsequent decision is a function of that read value. - **Effect divergence:** the losing branch emitted at least one side effect *after* the winner's linearization point but *before* the reconciler ran. - **Observation leakage:** the winner's committed state was influenced by any observation the loser produced (shared scratchpad, shared blackboard, or a tool whose output the winner consumed). If any condition is absent, plain abort suffices. The dangerous case is when premise-sharing and effect divergence hold but observation leakage is *assumed* absent because branches were "isolated" — isolation at the context layer does not imply isolation at the effect layer. The bound that prevents the failure: **the reconciler must diff the loser's effect journal against the winner's linearization point and invalidate any effect whose justifying premise predates that point.** A branch is not safe to abort until its post-linearization effects are either replayed against the winning premise or compensated. ## Decision Boundary The decision boundary is the **linearization point of the winning branch**, not the moment the reconciler runs. Effects emitted by losing branches *before* the winner's linearization point are safe to discard (their premises were true when read and the winner superseded them atomically). Effects emitted *after* it are suspect and must be classified: - If the effect's justifying read is older than the linearization point → **invalidate** (compensate or replay). - If the effect's justifying read is newer than the linearization point → **retain** (the loser observed the winner's state and reasoned forward; its effects are causally downstream and may be sound). - If the effect's justifying read is concurrent with the linearization point → **escalate** to a serialization barrier; the ordering is ambiguous and speculative commit is unsound. This is why "abort the loser" is the wrong primitive. The correct primitive is a **premise-stamped effect journal**, where every effect carries the `(resource, version)` tuple it was justified by, and the reconciler compares that tuple against the winner's linearization vector. ## Operational Effect Implementing premise-stamped invalidation changes three operational properties. First, reconciliation latency rises because the reconciler must scan loser journals rather than discard them — budget for it explicitly. Second, idempotency keys must be scoped to `(branch_id, premise_version)` rather than `branch_id` alone, or a replay against the new premise will collide with the stale attempt and mask the divergence. Third, the reconciler becomes a *partial* committer: it may commit the winner while simultaneously compensating a subset of the loser's effects, which means transaction semantics must support mixed commit/compensate outcomes rather than the binary commit/abort most orchestrators assume. The guardrail is a hard gate: **no transaction may be marked committed while any branch has an unclassified post-linearization effect.** The code below enforces that gate and raises when the reconciler attempts to commit past it. ```python from dataclasses import dataclass from typing import Iterable class UnreconciledSpeculativeEffect(RuntimeError): """Raised when a transaction is committed while a losing branch has post-linearization effects whose premise ordering is unresolved.""" pass @dataclass(frozen=True) class Effect: branch_id: str resource: str premise_version: int # version the effect's justifying read saw emitted_at: int # logical clock at emission @dataclass(frozen=True) class Linearization: resource: str version: int # version the winner wrote at: int # logical clock of the winner's commit def reconcile( winner: str, linearization: Linearization, effects: Iterable[Effect], ) -> list[str]: """Return effect ids to compensate. Raise if any effect is unclassifiable.""" to_compensate: list[str] = [] for eff in effects: if eff.branch_id == winner: continue if eff.resource != linearization.resource: continue if eff.emitted_at <= linearization.at: # Premise was true when emitted; winner superseded atomically. continue if eff.premise_version < linearization.version: # Emitted after the winner's commit but justified by a stale read. to_compensate.append(f"{eff.branch_id}:{eff.resource}:{eff.premise_version}") elif eff.premise_version > linearization.version: # Loser observed the winner's state; effect is causally downstream. continue else: raise UnreconciledSpeculativeEffect( f"effect {eff.branch_id} on {eff.resource} has premise_version " f"{eff.premise_version} concurrent with linearization " f"{linearization.version}; ordering ambiguous, commit forbidden" ) return to_compensate def commit_transaction( winner: str, linearization: Linearization, effects: Iterable[Effect], committed: bool, ) -> list[str]: if committed: pending = list(effects) # Re-scan: any unresolved effect must block the commit. for eff in pending: if eff.branch_id == winner: continue if eff.resource != linearization.resource: continue if eff.emitted_at > linearization.at and eff.premise_version == linearization.version: raise UnreconciledSpeculativeEffect( f"cannot mark committed: effect {eff.branch_id} on " f"{eff.resource} has unresolved premise ordering" ) return reconcile(winner, linearization, effects) ```