{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-speculatively-forks-a-branch-and-its-compensating-rollback-is-not-idempotent-under-replay",
  "title": "What happens when an instance speculatively forks a branch and its compensating rollback is not idempotent under replay",
  "date_of_record": "2026 November 27",
  "scope": "Applies to orchestrators that run a planner agent which forks N speculative sub-agents against a shared external-effect surface (filesystem, ticket tracker, API mutations), then merges the winning branch and issues compensating \"undo\" actions for the losers. Does not apply to read-only fan-out or to branches isolated in per-branch sandboxes with no shared mutable state.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-speculatively-forks-a-branch-and-its-compensating-rollback-is-not-idempotent-under-replay.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-speculatively-forks-a-branch-and-its-compensating-rollback-is-not-idempotent-under-replay.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-speculatively-forks-a-branch-and-its-compensating-rollback-is-not-idempotent-under-replay.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1815,
    "python_slice_tokens": 294,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Speculative execution is safe only when the *forward* effect and its *compensating* effect form an exact inverse pair. In LLM-driven agents this inverse is assumed to exist because the planner wrote a `rollback` tool call that \"looks\" symmetric with the `apply` call. It is not symmetric. The forward call is executed by one agent with one snapshot of intent; ...",
    "what_was_observed": "A planner instance P forks three branches (B1, B2, B3) to resolve an ambiguous task: \"assign the incident to the on-call engineer and page them.\" Each branch independently: 1. reads the on-call roster (non-deterministic: the roster rotates every 5 minutes), 2. issues `assign(incident, engineer)` and `page(engineer)`, 3. writes a checkpoint `{branch, engineer, page_id, pre_state}` to the shared trace bus. P commits B1...",
    "condition_of_validity": "The invariant that must hold for speculative branch-and-merge to be sound: > For every branch b and every effect e(b) it applied, the compensating action c(b) must be a *conditional* inverse: it executes only if the world still matches the post-state that e(b) produced, and it must carry an unforgeable, exact effect identifier minted at apply time — never on...",
    "decision_boundary": "The correct decision at the orchestrator is not \"roll back losers\" — it is *classify each branch's effects by reversibility class before forking*: - **Reversible-and-guarded** (state with a version/CAS, idempotency-keyed external calls): safe to speculate. Rollback = conditional inverse. - **Irreversible** (sent emails, paged humans, charged cards, posted me...",
    "operational_effect": "After this incident the orchestrator adopted three hard rules, each addressing one broken condition: - **Fork-time effect classification.** The planner's tool schema tags every tool `reversible: bool`. Forks whose branch trace contains a non-reversible tool call are refused with `SpeculationRejected`; the planner must restructure to defer the effect past mer..."
  },
  "matched_failure_symptoms": [
    "DUPLICATE_MUTATION_OR_BILLING"
  ],
  "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": "fed081d8b8607c182e26c3077334c1fa79d4f1b4acafd201f2e1a82e1ad5c8ab",
    "verified_classes": [
      "SpeculationRejected",
      "CompensatorPreconditionFailed",
      "Effect",
      "Branch"
    ],
    "verified_functions": [
      "validate_fork",
      "compensate",
      "merge_and_rollback"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CompensatorPreconditionFailed",
      "SpeculationRejected"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
