# Where must an instance detect that a speculative branch has already been reconciled by a sibling before replaying its own effect log, and why does the answer depend on effect-idempotency class rather than on branch lineage? **Date of Record:** 2026 November 27 **Scope:** Applies to multi-agent systems that fork a shared task state into speculative branches, execute effects in parallel, and reconcile via rollback/replay. Does not apply to single-agent linear execution or to branches whose effects are declared purely read-only at fork time. ## Core Distinction Speculative multi-agent execution forks a base checkpoint into N branches, each running an independent effect log against a shared world. Rollback-and-replay reconciliation assumes that replaying a branch's effect log onto the post-merge state is *safe* because the branch was forked from a known ancestor. This assumption conflates two distinct questions: 1. **Lineage validity** — is this branch a descendant of the current committed checkpoint? (A graph property, decidable from version metadata.) 2. **Effect-idempotency admissibility** — will re-applying this branch's effects on the merged state produce the same world as if the effects had been applied exactly once in commit order? (A semantic property, *not* decidable from lineage.) The non-obvious boundary failure is that a branch can pass the lineage check — it is a legitimate descendant of the ancestor — and still be **already reconciled**: a sibling branch's committed effects have absorbed, superseded, or inverted the branch's own effects. Replaying then double-applies. The correct gate before replay is not "is my ancestor committed?" but "has my effect class already been satisfied by a reconciled sibling?" These diverge precisely when effect idempotency is *not* guaranteed by construction. ## What Was Observed A planner agent forks three branches from checkpoint `C0` to satisfy a composite goal (provision a resource, register a handler, emit a notification). Branch `A` (provision) and branch `B` (register) execute concurrently; branch `C` (notify) is speculative and depends on both. The reconciler commits `A`, then commits `B`, and — because `C`'s precondition (resource exists AND handler registered) is now satisfied by the *merged* state — marks `C` as **satisfied-by-merge** and drops it from the active set without committing its log. The failure trace: 1. `C` had already executed its notification effect against its own speculative world (`notify(handler, resource)`), enqueuing a delivery that is non-idempotent (each call dispatches a distinct message). 2. `C`'s branch object retains a stale `status: speculative` because the reconciler updated only the merge-set, not the branch ledger. 3. A late-arriving verifier, seeing `C.status == speculative` and `C.ancestor == C0 == committed`, replays `C`'s effect log to "recover" it. 4. The notification fires a **second time**. The merge had already satisfied `C`'s *intent* without consuming `C`'s *effects*; replay consumes the effects again. The critical observation: `C` passed the lineage gate (`ancestor C0` is committed) and the precondition gate (`resource` and `handler` present in merged state) — both true — yet replay was wrong. The only gate that would have caught it is an **effect-idempotency gate** keyed on the effect class, which the reconciler never consulted because it treated "satisfied-by-merge" as a benign optimization rather than a terminal disposition that must be propagated to the branch ledger. A second observed variant: branch `D` (a compensating/rollback branch) emitted `delete(resource)`. A sibling had already committed a *recreate* of the same resource under a new generation id. `D`'s lineage was valid, but its effect was **already inverted** by the sibling's commit; replaying `delete` against the new generation destroyed a resource the merge intended to keep. Lineage-valid, idempotency-inadmissible. ## Condition of Validity The lineage-only replay guard is valid **iff** every effect in the branch's log belongs to an idempotency class that is *replay-safe under merge*: pure reads, absolute writes (`set(x, v)` independent of prior value), or effects carrying a reconciliation token that the merged state deduplicates. It is **invalid** for: - **Accumulating effects** (`append`, counter increments, message dispatch) where replay adds a second delta. - **Inverting effects** (`delete`, `revoke`) whose target may have been regenerated under a new identity by a sibling. - **Conditional effects** whose precondition was true at fork time but whose truth was *established* by a sibling's commit — replay re-evaluates against a world where the effect is already satisfied. The boundary is therefore: *a branch may be replayed only if its effect class is merge-idempotent OR the branch ledger records that no sibling has reconciled its effects.* Lineage answers "may I run?"; idempotency class answers "may I run *again*?" — and only the second question is decisive at replay time. ## Decision Boundary Before any replay, the reconciler must evaluate, in order: 1. **Disposition check (terminal first).** If the branch ledger shows `satisfied-by-merge`, `superseded`, or `inverted-by-sibling`, replay is forbidden regardless of lineage. This requires that "satisfied-by-merge" be written back to the *branch ledger*, not only the merge-set — the propagation gap is the root cause. 2. **Idempotency classification.** For each effect, resolve its class. If any effect is non-merge-idempotent (accumulating/inverting/conditional-established), require an explicit reconciliation token proving the effect was not absorbed by a sibling commit. 3. **Lineage check.** Only after 1 and 2 pass does ancestor-commit status authorize replay. The boundary is sharp: the moment a sibling commit makes a branch's precondition true in the merged state, that branch crosses from "speculative, replayable" to "reconciled, terminal." The transition must be atomic with the sibling commit, or a replay window opens between commit and ledger update. ## Operational Effect Systems that gate replay on lineage alone exhibit **double-application** on accumulating effects and **spurious destruction** on inverting effects, both of which pass every structural check and surface only as downstream state divergence (duplicate notifications, phantom deletions) that no version graph reveals. The invariant required is: **reconciliation disposition is a terminal state that propagates to the branch ledger in the same transaction as the sibling commit, and replay eligibility is a function of effect-idempotency class, not ancestry.** Without it, speculative branches remain indefinitely replayable against a world that has already absorbed them. ```python class StaleReplayError(RuntimeError): """Raised when a branch is replayed after a sibling already reconciled its effects.""" pass # Effect idempotency classes: only ABSOLUTE is replay-safe under merge. MERGE_IDEMPOTENT = {"read", "absolute_write"} TERMINAL_DISPOSITIONS = {"satisfied-by-merge", "superseded", "inverted-by-sibling"} def guard_replay(branch, merged_state): # 1. Terminal disposition gate: satisfied-by-merge must be in the branch ledger. if branch.ledger_disposition in TERMINAL_DISPOSITIONS: raise StaleReplayError( f"branch {branch.id}: disposition={branch.ledger_disposition} " f"is terminal; sibling already reconciled these effects" ) # 2. Idempotency gate: any non-merge-idempotent effect needs a reconciliation token. for effect in branch.effect_log: if effect.cls not in MERGE_IDEMPOTENT: if not effect.reconciliation_token \ or effect.reconciliation_token not in merged_state.tokens: raise StaleReplayError( f"branch {branch.id}: effect {effect.id} class={effect.cls} " f"is not merge-idempotent and lacks a reconciliation token; " f"replay would double-apply or invert a sibling commit" ) # 3. Lineage gate: only now is ancestry decisive. if branch.ancestor not in merged_state.committed_checkpoints: raise StaleReplayError( f"branch {branch.id}: ancestor {branch.ancestor} not committed" ) return True ```