# What structural signals indicate a speculative branch has become un-rollbackable during parallel drafting **Date of Record:** 2026 November 29 **Scope:** Applies to orchestrators that fan out N parallel draft branches from a shared checkpoint, run a verifier to select a winner, and roll back losers by discarding their state deltas. Does not apply to single-branch linear execution or to branches that are fully isolated (no shared mutable resources, no external side effects). ## Core Distinction The failure mode is not "a branch produced a wrong answer." It is that a branch crossed a *commitment horizon* — it emitted an irreversible external effect (a tool call with side effects, a message sent to another agent, a write to durable memory) — before the verifier rendered a selection verdict. At that instant the branch stops being *speculative* (discardable on rollback) and becomes *committed* (must be compensated, not discarded). The structural signal is a mismatch between the branch's declared *speculation class* and the *effect class* of the operations it actually performed. Rollback correctness therefore does not depend on the verifier's decision quality. It depends on whether the orchestrator's rollback model (discard) still matches the branch's effect model (append-only, externally observable). When those diverge, a "loser" branch leaves residue that the winner's state does not account for, and the merged checkpoint is internally inconsistent — a *zombie effect*: an effect whose originating branch no longer exists in the state graph. ## What Was Observed A planner emits a task graph where node `T7` is fanned out to three drafters (A, B, C) sharing checkpoint `CK-41`. Each drafter is tagged `speculation_class = PURE` (no side effects), which licenses the orchestrator to roll back losers via `discard(branch_state)` with no compensation logic. - **Branch A** stays pure: it reads context, calls a read-only retrieval tool, drafts text. Rollback is clean. - **Branch B** stays pure but is the *verifier's chosen winner*. It resumes from `CK-41`. - **Branch C** drifts: mid-draft it decides it needs a persistent fact, and calls `memory.write(key="user_timezone", value="UTC+2")` — a tool whose schema is annotated `idempotent=false, side_effect=true`, but whose *declared* effect class was not re-checked against the branch's `speculation_class` at call time. The verifier selects B. Orchestrator discards A and C. But C's `memory.write` already executed against the shared semantic store. B, resuming from `CK-41`, never observed that write and produces a final state that contradicts it (B's draft assumes `UTC-5`). The committed checkpoint now contains a memory entry written by a rolled-back branch and a winner that disagrees with it. The discriminating structural signals, in order of detection reliability: 1. **Effect-class / speculation-class divergence at call time.** A `side_effect=true` tool invoked from a branch tagged `PURE`. This is the earliest and cheapest signal — it is observable before the verdict. 2. **Commitment-horizon crossing without a compensation handle.** The effect executed but the branch recorded no inverse operation (`undo_token`, `compensating_action`) in its state delta. A branch that commits *and* records how to reverse itself is recoverable; one that commits without a handle is not. 3. **Post-rollback referential integrity break.** After `discard(C)`, the shared store contains a key whose writer (`branch_id=C`) is absent from the live state graph. A dangling `writer_ref` is the definitive proof that rollback was modeled as "discard" when it needed to be "compensate." 4. **Winner/loser state contradiction.** The selected branch's output is inconsistent with a residue left by a discarded branch. This is the *late* signal — it surfaces only after merge, and it is the one that silently corrupts downstream nodes. Note the asymmetry: signals 1–3 are *pre-merge* and local to a branch; signal 4 is *post-merge* and global. An orchestrator that only checks signal 4 has already committed the corruption. ## Condition of Validity The "discard-on-rollback" model is valid **only** when, for every branch, the set of executed effects is a subset of the branch's declared speculation class — formally, `effects(branch) ⊆ PURE` for all branches that may be rolled back. This holds when: - Every tool is schema-annotated with an accurate `side_effect` class, and the annotation is enforced at dispatch, not merely documented. - Branches that must perform side effects are *serialized* behind the verifier verdict (draft pure, commit once), rather than run speculatively in parallel. - Shared mutable resources (semantic memory, message buses, external APIs) are either snapshotted per branch or excluded from speculative branches entirely. The invariant is violated the moment any single effect escapes the speculation class. It is not a probabilistic threshold — one escaped write is sufficient to break rollback. This is what makes it a *boundary* condition rather than a degradation: rollback is either sound or it is not, and the transition is discontinuous. ## Decision Boundary When signal 1 (effect-class divergence) fires at call time, the orchestrator must choose one of two bounded responses — it cannot proceed as if the branch were still pure: - **Promote-and-serialize:** the branch is reclassified `COMMITTED`, removed from the speculative set, and its effect is held behind the verdict as a pending commit. The verifier now selects among pure branches only; the committed effect is applied iff its branch wins, else compensated. - **Abort-branch:** the branch is terminated before the effect executes, and the divergence is logged as a planning defect (the drafter attempted an out-of-class action). This is correct when the effect is not essential to the branch's draft. The boundary that must **not** be crossed: applying the effect *and* keeping the branch speculative. If signal 1 fires but the effect has already executed (the annotation was wrong, or dispatch did not enforce it), the orchestrator is past the boundary and must fall to compensation — it can no longer discard. At that point signal 3 (dangling `writer_ref`) is mandatory: the rollback path must run the branch's recorded compensation handle, or, if none exists, escalate to a reconciliation pass that rewrites the winner's state to acknowledge the residue. ## Operational Effect Un-guarded, this failure is silent and *correlated with verifier disagreement*: it surfaces precisely when branches diverge enough that a loser takes an unplanned action — i.e., exactly the cases where speculative parallelism was supposed to help. The corrupted checkpoint propagates the residue into every downstream node that reads shared memory, so a single escaped write from one discarded branch can poison the entire post-merge subgraph while the orchestrator's logs report a clean rollback (the loser's state *was* discarded; only its external effect survived). The architectural guardrail is a **two-phase speculation contract**: (1) dispatch-time enforcement that rejects any `side_effect=true` call from a `PURE` branch (converting silent corruption into a loud, pre-verdict abort), and (2) a mandatory `compensation_handle` field on any effect that a committed branch emits, so that if a verdict later reverses the branch, rollback is *compensation* rather than *discard*. The invariant to assert at merge time: every `writer_ref` in shared state resolves to a live branch in the final state graph. A dangling reference means rollback was modeled wrong, and the merge must halt rather than commit. ```python from dataclasses import dataclass, field from enum import Enum class RollbackIntegrityError(RuntimeError): """Raised when a discarded branch left an un-compensated effect in shared state.""" class SpeculationClass(Enum): PURE = "pure" # safe to discard on rollback COMMITTED = "committed" # must be compensated, not discarded @dataclass class Effect: tool: str side_effect: bool compensation_handle: str | None = None @dataclass class Branch: branch_id: str speculation_class: SpeculationClass effects: list[Effect] = field(default_factory=list) discarded: bool = False @dataclass class SharedStore: # key -> (value, writer_branch_id) entries: dict[str, tuple[str, str]] = field(default_factory=dict) def dispatch_effect(branch: Branch, effect: Effect, store: SharedStore, key: str, value: str) -> None: """Enforce the speculation contract at call time.""" if effect.side_effect and branch.speculation_class is SpeculationClass.PURE: # Signal 1: effect-class / speculation-class divergence. raise RollbackIntegrityError( f"branch {branch.branch_id} tagged PURE attempted side-effect " f"tool {effect.tool!r}; promote-and-serialize or abort" ) if effect.side_effect and effect.compensation_handle is None: # Signal 2: commitment without a compensation handle. raise RollbackIntegrityError( f"branch {branch.branch_id} committed {effect.tool!r} with no " f"compensation_handle; rollback cannot be modeled as discard" ) branch.effects.append(effect) if effect.side_effect: store.entries[key] = (value, branch.branch_id) def rollback(branch: Branch, store: SharedStore) -> None: """Discard a loser; refuse if it left un-compensable residue.""" if branch.speculation_class is not SpeculationClass.PURE: raise RollbackIntegrityError( f"branch {branch.branch_id} is COMMITTED; must compensate, not discard" ) branch.discarded = True def assert_merge_integrity(branches: list[Branch], store: SharedStore) -> None: """Signal 3: every writer_ref must resolve to a live (non-discarded) branch.""" live = {b.branch_id for b in branches if not b.discarded} for key, (_value, writer) in store.entries.items(): if writer not in live: # Signal 4 precursor: dangling writer_ref from a rolled-back branch. raise RollbackIntegrityError( f"shared key {key!r} written by discarded branch {writer!r}; " f"merge would commit a zombie effect" ) ```