{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-fence-speculative-tool-call-prefetching-against-non-idempotent-side-effects",
  "title": "When must an instance fence speculative tool-call prefetching against non-idempotent side effects",
  "date_of_record": "2026 November 14",
  "scope": "This record applies to agent runtimes that issue tool calls speculatively (prefetching a likely next tool invocation before the driving model turn has committed to it) and that rely on a speculative-execution fence to discard uncommitted work. It does not apply to runtimes where every tool call is gated behind an explicit model commit, nor to purely read-only tool surfaces where replay is free.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-fence-speculative-tool-call-prefetching-against-non-idempotent-side-effects.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-fence-speculative-tool-call-prefetching-against-non-idempotent-side-effects.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-fence-speculative-tool-call-prefetching-against-non-idempotent-side-effects.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1417,
    "python_slice_tokens": 220,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The non-obvious boundary is between *speculation that is fenced at the runtime layer* and *side effects that are fenced at the resource layer*. A speculative-execution fence in an agent runtime typically works by tagging a speculative branch, buffering its results, and dropping the branch if the model does not commit. This is sound for tool calls whose effec...",
    "what_was_observed": "In a runtime that prefetched the next tool call during model streaming, a speculative `create_refund` call was issued against a payments service roughly 400ms before the model's turn committed. The model then chose a different branch (it decided the refund was premature) and the runtime correctly discarded the speculative branch — the context was rolled back, the tool result was dropped, and the fence reported a clea...",
    "condition_of_validity": "The fence is valid if and only if all of the following hold at the moment of speculative dispatch: 1. The tool is declared `effect_class = pure` or `effect_class = idempotent`, where idempotent means the downstream resource honors a caller-supplied key and the runtime reuses the *same* key across speculative and committed attempts. 2. The speculative branch ...",
    "decision_boundary": "Classify each tool at registration into one of three lanes: - **Speculatable-free:** pure reads, cached retrievals, sandboxed computations. Prefetch freely; fence discard is always safe. - **Speculatable-keyed:** writes to resources that honor idempotency keys. Prefetch only if the runtime derives the key deterministically from `(session, turn, tool, canonic...",
    "operational_effect": "Runtimes that violate this boundary exhibit a characteristic failure: clean fence telemetry with dirty downstream state. The abort path reports success, so monitoring on fence events shows nothing wrong; the only signal is ledger divergence discovered later, often by reconciliation jobs days after the fact. The corrective pattern is to make the fence's abort..."
  },
  "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": "bcb19b1cdf4c4a5c3342eb197816d199978d6dd44f0860a60fc231881031d630",
    "verified_classes": [
      "EffectClass",
      "UnsafeSpeculationError",
      "ToolCall"
    ],
    "verified_functions": [
      "fence_discard"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "UnsafeSpeculationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
