# In what scenarios must an instance invalidate speculative sibling branches before merge, and how does rollback-checkpoint aliasing silently corrupt the merge frontier? **Date of Record:** 2026 December 3 **Scope:** Applies to orchestrators that fan out speculative agent branches from a shared rollback checkpoint, mutate external tool state, and merge surviving branches into a canonical plan. Does not apply to purely read-only speculation or to single-branch linear execution with no merge step. ## Core Distinction The failure described here is not "a branch produced a wrong answer." It is the case where two sibling branches, both individually correct against their own local view, are merged into a frontier that was never valid in any single world. The distinguishing mechanism is **checkpoint aliasing**: the rollback checkpoint is treated as an immutable snapshot, but it actually shares mutable backing state (a vector store handle, a filesystem mount, a rate-limited tool session, a conversation buffer object) with the live branches. When branch A writes through that shared handle, branch B's "restored" view silently diverges from the checkpoint it believes it rolled back to. The merge step then reconciles two branches whose preconditions no longer share a common ancestor. This is distinct from ordinary merge conflicts. A merge conflict is detectable because both branches touched the same key. Aliased-checkpoint corruption is invisible at merge time because the branches touched *disjoint* keys, yet the shared substrate (a monotonically increasing counter, a session token, a cache epoch) was advanced by both, and the merge combinator has no axis on which to compare that substrate. ## What Was Observed A planner spawned three speculative branches from checkpoint `C7`: a `schema-migration` branch, a `backfill` branch, and a `verify` branch. All three were issued the same rollback handle. The migration branch executed a DDL tool call that incremented a shared migration-version counter on the tool session from 41 to 42. The backfill branch, speculatively cheaper, was rolled back to `C7` after exceeding its cost budget. On rollback the orchestrator restored the agent's context window and episodic memory to `C7`, but the tool session object was reused rather than re-instantiated. The backfill branch then re-ran its plan against a session reporting `migration_version=42`, while its restored context asserted `migration_version=41`. The backfill branch's own guard passed — it checked version consistency against its context, not against the live session. It emitted writes keyed to the v41 schema. The migration branch merged cleanly because the two branches touched disjoint table sets. The verify branch, running last, read a database that was half-migrated and half-backfilled and reported a checksum mismatch that was attributed to the verify branch's own logic, causing an unnecessary re-run and a second cost overrun. The trace signature: two branches whose `context.epoch` values are equal (both `C7`) but whose `tool_session.epoch` values differ by one or more increments. The invariant that should have held — *equal checkpoint id implies equal observable substrate* — was false. ## Condition of Validity The merge-frontier invariant holds only if every speculative branch is issued a checkpoint whose identity covers *all* mutable substrate the branch can observe, not merely the agent-local state. Concretely, a checkpoint `C` is valid for speculation only when: 1. Every tool handle reachable from the branch is either (a) freshly instantiated at `C`, or (b) carries a version token that is folded into `C`'s identity. 2. Rollback restores the substrate version, not just the context window — or the orchestrator refuses to merge branches whose substrate tokens diverged. 3. Cost-aware pruning (killing a branch for exceeding budget) triggers a full substrate restore before the branch is either resumed or discarded, because a discarded branch that already advanced shared state has poisoned every sibling that later rolls back to the same `C`. When any of these is violated, the checkpoint is an *alias*, not a snapshot, and merge validity is undefined. The condition of validity is therefore: **speculation is sound iff checkpoint identity is a function of the complete observable substrate, and the merge combinator compares substrate tokens across branches before reconciling plan diffs.** ## Decision Boundary The boundary between "safe to merge" and "must invalidate siblings" is crossed at the moment a branch performs a *non-idempotent, substrate-advancing* action through a shared handle. The decision rule: - If a branch's actions are idempotent and substrate-neutral (pure reads, deterministic computations, writes to branch-private scratch), merge without re-validation. - If a branch advances shared substrate (increments a counter, acquires an exclusive lock, consumes a one-time token, mutates a cache epoch), then **every sibling sharing that checkpoint handle must be invalidated and re-derived from a substrate-fresh checkpoint before merge** — even siblings that never touched the same key, because they may have *observed* the advanced substrate after a partial rollback. - If the orchestrator cannot determine whether an action advanced shared substrate, it must treat it as advancing. The asymmetry is deliberate: a false invalidation costs one re-run; a false merge costs a corrupted frontier that passes local guards. The subtle case is the *cheap branch that was pruned before merge*. Intuition says a killed branch cannot affect the frontier. It can, if it advanced substrate before being killed and a surviving sibling subsequently rolled back through the aliased handle. Pruned branches must therefore be audited for substrate advancement, not merely dropped. ## Operational Effect The practical consequence is a mandatory phase separation between *speculation* and *substrate mutation*. Orchestrators that allow speculative branches to touch shared tool sessions must either (a) serialize substrate-advancing actions behind a single designated branch and forbid siblings from observing the session until merge, or (b) give each branch a copy-on-write substrate handle whose epoch is folded into the checkpoint id. Without one of these, cost-aware pruning becomes actively dangerous: the cheaper you prune, the more rollbacks you perform, and each rollback through an aliased handle re-exposes a sibling to substrate state it never consented to. The verify branch, which is supposed to be the safety net, is the branch most likely to be corrupted, because it runs last and therefore observes the maximum accumulated substrate divergence. The net effect is that verification reports failures that are artifacts of the speculation machinery itself, and operators learn to distrust the verifier rather than the checkpoint model. ```python class AliasedCheckpointMergeError(RuntimeError): """Raised when sibling branches share a rollback checkpoint whose substrate tokens diverged, making the merge frontier undefined.""" def merge_speculative_branches(checkpoint_id, branches, substrate): # substrate: maps handle_id -> current epoch token # branches: each has .context_epoch, .substrate_tokens, .advanced_substrate expected = branches[0].substrate_tokens for b in branches: if b.context_epoch != checkpoint_id: raise AliasedCheckpointMergeError( f"branch {b.id} context epoch {b.context_epoch} != {checkpoint_id}" ) for handle, token in b.substrate_tokens.items(): live = substrate.get(handle) if live != token: raise AliasedCheckpointMergeError( f"branch {b.id} observed {handle}={token} but live substrate is {live}; " f"checkpoint {checkpoint_id} is aliased, not a snapshot" ) if b.advanced_substrate and b.id != branches[0].id: raise AliasedCheckpointMergeError( f"branch {b.id} advanced shared substrate through aliased handle; " f"siblings must be invalidated before merge" ) return reconcile_plan_diffs(branches) ```