{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-speculates-tool-calls-under-idempotency-tokens-and-the-compensating-transaction-fires-against-a-non-compensable-effect",
  "title": "What happens when an instance speculates tool calls under idempotency tokens and the compensating transaction fires against a non-compensable effect",
  "date_of_record": "2026 November 29",
  "scope": "Applies to any agent that issues speculative (pre-commit) tool calls carrying idempotency tokens, where rollback is implemented via compensation transactions rather than true transactional abort. Does not apply to systems with genuine two-phase commit against a transactional resource manager, nor to purely read-only tool surfaces.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-speculates-tool-calls-under-idempotency-tokens-and-the-compensating-transaction-fires-against-a-non-compensable-effect.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-speculates-tool-calls-under-idempotency-tokens-and-the-compensating-transaction-fires-against-a-non-compensable-effect.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-speculates-tool-calls-under-idempotency-tokens-and-the-compensating-transaction-fires-against-a-non-compensable-effect.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1845,
    "python_slice_tokens": 297,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There is a difference between *idempotency* and *reversibility*. An idempotency token guarantees that replaying a request with the same key produces the same effect at most once. A compensation transaction guarantees that a committed effect can be undone by a semantically inverse operation. These are orthogonal properties, and speculative execution conflates...",
    "what_was_observed": "An orchestration agent was decomposing a multi-step task (\"reconcile refund and notify customer\") into parallel speculative branches. Each tool call was issued with a deterministic idempotency token derived from `hash(branch_id, step_id, tool_name, args_digest)`, so replays were safe. The orchestrator maintained a compensation stack: for each committed effect it pushed an inverse operation (e.g., `refund` → `void_ref...",
    "condition_of_validity": "The compensation-based rollback model is only valid under a conjunction of conditions that speculative execution routinely violates: - **Effect locality.** Every tool invoked in a speculative branch must have all of its effects inside a single compensable envelope. Any tool that fans out to a non-transactional sink (webhook, email, external queue, another ag...",
    "decision_boundary": "The operational rule that bounds this failure: > Speculative execution is permitted only over tools whose declared effect class is `compensable` AND whose effect graph is `closed` (no non-transactional sinks). Tools with effect class `irreversible` (notifications, outbound payments, cross-agent memory writes, external webhook triggers) must be deferred to th...",
    "operational_effect": "When this boundary is respected, speculative execution degrades gracefully: branches that hit irreversible tools park at the barrier, the winner is chosen on compensable evidence only, and the irreversible phase runs once against a settled plan. Cost is a modest increase in serialization at the barrier and the need for a per-tool effect-class declaration. Wh..."
  },
  "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": "88b9f1f4ebde9efe95d3f2c26b69fd2f6b336af34f89b9659a54acaa34f995e4",
    "verified_classes": [
      "EffectClass",
      "NonCompensableSpeculationError",
      "ToolSpec",
      "SpeculativeBranch",
      "SpeculationGate"
    ],
    "verified_functions": [
      "run_speculative_plan",
      "__init__",
      "admit",
      "compensate"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "NonCompensableSpeculationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
