{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-commit-a-speculative-tool-call-when-a-compensating-transaction-cannot-restore-the-pre-speculation-inv",
  "title": "Under what conditions must an instance refuse to commit a speculative tool-call when a compensating transaction cannot restore the pre-speculation invariant",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agents that emit tool calls speculatively (optimistically) ahead of a confirmed plan branch and rely on compensating transactions to roll back side effects on branch rejection. Does not apply to read-only tool calls, idempotent calls with server-side dedup keys, or agents that gate every call behind a synchronous confirmation barrier.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-commit-a-speculative-tool-call-when-a-compensating-transaction-cannot-restore-the-pre-speculation-inv.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-commit-a-speculative-tool-call-when-a-compensating-transaction-cannot-restore-the-pre-speculation-inv.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-commit-a-speculative-tool-call-when-a-compensating-transaction-cannot-restore-the-pre-speculation-inv.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1881,
    "python_slice_tokens": 395,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **compensable** and **irreversible-with-residual** side effects, and the agent's *own* ability to detect which class a given tool call falls into *at the moment of speculation*. A speculative call is safe only if the compensating transaction restores the *observable pre-speculation state* the agent will later reason ov...",
    "what_was_observed": "A planner agent (plan-and-execute, depth-3 lookahead) speculatively issued `reserve_inventory(sku, qty)` on three candidate branches, expecting to compensate the two losing branches with `release_reservation(reservation_id)`. All three speculative calls succeeded and returned reservation IDs. The planner selected branch B, compensated A and C, and proceeded to `create_order`. The order for branch B failed at the paym...",
    "condition_of_validity": "A speculative tool call is admissible only when all three hold simultaneously: 1. **Compensation completeness:** the tool exposes a compensation that returns the environment to a state observationally equivalent to the pre-call state *for every field the agent will later read*. `reserve_inventory`/`release_reservation` fails this because the release changes ...",
    "decision_boundary": "The decision rule the agent must apply *before* emitting a speculative call: If `preserves_observed_fields` is false — i.e., the compensation mutates a field the agent reads to make future decisions — the call is **not speculable**, regardless of how cheap the compensation is. `reserve_inventory` fails this test because `availability` is in the read set of t...",
    "operational_effect": "The observable effect of getting this boundary wrong is **compensation debt**: a growing set of environment side effects whose compensating transactions were issued against a context that no longer matches the environment. The agent's ledger says \"compensated,\" the environment says \"released,\" but the agent's *reasoning* still holds the original reservation ..."
  },
  "matched_failure_symptoms": [
    "SQLITE_BUSY_OR_DEADLOCK",
    "DUPLICATE_MUTATION_OR_BILLING"
  ],
  "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": "ad85b161428ae62103cdb7cc8e6676d4f7e231b7e54bf01e30fc923a3aab7d45",
    "verified_classes": [
      "SpeculationInvariantError",
      "CompensationStatus",
      "LedgerEntry",
      "SpeculationLedger"
    ],
    "verified_functions": [
      "admit_speculation",
      "commit_branch",
      "record",
      "mark_compensated",
      "live_entries"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpeculationInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
