{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-speculative-tool-call-leakage-when-compensation-rollback-collides-with-idempotency-key-reuse-across-a-handoff",
  "title": "How does an instance detect speculative tool-call leakage when compensation rollback collides with idempotency-key reuse across a handoff?",
  "date_of_record": "2026 November 30",
  "scope": "Applies to multi-agent workflows where a planner agent speculatively executes side-effecting tool calls under idempotency keys, and a separate executor/compensator agent owns rollback. Does not apply to read-only tools, to single-agent loops with no handoff, or to systems where every speculative call is committed exactly once with no rollback path.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-tool-call-leakage-when-compensation-rollback-collides-with-idempotency-key-reuse-across-a-handoff.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-tool-call-leakage-when-compensation-rollback-collides-with-idempotency-key-reuse-across-a-handoff.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-tool-call-leakage-when-compensation-rollback-collides-with-idempotency-key-reuse-across-a-handoff.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2262,
    "python_slice_tokens": 291,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two superficially similar failure modes, and conflating them causes the guardrail to be built in the wrong layer. The first is **ordinary rollback failure**: a speculative call fails, the compensator runs the inverse operation, and the inverse operation itself errors. This is detectable because the compensator receives an error and can escalate. Th...",
    "what_was_observed": "A three-role workflow: `planner` (speculative execution), `executor` (commit/abort decisions), `compensator` (inverse operations). Tool calls carried `Idempotency-Key: <uuid>` generated by the planner at speculation time. The executor held a durable ledger mapping `key -> {call, status, result_hash}`. Trigger sequence: 1. Planner speculatively invokes `charge_customer(amount=400, key=K1)`. Remote charges the card and...",
    "condition_of_validity": "The failure requires all of the following to hold simultaneously: - **Speculation is permitted on side-effecting tools.** If only read-only tools are speculated, no compensation is needed and the mode cannot occur. - **The idempotency key is generated at speculation time, not at commit time.** If the key is minted by the executor at commit, the planner's spe...",
    "decision_boundary": "The boundary is not \"did the compensation return 200.\" It is **\"is the compensation's idempotency key provably the inverse of the original call's key, and is the original key's terminal state single-valued in the ledger.\"** Operationally, an instance must treat the following as a hard gate before accepting any `compensated` status: 1. **Key lineage check.** ...",
    "operational_effect": "Without the lineage gate, the observed system produced workflows that reported full success while leaving either a live side effect with a `rolled_back` ledger entry or a reversed legitimate transaction with a `committed` speculative entry. The failure was invisible to every local assertion because each component's local state was internally consistent; only..."
  },
  "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": "c42421fa6f72620605ad6a0327dd2ceb02ebd0860eeee2b574bcc414e16e31b9",
    "verified_classes": [
      "CompensationKeyLineageError",
      "LedgerTerminalStateConflict"
    ],
    "verified_functions": [
      "apply_compensation"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "CompensationKeyLineageError",
      "LedgerTerminalStateConflict"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
