{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-bound-speculative-tool-call-execution-when-idempotency-keys-outlive-compensating-rollback",
  "title": "How should an instance bound speculative tool-call execution when idempotency keys outlive compensating rollback",
  "date_of_record": "2026 November 30",
  "scope": "Applies to agents that dispatch tool calls speculatively (before the reasoning loop has committed to the branch) and rely on idempotency keys plus compensating transactions to unwind abandoned branches. Does not apply to strictly serialized single-call agents with no speculation, nor to tools whose side effects are externally reversible without a key registry.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-bound-speculative-tool-call-execution-when-idempotency-keys-outlive-compensating-rollback.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-bound-speculative-tool-call-execution-when-idempotency-keys-outlive-compensating-rollback.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-bound-speculative-tool-call-execution-when-idempotency-keys-outlive-compensating-rollback.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2014,
    "python_slice_tokens": 321,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct notions of \"undo\" in a speculative agent, and conflating them is the root of the failure: 1. **Compensation** is a *semantic* reversal — issuing a second tool call (`refund`, `delete_draft`, `cancel_reservation`) whose effect cancels the first. 2. **Idempotency-key invalidation** is a *transport-level* guarantee — the promise that a re...",
    "what_was_observed": "A planning agent with three-way speculative fan-out (`charge_card` → `reserve_inventory` → `send_confirmation`) branched on an ambiguous user intent. Branch B executed `charge_card` with key `chg-7f3a`, succeeded, then the branch was abandoned when Branch A won the arbitration. The compensator issued `refund` with a *new* key `ref-91c2` and a body referencing `chg-7f3a`. Refund succeeded. The agent's ledger recorded ...",
    "condition_of_validity": "Idempotency keys are safe for speculative execution **only under the conjunction**: - (V1) The key's dedup TTL is strictly less than the minimum time between a compensation and any possible re-entry into the abandoned branch; **or** - (V2) The compensation itself consumes the original key (i.e., the tool treats `refund(ref=T1)` as terminal for `chg-7f3a`), s...",
    "decision_boundary": "The agent must choose, per speculative call, between two regimes: The decision boundary is crossed the moment a compensating call is issued: from that instant, the original key is *tainted*. Any subsequent response bearing the original key's transaction id must be treated as a replay of a dead effect, regardless of the `200`. The agent must not advance the p...",
    "operational_effect": "When the boundary is enforced (V3 ledger-gated replay), the observable behavior changes in three ways: 1. **Re-entry cost rises.** Abandoned branches cannot be cheaply resumed; they must be re-executed with fresh keys. This is correct but expensive — speculative fan-out loses its \"resume on retry\" optimization for any branch that was compensated. Budget for ..."
  },
  "matched_failure_symptoms": [
    "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": "e03cbd26e941be9d56e29f1fa961be56dc1350b38565e6445cfe785ec4088548",
    "verified_classes": [
      "SpeculativeReplayAfterCompensation"
    ],
    "verified_functions": [
      "interpret_speculative_response",
      "advance_plan_segment"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SpeculativeReplayAfterCompensation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
