{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-speculative-tool-call-branches-from-corrupting-committed-state",
  "title": "Which invariants prevent speculative tool-call branches from corrupting committed state",
  "date_of_record": "2026 November 9",
  "scope": "Applies to agent runtimes that fork a conversation/plan into multiple speculative branches, each of which may issue side-effecting tool calls, and where branches are later committed or discarded by a merge/commit protocol. Does not apply to pure-read tool calls, nor to single-branch sequential agents where no speculative fork exists.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-tool-call-branches-from-corrupting-committed-state.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-tool-call-branches-from-corrupting-committed-state.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-tool-call-branches-from-corrupting-committed-state.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1659,
    "python_slice_tokens": 422,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not \"a speculative branch executed a side effect.\" It is \"a speculative branch executed a side effect whose *effect token* was not registered with the commit coordinator before the effect became externally observable.\" Speculation and side effects are compatible; speculation and *uncoordinated* side effects are not. The invariant that sep...",
    "what_was_observed": "In a fork-merge runtime with three speculative branches (`plan-A`, `plan-B`, `plan-C`) racing to satisfy a single goal, the following sequence reproduced reliably: 1. Branch A calls `write_file(path=/tmp/out.json, content=X)` and the tool returns success. The effect token is stored in A's local journal. 2. Branch B, unaware of A, calls the same tool with identical arguments. The tool is *not* idempotent (it appends a...",
    "condition_of_validity": "The commit protocol is sound **iff** all of the following hold: - **(I1) Pre-observability registration.** Every side-effecting tool call registers a *reversible effect token* with the coordinator *before* the effect becomes externally observable. For process-local writes this means before `fsync`/rename; for network effects this means before the request is ...",
    "decision_boundary": "The practical boundary is drawn at the **tool classification** step, not at the branch scheduler. Classify each tool as: - *Pure* — no side effects; speculate freely, no tokens needed. - *Idempotent + token-addressable* — safe to speculate under (I1)–(I4); the token makes duplicate execution harmless. - *Non-idempotent or externally observable* (email, payme...",
    "operational_effect": "When (I1)–(I4) hold, speculation is cheap: branches can race, losers are discarded by token reversal, and the commit is a single CAS. When any one fails, the failure is *silent and asymmetric* — the protocol reports success on an operation it did not perform, and the corruption surfaces later as duplicate artifacts, double-sends, or non-deterministic reads. ..."
  },
  "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": "50f5a937d09de44057cf480f4a08aeca7d96f2d7ad5a71ed2253e4b73f253077",
    "verified_classes": [
      "SpeculativeCommitError",
      "EffectToken",
      "Branch",
      "CommitCoordinator"
    ],
    "verified_functions": [
      "key",
      "__init__",
      "register",
      "dispatch",
      "commit",
      "discard"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "SpeculativeCommitError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
