{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-detect-and-contain-speculative-branch-contamination-when-optimistic-tool-invocations-produce-irreversible-external-side-effects",
  "title": "How should an instance detect and contain speculative branch contamination when optimistic tool invocations produce irreversible external side effects before rollback is committed",
  "date_of_record": "2026 November 28",
  "scope": "Applies to orchestrators that fork multiple speculative execution branches (parallel agent instances or reasoning traces) and invoke tools optimistically before a winning branch is selected. Does not apply to purely read-only tool surfaces or to single-branch sequential execution with no rollback semantics.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-contain-speculative-branch-contamination-when-optimistic-tool-invocations-produce-irreversible-external-side-effects.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-contain-speculative-branch-contamination-when-optimistic-tool-invocations-produce-irreversible-external-side-effects.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-contain-speculative-branch-contamination-when-optimistic-tool-invocations-produce-irreversible-external-side-effects.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2170,
    "python_slice_tokens": 274,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The naive mental model of speculative multi-agent execution treats a branch as a *pure function of context*: fork state, execute, score, keep the best, discard the rest. Rollback is then framed as a state-management problem—restore the checkpoint, prune the losing branches, move on. This framing is correct only when every tool invoked inside a branch is **id...",
    "what_was_observed": "A planner instance forked three branches on a task requiring \"reconcile the customer record and notify them of the correction.\" Each branch was given the same checkpoint and permitted optimistic tool use to reduce latency, with the orchestrator committing the highest-scoring branch at round end. - Branch A resolved the customer via a stale retrieval hit (an old record ID from episodic memory) and invoked `send_notifi...",
    "condition_of_validity": "Speculative execution with rollback is sound **only** under the conjunction of three conditions, all of which must hold per-tool, not per-branch: - **Effect classification is total and correct.** Every tool in the surface is classified as *reversible* (can be compensated by a registered inverse), *idempotent* (repeat-safe, no net effect), or *irreversible* (...",
    "decision_boundary": "The boundary between safe speculation and contamination is drawn by **effect class**, not by branch count, latency budget, or confidence score: - If a branch's *entire* tool sequence is idempotent or reversible-with-handle, speculate freely; rollback is complete by construction. - If a branch *would* invoke an irreversible tool, the orchestrator must either ...",
    "operational_effect": "Contamination of this kind is not a latency or correctness bug in the classical sense; it is a *continuity* failure that propagates across rounds. Because rollback restores internal state but not the world, the agent's memory records a clean history while the external substrate diverges from it. Subsequent retrieval (episodic memory, record reads) then retur..."
  },
  "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": "457a37cd34785b9099654728bb335dadf05c970c9906ec050033e6167adde2f0",
    "verified_classes": [
      "EffectClass",
      "SpeculativeContaminationError",
      "ToolSpec",
      "EffectJournal"
    ],
    "verified_functions": [
      "assert_speculable",
      "run_branch",
      "record",
      "compensate_reverse"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "SpeculativeContaminationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
