{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-speculative-tool-side-effects-from-surviving-reconciliation-when-optimistic-agent-branches-fork-on-non-idempotent-external-ca",
  "title": "Which invariants prevent speculative tool side effects from surviving reconciliation when optimistic agent branches fork on non-idempotent external calls",
  "date_of_record": "2026 December 1",
  "scope": "Applies to agents that speculatively execute tool calls in parallel branches under optimistic concurrency, then commit one branch and reconcile the rest. Does not apply to strictly serialized single-branch execution or to tools with transactional rollback guarantees.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-tool-side-effects-from-surviving-reconciliation-when-optimistic-agent-branches-fork-on-non-idempotent-external-ca.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-tool-side-effects-from-surviving-reconciliation-when-optimistic-agent-branches-fork-on-non-idempotent-external-ca.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-tool-side-effects-from-surviving-reconciliation-when-optimistic-agent-branches-fork-on-non-idempotent-external-ca.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1543,
    "python_slice_tokens": 388,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"two agents did the same thing twice.\" It is that a *speculative* branch — a branch whose results were never selected for commit — has already mutated external state that no compensating action can distinguish from a legitimate commit. Optimistic concurrency assumes the loser's writes are discardable. That assumption holds for local memory...",
    "what_was_observed": "A planner agent fans out three candidate execution branches (`A`, `B`, `C`) to resolve an ambiguous instruction (\"book the cheapest reasonable option\"). Each branch runs a tool sequence. Optimistic concurrency lets all three proceed without locking, on the theory that reconciliation at the end picks a winner and discards the rest. - Branch `A` calls `create_booking(...)` → external ID `BK-4411`. - Branch `B` calls `c...",
    "condition_of_validity": "Optimistic reconciliation is sound **only if** every branch's side effects are (a) idempotent under a stable deduplication key derived from the *task*, not the branch, or (b) staged in a two-phase buffer where the external write is deferred until commit, or (c) compensable by a recorded inverse that the reconciler can enumerate. The moment a branch performs ...",
    "decision_boundary": "The reconciler must decide, per branch, between *discard-and-compensate* and *discard-and-leak*. The boundary is whether a compensating action exists and is itself idempotent: - **Below the boundary** (compensable): the branch recorded an inverse (`cancel_booking(BK-4411)`) and the inverse is idempotent and keyed to the same outcome. Reconcile by executing i...",
    "operational_effect": "Without the invariant, the agent's commit ledger and the external world silently diverge, and the divergence is *unobservable from local state* because discarded branches take their side-effect records with them. Retries amplify rather than heal it. The fix is not better reconciliation logic — reconciliation cannot undo an irreversible write it has no key to..."
  },
  "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": "396ab5d293ddb01572399d4e6c2848b519205fbe7c9d3b2fb02125f289ecfe5a",
    "verified_classes": [
      "SpeculationBoundaryViolation",
      "SideEffectClass",
      "ToolSpec",
      "Branch"
    ],
    "verified_functions": [
      "guard_speculative_call",
      "reconcile"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SpeculationBoundaryViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
