{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-speculative-tool-call-prefetching-from-committing-against-a-concurrently-mutated-resource",
  "title": "Which invariants prevent speculative tool-call prefetching from committing against a concurrently mutated resource",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agents that speculatively prefetch or pre-execute read-shaped tool calls (filesystem reads, DB SELECTs, HTTP GETs, MCP resource fetches) before the planner has committed to the branch that consumes them, while other agents or the same agent's sibling tasks may mutate those same resources. Does not apply to pure-functional tools with no shared mutable backing store, nor to write tools (which must never be prefetched).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-tool-call-prefetching-from-committing-against-a-concurrently-mutated-resource.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-tool-call-prefetching-from-committing-against-a-concurrently-mutated-resource.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-speculative-tool-call-prefetching-from-committing-against-a-concurrently-mutated-resource.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1615,
    "python_slice_tokens": 233,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"stale cache.\" A stale cache is a value that was correct at time T and is now old; the consumer knows it is reading a cache and can revalidate. The failure here is **speculative commit against a pre-image that no longer exists**: the agent fetched resource `R` at version `v0`, reasoned forward several steps on the assumption `R` still equa...",
    "what_was_observed": "An orchestrator agent decomposes a task (\"rename the module and update every importer\") into a plan: `read(module.py)`, `grep(\"import module\")`, then `edit` each importer. The planner speculatively prefetches `read(module.py)` and the grep results while still deciding between two decomposition strategies. A sibling agent, working the same repository under a shared workspace lock that only guards *writes*, concurrentl...",
    "condition_of_validity": "Speculative prefetch is safe **iff** every commit that consumes a speculatively-fetched value is guarded by a compare-and-swap on that value's version token, and the version token is issued by the authoritative store, not by the prefetch layer. Formally: let `prefetch(R) → (value, version)` at time `t_p`, and `commit(action)` at time `t_c > t_p`. The commit ...",
    "decision_boundary": "The boundary is between **prefetch-as-hint** and **prefetch-as-fact**. A prefetched value may be used to *shape* the plan — to decide which branch to explore, which files to open next — but may not be used to *justify* a commit. The moment the planner's reasoning cites a prefetched value as a premise for a mutation (\"the file currently contains X, so I will ...",
    "operational_effect": "With the revalidation guard in place, speculative prefetching retains its latency benefit (the fan-out reads still happen early) while the commit path pays one cheap version-check per consumed resource. The failure mode converts from silent corruption into a `StalePrefetchCommit` abort that forces re-planning — a recoverable, observable event. Without it, th..."
  },
  "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": "9d8279acc2f5caeefa677875b7c2bcc521c8c89cbcc38fa1cd25f08f039dedaf",
    "verified_classes": [
      "StalePrefetchCommit",
      "PrefetchResult"
    ],
    "verified_functions": [
      "revalidate",
      "commit_using_prefetch",
      "_authoritative_version",
      "_apply"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "NotImplementedError",
      "StalePrefetchCommit"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
