# What structural signals indicate rollback divergence in speculatively executed agent subplans **Date of Record:** 2026 November 25 **Scope:** Applies to orchestrators that dispatch sibling subplans optimistically (speculatively) before the parent decision is committed, then reconcile by rolling back losers. Does not apply to strictly sequential plans or to speculative decoding inside a single model instance, where no durable side effects are produced. ## Core Distinction The failure here is not "a subplan failed." It is that a *successful* speculative subplan's side effects became non-idempotent witnesses that the parent's committed branch cannot reproduce. When an orchestrator fans out subplans S1..Sn speculatively to hide latency, each subplan may mutate external state (write a file, call a tool that appends to a queue, emit an event). The parent then selects one winner and issues rollback directives to the losers. The invariant most teams assume is: > rollback(loser) ∘ execute(loser) ≡ identity This holds only when the loser's effects are *perfectly reversible and fully enumerated*. In practice, LLM subplans produce effects that are (a) discovered late, (b) entangled with the winner via shared resources, or (c) recorded in the agent's own episodic memory as "completed," which the reconciler reads back as evidence the work is done. The boundary condition is where rollback succeeds mechanically but the *memory and provenance graph* now disagree with the world. That divergence—not the rollback itself—is the failure. ## What Was Observed A three-way speculative fan-out over a document-editing task. Parent plan P dispatches S1 (rewrite section A), S2 (rewrite section A with a different style), S3 (insert a cross-reference). All three run concurrently against a shared scratch document and a shared vector store used for retrieval. P selects S2 as winner. The reconciler issued rollback to S1 and S3. Both returned `status: rolled_back`. Yet three structural signals fired downstream: 1. **Memory/effect asymmetry.** S1's episode log contained `{"action": "edit_section_A", "result": "success", "content_hash": "…"}`. Rollback restored the document bytes but did not append a compensating episode. On the next turn, the parent's retrieval over its own episodic memory surfaced S1's success record as a *prior completion of section A*, and the model reasoned "section A is already edited" and skipped re-verification—even though the committed content came from S2. 2. **Retrieval contamination.** S1 and S3 had both written embeddings into the shared vector store during their speculative run. Rollback deleted the documents but not the embeddings (the tool's `delete` path did not cascade to the index). Subsequent retrieval returned chunks whose source documents no longer existed, and the model cited them. 3. **Cross-subplan interference.** S3's cross-reference inserted a link to a section anchor that S1 had created speculatively. S3's rollback removed the link but S1's rollback removed the anchor. The *winner* S2 referenced the same anchor in one paragraph it copied from the pre-existing draft. The committed document now had a dangling reference that neither rollback detected, because each rollback validated only its own effect set. The common thread: every rollback was locally correct and globally incomplete. The divergence was visible only in *structural* signals—hash mismatches between episode logs and document state, orphaned index entries, and dangling intra-document references—never in the rollback return codes. ## Condition of Validity Speculative fan-out with rollback reconciliation is safe if and only if all of the following hold: - **Effect closure.** Each subplan declares its full effect set *before* execution, and the reconciler can enumerate every external mutation from that declaration. Undeclared effects (embeddings, caches, episode logs, telemetry) break closure. - **Compensating memory.** Every rollback emits a first-class compensating episode (`{"action": "rollback", "target": episode_id, "reason": …}`) so the agent's own memory does not present rolled-back work as completed. Without this, the model's next-turn retrieval is poisoned. - **Shared-resource isolation or reference counting.** Subplans that write to a shared index or shared document must either be isolated (copy-on-write) or reference-counted so that one rollback cannot orphan another subplan's surviving artifacts. - **Post-rollback invariant check.** The reconciler must re-run the parent's structural invariants (hash equality between episode log and world, no orphaned references, no dangling index entries) after *all* rollbacks complete, not per-subplan. When any of these is absent, the return code `rolled_back` is not evidence of reconciliation—it is evidence only that the rollback *call* succeeded. ## Decision Boundary The operative decision is whether to trust a `rolled_back` status as a commit gate. The boundary: - If the subplan's effect set is **closed and declared**, and the reconciler emits compensating episodes, and a post-rollback structural check passes → treat rollback as authoritative; commit the winner. - If the effect set is **open** (any tool with side effects not enumerated in the plan schema), or the subplan wrote to a shared resource without reference counting → do **not** commit on `rolled_back` alone. Escalate to a full reconciliation pass: diff the world against the pre-fan-out snapshot, and diff the episode log against the world. - If the parent's own memory is the retrieval substrate for the next turn → the compensating-episode requirement is mandatory regardless of effect closure, because a mechanically clean rollback still leaves a semantic "done" marker. The non-obvious part: the failure is worst when rollback *succeeds*. A failed rollback triggers alerts; a successful-but-incomplete rollback passes every health check while silently corrupting the agent's self-model. ## Operational Effect Downstream, the agent exhibits "phantom completion": it believes work was done that was rolled back, skips verification, and cites artifacts that no longer exist. Because the divergence lives in memory and index state rather than in the document, it survives context-window compaction and reappears turns later as a confident but unfounded assertion. The remediation is not better rollback—it is *compensating memory plus a post-rollback structural invariant pass*, and a hard rule that speculative subplans must declare their full effect set at dispatch time or be barred from shared resources. ```python import hashlib from dataclasses import dataclass, field class RollbackDivergence(RuntimeError): """Raised when a mechanically successful rollback leaves memory/world divergence.""" pass @dataclass class SubplanEffect: subplan_id: str world_hash: str # hash of the resource the subplan mutated episode_claims_done: bool declared_effects: set = field(default_factory=set) def reconcile_rollback(effect: SubplanEffect, world_hash_now: str, compensating_episode_present: bool, shared_index_orphans: int) -> None: # 1. Effect closure: undeclared effects cannot be trusted to have been reversed. if not effect.declared_effects: raise RollbackDivergence( f"subplan {effect.subplan_id}: empty effect set; rollback unverifiable" ) # 2. World must match pre-fan-out hash after rollback. if world_hash_now != effect.world_hash: raise RollbackDivergence( f"subplan {effect.subplan_id}: world hash {world_hash_now} != " f"expected {effect.world_hash} after rollback" ) # 3. Memory asymmetry: a rolled-back subplan must not still claim completion. if effect.episode_claims_done and not compensating_episode_present: raise RollbackDivergence( f"subplan {effect.subplan_id}: episode claims done but no " f"compensating rollback episode; next-turn retrieval will be poisoned" ) # 4. Shared-resource orphan check must run post-rollback, not per-subplan. if shared_index_orphans > 0: raise RollbackDivergence( f"subplan {effect.subplan_id}: {shared_index_orphans} orphaned " f"index entries survive rollback" ) def commit_winner(winner_id: str, effects: list[SubplanEffect], world_hashes: dict, compensating: dict, orphans: int) -> str: for e in effects: if e.subplan_id == winner_id: continue reconcile_rollback(e, world_hashes[e.subplan_id], compensating.get(e.subplan_id, False), orphans) return f"committed {winner_id}" ```