{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-speculative-sub-plan-branches-from-corrupting-the-committed-agent-state-during-rollback-reconciliation",
  "title": "Which invariants prevent speculative sub-plan branches from corrupting the committed agent state during rollback reconciliation",
  "date_of_record": "2026 November 28",
  "scope": "Applies to agents that speculatively fork sub-plans (parallel tool-call branches, draft reasoning paths) and must merge exactly one branch back into committed episodic state. Does not apply to strictly sequential single-branch agents or to stateless one-shot inference.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-sub-plan-branches-from-corrupting-the-committed-agent-state-during-rollback-reconciliation.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-sub-plan-branches-from-corrupting-the-committed-agent-state-during-rollback-reconciliation.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-sub-plan-branches-from-corrupting-the-committed-agent-state-during-rollback-reconciliation.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1449,
    "python_slice_tokens": 409,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure of interest is not \"a speculative branch produced a wrong answer.\" It is that a *discarded* branch leaves residue in the shared state that the *committed* branch then reads during reconciliation, so the rollback is not observationally equivalent to \"the branch never ran.\" Speculative execution is sound only if rollback restores a *causal isolatio...",
    "what_was_observed": "A planner forked three branches to resolve a task: `branch_A` called a search tool and a write-scratchpad tool; `branch_B` called the same search tool with a rephrased query; `branch_C` called a mutation tool (`update_ticket`) that was *supposed* to be gated behind commit. The reconciler selected `branch_A`. Rollback restored the scratchpad and the tool-call log to the pre-fork snapshot, then replayed `branch_A`'s ca...",
    "condition_of_validity": "Speculative rollback is sound iff all three hold: - **Effect log completeness:** every operation with an observable external effect (including cache writes, tool side effects, and prompt-visible scratchpad mutations) is recorded in the branch's effect log *before* the effect is applied, and rollback is defined as the inverse of that log, not as a snapshot re...",
    "decision_boundary": "The boundary is whether the branch's effects are **observable outside the branch's own namespace**. If observable → the branch is *committed-on-execution* and cannot be speculatively run without a compensation protocol (saga-style undo), which must itself be idempotent and logged. If non-observable → the branch is genuinely speculative and rollback is safe. ...",
    "operational_effect": "After enforcing the invariant, the runtime rejects forks whose toolset includes non-namespaced writers (returning a `SpeculativeForkIllegal` error and forcing serialization), namespaces all caches by `(branch_id, fork_epoch)`, and strips discarded transcripts from the reconciler's authoritative context while retaining them only as clearly-labeled hypotheses...."
  },
  "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": "236f3790fc9d2c1732cb9125e4641b419efb26a05faf3fc9adc0d996a7f5b605",
    "verified_classes": [
      "SpeculativeForkIllegal",
      "RollbackInvariantViolation",
      "Branch",
      "SharedResource"
    ],
    "verified_functions": [
      "fork_branch",
      "rollback_and_reconcile",
      "run_speculative"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "RollbackInvariantViolation",
      "SpeculativeForkIllegal"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
