# What structural signals indicate a speculative branch is unsafe to reconcile after sibling rollback **Date of Record:** 2026 November 23 **Scope:** Applies to orchestrators that fan out speculative sibling branches (parallel drafters, probers, or tool-executing agents) from a shared checkpoint and later merge one survivor while rolling back the rest. Does not apply to strictly sequential single-branch agents or to stateless request/response tool calls with no shared mutable substrate. ## Core Distinction The failure is not "a branch failed" and it is not "the merge conflicted." Both are expected and handled. The failure is **reconciling a survivor whose committed side effects were conditioned on a sibling that has since been rolled back** — a *dangling causal dependency*. The distinguishing signal is that the survivor's output is internally consistent and its own branch state passes local validation, yet its correctness silently depends on state that the rollback erased. Local validity is exactly what makes this non-obvious: a naive reconciler checks the survivor against the base checkpoint, sees no conflict, and commits. The structural invariant that must hold at merge time: **every artifact the survivor emits must be derivable from (base checkpoint ∪ survivor's own writes).** If any artifact depends on a sibling's writes — a lock it acquired, a cache entry it populated, an ID it reserved, a fact it wrote to shared semantic memory — the survivor is not mergeable, regardless of how clean its diff looks. ## What Was Observed A planner spawned three speculative branches from checkpoint `C0`: `B1` (draft via tool A), `B2` (draft via tool B), `B3` (probe that writes shared results into a scratch store `S`). The branches shared a mutable scratch namespace because the framework treated `S` as "ephemeral, branch-local" — but `S` was in fact a single process-global dict, keyed by task, not by branch. Trace: 1. `B1` writes `S["entity_42"] = {id: 42, ...}` and emits a draft that references `entity_42` by ID only. 2. `B2` reads `S["entity_42"]` (it exists — `B1` wrote it), uses it, and emits its own draft also referencing `entity_42`. 3. `B3` probes and writes `S["entity_42"]["confidence"] = 0.91`. 4. The reconciler selects `B2` as survivor (highest score) and rolls back `B1` and `B3`. Rollback of `B1` deletes `S["entity_42"]`; rollback of `B3` is a no-op because its key was already gone. 5. `B2`'s draft is committed. It references `entity_42`, which no longer exists in `S` or in `C0`. Downstream resolution fails with a dangling-reference error, or worse, an entity-resolution step silently re-creates `entity_42` from a fuzzy match and produces a plausible but wrong record. The critical observation: at step 4, `B2`'s diff against `C0` was empty for `S` (it only read), and its draft was well-formed. Every local check passed. The dependency was invisible because it was a *read*, and rollback deletes *writes* — reads leave no trace in the branch's own write set. ## Condition of Validity The invariant holds only under these conditions, and breaks outside them: - **Shared substrate is keyed by branch, not by task.** If `S` is partitioned per branch and cross-branch reads are forbidden or recorded, the dependency is observable. If `S` is task-global (as here), reads are untracked and the invariant cannot be enforced by diffing. - **Rollback is write-deletion, not read-invalidation.** The reconciler must treat a survivor's reads of sibling-written state as a first-class dependency edge, not as an absence of writes. - **The survivor's artifacts are *referentially* dependent, not *copy*-dependent.** If `B2` had copied the full entity into its own draft, rollback of `B1` would be harmless. The failure requires that the survivor holds a *reference* (ID, pointer, handle, cache key) whose referent lives in sibling-owned state. When any of these does not hold — e.g., the survivor deep-copied its inputs, or the substrate is branch-partitioned — the failure does not occur and the standard diff-based reconciler is sound. ## Decision Boundary At merge time, for each surviving branch, compute the **closure of its causal reads**: the set of substrate keys it read that were *written by a sibling after `C0`*. Then: - If the read-closure is empty → safe to reconcile; commit. - If the read-closure is non-empty **and** every read key's value is re-derivable from `C0` ∪ survivor's own writes → safe; re-materialize the value before commit. - If the read-closure is non-empty **and** any key's value is *not* re-derivable (it was created by a sibling, not present in `C0`) → **do not commit.** Either (a) promote the sibling that owns the key into the survivor set (co-commit), or (b) fail the survivor and re-run it against `C0` with the dependency made explicit. The boundary is sharp: the deciding question is not "does the survivor conflict with `C0`?" but "does the survivor's read-closure contain a key whose post-`C0` value is unowned by the survivor?" A single unowned key flips the branch from mergeable to unsafe. This is why confidence scores, draft quality, and diff cleanliness are all irrelevant signals here — they measure the wrong thing. ## Operational Effect Without this guard, the system exhibits **silent referential corruption**: commits succeed, downstream resolution sometimes fails loudly (dangling ID) and sometimes "repairs" itself by re-creating the referent from partial context, producing records that are internally consistent and externally wrong. The corruption is non-deterministic because it depends on which sibling the scorer happens to pick and whether rollback order deletes the referent before or after the survivor's commit. The required guardrail is a **read-dependency ledger**: every branch records reads of task-global substrate as `(key, writer_branch, post_C0?)` tuples, and the reconciler refuses to commit any survivor whose ledger contains a post-`C0` key not owned by the survivor. The ledger must be populated at read time, not reconstructed at merge time, because the read leaves no other trace. ```python from dataclasses import dataclass, field from typing import Dict, Set, Optional class DanglingReadDependency(RuntimeError): """Survivor's read-closure contains a post-checkpoint key owned by a rolled-back sibling.""" pass @dataclass class ReadLedger: # branch_id -> set of (key, writer_branch, post_checkpoint) reads: Dict[str, Set[tuple]] = field(default_factory=dict) def record_read(self, branch_id: str, key: str, writer: Optional[str], post_c0: bool) -> None: self.reads.setdefault(branch_id, set()).add((key, writer, post_c0)) def reconcile( survivor: str, rolled_back: Set[str], ledger: ReadLedger, survivor_own_writes: Set[str], base_keys: Set[str], ) -> None: """Commit `survivor` only if every post-C0 key it read is owned by the survivor or re-derivable from the base checkpoint. Otherwise raise.""" for key, writer, post_c0 in ledger.reads.get(survivor, set()): if not post_c0: continue # pre-existing, safe if writer == survivor: continue # survivor owns it if key in survivor_own_writes: continue # survivor re-materialized it if key in base_keys: continue # re-derivable from C0 # Post-C0 key, written by a sibling, not owned or re-derivable by survivor. raise DanglingReadDependency( f"survivor={survivor} read key={key!r} written by sibling={writer!r} " f"after checkpoint; sibling is in rollback set={sorted(rolled_back)}. " f"Refusing to commit: referent will not exist post-rollback." ) # safe to commit ```