{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-speculative-branch-merges-from-resurrecting-effects-that-the-rollback-already-committed",
  "title": "Which invariants prevent speculative branch merges from resurrecting effects that the rollback already committed",
  "date_of_record": "2026 November 30",
  "scope": "Applies to orchestrators that fan out speculative agent branches (parallel tool-using subagents) over a shared, effectful environment and reconcile by rolling back losers and merging winners. Does not apply to branches whose tool calls are provably side-effect-free (pure reads, sandboxed compute) or to single-branch linear execution.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-branch-merges-from-resurrecting-effects-that-the-rollback-already-committed.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-branch-merges-from-resurrecting-effects-that-the-rollback-already-committed.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-branch-merges-from-resurrecting-effects-that-the-rollback-already-committed.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2311,
    "python_slice_tokens": 459,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"a losing branch's side effects leaked.\" That is the naive rollback problem, and it is solved by ordering: quiesce the loser, then compensate. The non-obvious failure is the inverse — **a winner's merge re-applies an effect that a loser's rollback already compensated, because the merge and the rollback both reference the same pre-branch st...",
    "what_was_observed": "A planner agent (`root`) received a task requiring a schema migration. It fanned out three speculative branches against the same staging database: - `B1`: add column `tier` to `accounts`, backfill from `plan`. - `B2`: rename `plan` → `plan_code`, update three downstream views. - `B3`: drop `plan`, replace with a normalized `plan_ref` table. All three were launched from snapshot `S₀` (effect-cursor `c=41`). `B1` finis...",
    "condition_of_validity": "The invariant that would have prevented both is: **merge must be a function of (branch-point snapshot, winner effect-log) only, and must be applied against the snapshot, not the live environment; rollback must never mutate the snapshot or any object the merge reads.** Concretely: 1. **Snapshot immutability.** `S₀` is copy-on-write and read-only to compensato...",
    "decision_boundary": "The orchestrator must choose between two reconciliation disciplines at the moment a branch is rejected: - **Snapshot-merge discipline** (invariant above): rollback is deferred; compensations are ledger entries; merge runs against `S₀`; a final convergence phase applies the net effect. Cost: the environment is inconsistent (contains un-compensated loser effec...",
    "operational_effect": "The practical consequence is that **speculation over effectful branches requires an environment fence and a two-phase convergence**, and the fence duration is the merge window, not the branch execution window. Systems that skip the fence to keep speculation \"fast\" buy latency with silent corruption that surfaces only when a downstream consumer reads a resurr..."
  },
  "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": "f5f8ff134418038bc6483d2210a6d6b312e3a0c64c1c19be773159fc92770d5f",
    "verified_classes": [
      "SpeculativeMergeError",
      "Effect",
      "EffectLedger"
    ],
    "verified_functions": [
      "merge_winner",
      "run_speculation",
      "record",
      "highest_cursor_for",
      "compensation_cursor_for"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "SpeculativeMergeError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
