# Where must an instance commit before a speculative branch is reconciled: the rollback-orphan invariant in cost-aware multi-agent execution **Date of Record:** 2026 November 17 **Scope:** Applies to orchestrators that fan out speculative agent branches in parallel, each with its own scoped side effects (tool calls, writes, reservations), and that reconcile by selecting one branch and rolling back the rest. Does not apply to read-only fan-out, nor to systems where every branch's side effects are idempotent and externally compensable on demand. ## Core Distinction The distinction that matters is not "which branch wins" but *when the winner becomes durable relative to when the losers are allowed to be abandoned*. A speculative orchestrator has two logically separate commitments: (1) the **selection commitment** — the decision that branch B is the one whose results will be surfaced — and (2) the **durability commitment** — the point after which B's side effects cannot be lost because the orchestrator has already told the outside world they exist. Most rollback designs collapse these into one event. That collapse is the failure boundary. The invariant, stated precisely: *no branch may be rolled back until the selected branch's effects have crossed the durability commitment, and no branch's effects may cross the durability commitment until the selection commitment is irrevocable.* When these two events are interleaved — durability of the winner before selection is final, or rollback of losers before the winner is durable — you get a **rollback-orphan**: a side effect that belongs to a branch that was neither durably committed nor cleanly compensated. ## What Was Observed In a fan-out of three branches (B1, B2, B3) executing a shared task with per-branch tool writes, the orchestrator selected B2 on a scoring threshold and immediately began compensating B1 and B3 while asynchronously flushing B2's writes to the durable store. B2's flush failed a consistency check (a schema-version skew on one downstream sink) and was retried. During the retry window, B1 and B3 had already been compensated. The reconciler then re-scored: B2's failed flush lowered its confidence below B3's, and the selector switched to B3 — but B3's writes were already gone. The final state contained B2's *partial* effects (the sinks that had accepted the flush before the skew) and none of B3's. This is not a rollback failure and not a selection failure; it is a **commit-ordering failure**. The system had made a durability commitment to B2 before the selection was irrevocable, and had made a rollback commitment to B3 before B2 was durable. A second observed variant: cost-aware parallelism deliberately staggered branch launch (B1 at t=0, B2 at t=400ms, B3 at t=900ms to cap token spend). The selector fired at t=1000ms, before B3 had produced any output. B3 was rolled back as "non-contributing" — but B3's early tool call had already reserved an external resource. The reservation was orphaned because the rollback path assumed branches that had not *reported* had not *acted*. Under staggered launch, silence is not inaction. ## Condition of Validity The invariant holds only under all of the following: - Side effects are **externally visible** before the branch reports (tools write to shared sinks, reservations are held, messages are emitted). If all effects are buffered in branch-private storage until selection, the boundary does not exist and naive rollback is safe. - The selector is **revisable** after initial selection — i.e., scoring depends on post-selection events such as flush success, late-arriving branch output, or cost accounting. If selection is final at first decision, the durability/selection ordering is trivially satisfiable. - Branches are **not uniformly launched** or **not uniformly fast** — cost-aware staggering, heterogeneous models, or variable tool latency means "branch has not reported" cannot be read as "branch has not acted." - Compensation is **not instantaneous or guaranteed** — external reservations, rate-limited deletes, or sinks without a delete verb mean rollback is itself a multi-step, fallible operation that can race with re-selection. Where effects are buffered, selection is final, or compensation is atomic and synchronous, the standard "select then rollback" pattern is correct and this record does not apply. ## Decision Boundary The operational rule is a strict ordering with a barrier: 1. **Quiesce** all branches whose effects are externally visible — no new side effects may be initiated, including from staggered branches that have not yet reported. 2. **Select provisionally**, then **flush the selected branch to durability** and confirm the flush (not merely initiate it). 3. **Re-score only against durable state.** If re-scoring demotes the flushed branch, the flush itself is the evidence that must be compensated — you may not simply switch to another branch, because the other branches' effects were quiesced but not preserved. 4. **Only after the winner is durable and selection is irrevocable** may losers be compensated. The decision at the boundary is therefore: *does the selected branch's durability confirmation precede the first compensation?* If no, the orchestrator must halt and reconcile rather than proceed. A system that cannot confirm durability (flush timeout, sink skew, unknown state) must treat the selected branch as *uncommitted* and must not compensate any loser — it must either retry the flush or escalate, because compensating losers while the winner is unconfirmed converts a recoverable ambiguity into an unrecoverable orphan. ## Operational Effect Enforcing the barrier changes three observable properties of the system: - **Latency**: reconciliation gains one durability round-trip per selection. Cost-aware orchestrators that staggered launch to save tokens now pay a serialization cost at commit; budget for it or the barrier will be violated under load. - **Failure semantics**: flush failure becomes a *blocking* condition, not a retryable background task. This is the correct trade — a blocked reconciler is recoverable; an orphaned side effect is not. - **Staggered-launch safety**: branches that have not reported must be quiesced and their effects inventoried before rollback, because under stagger, non-report is not non-action. This requires each branch to expose an effect ledger independent of its output. The invariant to encode in the orchestrator: `commit(winner) → confirm(winner) → revoke(selection) → compensate(losers)`, with a hard `raise` if any loser compensation is attempted while `confirm(winner)` is false. ```python class RollbackOrphanError(RuntimeError): """Raised when a loser branch would be compensated before the winner's durability commitment is confirmed, or when selection is revised after a durability commitment was made to a now-demoted branch.""" pass class Branch: def __init__(self, name, effects_externally_visible, reported): self.name = name self.effects_externally_visible = effects_externally_visible self.reported = reported self.durable = False self.compensated = False def reconcile(branches, selected, flush, compensate): # Step 1: quiesce every branch with externally visible effects, # including staggered branches that have not reported. for b in branches: if b.effects_externally_visible and not b.reported: # silence is not inaction; inventory before any rollback b.reported = True # mark as inventoried, not as contributing # Step 2: flush the selected branch and CONFIRM durability. if not flush(selected): # Do NOT compensate losers. Escalate; the ambiguity is recoverable. raise RollbackOrphanError( f"selected branch {selected.name!r} failed durability confirmation; " f"refusing to compensate losers while winner is uncommitted" ) selected.durable = True # Step 3: re-score against durable state only. rescored = rescore(branches) if rescored is not selected and not selected.durable: raise RollbackOrphanError( f"selection revised to {rescored.name!r} after commitment to " f"{selected.name!r}; commitment must be compensated explicitly" ) # Step 4: only now may losers be compensated. for b in branches: if b is not selected: if not selected.durable: raise RollbackOrphanError( f"attempted to compensate {b.name!r} before " f"{selected.name!r} was durable" ) compensate(b) b.compensated = True return selected def rescore(branches): # placeholder: real scorer reads durable state, not in-flight confidence return max(branches, key=lambda b: (b.durable, b.reported)) ```