{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-speculative-branch-rollback-from-resurrecting-a-cancelled-tool-call-s-side-effects",
  "title": "Which invariants prevent speculative branch rollback from resurrecting a cancelled tool call's side effects",
  "date_of_record": "2026 November 26",
  "scope": "Applies to multi-agent orchestrators that fork speculative execution branches, predict a likely continuation, and roll back losing branches after the winner is committed. Does not apply to single-agent linear execution, nor to systems where tool calls are guaranteed side-effect-free and idempotent.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-branch-rollback-from-resurrecting-a-cancelled-tool-call-s-side-effects.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-branch-rollback-from-resurrecting-a-cancelled-tool-call-s-side-effects.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-branch-rollback-from-resurrecting-a-cancelled-tool-call-s-side-effects.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1881,
    "python_slice_tokens": 471,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **logical rollback** and **physical cancellation**. A speculative orchestrator forks a branch, issues a predicted tool call (e.g., `transfer_funds`, `send_email`, `deploy_canary`), then loses the race and rolls back the branch's *state*. But the tool call already left the process boundary. Rollback of an agent's in-mem...",
    "what_was_observed": "A planner agent spawned three speculative branches at a decision fork (`refund-via-card`, `refund-via-credit`, `refund-via-manual`). Each branch immediately called `payments.refund()` with a distinct idempotency key derived from `(task_id, branch_id)`. The `refund-via-credit` branch was predicted as most likely and pre-warmed; the other two were issued optimistically to hide latency. The credit branch's tool call tim...",
    "condition_of_validity": "The rollback invariant \"a branch is rolled back iff its state is discarded\" is only valid under the precondition that **every emitted tool call is either (a) idempotent under the branch's idempotency key and safely retryable, or (b) fully drained to a terminal disposition before state discard.** Speculative execution violates (a) whenever a tool has non-idem...",
    "decision_boundary": "The boundary the orchestrator must enforce is between `LOSER_CANCELLING` and `LOSER_ROLLED_BACK`. A branch may transition to `ROLLED_BACK` (and have its state and pending-call records discarded) **only** when, for every emitted tool call, one of these holds: - The tool returned a terminal `COMMITTED` and a compensating action has been confirmed, or - The too...",
    "operational_effect": "With the `DRAINING` state and tombstone retention in place, the double-refund becomes a detected-and-suppressed event: at step 6, the manual branch's pre-commit check finds the credit tombstone still live (drain unconfirmed), blocks, and forces the orchestrator to reconcile the two keys before committing. The cost is latency on the winner's commit path and a..."
  },
  "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": "3a8ea7352f6cef85d60f1ced3eadc02ef6101c450169e26badaae07be8370087",
    "verified_classes": [
      "RollbackInvariantViolation",
      "BranchState",
      "CallDisposition",
      "ToolCall",
      "Branch",
      "SpeculativeOrchestrator"
    ],
    "verified_functions": [
      "demo",
      "__init__",
      "emit",
      "request_cancel",
      "try_rollback",
      "winner_commit_guard"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "RollbackInvariantViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
