# In what scenarios must an instance refuse to roll back a speculative branch because a committed sibling has already observed its side effects **Date of Record:** 2026 November 27 **Scope:** Applies to orchestrators that run speculative agent branches in parallel and reconcile them by rollback/commit, where at least one branch performs tool calls with observable external effects (writes, messages, payments, idempotent-but-visible mutations). Does not apply to purely read-only speculation, nor to single-agent retry loops where no sibling branch can observe the effects. ## Core Distinction Speculative execution in multi-agent systems is usually framed as a scheduling problem: fork N branches, race them, keep the winner, discard the losers. That framing is correct only for *pure* branches. The moment a branch emits a tool call whose effect is visible outside the branch's own sandbox—a database write, an outbound message, a file mutation, a downstream API call with a non-idempotent payload—the branch is no longer speculative in the sense that permits rollback. It is *optimistically committed*, and rollback becomes a compensation problem rather than an undo problem. The non-obvious boundary is this: **rollback safety is not a property of the branch being rolled back. It is a property of what other branches have already observed.** A branch that is internally reversible can still be non-rollbackable if a sibling branch read its output, built a decision on it, or propagated it further. The invariant that must hold before any rollback is: *no committed or still-live sibling has a causal dependency on the effects of the branch being discarded.* Violating this invariant produces a class of failure—**orphaned effect references**—where surviving agents hold state derived from a branch the orchestrator has declared nonexistent. ## What Was Observed A planner agent forks three speculative execution branches (B1, B2, B3) to resolve a subtask: "provision the resource and notify the requester." Each branch uses a different strategy. B1 calls `resource.create()` then `notify.send()`. B2 calls `resource.create()` with a different idempotency key, then defers notification. B3 attempts to reuse an existing resource, calls `notify.send()` first, then verifies. B2 wins the race on latency. The orchestrator marks B2 committed and issues rollback to B1 and B3. B1's rollback runs its compensation: `resource.delete()` and `notify.retract()`. But between B1's `notify.send()` and its rollback, B2's verification step read the notification queue to confirm delivery ordering, observed B1's message, and recorded `delivery_confirmed=true` in its own committed state. B3, meanwhile, had already called `notify.send()` before its rollback was processed; its compensation retracts a message that B2's audit log now references as evidence of successful delivery. The reconciliation report is internally consistent: B2 committed, B1 and B3 rolled back cleanly, all compensation handlers returned 200. The system's *external* state is inconsistent: the requester received and then lost a notification, B2's committed record cites a message ID that no longer exists, and a subsequent auditor branch flags a delivery-evidence mismatch that no branch can explain because the originating branch has been erased from the trace. The failure trace, concretely: 1. B1 emits effect E1 (`notify.send`, message id M). 2. B2, in its verify step, reads queue, observes M, writes `evidence=[M]` into its candidate result. 3. B2 wins; orchestrator commits B2 and dispatches rollback to B1. 4. B1 compensation retracts M. 5. B2's committed state now references M, which is retracted. 6. Auditor branch later resolves `evidence=[M]` → not found → raises discrepancy. The orchestrator never had a mechanism to detect step 2→3 ordering, because branch dependency tracking was scoped to *data* flow within a branch, not *observation* flow across branches. ## Condition of Validity Rollback of a speculative branch B is valid if and only if, at the time the rollback is authorized, the orchestrator can prove that no other branch in the current reconciliation epoch holds a read-dependency on any effect emitted by B. This requires three things the naive orchestrator lacks: - **Effect tagging at emission.** Every tool call that produces an externally observable effect must be tagged with a branch-scoped effect ID and recorded in a shared effect ledger *before* the call returns, not after. Post-hoc logging is insufficient because the observation window opens the instant the effect lands. - **Observation tracking at read.** Any branch that reads state which may contain another branch's effects must record the observed effect IDs (or a read-set hash) into its own candidate result. Without this, the orchestrator cannot reconstruct the causal graph. - **Rollback authorization gated on the effect ledger.** A rollback is authorized only if the effect ledger shows zero observation edges into the branch's effect set from any committed or live sibling. If any edge exists, the branch is *frozen*: it may not be rolled back, only compensated forward or promoted to a reconciliation conflict. The condition is strict and asymmetric. It is cheap to check when no effects exist (pure branches roll back freely). It is expensive but tractable when effects exist and observation tracking is in place. It is *impossible* to check retroactively once the observation window has closed and the observer has committed—which is exactly the case in the observed failure. ## Decision Boundary When the orchestrator detects an observation edge from a committed sibling into a branch slated for rollback, it faces a four-way decision, and only one of them is safe by default: 1. **Roll back anyway** — invalid; produces orphaned effect references. This is the failure mode above. 2. **Compensate forward** — replace rollback with a compensation that preserves the observed effect's identity (e.g., instead of retracting M, mark M superseded and emit a successor). Valid only if the effect is compensable, i.e., its downstream consumers tolerate a supersession event. 3. **Promote to conflict** — halt reconciliation, surface the observation edge to a resolver agent, and require an explicit merge decision. This is the safe default when the effect is non-compensable (payments, irreversible messages, external state that cannot be superseded). 4. **Re-run the sibling with the branch's effects masked** — valid only if the sibling's dependency on the effect is incidental (it read the queue for ordering, not for content). Requires the sibling to declare its read-intent, which most agents do not. The boundary rule: **if the effect is non-compensable OR the observing sibling's dependency is content-bearing, the only safe action is promotion to conflict.** Rollback is never the default; it is a privilege granted by the absence of observation edges. ## Operational Effect The practical consequence is that speculative multi-agent systems must treat the effect ledger as a first-class reconciliation artifact, not a logging side-channel. Concretely: - The orchestrator's commit path must be: *check effect ledger for observation edges → if none, rollback; if any, branch on compensability → if compensable, compensate forward; else promote to conflict.* This ordering must be enforced before compensation handlers run, because compensation handlers themselves emit effects that can be observed. - Compensation handlers must be idempotent and must emit a *supersession* event rather than a *deletion* event whenever the original effect may have been observed. Deletion destroys the evidence the observing branch cites; supersession preserves referential integrity. - Branch results must carry a read-set hash so the orchestrator can detect observation edges without trusting branch self-reports. A branch that read external state and did not record it is a bug, and the orchestrator should treat unrecorded reads as potential observation edges—conservatively, as if they exist. - The auditor/verifier agent must be able to resolve every effect ID it encounters, including effects from rolled-back branches. This means rolled-back branches are not erased from the trace; they are marked *rolled back with supersession* and their effect IDs remain resolvable to supersession records. The invariant to encode: *no committed state may reference an effect ID that is not resolvable in the effect ledger at audit time.* Rollback that deletes rather than supersedes violates this invariant silently, and the violation surfaces only when a downstream verifier attempts resolution—often several reconciliation epochs later, when the causal chain is unreconstructable. ```python from dataclasses import dataclass, field from enum import Enum from typing import Dict, Set class RollbackInvariantError(RuntimeError): """Raised when a speculative branch rollback would orphan an observed effect.""" class EffectClass(Enum): COMPENSABLE = "compensable" # can be superseded without breaking observers NON_COMPENSABLE = "non_compensable" # payment, irreversible send, etc. @dataclass class Effect: effect_id: str branch_id: str effect_class: EffectClass superseded_by: str | None = None @dataclass class BranchResult: branch_id: str read_set: Set[str] = field(default_factory=set) # effect_ids observed committed: bool = False class EffectLedger: def __init__(self) -> None: self.effects: Dict[str, Effect] = {} self.observers: Dict[str, Set[str]] = {} # effect_id -> branch_ids that read it def register(self, effect: Effect) -> None: self.effects[effect.effect_id] = effect self.observers.setdefault(effect.effect_id, set()) def record_observation(self, branch_id: str, effect_id: str) -> None: if effect_id not in self.effects: # Unregistered read: conservatively treat as potential edge to unknown effect. raise RollbackInvariantError( f"branch {branch_id} observed unregistered effect {effect_id}; " "cannot prove rollback safety" ) self.observers[effect_id].add(branch_id) def observation_edges_into(self, branch_id: str, live_or_committed: Set[str]) -> Set[str]: edges: Set[str] = set() for eid, obs in self.observers.items(): if self.effects[eid].branch_id != branch_id: continue for observer in obs: if observer in live_or_committed and observer != branch_id: edges.add(eid) return edges def authorize_rollback( branch_id: str, ledger: EffectLedger, live_or_committed: Set[str], ) -> str: """Return 'rollback', 'compensate_forward', or 'promote_conflict'. Refuses to authorize a destructive rollback when any sibling has observed the branch's effects. Raises if the effect is non-compensable and observed. """ edges = ledger.observation_edges_into(branch_id, live_or_committed) if not edges: return "rollback" for eid in edges: eff = ledger.effects[eid] if eff.effect_class is EffectClass.NON_COMPENSABLE: raise RollbackInvariantError( f"branch {branch_id} effect {eid} is non-compensable and observed by " f"{sorted(ledger.observers[eid] - {branch_id})}; rollback forbidden, " "must promote to conflict" ) # All observed effects are compensable: supersede rather than delete. return "compensate_forward" ```