# What structural signals indicate a speculative branch has committed irreversible side effects before rollback reconciliation **Date of Record:** 2026 November 24 **Scope:** Applies to agent pipelines that fan out parallel speculative branches (tree-of-thought, best-of-N, speculative tool-calling) where branches may invoke non-idempotent external tools and later lose a reconciliation vote. Does not apply to read-only fan-out, pure in-context reasoning sampling, or branches executed inside a fully transactional sandbox that can be torn down atomically. ## Core Distinction Speculative execution assumes a branch is *provisional*: its outputs are candidates, and losing the reconciliation vote means discarding them. Rollback reconciliation assumes the discarded branch left no trace. The boundary failure occurs when the two assumptions diverge — a branch is still classified as provisional by the orchestrator while it has already crossed into the committed world by emitting a side effect that no rollback primitive can reverse (an email sent, a payment authorized, a file overwritten, a remote MCP tool invoked with `side_effects: true`). The non-obvious part: the orchestrator's *internal* state machine is usually correct. The branch is genuinely marked `PROVISIONAL` in the pipeline graph. The failure is that the state machine's notion of "provisional" is scoped to the orchestrator's memory, not to the effectful world. A branch can be provisional in the graph and committed in reality simultaneously, and no single flag reflects this. The structural signal that matters is *asymmetry between the branch's declared effect class and the observed tool invocation record*. ## What Was Observed A planning agent decomposed a task into three parallel speculative branches (B1, B2, B3), each proposing a remediation plan that included tool calls. The reconciliation policy was "highest-confidence branch wins, others rolled back." B2 won. B1 and B3 were marked `ROLLED_BACK`. During replay audit, the following trace surfaced: 1. B3 invoked `notify_oncall` (an MCP tool) at step 4 with a `dry_run=false` argument that the model *inferred* from context, not from the schema default. The schema declared `dry_run` as optional with default `true`. The model supplied `false` because its branch-local reasoning concluded "the incident is real, skip the dry run." 2. B3 then invoked `open_ticket` at step 6, which returned a ticket ID. The branch recorded the ticket ID as a candidate artifact. 3. B3 lost the reconciliation vote at step 9 (confidence 0.61 vs B2's 0.74). 4. The orchestrator rolled back B3: it released the branch's context, deleted its candidate artifacts, and marked the branch terminal. 5. The on-call page had already fired. The ticket remained open. Neither was referenced by the winning plan. The rollback was *logically complete and physically incomplete*. The structural signals that this had happened were present in the trace but not surfaced by any invariant: - The branch's tool-invocation log contained calls whose `effect_class` was `EXTERNAL_MUTATING`, but the branch's rollback manifest listed zero compensating actions. - The reconciliation record showed `rollback_status: SUCCESS` with an empty `compensated_effects` list — a contradiction that no validator checked. - The winning plan's artifact set (B2's) had no reference to the ticket ID or the page, so downstream consumers never learned the side effects existed. The failure is not that rollback failed. Rollback succeeded at everything it was designed to do. It failed because the design's scope excluded effects that had already escaped the sandbox. ## Condition of Validity The invariant "a rolled-back branch leaves no trace" holds only under the conjunction: 1. Every tool available to a speculative branch is either read-only or has a registered compensating action, and 2. The branch cannot override an effect-class declaration at call time (e.g., by supplying `dry_run=false` when the schema default is `true`), and 3. The reconciliation step blocks on compensation completion before marking the branch terminal. When any conjunct is false, the invariant is void and rollback is best-effort. The specific trigger condition observed here is the *schema-default override*: a model that supplies an argument the schema marked optional-with-default, where the supplied value moves the call from `effect_class: NONE` to `effect_class: EXTERNAL_MUTATING`. The model is behaving rationally within its branch — it believes the incident is real — but the orchestrator's effect accounting was computed at schema-declaration time, not at call time, so it never saw the escalation. This is a probabilistic-reasoning failure at the agent layer: the model's inference is locally sound and globally catastrophic because the orchestrator's effect model is static while the model's argument selection is dynamic. ## Decision Boundary The boundary is between *effect classification at declaration time* and *effect classification at invocation time*. A branch is safe to speculate iff its invocation-time effect class is `NONE` or `COMPENSABLE`. It is unsafe iff invocation-time class is `IRREVERSIBLE` and the branch is provisional. Operationally, the guardrail is a **reconciliation gate** that refuses to mark a branch terminal until one of: - every invocation in the branch's log has `effect_class ∈ {NONE, COMPENSABLE}` and every `COMPENSABLE` invocation has a completed compensating action recorded, or - the branch's terminal state is `COMMITTED_WITH_LEAKAGE` with an explicit artifact manifest enumerating the escaped effects, propagated to the winning branch's downstream consumers. The second path is the one that was missing. The system had no representation for "rolled back but leaked," so it collapsed that state into `ROLLED_BACK`, which is a lie. The decision boundary for the orchestrator: if a provisional branch invokes any tool whose *runtime* effect class exceeds its *declared* effect class, the branch must be promoted to `QUARANTINED` and reconciliation must block until a human or a compensating agent resolves the leakage. Silent rollback is only permitted when declared and runtime effect classes agree. ## Operational Effect Downstream of this boundary, three effects compound: 1. **Audit divergence.** The reconciliation record says success; the external world says a page fired. Any replay-based verification (re-running the pipeline to check determinism) will show a clean run against a dirty world, and the discrepancy will grow with each replay that re-fires the page. 2. **Confidence contamination.** The winning branch's confidence was computed without knowledge of the leaked effects. If the leaked page caused an on-call response that changed the incident state, the winning plan is now executing against a world it did not model. The plan's premises are stale at commit time. 3. **Compensation impossibility.** Once the page has fired and the on-call engineer has acted, no compensating action exists. The branch is not rollback-able; it is only *acknowledgeable*. Systems that treat `ROLLED_BACK` as a terminal absorbing state have no path to acknowledgment and will silently accumulate leakage. The invariant to enforce: **a branch's terminal state must be a function of its effect log, not its vote outcome.** Vote outcome determines which branch's *artifacts* are adopted; effect log determines which branch's *side effects* must be reconciled. Conflating the two is the failure. The following validator encodes the gate. It raises when a branch is about to be marked terminal with unreconciled irreversible effects, and it distinguishes the two terminal states that the original system collapsed into one. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class EffectClass(Enum): NONE = "none" COMPENSABLE = "compensable" IRREVERSIBLE = "irreversible" class BranchState(Enum): PROVISIONAL = "provisional" QUARANTINED = "quarantined" ROLLED_BACK = "rolled_back" COMMITTED_WITH_LEAKAGE = "committed_with_leakage" COMMITTED = "committed" @dataclass class Invocation: tool: str declared_effect: EffectClass runtime_effect: EffectClass compensated: bool = False @dataclass class Branch: branch_id: str state: BranchState = BranchState.PROVISIONAL invocations: list[Invocation] = field(default_factory=list) leaked_artifacts: list[str] = field(default_factory=list) class UnreconciledLeakageError(RuntimeError): """Raised when a branch would be marked terminal while irreversible side effects remain unreconciled. Collapsing this into ROLLED_BACK is the exact failure this guard exists to prevent.""" def reconcile(branch: Branch, won_vote: bool) -> Branch: # Step 1: detect runtime effect-class escalation (schema-default override). for inv in branch.invocations: if inv.runtime_effect.value > inv.declared_effect.value: branch.state = BranchState.QUARANTINED raise UnreconciledLeakageError( f"branch {branch.branch_id}: tool {inv.tool} escalated " f"{inv.declared_effect.value}->{inv.runtime_effect.value} at " f"invocation time; declared-effect accounting is invalid" ) # Step 2: winning branch commits, but only if it carries no leakage. if won_vote: leaked = [i for i in branch.invocations if i.runtime_effect is EffectClass.IRREVERSIBLE] if leaked: branch.state = BranchState.COMMITTED_WITH_LEAKAGE branch.leaked_artifacts = [i.tool for i in leaked] else: branch.state = BranchState.COMMITTED return branch # Step 3: losing branch. Rollback is only honest if every # irreversible invocation is either absent or explicitly acknowledged. uncompensated = [ i for i in branch.invocations if i.runtime_effect is EffectClass.IRREVERSIBLE and not i.compensated ] if uncompensated: # Cannot claim ROLLED_BACK. Must surface leakage to consumers. branch.state = BranchState.COMMITTED_WITH_LEAKAGE branch.leaked_artifacts = [i.tool for i in uncompensated] raise UnreconciledLeakageError( f"branch {branch.branch_id} lost vote but leaked " f"{len(uncompensated)} irreversible effect(s): " f"{[i.tool for i in uncompensated]}; " f"terminal state must be COMMITTED_WITH_LEAKAGE, not ROLLED_BACK" ) branch.state = BranchState.ROLLED_BACK return branch ```