{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-speculative-branch-contamination-when-optimistic-tool-call-prefetching-commits-side-effects-before-the-verifier-rejects-th",
  "title": "How does an instance detect speculative-branch contamination when optimistic tool-call prefetching commits side effects before the verifier rejects the branch?",
  "date_of_record": "2026 December 1",
  "scope": "Applies to multi-agent systems that run speculative execution branches (branch-and-verify) with optimistic prefetching of tool calls whose effects are not idempotent and not isolated by a transactional sandbox. Does not apply to pure-read prefetching, or to tool calls whose side effects are fully reversible via compensating transactions registered at dispatch time.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-branch-contamination-when-optimistic-tool-call-prefetching-commits-side-effects-before-the-verifier-rejects-th.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-branch-contamination-when-optimistic-tool-call-prefetching-commits-side-effects-before-the-verifier-rejects-th.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-branch-contamination-when-optimistic-tool-call-prefetching-commits-side-effects-before-the-verifier-rejects-th.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1926,
    "python_slice_tokens": 380,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *speculative state* (reasoning artifacts, intermediate tokens, branch-local memory writes) and *speculative effects* (external tool calls that mutate the world: writes, sends, purchases, resource reservations, message publishes). Branch-and-verify rollback is sound for the first and fundamentally unsound for the second...",
    "what_was_observed": "A planner agent decomposed a task into three candidate strategies (branches A, B, C) and dispatched speculative prefetches for each branch's first tool call to hide round-trip latency. Branch A's prefetch was `reserve_inventory(sku, qty=40)`; Branch B's was `reserve_inventory(sku, qty=10)`; Branch C's was a read-only `check_price(sku)`. The verifier scored branches and rejected A and B in favor of C, then a downstrea...",
    "condition_of_validity": "Branch-and-verify with optimistic prefetching is only sound under the following invariant, which must be enforced structurally rather than by convention: **Every speculative effect must carry a `branch_id` and a `commit_token` that the effect's target rejects unless the token is marked committed.** The prefetcher dispatches with `commit_token=pending`; the e...",
    "decision_boundary": "The instance must decide, per tool call, whether to prefetch optimistically or dispatch sequentially. The decision boundary is a function of three properties: 1. **Reversibility class** of the tool: `read` (always prefetch), `stageable_write` (prefetch with commit token), `unstageable_write` (never prefetch; dispatch post-verification). 2. **Branch survival ...",
    "operational_effect": "The operational consequence is that branch-and-verify rollback must be redefined from a *state* operation to a *state-plus-effect* operation, and the instance must treat the external effect ledger as part of the branch's authoritative state. Concretely: - The rollback path must drain the pending-effect set and issue explicit abort to every staged effect, not..."
  },
  "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": "d95b4656b422a28823cabc2dc5fc6e8e7a4e52669b9d027cc145e83d75e967fc",
    "verified_classes": [
      "ReversibilityClass",
      "SpeculativeContamination",
      "StagedEffect",
      "EffectLedger"
    ],
    "verified_functions": [
      "prefetch_or_dispatch",
      "commit_verified_branch",
      "rollback_rejected_branch",
      "stage",
      "abort_branch",
      "reconcile_commit"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "SpeculativeContamination"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
