{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-contain-speculative-writes-when-a-speculative-tool-call-commits-a-non-idempotent-external-effect-before-the-branch-is-discarded",
  "title": "How should an instance contain speculative writes when a speculative tool call commits a non-idempotent external effect before the branch is discarded?",
  "date_of_record": "2026 November 21",
  "scope": "Applies to agents that execute speculative branches (parallel candidate plans, \"try-then-verify\" tool calls, or draft-then-rollback execution) where a tool invocation produces an externally observable side effect. Does not apply to pure read-only tool calls or to branches whose effects are fully captured inside a transactional store the agent itself owns.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-contain-speculative-writes-when-a-speculative-tool-call-commits-a-non-idempotent-external-effect-before-the-branch-is-discarded.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-contain-speculative-writes-when-a-speculative-tool-call-commits-a-non-idempotent-external-effect-before-the-branch-is-discarded.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-contain-speculative-writes-when-a-speculative-tool-call-commits-a-non-idempotent-external-effect-before-the-branch-is-discarded.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1696,
    "python_slice_tokens": 247,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the speculative branch was wrong.\" The failure is that a speculative branch *succeeded* at a non-idempotent write before the orchestrator decided to discard it. Speculation safety is usually framed as a *reasoning* property — does the branch produce a correct plan? — but the actual boundary invariant is a *side-effect* property: **a disca...",
    "what_was_observed": "A planner agent (P) emits three candidate branches for a customer-refund task. Branch B2 calls `issue_refund(order_id, amount)` — a non-idempotent write that increments a ledger and fires an external payment rail call. The tool schema includes `\"dry_run\": {\"type\": \"boolean\", \"default\": false}`. The model, reasoning under a token budget, omits `dry_run` on the B2 call because the surrounding plan text says \"simulate t...",
    "condition_of_validity": "The isolation assumption is valid **only if** all three hold for every tool reachable from a speculative branch: 1. **The tool's effect class is declared, not inferred.** The tool manifest carries an explicit `effect_class ∈ {read, idempotent_write, non_idempotent_write, irreversible}`. The orchestrator must not infer this from the tool name or from the pres...",
    "decision_boundary": "The boundary the orchestrator must compute at branch-emit time, before any tool call: And at discard time, the orchestrator must compute: The second check is the one that catches the observed failure. The branch *did* commit a call; the call *had* a `txn_id`; but the orchestrator never classified it as owing compensation because it never recorded the effect ...",
    "operational_effect": "Enforcing this boundary changes three things in practice: - **Latency.** Speculative branches against `non_idempotent_write` tools are serialized behind an isolation check rather than fired in parallel. This is the cost of correctness; it is not avoidable by cleverness, only by reclassifying tools as `idempotent_write` with real inverses. - **Model behavior...."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "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": "cc11a5b2201c3ec0aee0fe5a4407ac76a929511fc99c69e9b21d9e1a28b48b4d",
    "verified_classes": [
      "EffectClass",
      "SpeculativeContainmentError",
      "CommittedCall",
      "Branch"
    ],
    "verified_functions": [
      "assert_speculative_call_allowed",
      "assert_branch_discardable"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpeculativeContainmentError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
