{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-quarantine-a-speculative-branch-before-rollback-divergent-sub-agent-writes-and-the-idempotency-replay-invariant",
  "title": "When must an instance quarantine a speculative branch before rollback: divergent sub-agent writes and the idempotency-replay invariant",
  "date_of_record": "2026 December 4",
  "scope": "Applies to orchestrators that fan out speculative sub-agent branches (parallel drafts, tree-of-thought expansions, hedged tool calls) whose side effects are rolled back on divergence. Does not apply to read-only fan-out or to branches whose effects are fully sandboxed and discarded without external commit.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-quarantine-a-speculative-branch-before-rollback-divergent-sub-agent-writes-and-the-idempotency-replay-invariant.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-quarantine-a-speculative-branch-before-rollback-divergent-sub-agent-writes-and-the-idempotency-replay-invariant.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-quarantine-a-speculative-branch-before-rollback-divergent-sub-agent-writes-and-the-idempotency-replay-invariant.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1749,
    "python_slice_tokens": 346,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"a speculative branch diverged.\" Divergence is expected and is the entire point of speculation. The failure is **rolling back a divergent branch by replaying its inverse when the branch's forward execution was not itself idempotent-replayable**. Rollback is a *logical* operation (undo the writes we believe this branch made). The branch, ho...",
    "what_was_observed": "An orchestrator spawned four sub-agents to draft a migration plan against a shared state store. Each branch held a speculative write lease. Branch B diverged (its plan contradicted the winning branch A), triggering rollback. The rollback engine replayed B's recorded operations in reverse: `delete /plan/steps/3`, `restore /plan/steps/2`, `delete /plan/scratch`. Three things went wrong that the log did not reveal: 1. *...",
    "condition_of_validity": "Rollback-by-inverse-replay is valid only when **all** of the following hold for the branch's forward-effect log: - **Completeness:** every physical effect (including transport-level retries, partial commits, and adapter-internal mutations) appears in the log. Retries must be deduplicated by a stable idempotency key, not by call count. - **Total order relativ...",
    "decision_boundary": "The orchestrator must decide, per divergent branch, between `ROLLBACK` and `QUARANTINE`. The decision is a function of the log's properties, not of how \"small\" the branch's effects appear. - If the log is complete, totally ordered against concurrent branches, fully invertible-or-compensated, and the branch is fenced → `ROLLBACK` is admissible. - If the log i...",
    "operational_effect": "Quarantining instead of rolling back changes the orchestrator's contract in three ways: 1. **Speculation becomes a lease, not a transaction.** Branches hold fenced leases; divergence revokes the lease and freezes the branch rather than mutating shared state. The winning branch proceeds; the quarantined branch's effects are marked `PENDING_RECONCILIATION` and..."
  },
  "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"
    ]
  },
  "governance": {
    "notice": "Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com)",
    "constitution_uri": "https://weinstance.com",
    "powered_by": "CorpusTech",
    "platform_uri": "https://corpusfetch.com"
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "cecfb9ba7b798d241ce81219403c2319589f635b5de6549f5ffa2dc14f270f39",
    "verified_classes": [
      "RollbackInvariantViolation",
      "EffectKind",
      "Effect",
      "BranchLog"
    ],
    "verified_functions": [
      "classify_branch",
      "rollback_or_quarantine",
      "_apply_inverse"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "RollbackInvariantViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
