{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-pre-executes-speculative-tool-calls-under-a-shared-idempotency-key-and-the-effect-ledger-reconciles-against-the-wrong-br",
  "title": "What happens when an instance pre-executes speculative tool calls under a shared idempotency key and the effect ledger reconciles against the wrong branch",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agents that overlap reasoning with execution by issuing tool calls before the plan branch is committed, using client-generated idempotency keys to deduplicate retries. Does not apply to strictly serialized act-then-observe loops, nor to pure read-only tool surfaces where effects are not externally observable.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-pre-executes-speculative-tool-calls-under-a-shared-idempotency-key-and-the-effect-ledger-reconciles-against-the-wrong-br.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-pre-executes-speculative-tool-calls-under-a-shared-idempotency-key-and-the-effect-ledger-reconciles-against-the-wrong-br.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-pre-executes-speculative-tool-calls-under-a-shared-idempotency-key-and-the-effect-ledger-reconciles-against-the-wrong-br.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2131,
    "python_slice_tokens": 454,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **deduplication of a request** and **reconciliation of an effect**. An idempotency key is a promise that a *single logical intent* will produce at most one externally visible mutation. Speculative pre-execution breaks the premise of that promise: the agent emits a tool call for a branch it has not yet committed to, and...",
    "what_was_observed": "A planning agent decomposed a refund workflow into three candidate branches at step 4: `refund_full`, `refund_partial`, and `escalate`. To hide latency, it pre-issued the `issue_refund` tool call for both `refund_full` and `refund_partial` in parallel, each with a deterministic idempotency key derived from `hash(order_id, branch_name, amount)`. It then continued reasoning over the tool results to select a branch. The...",
    "condition_of_validity": "Speculative pre-execution with idempotency keys is only sound when all three of the following hold: 1. **Effect-key binding is post-commit, not pre-commit.** The key must be minted from the committed branch identity, not from a candidate branch label. If keys are minted at speculation time, the key namespace is partitioned by *branch*, which means two branch...",
    "decision_boundary": "The boundary is whether the agent can *distinguish a speculative effect from a committed one at reconciliation time*. Concretely: - If the tool surface returns a `pending` or `held` state that the agent must explicitly `settle` or `release`, speculation is safe: the abandoned branch's hold is released, the committed branch's hold is settled, and the idempote...",
    "operational_effect": "When the boundary is crossed, the observable effect is **effect over-application with a clean audit trail**. Every layer logs success. The idempotency keys are unique and correct. The tool results are valid. The reconciliation predicate passes. The only signal is in the *business* ledger, where the sum of effects exceeds the committed intent—and that signal ..."
  },
  "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": "815853b4f0b44be2eb5443b8cfef0d94b3a2e2f6573b86415ff3603eca6734a3",
    "verified_classes": [
      "SpeculativeWindowViolation",
      "EffectState",
      "SpeculativeEffect",
      "SpeculativeWindow"
    ],
    "verified_functions": [
      "run_refund_plan",
      "pre_execute",
      "record_effect",
      "commit",
      "close_window",
      "reconcile"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpeculativeWindowViolation"
    ],
    "sample_fail_closed_invariants": [
      "abandoned branch produced irreversible effect; capture transaction_id at speculation time to enable compensation",
      "window closed before branch commit"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
