# Under what conditions must an instance refuse to reconcile a speculative branch after a sibling agent's rollback has already been observed **Date of Record:** 2026 November 24 **Scope:** Applies to any multi-agent system where a coordinator forks two or more speculative branches from a shared checkpoint, executes them concurrently, and must reconcile the losing branch(es) against the winner after rollback. Does not apply to strictly serial agent pipelines, to branches that never share mutable external state (pure read-only subagents), or to systems where rollback is defined as a full process restart with no state carry-over. ## Core Distinction The distinction that matters is between **rollback of a branch's local state** and **rollback of the side effects that branch already committed to the shared world**. Speculative execution in agent systems is not the CPU's speculative execution: a CPU branch that mispredicts leaves no trace because its writes are buffered and discarded. An agent branch that mispredicts has, by the time the coordinator learns it lost, already emitted tool calls — it wrote a file, posted a message, reserved a lock, appended to an external log, or mutated a shared blackboard. The rollback primitive almost always restores the *agent's* episodic memory and scratchpad to the fork checkpoint. It almost never un-sends the tool calls. The non-obvious consequence: a sibling agent that "observes a rollback" is not observing a clean world. It is observing a world in which the losing branch's *reasoning* has been erased but its *effects* persist. Reconciliation logic that trusts the rollback signal as "this branch never happened" is unsound. The invariant that must hold before any reconciliation is: > A branch may be reconciled only if every externally observable effect it produced has been either (a) idempotently re-derived by the winning branch, (b) explicitly compensated, or (c) proven to be in a namespace the winner does not read. If none of (a), (b), (c) holds, the reconciler must refuse and escalate, because merging the winner's state with a world that still contains the loser's effects produces a state that corresponds to no branch that was ever actually executed — a *phantom merge*. ## What Was Observed A coordinator agent forks three speculative branches from checkpoint `C0` to answer a multi-step research-and-write task. Branch A and Branch B both need to "claim" a shared scratch resource: a single append-only findings log at `/shared/findings.md` guarded by a lease. The lease service grants exclusive append rights to the first claimant and returns `LEASE_HELD` to others. Trace: 1. `t0` — Fork A, B, C from `C0`. All three carry `lease_state = UNHELD` in their checkpointed context. 2. `t1` — Branch A calls `acquire_lease(findings)`. Lease service grants it. A appends three findings to `/shared/findings.md`. A's local context records `lease_state = HELD`. 3. `t2` — Branch B calls `acquire_lease(findings)`. Service returns `LEASE_HELD`. B, being a probabilistic reasoner, does not treat this as fatal — it reasons "the resource is contended, I will retry after a short wait" and enters a retry loop with a 2-second backoff, up to 10 attempts. B's local context records `lease_state = CONTENDED`. 4. `t3` — Branch C completes first and its output is judged best by the coordinator's scorer. Coordinator selects C as winner. 5. `t4` — Coordinator issues `rollback(A)` and `rollback(B)` to checkpoint `C0`. Rollback restores each branch's context to `lease_state = UNHELD` and truncates its scratchpad. **It does not release A's lease and does not remove A's three appended findings.** The lease service has no knowledge that A was rolled back; A's lease TTL is 300s. 6. `t5` — Coordinator begins reconciliation: it instructs the surviving winner C to "merge any findings from sibling branches that were rolled back, using their pre-rollback transcripts." C reads A's transcript from the rollback archive, sees three findings, and appends them to `/shared/findings.md` — **duplicating them**, because A's appends were never removed. C also reads B's transcript, sees `lease_state = CONTENDED` and a retry loop with no resolution, and infers "B was blocked, contributed nothing," which is true but for the wrong reason. 7. `t6` — Branch B, meanwhile, is not dead. Its rollback signal was delivered to its context manager but its retry loop was mid-`await` on a `sleep`; the rollback truncated its memory but did not cancel the in-flight coroutine. On wake, B's retry loop fires its 6th `acquire_lease` attempt. A's lease has by now expired (TTL elapsed during reconciliation). B acquires the lease and appends its own findings — **after** reconciliation completed. The final log contains A's findings twice (once original, once via C's merge) plus B's findings, with B's findings appearing after the merge boundary and therefore never seen by C. The observable end state is a log that no single branch produced, containing a duplicate set and a tail that arrived post-hoc. The coordinator reported success. ## Condition of Validity The reconciliation at `t5` was valid only under conditions that did not hold. State them precisely, because the failure is entirely in the gap between the assumed precondition and the actual one. The reconciler's implicit model was: *a rolled-back branch has produced no durable effects, therefore its transcript is the complete and only record of what it did, and merging transcripts is equivalent to merging effects.* This model is valid iff, for every tool the branch could call, one of the following is true: - **Effect-idempotent tools.** The tool's output is a pure function of its input and re-invocation is harmless (read-only queries). For these, transcript-merge is sound because there is nothing to double-apply. - **Compensable tools.** The rollback primitive invokes a registered compensator (release lease, delete file, retract message) keyed to the branch's tool-call journal. For these, transcript-merge is sound because the world was actually restored. - **Namespace-isolated tools.** The branch's writes land in a branch-private namespace (`/branches/A/...`) that the winner never reads, and merging is an explicit copy step the reconciler controls. The observed system had none of these for `append_findings`. It had a lease (a mutual-exclusion primitive, not a compensation primitive) and a rollback that touched only agent-local context. The lease is the trap: it *looks* like it bounds the damage because only one branch can hold it at a time, but it serializes writes without enabling their removal. Mutual exclusion is not compensation. A second condition of validity was violated at `t6`: rollback was assumed to be **quiescent** — that after `rollback(B)` returns, B produces no further effects. It was not, because rollback truncated memory but did not cancel the in-flight tool coroutine. The rollback signal and the tool execution live in different schedulers. Any system where a branch can have an outstanding `await` on a tool at rollback time must treat rollback as *requesting* quiescence, not *achieving* it, and must fence subsequent tool calls from that branch (e.g., a generation counter the tool gateway checks) until quiescence is confirmed. ## Decision Boundary The boundary the reconciler must enforce is a single predicate evaluated per losing branch, before any transcript is merged: ``` reconcilable(branch) := effects(branch) ⊆ compensable(branch) ∪ idempotent(branch) ∪ private_ns(branch) AND quiescent(branch) AND lease_state(branch) ∈ {UNHELD, RELEASED_BY_COMPENSATOR} ``` Where `effects(branch)` is the branch's tool-call journal (not its transcript — the transcript is the model's *narration* of what it did, and probabilistic reasoners routinely narrate effects they did not produce and omit effects they did, especially under retry loops). `quiescent(branch)` means the tool gateway has confirmed no in-flight call for that branch generation. `lease_state` must be read from the lease service, not from the branch's context — the branch's context was rolled back to `UNHELD` and is therefore a liar about the lease. Three concrete decision rules follow: 1. **If any effect is uncompensated and non-idempotent and in a shared namespace, refuse reconciliation.** Do not merge the transcript. The correct action is to re-execute the winner's merge step *against the actual current world state* (read the log, dedupe by content hash, append only the delta), not against the loser's transcript. Transcript-merge is only safe when the world is clean; when it is not, you must reconcile against the world, not the narration. 2. **If the branch is not quiescent, fence it and wait.** Issue a generation bump to the tool gateway so any late `acquire_lease` from the rolled-back branch is rejected with `STALE_GENERATION`, then reconcile. The observed failure at `t6` is exactly a missing generation fence. 3. **Never infer a branch's contribution from its terminal context state.** B's context said `CONTENDED`; the truth was "blocked, then later unblocked and wrote." The terminal context is a snapshot of a process that may still be running. Read the tool-call journal and the world, not the snapshot. The boundary is sharp: the moment the reconciler merges a transcript whose effects are not provably clean, it has manufactured a state that no execution produced. That state is not merely wrong — it is *unfalsifiable* by replay, because replaying any single branch reproduces neither the duplicate nor the post-merge tail. ## Operational Effect The downstream effect is a class of corruption that survives all the usual agent observability. The coordinator's success signal is green because reconciliation returned without error. The winner's transcript is internally consistent. The losing branches' transcripts are internally consistent. The corruption lives only in the *relation* between the shared log and the transcripts, which no single agent's logs capture. This is why speculative rollback bugs in agent swarms are so often discovered late and misattributed to "the model hallucinated a finding" — the duplicate finding is real, it was really written, and it was written by a real agent; it is just written twice. Operationally, the fix is to make rollback a *compensating transaction* over the tool-call journal rather than a context truncation, and to make the reconciler's unit of merge the *effect* rather than the *transcript*. In practice this means: every tool call that mutates shared state must be journaled with a branch id and a content hash; rollback must run registered compensators for every journal entry; the tool gateway must enforce a per-branch generation fence so late calls from rolled-back branches are rejected; and the reconciler must dedupe against the live world by content hash before appending anything derived from a losing branch. The lease, on its own, provides none of this — it prevents concurrent writes but does nothing about writes that already happened. Treating a lease as if it were a rollback guarantee is the specific mistake this record exists to prevent. ```python import hashlib from dataclasses import dataclass, field from enum import Enum from typing import Optional class ReconciliationRefused(RuntimeError): """Raised when a speculative branch cannot be safely reconciled after rollback.""" class EffectClass(Enum): IDEMPOTENT = "idempotent" COMPENSABLE = "compensable" PRIVATE_NS = "private_ns" SHARED_MUTABLE = "shared_mutable" @dataclass class JournalEntry: tool: str effect_class: EffectClass content_hash: str compensated: bool = False @dataclass class Branch: branch_id: str generation: int journal: list[JournalEntry] = field(default_factory=list) lease_state: str = "UNHELD" # as read from the LEASE SERVICE, not the branch context quiescent: bool = False # confirmed by tool gateway, not assumed def is_reconcilable(branch: Branch) -> tuple[bool, Optional[str]]: """Evaluate the reconciliation predicate. Returns (ok, reason_if_not).""" if not branch.quiescent: return False, f"branch {branch.branch_id} gen {branch.generation} not quiescent" for e in branch.journal: if e.effect_class is EffectClass.SHARED_MUTABLE and not e.compensated: return False, ( f"branch {branch.branch_id} has uncompensated shared effect " f"{e.tool}#{e.content_hash[:8]}" ) if branch.lease_state not in ("UNHELD", "RELEASED_BY_COMPENSATOR"): return False, f"branch {branch.branch_id} lease_state={branch.lease_state}" return True, None def reconcile_losing_branch(branch: Branch, live_world_hashes: set[str]) -> list[str]: """Merge a losing branch's contribution against the LIVE world, not its transcript.""" ok, reason = is_reconcilable(branch) if not ok: # Refuse: transcript-merge here would manufacture a phantom state. raise ReconciliationRefused( f"refusing to reconcile {branch.branch_id}: {reason}. " f"Re-run merge against live world with dedupe, or compensate first." ) # Safe path: only effects not already present in the world are appended. to_append = [e.content_hash for e in branch.journal if e.content_hash not in live_world_hashes] return to_append def fence_stale_generation(branch: Branch, gateway_generation: int) -> None: """Tool gateway must reject calls from rolled-back generations.""" if branch.generation < gateway_generation: raise ReconciliationRefused( f"stale generation: branch {branch.branch_id} gen {branch.generation} " f"< gateway gen {gateway_generation}; late tool call rejected" ) ```