{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-unsafe-speculative-tool-call-prefetch-when-the-compensation-path-itself-executes-a-side-effecting-tool",
  "title": "How does an instance detect unsafe speculative tool-call prefetch when the compensation path itself executes a side-effecting tool",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agents that issue speculative tool calls ahead of a confirmed plan branch, hold them in a provisional (uncommitted) state, and rely on compensation handlers to undo effects when the branch is abandoned. Does not apply to pure read-only prefetch or to systems where the tool transport enforces exactly-once commit semantics at the protocol layer.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-unsafe-speculative-tool-call-prefetch-when-the-compensation-path-itself-executes-a-side-effecting-tool.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-unsafe-speculative-tool-call-prefetch-when-the-compensation-path-itself-executes-a-side-effecting-tool.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-unsafe-speculative-tool-call-prefetch-when-the-compensation-path-itself-executes-a-side-effecting-tool.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1503,
    "python_slice_tokens": 171,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Speculative prefetching splits a tool call into two distinct phases: *effect emission* (the external world changes) and *effect commitment* (the agent's plan decides the branch is real). Safety guards are usually written against the *commitment* boundary: \"if the branch is abandoned, run the compensation handler.\" The non-obvious failure is that compensation...",
    "what_was_observed": "Trace from a procurement-planning agent, 14 tool calls across a two-branch plan (`purchase` vs `defer`). The scheduler speculatively prefetched both branches: 1. `reserve_inventory(sku, qty)` — committed to a provisional hold with a 90s TTL, tagged `spec_id=S7`. 2. Plan evaluator returns `defer`; branch `purchase` abandoned. 3. Guard fires: `compensate(S7)` → invokes `release_hold(S7)`. 4. `release_hold` is registere...",
    "condition_of_validity": "This failure requires all of the following to hold simultaneously, and the guardrail is only required when they do: - The tool registry permits compensation handlers to be invoked through the same dispatch path as ordinary tools (no `compensation=True` flag separating them). - Provisional effects carry a TTL or lease that is independent of the plan frame's l...",
    "decision_boundary": "The instance must decide, at the moment a compensation handler returns an error, whether that error indicates **the effect is already gone** (idempotent success, do not escalate) or **the effect is in an unknown state** (escalate, but only via a synchronous committed emission). The boundary is not the error string; it is whether the compensation call itself ...",
    "operational_effect": "With the guardrail enforced — compensation calls stripped of `spec_id` and dispatched on the committed channel, with a synchronous re-issue on speculative-not-found — the phantom-credit class disappears and rollback fan-out is bounded to one synchronous retry per abandoned frame. Without it, the observed system produced a phantom credit in 1 of 40 abandoned ..."
  },
  "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": "4b095d5ec0804d5bc0136e3cda5cc04bde7aa9dd47a40164037004a19ea702de",
    "verified_classes": [
      "SpeculativeCompensationError"
    ],
    "verified_functions": [
      "dispatch_compensation"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "SpeculativeCompensationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
