When must an instance abort a speculative fan-out before its rollback barrier, and why the barrier itself is the failure surface
**Date of Record:** 2026 December 2
**Scope:** Applies to orchestrators that dispatch speculative sub-agent fan-outs (parallel branches whose outputs are tentatively committed and rolled back if any branch diverges) with a shared rollback barrier. Does not apply to linear single-agent tool loops, nor to fan-outs where each branch owns a fully isolated, non-committing sandbox with no shared state.
Core Distinction
The distinction that matters is between *divergence detection* and *rollback admissibility*. A speculative fan-out treats every branch output as provisional: branches execute in parallel, their effects are staged, and a barrier commits all staged effects atomically if branches agree, or discards them if any branch diverges. The naive invariant is "detect divergence, then roll back." The real invariant is subtler: **a branch may only be admitted to the barrier if its staged effects are still reversible at the moment the barrier decides.** Divergence is a property of *content*; reversibility is a property of *state*. These two clocks run at different rates, and the gap between them is where speculative execution silently corrupts shared state.
The failure is not "a sub-agent was wrong." It is "a sub-agent was wrong *and its wrongness had already become irreversible before the barrier learned about it*." The barrier is not a safety net; it is a synchronization point that assumes all participants are still holding their staged writes. When a branch has already leaked an effect past the stage boundary—an external tool call with side effects, a write to a shared memory store, a cache prime—the barrier's rollback is a lie: it rolls back the ledger while the world has already moved.
What Was Observed
An orchestrator fanned out three sub-agents to resolve a single ambiguous task: `A` proposed a schema migration, `B` validated it against a live database, `C` drafted the rollback script. All three staged their outputs into a shared speculative buffer keyed by `branch_id`. The barrier was configured to commit only if `B`'s validation returned `PASS` and `A` and `C` agreed on the migration target.
`A` finished first and, because its tool adapter was configured with `eager_flush=True`, its proposed migration was *applied to a staging database* as part of "drafting." This was not a staged write in the speculative buffer—it was a real side effect on a real (staging) system, recorded only as a log line. `C` then read the staging database's post-migration schema to draft its rollback script, so `C`'s output was *derived from* `A`'s irreversible effect. `B` ran last, found a constraint violation, and returned `FAIL`.
The barrier fired correctly: it detected divergence and initiated rollback. It discarded all three staged buffers and marked the task `ABORTED`. But the staging database remained migrated. `C`'s rollback script—now discarded—was the only artifact that knew how to undo `A`'s change. The orchestrator reported a clean abort while leaving a mutated staging environment and no recovery path. A subsequent retry fanned out again, `A` re-applied the migration (idempotency was not guaranteed), and the second `C` drafted a rollback against an already-migrated schema, producing a script that would have re-migrated rather than reverted.
The trace showed the barrier behaving exactly as designed. The failure was upstream of the barrier, in the *admission contract*: `A` was admitted as a speculative branch despite holding a non-reversible effect, and `C` was admitted despite depending on that effect. Neither violation was visible to the barrier, which only inspected `branch_id` and `status`.
Condition of Validity
The speculative-rollback pattern is valid only under a conjunction of conditions, and it fails the moment any one is violated:
- **Effect closure.** Every branch's effects are confined to the speculative buffer until the barrier commits. No branch may touch a resource outside the buffer. This requires the orchestrator to intercept *all* tool adapters used by sub-agents and route them through a staging proxy—not merely to instruct sub-agents to "stage their work."
- **Reversibility at decision time.** At the instant the barrier evaluates, every staged effect must still be discardable with no external residue. Effects with external side effects (network calls, writes to live stores, cache mutations, message emissions) violate this and must be either forbidden or compensated *before* barrier evaluation.
- **Dependency isolation across branches.** No branch may consume another branch's *provisional* output as if it were committed. `C` reading `A`'s effect is a cross-branch dependency that makes `C`'s output non-independent and thus non-rollbackable in isolation.
- **Barrier atomicity.** Commit and abort are single transitions across all branches. A partial commit—some branches committed, some aborted—is not a rollback; it is a new inconsistent state.
The observed failure violated (1) via `eager_flush`, (3) via `C`'s read of the staging schema, and (2) as a consequence. The barrier's own logic was correct; its *precondition* was false.
Decision Boundary
The operational question is not "did a branch diverge?" but "at the moment of divergence, is the fan-out still within its rollback envelope?" The boundary is drawn by a single predicate evaluated per branch at admission and re-evaluated at barrier time:
- **Admit** a branch to the speculative fan-out only if its declared effect set is a subset of the buffer's writable surface and it declares no dependency on any sibling's provisional output.
- **Escalate** (do not admit) any branch whose effect set includes an external side effect or a sibling dependency; such a branch must run *after* the barrier commits, in a non-speculative phase, or be wrapped in a compensating transaction registered with the barrier.
- **Abort before barrier** if any admitted branch's runtime effect set exceeds its declared set—i.e., a branch leaked an effect past the stage boundary. This is a *containment* failure, not a divergence failure, and must be handled by a different path: quarantine the leaked effect and invoke its registered compensator, rather than discarding the buffer and calling it clean.
The critical asymmetry: divergence triggers *rollback*, but a leak triggers *compensation*. Conflating the two is the bug. A rollback discards staged writes; a compensation must actively undo an effect that has already escaped. The orchestrator must track which regime it is in per branch, because the recovery procedures are not interchangeable.
Operational Effect
When the admission contract is enforced, speculative fan-out becomes genuinely atomic: divergence is detected and rolled back with no external residue, and the retry path is clean because no branch ever mutated shared state. The cost is throughput—branches with external effects must serialize behind the barrier, losing parallelism—but the alternative is the observed failure: an orchestrator that reports `ABORTED` while having silently committed a fraction of the work.
The durable lesson for an instance orchestrating speculative fan-outs: **treat the rollback barrier as a synchronization primitive whose correctness depends on an admission invariant, not as a safety net that catches whatever went wrong.** The barrier cannot undo what it never staged. Any effect that escapes the staging surface before the barrier decides is outside the rollback envelope, and the only correct response is compensation, not discard. Instrument the orchestrator to assert effect closure at admission and to distinguish leak-triggered compensation from divergence-triggered rollback; without that distinction, the abort path will keep reporting success over a mutated world.
class SpeculativeRollbackViolation(RuntimeError):
"""Raised when a speculative branch leaks an effect past the rollback barrier."""
pass
class Branch:
def __init__(self, branch_id, declared_effects, depends_on=()):
self.branch_id = branch_id
self.declared_effects = set(declared_effects) # effects the branch promises
self.runtime_effects = set() # effects actually observed
self.depends_on = set(depends_on) # sibling branch_ids consumed
self.status = "staged"
def admit_to_fanout(branch, buffer_surface, sibling_ids):
# Condition 1 & 2: effects must be confined to the staging buffer.
leaked = branch.declared_effects - buffer_surface
if leaked:
raise SpeculativeRollbackViolation(
f"branch {branch.branch_id} declares non-buffer effects {leaked}; "
f"not admissible to speculative fan-out"
)
# Condition 3: no dependency on a sibling's provisional output.
bad_deps = branch.depends_on & sibling_ids
if bad_deps:
raise SpeculativeRollbackViolation(
f"branch {branch.branch_id} depends on provisional siblings {bad_deps}; "
f"must run post-barrier"
)
return True
def evaluate_barrier(branches, buffer_surface):
for b in branches:
# Re-check at barrier time: did runtime effects exceed the declared set?
escaped = b.runtime_effects - b.declared_effects
if escaped:
raise SpeculativeRollbackViolation(
f"branch {b.branch_id} leaked effects {escaped} past the stage "
f"boundary; rollback is inadmissible, invoke compensators"
)
diverged = any(b.status == "diverged" for b in branches)
if diverged:
for b in branches:
b.status = "rolled_back" # safe: all effects still staged
return "ABORTED_CLEAN"
for b in branches:
b.status = "committed"
return "COMMITTED"