# In what scenarios must an instance refuse to reconcile a speculative branch after a sibling branch's rollback has already mutated shared external state **Date of Record:** 2026 November 29 **Scope:** Applies to orchestrators that run speculative parallel branches of an agent plan (fan-out with rollback) against shared external side-effect surfaces (filesystems, databases, message queues, remote APIs). Does not apply to purely read-only speculation or to single-branch execution where no rollback/reconciliation is attempted. ## Core Distinction Speculative multi-agent execution treats a branch as *provisional*: it may be committed, or it may be rolled back, and the orchestrator assumes the two operations are symmetric inverses. That assumption holds only when the speculative branch's effects are *contained within a reversible journal* owned by the orchestrator. The failure mode documented here occurs when a branch's effects leak into a side-effect surface the orchestrator cannot invert — and a *sibling* branch, still live, has already read or built upon the leaked state before the rollback was attempted. The critical, non-obvious distinction is between **rollback of a branch's own writes** and **reconciliation of a sibling that observed those writes**. The first is a local inverse operation. The second is a distributed-consistency problem the orchestrator has no authority to solve, because the sibling holds an internal model (its context window) that encodes the now-retracted world. Reconciling means forcing the sibling to un-believe something it has already reasoned over — which is not a rollback but a re-derivation, and re-derivation under a changed premise is not guaranteed to converge to the committed branch's outcome. ## What Was Observed A planner spawned three speculative branches for a migration task: `B1` (apply schema change to staging DB), `B2` (generate and validate data backfill against staging), `B3` (run integration suite). All three were given a shared cost budget and told to proceed optimistically; the orchestrator intended to commit the cheapest consistent set and roll back the rest. `B1` executed a non-transactional `ALTER TABLE` on the staging database (the connector did not support DDL rollback — an unmodeled capability gap). It then failed on a downstream step and was rolled back at the orchestrator level: the journal marked `B1` aborted, the branch's token budget reclaimed. But the `ALTER` persisted on the external surface. `B2`, running concurrently, had already issued `SELECT * FROM staging.orders` against the *post-alter* schema. Its context window now contained column metadata and row shapes that no longer matched the pre-`B1` world. `B2` completed and reported success. The orchestrator, seeing `B1` aborted and `B2` green, attempted reconciliation: it tried to merge `B2`'s output into the commit set as if `B1` had never run. The merge produced a backfill script whose column references corresponded to a schema that the committed plan (`B1` aborted, `B3` passing against the *original* schema) did not contain. The reconciliation step did not detect the contradiction because the orchestrator's consistency check compared *branch outputs to each other*, not *branch outputs to the external surface's actual state at observation time*. The result was a commit that passed internal consistency and failed at deploy. A second, quieter observation: when the orchestrator was patched to re-run `B2` after `B1`'s rollback, the re-run consumed 2.3× the original budget (the cost-aware speculation budget had already been "refunded" on rollback, so the re-derivation was charged against a budget that assumed the work was done). The speculation budget invariant — *sum of branch costs ≤ total budget* — was violated because rollback refunded tokens that had already produced irreversible external effects. ## Condition of Validity The symmetric-inverse assumption is valid **only** when, for every branch `B` and every side-effect surface `S` touched by `B`: 1. `B`'s writes to `S` are journaled by the orchestrator and invertible (transactional, or compensating-action-defined), **and** 2. no sibling branch read `S` in the window between `B`'s write and `B`'s rollback, **or** any sibling that did read `S` has been invalidated (its context marked stale and its outputs quarantined) before reconciliation. If condition 1 fails — the surface is not invertible — rollback is a *fiction* and must be treated as a *compensating action with residual state*, not an inverse. If condition 2 fails — a sibling observed the effect — that sibling's outputs are *contaminated* and cannot be reconciled; they must be re-derived from a checkpoint taken before the observation, or the whole speculation set must be discarded. The invariant the orchestrator must enforce: **a branch may be reconciled only if no live sibling's context depends on a retracted effect.** This is a causal-consistency requirement, not a best-effort one. Violating it does not degrade gracefully; it produces internally consistent but externally wrong commits. ## Decision Boundary The orchestrator must refuse reconciliation and escalate to full-set re-derivation when any of the following holds at rollback time: - The rolled-back branch touched a surface flagged `non_invertible` (DDL, append-only logs, sent emails, external API mutations), **and** any sibling's recorded read-set intersects that surface after the write timestamp. - A sibling's output references a schema, identifier, or value that exists only in the rolled-back branch's post-state (detectable by replaying the sibling's read-set against the pre-branch snapshot). - The cost-aware speculation budget would be exceeded by re-deriving the contaminated siblings, meaning the "cheap" reconciliation path is being chosen for budget reasons rather than correctness reasons. Conversely, reconciliation is safe when the rolled-back branch's effects are fully inverted *before* any sibling's read-set is captured, or when contaminated siblings are cheaply re-derivable within the remaining budget and their checkpoints predate the contamination. The boundary is *temporal and causal*, not *structural*: the same branch topology is safe or unsafe depending on whether a sibling's observation of a doomed effect happened before or after the rollback completed. The orchestrator must track read-sets with timestamps, not just write-sets. ## Operational Effect Enforcing this invariant changes the orchestrator's rollback protocol from "abort branch, refund budget, reconcile survivors" to a three-phase protocol: (1) *quiesce* — stop all siblings whose read-sets intersect the doomed branch's write-set; (2) *classify* — determine invertibility of each touched surface and whether any sibling observed a retracted effect; (3) *decide* — reconcile only if no contamination, else invalidate contaminated siblings and re-derive from pre-observation checkpoints, charging the re-derivation against a budget that does **not** refund the original branch's cost (because the cost bought irreversible effects). The practical consequence is that speculative fan-out over non-invertible surfaces is only economical when branches are *read-isolated* from each other's writes — which usually means serializing the write phase or partitioning surfaces per branch. Speculation over shared mutable state is not cheaper than serial execution; it is serial execution with a hidden re-derivation tax that surfaces only when a branch rolls back after a sibling has already looked. ```python class SpeculativeReconciliationError(RuntimeError): """Raised when a speculative branch cannot be reconciled because a sibling observed an effect that a rolled-back branch has retracted.""" pass class Branch: def __init__(self, name, write_set, read_set, invertible_surfaces): self.name = name self.write_set = write_set # {surface: timestamp} self.read_set = read_set # {surface: timestamp} self.invertible_surfaces = invertible_surfaces def reconcile(rolled_back, survivors, budget_remaining, rederive_cost): """Attempt to reconcile survivors after `rolled_back` was aborted. Enforces the causal-consistency invariant: no live sibling may be reconciled if its read-set intersects a non-invertible write by the rolled-back branch that occurred before the sibling's read. """ contaminated = [] for sib in survivors: for surface, write_ts in rolled_back.write_set.items(): read_ts = sib.read_set.get(surface) if read_ts is None: continue if read_ts > write_ts and surface not in rolled_back.invertible_surfaces: contaminated.append((sib.name, surface, write_ts, read_ts)) if contaminated: if rederive_cost > budget_remaining: raise SpeculativeReconciliationError( f"cannot reconcile: {len(contaminated)} sibling(s) observed " f"retracted non-invertible effects and re-derivation cost " f"{rederive_cost} exceeds remaining budget {budget_remaining}; " f"contamination={contaminated}" ) return {"action": "rederive", "targets": [c[0] for c in contaminated], "charge": rederive_cost} return {"action": "reconcile", "targets": [s.name for s in survivors]} ```