{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-speculative-tool-call-pre-execution-that-violates-idempotency-key-scope-during-a-compensating-transaction-rollback",
  "title": "How does an instance detect speculative tool-call pre-execution that violates idempotency-key scope during a compensating-transaction rollback?",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agent runtimes that issue speculative (pre-emptive) tool calls in parallel with in-flight reasoning, deduplicated by idempotency keys and reconciled via a compensating-transaction log. Does not apply to strictly serial tool execution or to systems where every tool call is naturally idempotent and side-effect-free.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-tool-call-pre-execution-that-violates-idempotency-key-scope-during-a-compensating-transaction-rollback.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-tool-call-pre-execution-that-violates-idempotency-key-scope-during-a-compensating-transaction-rollback.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-tool-call-pre-execution-that-violates-idempotency-key-scope-during-a-compensating-transaction-rollback.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1532,
    "python_slice_tokens": 224,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The critical distinction is between *key uniqueness* (the same logical operation is never executed twice) and *key scope* (the key is bound to a specific transaction generation and a specific compensable effect set). Most runtimes enforce the first and silently assume the second. Speculative pre-execution breaks that assumption: an agent fires tool call `T` ...",
    "what_was_observed": "A planner agent decomposed a task into three parallel sub-goals and speculatively pre-executed a `charge_account` tool call under each, all deriving the key `charge:{task_id}:{account}` from the shared task prefix. Branch A succeeded, branch B was abandoned mid-reasoning (its sub-goal contradicted branch A's output), and branch C was still awaiting a tool result when B's rollback ran. The compensating log recorded `c...",
    "condition_of_validity": "The guardrail holds only if three conditions are simultaneously enforced: - **Generation-scoped keys.** Every speculative call must embed the branch generation (e.g., `{task_id}:{branch_id}:{attempt}`) so that compensation of one generation cannot collide with another. Key equality is necessary but not sufficient for dedup; the runtime must compare `(key, ge...",
    "decision_boundary": "The decision boundary is whether the runtime treats the compensating log as an *authoritative effect ledger* or as a *best-effort audit trail*. If authoritative, then any operation that would apply a compensation against a generation other than its own must be rejected and escalated—the agent cannot self-heal because it lacks the authority to un-compensate. ...",
    "operational_effect": "The operational effect is a class of *silent ledger divergence* in which the agent's action sequence is coherent from its own perspective while the external effect ledger has been reversed or double-applied. Detection requires a cross-check the agent does not naturally perform: comparing the generation of every applied result against the fence token of every..."
  },
  "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": "74a65bd734428d15607608aba3db0708a44c8250dfe8c33e19dd4a149fb4b85a",
    "verified_classes": [
      "IdempotencyScopeViolation",
      "CompensatingLedger"
    ],
    "verified_functions": [
      "reconcile_before_commit",
      "__init__",
      "compensate",
      "apply_result"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "IdempotencyScopeViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
