# What structural signals indicate speculative branch divergence has silently orphaned verified tool-call side effects **Date of Record:** 2026 November 25 **Scope:** Applies to multi-agent systems where a planner agent forks speculative branches, each branch preemptively issues tool calls (writes, payments, mutations) under a "verify-then-commit" rollback protocol, and a verifier agent selects one branch to promote. Does not apply to read-only tool surfaces, single-branch execution, or systems where tool calls are fully transactional at the transport layer. ## Core Distinction The failure we are isolating is not "a speculative branch produced a wrong answer." It is the structural case where **a branch that the verifier rejected had already emitted a non-idempotent tool call whose side effect survives rollback because the rollback ledger keys on branch identity rather than on the effect's causal provenance.** The distinction that matters operationally: *speculative divergence* (branches disagree on reasoning, harmless) versus *speculative side-effect leakage* (a rejected branch's tool call committed against the real world and the promotion of the surviving branch does not compensate for it). Most branch-and-verify designs conflate these because they assume rollback is symmetric with fork. It is not. Fork is cheap and pure; tool calls are impure and preemption makes them *partially* durable. The non-obvious structural signal: **the count of committed effects exceeds the count of effects attributable to the promoted branch's causal chain.** When you reconcile the effect ledger against the promoted branch's provenance graph, the surplus effects are orphans — real mutations with no surviving parent. They do not raise errors. They do not fail verification, because the verifier only inspects the branch it is promoting. They are invisible until a downstream consumer observes state it cannot explain. ## What Was Observed A planner forks three branches (B1, B2, B3) to satisfy a task requiring two tool calls: `reserve_inventory(sku, qty)` and `charge(customer, amount)`. All three branches speculatively preempt both calls to reduce latency. The preemption layer issues `reserve_inventory` immediately on branch creation, before verification, on the theory that reservation is "cheap to undo." - B1 reserves 10 units, charges $400. Verifier scores it 0.81. - B2 reserves 10 units, charges $380 (different discount reasoning). Verifier scores it 0.88 — promoted. - B3 reserves 10 units, then its `charge` call times out mid-flight and the branch is abandoned. The rollback ledger records B1 and B3 as rejected and issues compensating `release_inventory` for each. But B3's `reserve_inventory` had already been *re-issued* by the preemption retry logic after a transient 503 — the retry landed under a new idempotency key derived from `(branch_id, attempt)`, not `(sku, qty, reservation_intent)`. Rollback releases one reservation. The second reservation — same branch, different attempt key — is orphaned. The promoted branch B2's inventory now reads 10 units reserved by B2, 10 by B3-attempt-1 (released), and 10 by B3-attempt-2 (**not released**). Total reserved: 20 against an intent of 10. The verifier, inspecting only B2, reported success. The orphan surfaced 40 minutes later when a fulfillment agent found inventory over-committed and could not attribute the surplus to any live branch. ## Condition of Validity This failure requires the conjunction of four conditions; remove any one and the orphan cannot form: 1. **Preemption precedes verification.** The tool call fires before the branch is scored. If tool calls are deferred until after promotion, there is nothing to orphan. 2. **Rollback is keyed on branch identity, not effect provenance.** The compensating action targets `branch_id`, so any effect whose key diverged from the branch key (via retry, via sub-agent delegation, via a tool that internally fans out) escapes compensation. 3. **At least one tool call is non-idempotent or has a retry path that mints new keys.** Idempotent-by-construction calls (deterministic key from intent) collapse retries and cannot orphan. 4. **The verifier's inspection scope is the promoted branch only.** If the verifier audits the *effect ledger* rather than the branch, the surplus is caught. This is the load-bearing condition — it is what makes the failure silent. The invariant that must hold for safety: **every committed effect must be reachable from exactly one live branch's provenance graph, or be explicitly tombstoned.** Orphan detection is exactly the check that this invariant is violated. ## Decision Boundary The boundary is between *rollback as branch cancellation* and *rollback as effect reconciliation*. Below the boundary — low tool-call fan-out, idempotent tools, single-attempt calls — branch-keyed rollback is sufficient and cheaper. Above the boundary — any non-idempotent tool, any retry logic, any sub-agent that re-issues calls under derived keys — branch-keyed rollback is unsound and you must reconcile on the effect ledger. The decision rule: **if the tool surface contains any call whose idempotency key is not a pure function of the semantic intent, rollback must be provenance-based.** You detect this by asking, for each tool, "can two calls with the same intent produce two distinct durable effects?" If yes for any tool, the branch-keyed rollback is a latent orphan generator. A second boundary governs detection cadence. You cannot rely on downstream consumers to surface orphans — they surface as unexplained state, not as errors, and often after the compensation window has closed. The reconciliation must run **at promotion time**, comparing the effect ledger's committed set against the union of all live branches' provenance closures, before the promoted branch's effects are declared final. ## Operational Effect When the invariant is enforced at promotion, the failure converts from silent state corruption into a catchable promotion abort: the reconciler finds a committed effect with no live parent, halts promotion, and either compensates the orphan or escalates. The cost is one ledger scan per promotion — O(committed effects) — which is negligible against the cost of a mis-charged customer or over-committed inventory discovered an hour later. When it is not enforced, the orphan persists until a downstream agent's own invariant check fires, at which point the causal chain back to the speculative branch is already cold and the orphan is misattributed to a live branch, triggering a *second* erroneous compensation. The failure compounds: one orphan becomes two anomalies, and the reconciliation that should have been a single ledger diff becomes a forensic reconstruction across agent logs that may have already rotated. The structural signal to monitor in production is the **effect-to-provenance ratio per promotion**: committed effects divided by effects reachable from the promoted branch's closure. A ratio of exactly 1.0 is clean. Any value above 1.0 at promotion time is an orphan, and the magnitude tells you how many. This ratio is cheap to compute, requires no semantic understanding of the effects, and is the single most reliable early indicator that speculative preemption has outrun rollback. ```python class OrphanedEffectError(RuntimeError): """Raised when a committed tool effect has no live speculative-branch parent.""" pass def reconcile_at_promotion( committed_effects: list[dict], live_branches: dict[str, set[str]], promoted_branch_id: str, ) -> None: """ Enforce the invariant: every committed effect is reachable from exactly one live branch's provenance closure, or explicitly tombstoned. committed_effects: each has {'effect_id', 'causal_key', 'tombstoned'} live_branches: branch_id -> set of causal_keys in its provenance closure """ reachable: set[str] = set() for branch_id, closure in live_branches.items(): reachable |= closure orphans = [ e for e in committed_effects if not e.get("tombstoned") and e["causal_key"] not in reachable ] if orphans: # Promotion must abort: the promoted branch cannot be declared final # while effects exist that no live branch can account for. orphan_ids = [e["effect_id"] for e in orphans] ratio = len(committed_effects) / max(len(reachable), 1) raise OrphanedEffectError( f"Promotion of {promoted_branch_id} aborted: " f"{len(orphans)} orphaned effect(s) {orphan_ids} " f"have no live provenance parent " f"(effect-to-provenance ratio={ratio:.2f}). " f"Compensate orphans or tombstone before re-promoting." ) # Invariant holds; promotion may proceed. return None ```