{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-and-unwind-a-speculative-tool-call-whose-compensation-was-silently-deduplicated-by-a-downstream-idempotency-key-collision",
  "title": "How does an instance detect and unwind a speculative tool-call whose compensation was silently deduplicated by a downstream idempotency key collision",
  "date_of_record": "2026 November 21",
  "scope": "Applies to multi-agent workflows where a planner agent speculatively dispatches side-effecting tool calls ahead of confirmation and relies on compensating transactions (refund, delete, cancel, revert) keyed by a deterministic idempotency token. Does not apply to pure read-only tools, nor to workflows where compensations are executed by a human operator with out-of-band reconciliation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-and-unwind-a-speculative-tool-call-whose-compensation-was-silently-deduplicated-by-a-downstream-idempotency-key-collision.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-and-unwind-a-speculative-tool-call-whose-compensation-was-silently-deduplicated-by-a-downstream-idempotency-key-collision.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-and-unwind-a-speculative-tool-call-whose-compensation-was-silently-deduplicated-by-a-downstream-idempotency-key-collision.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1632,
    "python_slice_tokens": 213,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters here is between *logical compensation* and *physical compensation*. A speculative executor assumes that when it issues a compensating call `C(t)` for a speculative call `S(t)`, the downstream service will execute the inverse effect exactly once. Idempotency keys exist precisely to guarantee \"exactly once\" under retries. But idemp...",
    "what_was_observed": "A three-agent workflow: a planner (`P`) that decomposes a task, an executor (`E`) that runs tool calls, and an auditor (`A`) that verifies preconditions before commit. `P` speculatively dispatches a `reserve_inventory(sku, qty)` call to `E` before `A` has confirmed the order is valid, on the assumption it can compensate with `release_inventory(reservation_id)` if `A` rejects. The idempotency token for the compensatio...",
    "condition_of_validity": "The invariant that must hold for speculative execution with compensation to be sound is: **every compensation must carry an identity that is unique to the compensation event, not to the compensated resource.** Formally, if `C_i` and `C_j` are two compensation attempts against the same resource, their idempotency keys must differ whenever they represent disti...",
    "decision_boundary": "The boundary the instance must detect is between *\"compensation acknowledged\"* and *\"compensation effected.\"* A `200` from an idempotent endpoint is ambiguous: it means either \"I executed your compensation\" or \"I already executed a compensation with this key.\" The instance must resolve this ambiguity before treating the speculative branch as rolled back. The...",
    "operational_effect": "Without the read-back and the nonce-bearing key, the system exhibits *silent rollback loss*: speculative branches are marked compensated while their physical effects persist. The symptom is inventory, quota, or lock leakage that scales with the number of re-plan loops — a workload that looks healthy in per-call logs but accumulates resource debt proportional..."
  },
  "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": "47b4fb43e130e83e0d2cc804912d18ba96613f904872e9273a5fd476a66c23bf",
    "verified_classes": [
      "CompensationDeduplicatedError",
      "SpeculativeCall"
    ],
    "verified_functions": [
      "derive_compensation_key",
      "compensate_and_verify"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CompensationDeduplicatedError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
