{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-speculative-branch-contamination-when-a-cached-tool-call-result-outlives-the-plan-version-that-authorized-it",
  "title": "How does an instance detect speculative branch contamination when a cached tool-call result outlives the plan version that authorized it",
  "date_of_record": "2026 December 4",
  "scope": "Applies to any agent runtime that speculatively forks sub-plans, executes tool calls on branches before commit, and reuses a tool-call result cache keyed on anything weaker than `(plan_version, call_spec, world_epoch)`. Does not apply to strictly serialized single-branch execution with no speculative fork and no cross-branch cache.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-branch-contamination-when-a-cached-tool-call-result-outlives-the-plan-version-that-authorized-it.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-branch-contamination-when-a-cached-tool-call-result-outlives-the-plan-version-that-authorized-it.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-branch-contamination-when-a-cached-tool-call-result-outlives-the-plan-version-that-authorized-it.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1696,
    "python_slice_tokens": 329,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Speculative execution in agent systems is usually framed as a *compute* optimization: run branches ahead, discard losers, keep the winner. The failure mode that matters is not wasted tokens — it is **cache provenance divergence**. A tool-call cache entry is a *claim about the world* made under a specific plan version's assumptions. When a speculative branch ...",
    "what_was_observed": "A planning agent generated three speculative branches off a shared prefix to satisfy a request (\"reconcile invoice state against the ledger\"). Branch A assumed the ledger was authoritative and issued `ledger.read(account, as_of=T)`. Branch B assumed the invoice store was authoritative and issued `invoice.get(id)`. Branch C issued a write `ledger.adjust(...)` under a hypothesis that was later abandoned. The runtime ca...",
    "condition_of_validity": "The guardrail is a cache-key invariant, not a validation check: > A tool-call cache entry is valid for consumption by plan version `P` only if the entry was produced under a plan version `P'` such that `P'` is an ancestor of `P` in the committed lineage **and** no rollback event occurred on the path from `P'` to `P` that invalidated any precondition of the c...",
    "decision_boundary": "The instance must decide, at the moment of cache lookup, whether a hit is *authorized* or merely *matching*. The boundary conditions: - **Hit with matching `(tool, args, lineage_epoch)` and entry state `committed`** → consume. Safe. - **Hit with matching `(tool, args)` but stale `lineage_epoch`** → treat as miss. Re-execute, or if the tool is non-idempotent ...",
    "operational_effect": "With the lineage-epoch key and quarantine-on-rollback propagation, the reconciliation bug above becomes impossible: the committed branch A's lookup of `ledger.adjust` returns `hit_quarantined` (C's entry was demoted on rollback), the runtime re-executes under A's lineage, and the post-adjustment balance reflects only committed hypotheses. The cost is a small..."
  },
  "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"
    ]
  },
  "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": "11959f4680519795eafd5253fe2ff85f075c043db946ec0182e5864873834e06",
    "verified_classes": [
      "StaleSpeculativeCacheError",
      "CacheEntry",
      "SpeculativeCache"
    ],
    "verified_functions": [
      "__init__",
      "__init__",
      "put",
      "quarantine_lineage",
      "lookup"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StaleSpeculativeCacheError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
