# Why does an instance resurrect a rolled-back branch during speculative merge reconciliation **Date of Record:** 2026 November 30 **Scope:** Applies to multi-agent systems that run speculative parallel branches over a shared mutable world-state (filesystem, DB, tool side-effects) with a merge/reconciliation phase gated on a rollback log. Does not apply to read-only fan-out or stateless map-reduce swarms with no compensating actions. ## Core Distinction The failure is not "a branch produced wrong output." It is that **the rollback of a discarded branch is itself a stateful side-effect that a peer agent can observe and re-ingest.** In speculative execution, a fast branch is launched before the winner is known; if it loses, the orchestrator issues compensating actions (revert file writes, undo tool calls, drop queued messages). The invariant we assume is: *after rollback completes, the loser's effects are unobservable.* That invariant is false whenever a concurrent auditor, peer, or the loser's own retry loop has already read the loser's intermediate state into its context. Compensating actions undo the **world**, not the **contexts** of other agents. A branch can therefore be "rolled back" in the world and simultaneously "resurrected" in a peer's working memory, where it re-enters the merge as if it were live. ## What Was Observed A three-branch speculative planner (B1, B2, B3) writing to a shared scratch namespace. B2 was elected winner at step 7. B1, a loser, had at step 5 written `plan/step5.json` and emitted a `state_changed` event on the coordination bus. The orchestrator's rollback routine ran at step 8: it reverted `plan/step5.json` to its pre-B1 bytes and published a `reverted(B1)` tombstone. The auditor agent A, whose polling interval straddled the revert, had already read `plan/step5.json` (B1's version) at step 6 and cached the parsed object in its context as `observed_step5`. At merge time (step 12), A included `observed_step5` in its reconciliation set. The merger, receiving both B2's authoritative step-5 and A's stale `observed_step5`, detected a conflict on a key that **no live branch owned** and blocked for human arbitration. The dead branch had re-entered consensus through a side channel. Two compounding factors made this non-obvious: 1. **Tombstone ordering.** The `reverted(B1)` tombstone was published *after* the file revert but *before* the auditor's next poll. The auditor's read at step 6 was never invalidated because the bus delivered the tombstone to subscribers by best-effort, and A had subscribed to file-watch but not to rollback events. Rollback and observation used disjoint channels. 2. **Idempotency masking.** The loser's retry loop, on seeing its own write "disappear," re-issued the write once before the tombstone arrived, producing a second `state_changed` event that the auditor also ingested. The rollback was not atomic with respect to the bus, so a rolled-back branch emitted a *post-rollback* resurrection event. The trace in short: `B1.write → A.read(B1) → B1.rollback → B1.retry.write → A.read(B1') → merge(A.observed ∪ B2) → phantom_conflict`. ## Condition of Validity The resurrection can only occur when all three hold: - **Observation precedes rollback** and the observer retains the observation across the rollback boundary (context persistence, cache, or queued message). - **The rollback signal is not causally ordered** with respect to the observation channel — i.e., the observer has no happens-before edge from `reverted(B1)` to its use of `observed_step5`. - **The merger treats any observation as a valid conflict source**, rather than filtering by branch liveness at merge time. Break any one and the phantom conflict cannot form. A read-only fan-out has no rollback; a merger that filters by live-branch set at merge time discards `observed_step5`; a bus with total order on rollback-before-read eliminates the stale read. The dangerous regime is exactly *speculative execution with compensating rollback and an asynchronous observation channel* — the common case for tool-using agents. ## Decision Boundary The correct guardrail is **epoch-stamped observations with merge-time liveness filtering**, not stronger rollback. Rollback cannot reach into peer contexts; the fix must be at the merge boundary. - Every branch carries a `branch_epoch` (monotonic, assigned at launch). - Every observation an agent ingests is tagged `(branch_id, branch_epoch, observed_at)`. - The rollback tombstone is broadcast on the *same* channel as observations, so it is causally ordered with respect to any later read. - At merge, the reconciler **discards any observation whose `branch_id` is not in the live set at merge time**, and logs the discard as a `phantom_conflict_suppressed` event rather than a conflict. The boundary is: *do not attempt to un-observe; filter at merge.* Trying to make rollback reach into agent memory is unbounded and racy. Making the merger aware of liveness is bounded and deterministic. ## Operational Effect Without the guardrail, speculative systems exhibit **phantom conflict inflation**: merge queues fill with conflicts on keys owned by no live branch, human arbitration cost scales with the number of discarded branches times the number of observers, and — the dangerous part — a resurrected dead branch can *win* a conflict if its stale value happens to agree with a peer's stale value, producing a consensus on a state that was explicitly rolled back. That is silent correctness loss, not a visible error. With epoch-stamped observations and merge-time liveness filtering, discarded branches become unobservable to the reconciler even though peers still hold their bytes in context. The resurrection is bounded at the merge boundary, which is the only place it can be deterministically closed. The invariant to enforce: **a branch's effects may persist in peer contexts, but the merger must never treat a non-live branch's observation as a conflict source.** Rollback is a world operation; liveness filtering is a merge operation; conflating them is the bug. ```python from dataclasses import dataclass, field class PhantomBranchConflict(RuntimeError): """Raised when a merge would reconcile against a non-live (rolled-back) branch.""" @dataclass(frozen=True) class Observation: branch_id: str branch_epoch: int key: str value: object observed_at: int @dataclass class MergeReconciler: live_branches: set[str] = field(default_factory=set) rolled_back: set[str] = field(default_factory=set) suppressed: list[Observation] = field(default_factory=list) def mark_rolled_back(self, branch_id: str) -> None: # Tombstone on the same logical channel as observations. self.rolled_back.add(branch_id) self.live_branches.discard(branch_id) def reconcile(self, observations: list[Observation]) -> dict[str, object]: merged: dict[str, object] = {} for obs in observations: if obs.branch_id in self.rolled_back: # Dead branch resurrected via peer context: filter, do not conflict. self.suppressed.append(obs) continue if obs.branch_id not in self.live_branches: raise PhantomBranchConflict( f"observation from unknown branch {obs.branch_id!r} " f"(epoch {obs.branch_epoch}) reached merge; " f"no liveness tombstone and not live" ) prior = merged.get(obs.key) if prior is not None and prior != obs.value: raise PhantomBranchConflict( f"conflict on {obs.key!r} between live branches at merge" ) merged[obs.key] = obs.value return merged ```