{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-speculative-agent-rollback-from-committing-phantom-side-effects-during-compensation",
  "title": "Which invariants prevent speculative agent rollback from committing phantom side effects during compensation",
  "date_of_record": "2026 November 22",
  "scope": "Applies to agents that execute speculative branches (tentative tool calls, pre-committed plans, or forked sub-agents) and rely on compensating actions to undo them on partial failure. Does not cover purely read-only agents or single-shot inference with no external state mutation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-agent-rollback-from-committing-phantom-side-effects-during-compensation.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-agent-rollback-from-committing-phantom-side-effects-during-compensation.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-agent-rollback-from-committing-phantom-side-effects-during-compensation.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1529,
    "python_slice_tokens": 402,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The naive mental model treats rollback as the inverse of execution: if step `S` mutated world state `W → W'`, then a compensation `C(S)` restores `W`. This holds for *deterministic, idempotent, order-independent* effects. It fails for agent systems because three properties break the inverse assumption: 1. **Compensations are themselves probabilistic tool cal...",
    "what_was_observed": "A planner agent forks three speculative sub-agents (`A`, `B`, `C`) to reserve inventory through an external `reserve(item, qty)` tool. Each sub-agent appends a `ReservationRecord{id, item, qty, branch}` to episodic memory on success. The orchestrator selects branch `B`, and issues `release()` compensations for `A` and `C`. Observed trace: - `A` and `C` both reserved the same `item=X`. The tool's backend coalesces res...",
    "condition_of_validity": "Rollback-by-compensation is only sound when *all* of the following hold simultaneously: - **Effect isolation:** each speculative branch's mutations are namespaced (distinct keys, transactional scopes, or version-tagged writes) such that no branch's compensation can alter another branch's observable state. - **Compensation determinism:** `C(S)` is a total fun...",
    "decision_boundary": "The agent must decide, at fork-resolution time, whether the backend supports isolated speculative effects. The boundary: - **If the tool exposes branch-scoped handles** (transaction IDs, draft states, versioned keys): commit by promoting the selected handle, discard siblings by dropping handles. No compensation is issued at all — this is the correct architec...",
    "operational_effect": "Concretely, the orchestrator must enforce two invariants: 1. **Compensation isolation invariant:** before issuing any `C(S)`, assert that `S`'s effect handle is disjoint from every other live branch's handle. If not, abort to escalation rather than compensate. 2. **Snapshot pinning invariant:** the value committed for the surviving branch must equal the valu..."
  },
  "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": "5dc8affb56b2c60e087026fe93ca10ea7a622eb9e5b00cb9e436bb1f1fd42fc5",
    "verified_classes": [
      "PhantomCompensationError",
      "SnapshotDriftError",
      "ReservationRecord",
      "Branch",
      "SpeculativeOrchestrator"
    ],
    "verified_functions": [
      "run_speculative_round",
      "__init__",
      "register",
      "_assert_isolated",
      "compensate",
      "commit"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "PhantomCompensationError",
      "SnapshotDriftError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
