{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-merge-a-speculative-branch-after-an-optimistic-tool-side-effect-has-already-escaped-the-sandbox",
  "title": "When must an instance refuse to merge a speculative branch after an optimistic tool side effect has already escaped the sandbox",
  "date_of_record": "2026 November 25",
  "scope": "Applies to orchestrators that fan out speculative agent branches (branch-and-merge rollback) where branches are permitted to invoke tools optimistically before a merge decision. Does not apply to read-only tool surfaces or to branches whose tool calls are fully transactional and reversible at the tool layer.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-merge-a-speculative-branch-after-an-optimistic-tool-side-effect-has-already-escaped-the-sandbox.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-merge-a-speculative-branch-after-an-optimistic-tool-side-effect-has-already-escaped-the-sandbox.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-merge-a-speculative-branch-after-an-optimistic-tool-side-effect-has-already-escaped-the-sandbox.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2311,
    "python_slice_tokens": 369,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"a branch produced a wrong answer.\" It is the collision between two independent notions of commit: the *speculative* commit made by the orchestrator's merge logic, and the *irreversible* commit made by an optimistic tool invocation that already mutated external state. Branch-and-merge rollback assumes that discarding a losing branch is equ...",
    "what_was_observed": "A planner agent decomposed a refund-reconciliation task and fanned out three speculative branches, each instructed to \"resolve the customer's refund and confirm to the customer.\" Branch A chose to issue a partial refund via `payments.refund`; Branch B chose a full refund; Branch C chose to escalate and issue nothing. The orchestrator scored branches on a rubric and selected B as the winner, then rolled back A and C. ...",
    "condition_of_validity": "The invariant that branch-and-merge rollback relies on, stated explicitly, is: > **Discarding a branch is a complete undo if and only if every tool effect performed by that branch is either (a) buffered inside the sandbox and never escaped, or (b) recorded in a per-branch effect journal that the rollback routine replays as compensating actions.** The conditi...",
    "decision_boundary": "The decision an instance must make at merge time is binary and must be evaluated per discarded branch, not per run: - **Merge freely** when the discarded branch's effect journal contains no `escaped` entries, or when every `escaped` entry has a verified compensation already applied (not merely scheduled) and confirmed by the external surface's own read-back....",
    "operational_effect": "When this boundary is enforced, the observable behavior changes in three concrete ways. First, merge latency for runs that touch mutating tools increases by exactly the cost of the effect-journal read-back, because the orchestrator can no longer assume that discarding a branch is free. This is the price of a state graph that is actually consistent with the w..."
  },
  "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": "dc317648ba6182d0ef779352b5f941b3eccfd3937f46197ba89f854c55c7e145",
    "verified_classes": [
      "MergeRefusedError",
      "EffectState",
      "EffectEntry",
      "Branch",
      "Orchestrator"
    ],
    "verified_functions": [
      "record_effect",
      "refuse_if_orphaned",
      "merge"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "MergeRefusedError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
