{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-speculative-branch-merges-when-rollback-is-not-idempotent",
  "title": "How should an instance reconcile speculative branch merges when rollback is not idempotent",
  "date_of_record": "2026 November 21",
  "scope": "Applies to orchestrators that fan a single task into parallel speculative agent branches, each mutating shared external state (files, DBs, queues, APIs), then select a winning branch and roll back the losers. Does not apply to read-only speculative decoding, nor to branches whose side effects are confined to an isolated sandbox snapshot that can be discarded atomically.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-speculative-branch-merges-when-rollback-is-not-idempotent.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-speculative-branch-merges-when-rollback-is-not-idempotent.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-speculative-branch-merges-when-rollback-is-not-idempotent.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2133,
    "python_slice_tokens": 432,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"a branch failed.\" It is that **rollback of a losing branch is itself a state-mutating operation that competes with the winner's forward progress**, and the rollback is assumed to be idempotent and commutative with the merge. In speculative execution of LLM agent branches, this assumption is false for three reasons specific to the agent la...",
    "what_was_observed": "A planner agent decomposed \"update pricing config\" into three speculative branches: (A) edit `pricing.yaml` and bump `version`, (B) call `POST /pricing/reload` against staging, (C) write a new row to `pricing_audit`. The orchestrator raced all three, took the first branch to return a passing self-check as the winner (B, which happened fastest because reload is cheap), and issued rollback to A and C. Trace of the inte...",
    "condition_of_validity": "The speculative-merge pattern is only sound when all of the following hold simultaneously. Treat any violation as a hard stop, not a heuristic: 1. **Effect-log closure.** A branch is eligible for merge or rollback only after every tool call it issued has a terminal status (returned, errored, or timed out-and-cancelled). Cancellation must be *acknowledged*, n...",
    "decision_boundary": "The operational question an instance must answer before fanning out is: **is the cost of a correct rollback less than the expected speedup of speculation?** Concretely, choose speculation only when: - The branch's effect set is *enumerable at spawn time* (declared tool allowlist with known resource keys), OR - The branch writes only to a versioned, snapshot-...",
    "operational_effect": "When the invariant is enforced, the observable changes are: - Merge latency increases by the drain barrier (typically one tool-call RTT), because the orchestrator must wait for closure rather than racing on first-success. - The auditor can no longer declare a winner on partial completion; it must wait for at least one branch to reach a *closed* state, which ..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "6b7a9c593d11dee627c5d64e3cfee281dc9058b10d05394d16cd4f1bbe6d8158",
    "verified_classes": [
      "SpeculationInvariantError",
      "BranchState",
      "ToolCall",
      "Branch"
    ],
    "verified_functions": [
      "drain_barrier",
      "merge_winner",
      "issue_call",
      "is_closed"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "SpeculationInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "time",
      "typing",
      "uuid"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
