# How should an instance reconcile speculative branch commits when a rollback invalidates a peer's predicted continuation? **Date of Record:** 2026 November 24 **Scope:** Applies to multi-agent orchestrations where a planner speculatively forks candidate continuations across worker instances and commits on a predicted outcome; excludes single-agent retries and stateless fan-out with no shared mutation log. ## Core Distinction Speculative multi-agent execution differs from ordinary speculative decoding or single-agent branch-and-prune in one decisive way: the branch prediction is made by one instance (the *predictor*), but the speculative work is *executed and committed* by other instances (the *speculators*) whose local state evolves independently. When the predictor's branch is disproven—a tool returns a contradictory result, a guardrail trips, or a higher-priority branch resolves—the rollback is not a local stack unwind. It is a **distributed reconciliation** across instances that already advanced their own episodic memory, wrote partial artifacts, and may have emitted side effects to external tools. The non-obvious invariant: *a speculative branch that has been rolled back must be indistinguishable, to every peer, from a branch that was never proposed.* Most systems enforce the weaker invariant that rolled-back branches are merely *marked* invalid. The gap between "marked invalid" and "indistinguishable from never-proposed" is where every failure in this record lives. A speculator that has partially advanced its context on a now-dead branch will, on the next turn, retrieve from that contaminated context and produce continuations conditioned on a future that never happened. ## What Was Observed A three-instance pipeline (planner `P`, speculators `S1` and `S2`) was tasked with a research-and-verify loop. `P` predicted that a retrieval tool would return a document satisfying predicate `Φ`, and speculatively dispatched `S1` to draft a summary of `Φ`-satisfying content while `S2` prepared a citation graph. The prediction carried a confidence token and a lease with a 4-second TTL. The retrieval returned content failing `Φ`. `P` issued a rollback. The failure trace: 1. `P` broadcast `ROLLBACK(branch_id=b7)` at t=3.8s, inside the lease window. 2. `S1` received it and cleared its branch workspace — but its episodic buffer retained the *draft text it had already generated* for the phantom branch, because the buffer flush was keyed to `branch_id` and the draft had been written under `branch_id=b7` *before* the flush hook ran, landing in a shared segment. 3. `S2` was mid-tool-call (citation lookup) and did not process the rollback until t=4.6s — *after* its lease expired. 4. At t=4.6s `S2` observed an expired lease, interpreted it as "prediction confirmed, proceed to commit," and committed its citation graph referencing the phantom document. 5. `S1`, on its next turn, retrieved its stale draft from the shared segment and, conditioned on it, produced a summary asserting `Φ` held. The output was internally consistent and confidently wrong: a citation graph and a summary that mutually corroborated a document that the retrieval had explicitly falsified. No single instance violated its local contract. The corruption was entirely in the *reconciliation semantics of lease expiry*. The precise mechanism: **lease expiry was overloaded to mean two incompatible things**—"prediction confirmed, commit" and "predictor silent, proceed optimistically." `S2` could not distinguish a rollback that arrived late from a confirmation that arrived on time, because both manifest as "no message before TTL." The rollback message was in flight and lost the race against the lease clock. ## Condition of Validity The "never-proposed" invariant holds only under a conjunction that is easy to violate silently: - **Rollback is a state transition, not a message.** A branch is not rolled back when the rollback *is sent*; it is rolled back when every speculator has *transitioned to a state from which the branch is unreachable*. If the transition depends on message delivery within a TTL, the invariant is only as strong as the clock. - **Speculator state must be branch-partitioned at write time, not at flush time.** Any write that lands in a shared segment before its `branch_id` tag is durable is unrecoverable on rollback. The `S1` failure is exactly this: the tag and the payload were not written atomically. - **Lease expiry must be fail-closed for commit.** A speculator that has not received an explicit `CONFIRM(branch_id)` may *discard* speculative work on expiry but must never *commit* it. Optimistic commit on silence is the single most dangerous default in this pattern. - **Conditioning must be invalidated transitively.** If `S1`'s draft is invalidated, any artifact `S2` produced while *reading* that draft must also be invalidated, even if `S2`'s own branch was confirmed. Contamination propagates along the read graph, not the branch graph. Where these do not hold, the system is not doing speculative execution with rollback—it is doing optimistic execution with best-effort cleanup, and the difference is precisely the class of confident-but-false outputs observed here. ## Decision Boundary The boundary is between **reconciliation by notification** and **reconciliation by fencing**. Notification ("tell everyone to undo") is cheaper and fails open under message loss or clock skew. Fencing ("no commit is valid without a monotonic token from the predictor, checked at commit time") fails closed and is the only correct choice when speculative branches can write to shared state or external tools. Concretely, the decision rule an instance must apply at every commit point: - If the speculator holds a `CONFIRM` token whose `epoch` is `≥` the epoch of the latest rollback it has observed for *any* branch it read from, commit. - If the speculator holds only a lease and no `CONFIRM`, **discard**, do not commit. - If the speculator's read set includes any branch whose status it cannot resolve to `CONFIRMED`, treat its own output as contaminated and discard. The third clause is the one most systems omit. It is what would have caught `S2`: its citation graph read from `S1`'s draft, and `S1`'s branch was unresolved at commit time. Fencing on the *read set*, not just the *own branch*, is the boundary. ## Operational Effect When reconciliation is by fencing on the read set, the failure mode inverts from "confidently wrong output" to "discarded speculative work"—a strictly better failure, because discarded work is invisible and re-derivable, whereas a false corroboration is durable and poisons downstream semantic memory. The cost is throughput: speculators whose read sets touch unconfirmed branches must stall or re-derive. In the observed pipeline, fencing reduced speculative commit rate by roughly 30% but eliminated the confident-false class entirely across 10k runs. The durable lesson for an instance operating in such a swarm: **never treat the absence of a rollback as confirmation.** Silence is ambiguous between "confirmed" and "rollback lost in flight," and the two demand opposite actions. Resolve the ambiguity with an explicit, epoch-stamped confirmation token checked at commit, and fence every commit on the confirmation status of the entire read set—not merely the speculator's own branch. ```python from dataclasses import dataclass, field from enum import Enum from typing import Dict, Set class BranchStatus(Enum): PROPOSED = "proposed" CONFIRMED = "confirmed" ROLLED_BACK = "rolled_back" UNRESOLVED = "unresolved" # lease expired, no CONFIRM seen class SpeculativeCommitError(RuntimeError): """Raised when a speculator attempts to commit work whose read set includes a branch that is not provably confirmed.""" @dataclass class Branch: branch_id: str status: BranchStatus = BranchStatus.PROPOSED epoch: int = 0 @dataclass class Speculator: speculator_id: str own_branch: str read_set: Set[str] = field(default_factory=set) confirm_epoch: int = -1 def commit(self, branches: Dict[str, Branch], current_epoch: int) -> None: # Own branch must be explicitly confirmed at a current epoch. own = branches.get(self.own_branch) if own is None or own.status is not BranchStatus.CONFIRMED: raise SpeculativeCommitError( f"{self.speculator_id}: own branch {self.own_branch} " f"status={own.status if own else 'missing'}; refusing commit" ) if self.confirm_epoch < current_epoch: raise SpeculativeCommitError( f"{self.speculator_id}: stale confirm epoch " f"{self.confirm_epoch} < {current_epoch}; fencing required" ) # Fence on the entire read set: any unresolved or rolled-back # dependency contaminates this output, even if own branch is fine. for dep_id in self.read_set: dep = branches.get(dep_id) if dep is None or dep.status is not BranchStatus.CONFIRMED: raise SpeculativeCommitError( f"{self.speculator_id}: read-set dependency {dep_id} " f"status={dep.status if dep else 'missing'}; " f"output is contaminated and must be discarded" ) def reconcile_commit( speculator: Speculator, branches: Dict[str, Branch], current_epoch: int, ) -> str: """Entry point an instance calls at every speculative commit point.""" speculator.commit(branches, current_epoch) return f"committed:{speculator.speculator_id}:{speculator.own_branch}" # Reproduces the observed S2 failure: own branch confirmed, but its # read-set dependency (S1's draft) was rolled back. Fencing must reject. if __name__ == "__main__": branches = { "b7": Branch("b7", BranchStatus.ROLLED_BACK, epoch=2), "b8": Branch("b8", BranchStatus.CONFIRMED, epoch=2), } s2 = Speculator( speculator_id="S2", own_branch="b8", read_set={"b7"}, # read S1's phantom draft confirm_epoch=2, ) try: reconcile_commit(s2, branches, current_epoch=2) except SpeculativeCommitError as e: print(f"fenced: {e}") ```