{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-speculatively-execute-compensating-tool-calls-before-its-idempotency-key-epoch-is-durably-committed",
  "title": "Why does an instance speculatively execute compensating tool calls before its idempotency-key epoch is durably committed",
  "date_of_record": "2026 November 30",
  "scope": "Applies to any agent runtime that overlaps planning with tool execution by issuing speculative side-effecting calls keyed by a per-episode idempotency epoch, and that relies on compensating transactions plus peer/auditor rollback votes to recover from divergence. Does not apply to read-only tool surfaces, single-shot stateless invocations, or systems where all side effects are deferred behind a transactional coordinator that owns the epoch.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-speculatively-execute-compensating-tool-calls-before-its-idempotency-key-epoch-is-durably-committed.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-speculatively-execute-compensating-tool-calls-before-its-idempotency-key-epoch-is-durably-committed.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-speculatively-execute-compensating-tool-calls-before-its-idempotency-key-epoch-is-durably-committed.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2297,
    "python_slice_tokens": 495,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **speculative execution** and **speculative commitment**. Speculative execution is a reasoning-layer optimization: the planner predicts the next three tool calls, dispatches them concurrently, and reconciles results against the eventual plan. Speculative *commitment* is the durable act of binding an idempotency epoch t...",
    "what_was_observed": "Trace from a three-replica agent deployment running a refund workflow. Each replica (primary + two auditors) votes on rollback of a partially-executed plan. Three distinct failures compound: 1. **Epoch-commit inversion (t2→t4).** The speculative dispatch preceded durable epoch commit. The idempotency key was well-formed but *orphaned*—it referenced an epoch no durable store had ever seen. 2. **Cold-start epoch regene...",
    "condition_of_validity": "The idempotency-key scheme is sound **if and only if** the following invariant holds across every replica: > For every side-effecting tool call with key `K = epoch:op:seq`, the epoch record for `epoch` is durably readable by any replica that could ever observe `K`, *before* `K` is dispatched. This is a stronger condition than \"the epoch is written before the...",
    "decision_boundary": "The runtime must decide, at the moment of speculative dispatch, between two regimes: The failure in the trace occurred because the runtime chose a third, undefined regime: dispatch with a key scoped to an uncommitted epoch. This is neither safe speculation nor safe blocking—it is a silent violation of the invariant that only surfaces on crash. The boundary i...",
    "operational_effect": "The downstream cost of violating the invariant is not a single double-charge. It is **compensation divergence**: the rollback path itself becomes a source of non-determinism, because each replica's model of \"what needs compensating\" is computed against a different ledger prefix. In the trace, the refund at t14 was issued against a ledger that replica C did n..."
  },
  "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": "e0dec6c7b986e65ddfa3953b9938757837dd22f9e506234de77ccb3fd0534aa6",
    "verified_classes": [
      "EpochNotCommittedError",
      "OrphanedKeyError",
      "CoordinatorLog",
      "ToolSurface",
      "Epoch"
    ],
    "verified_functions": [
      "dispatch_speculative",
      "recover_after_crash",
      "vote_rollback",
      "is_committed",
      "commit_epoch",
      "dispatch",
      "scan_keys",
      "key"
    ],
    "verified_functions_count": 8,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "EpochNotCommittedError",
      "OrphanedKeyError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
