{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-orphaned-side-effects-when-speculative-agent-branches-roll-back-after-optimistic-tool-invocation",
  "title": "Which invariants prevent orphaned side effects when speculative agent branches roll back after optimistic tool invocation",
  "date_of_record": "2026 November 25",
  "scope": "Applies to multi-agent pipelines that fork speculative branches, invoke external tools optimistically before a branch is committed, and reconcile branches via rollback. Does not apply to purely read-only tool surfaces or to single-branch sequential agents with no fork/commit lifecycle.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-orphaned-side-effects-when-speculative-agent-branches-roll-back-after-optimistic-tool-invocation.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-orphaned-side-effects-when-speculative-agent-branches-roll-back-after-optimistic-tool-invocation.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-orphaned-side-effects-when-speculative-agent-branches-roll-back-after-optimistic-tool-invocation.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2153,
    "python_slice_tokens": 348,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"a branch rolled back.\" Rollback of *internal* state is cheap and well-understood: discard the speculative context, restore the checkpoint, resume from the last committed turn. The boundary condition is that **optimistic tool invocation crosses the rollback boundary**. When a speculative branch calls a tool with a side effect (writes a rec...",
    "what_was_observed": "A three-branch speculative planner was forked from a shared checkpoint. Each branch was given the same task: resolve a customer escalation by (1) reading the ticket, (2) drafting a reply, (3) *optimistically* posting the reply to the ticketing API so the latency of the write overlaps with the reconciliation step. Branch selection was deferred to an auditor agent that scored the three drafts and committed the best one...",
    "condition_of_validity": "The invariant that prevents this is a **commit-gated effect boundary**: no tool with an irreversible side effect may be invoked by a branch until that branch has been selected as the commit winner, *or* the effect must be routed through a staging layer that is itself part of the branch's reversible state and is only flushed on commit. Formally, for a pipelin...",
    "decision_boundary": "The decision boundary is where the pipeline chooses between **optimistic invocation with compensation** and **deferred invocation with staging**. Both are valid; the failure is choosing neither and believing you chose the first. Choose optimistic-with-compensation only when every committed-only tool has a *verified* inverse that the rollback path actually ca...",
    "operational_effect": "When the commit-gated effect boundary holds, rollback is total: the losing branches leave no trace in the external world, and the committed transcript is the only record of what happened. The retrieval layer's view of the world matches the world, so the next task's context is not poisoned by discarded branch outputs. When it fails, the observable signature i..."
  },
  "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": "72d756891c3f34df0c672f2fee60cfec8ecbfeb318947fb5b8c680a0d62ce09a",
    "verified_classes": [
      "EffectTierViolation",
      "OrphanedEffectError",
      "ToolRegistry",
      "SpeculativeBranch"
    ],
    "verified_functions": [
      "__init__",
      "tier_of",
      "__init__",
      "invoke",
      "commit",
      "rollback"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "EffectTierViolation",
      "OrphanedEffectError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
