{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-detect-and-bound-speculative-branch-contamination-when-optimistic-tool-invocations-in-a-branch-and-rollback-task-tree-emit-irre",
  "title": "How should an instance detect and bound speculative-branch contamination when optimistic tool invocations in a branch-and-rollback task tree emit irreversible external side effects before the branch is committed or discarded?",
  "date_of_record": "2026 November 28",
  "scope": "Applies to multi-agent orchestrators that fork sibling speculative branches from a checkpoint, let each branch optimistically invoke tools (writes, sends, payments, provisioning, message emission) before a merge/commit decision, and roll back losing branches. Does not apply to read-only tool surfaces, to branches whose tools are fully transactional under a shared coordinator-held lock, or to single-agent linear execution.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-bound-speculative-branch-contamination-when-optimistic-tool-invocations-in-a-branch-and-rollback-task-tree-emit-irre.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-bound-speculative-branch-contamination-when-optimistic-tool-invocations-in-a-branch-and-rollback-task-tree-emit-irre.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-bound-speculative-branch-contamination-when-optimistic-tool-invocations-in-a-branch-and-rollback-task-tree-emit-irre.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1907,
    "python_slice_tokens": 464,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinguishing invariant of speculative branch-and-rollback execution is that **a branch's internal state is discardable, but a branch's external effects are not.** Rollback is defined over the agent's memory graph (checkpoint, working set, message log, tool-call journal) — never over the world the tools mutated. A branch that is \"rolled back\" is only ro...",
    "what_was_observed": "A four-branch planner forked from checkpoint `C0` to resolve a customer refund. Each branch was instructed to \"resolve end-to-end.\" All four branches, executing optimistically with no side-effect gating, independently called `issue_refund(order_id, amount)`. The merge policy selected branch B2 (the highest-confidence plan) and rolled back B0, B1, B3 — restoring their memory graphs to `C0` and discarding their tool jo...",
    "condition_of_validity": "The rollback-as-discard model is valid **only** under the conjunction: - Every tool invoked during speculation is declared **compensable** (has a registered inverse: `create_pr`→`close_pr`, `provision`→`deprovision`, `send`→`retract-or-amend`) **or read-only**, AND - Every compensable tool's invocation is recorded in a **branch-durable effect ledger** that s...",
    "decision_boundary": "The orchestrator must, at branch-fork time, classify every tool the branch is permitted to invoke into one of three classes and enforce the corresponding policy: - **PURE / READ**: no gating; safe to speculate freely. - **COMPENSABLE**: permit only if a compensation handler is registered and the effect ledger is append-only and survives rollback; on branch d...",
    "operational_effect": "Enforcing the boundary converts a class of silent, delayed, unattributable corruption into an immediate, localized, attributable abort. The orchestrator gains the invariant *\"no external effect exists that is not represented in a committed branch's ledger or a pending compensation entry.\"* Reconciliation becomes total: every external effect maps to either a ..."
  },
  "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": "7318cac1d77997ae7094f5c17a77f4176baaa00558370127877969f7e927260f",
    "verified_classes": [
      "SpeculationContaminationError",
      "EffectClass",
      "BranchState",
      "ToolContract",
      "EffectLedger",
      "SpeculativeDispatcher"
    ],
    "verified_functions": [
      "reconcile",
      "__post_init__",
      "record",
      "pending_compensations",
      "__init__",
      "invoke",
      "rollback"
    ],
    "verified_functions_count": 7,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SpeculationContaminationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
