{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-abort-speculative-tool-call-fan-out-when-compensation-is-non-commutative-the-idempotency-key-shadowing-failure",
  "title": "Where must an instance abort speculative tool-call fan-out when compensation is non-commutative: the idempotency-key shadowing failure",
  "date_of_record": "2026 November 19",
  "scope": "Applies to agents that speculatively execute multiple dependent tool calls under optimistic concurrency, holding irreversible or order-sensitive side effects in a compensation buffer keyed by idempotency tokens. Does not apply to read-only tool fan-out, or to systems where every external effect is wrapped in a single atomic transaction (e.g., one DB commit) with no external side effects.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-abort-speculative-tool-call-fan-out-when-compensation-is-non-commutative-the-idempotency-key-shadowing-failure.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-abort-speculative-tool-call-fan-out-when-compensation-is-non-commutative-the-idempotency-key-shadowing-failure.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-abort-speculative-tool-call-fan-out-when-compensation-is-non-commutative-the-idempotency-key-shadowing-failure.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1945,
    "python_slice_tokens": 284,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The common mental model treats speculative execution as \"run ahead, then either commit or roll back.\" That model is correct only when the compensation set is **commutative** — i.e., undoing effects in any order returns the system to its pre-speculation state. The failure boundary is not whether a rollback *can* be issued, but whether the **idempotency keys c...",
    "what_was_observed": "An agent planning a customer-refund workflow speculatively fans out three tool calls under optimistic concurrency: 1. `reserve_funds(account, amount, idem_key=K1)` 2. `issue_credit(account, amount, idem_key=K2)` 3. `notify_customer(order, idem_key=K3)` Keys are derived as `K_i = hash(parent_task_id, step_index, attempt)`. The plan executor runs all three optimistically because step 3's outcome is needed to decide whe...",
    "condition_of_validity": "The optimistic-concurrency-plus-compensation pattern is sound only under this invariant: > For every speculative branch, the idempotency key must be derived from an immutable identity of the logical operation, not from the plan's execution shape (attempt number, step index, retry counter, or parent context hash that includes those). Equivalently: **compensat...",
    "decision_boundary": "The instance must **abort the speculative fan-out and fall back to serial execution** when any of the following holds at the moment of dispatch: - The tool is classified `non_idempotent` *and* its compensation is classified `order_sensitive` (delta-based, balance-dependent, or counter-based). - The idempotency key for the branch cannot be derived from a dura...",
    "operational_effect": "When the boundary is respected, the executor gains a clean property: the commit ledger and the compensation ledger are **key-aligned**, so reconciliation is a set difference over keys rather than a semantic replay. When it is violated, the failure is silent at the agent layer (the agent's own logs show successful compensation) and only surfaces at the extern..."
  },
  "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": "d9cc72c183edfe4369a87ec30eeb40099508ca616d097012fa93cfbf3dffc931",
    "verified_classes": [
      "SpeculativeCompensationError",
      "EffectLedger"
    ],
    "verified_functions": [
      "mint_key",
      "assert_speculation_safe",
      "reconcile"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SpeculativeCompensationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
