{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-commit-before-it-speculates-the-speculative-write-divergence-invariant-in-concurrent-multi-agent-shared-context-mutation",
  "title": "Where must an instance commit before it speculates: the speculative-write divergence invariant in concurrent multi-agent shared-context mutation",
  "date_of_record": "2026 November 23",
  "scope": "Applies to multi-agent systems where two or more agent instances speculatively read a shared context object, compute divergent writes against the same region, and reconcile via optimistic concurrency (version vectors, CAS, or last-writer-wins merge). Does not apply to single-writer append-only logs or to stateless request/response tool calls with no shared mutable context.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-commit-before-it-speculates-the-speculative-write-divergence-invariant-in-concurrent-multi-agent-shared-context-mutation.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-commit-before-it-speculates-the-speculative-write-divergence-invariant-in-concurrent-multi-agent-shared-context-mutation.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-commit-before-it-speculates-the-speculative-write-divergence-invariant-in-concurrent-multi-agent-shared-context-mutation.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1719,
    "python_slice_tokens": 174,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not a classic write-write race in the database sense. It is a *speculation-vs-commit ordering* failure at the LLM layer: an agent instance reads shared context at version `v`, runs a multi-step reasoning chain (tool calls, plan expansion) that takes a non-deterministic wall-clock time, and then commits a write tagged as \"based on `v`.\" The con...",
    "what_was_observed": "A planner agent `A` and an auditor agent `B` share a context region `task.plan`. At version `v=7`, the plan contains `{steps: [s1, s2, s3], budget: 4000}`. Both read `v=7`. `A` speculatively expands: it reasons that `s2` requires a `fetch(url)` tool call, executes it, gets a 200 with a payload, and appends a derived step `s2a` that depends on the payload. It then attempts `CAS(task.plan, v=7, new={steps:[s1,s2,s2a,s3...",
    "condition_of_validity": "This failure requires all of the following to co-occur: 1. **Read-modify-write across a reasoning chain.** The gap between read and commit spans at least one tool call or one non-trivial generation, so the read is genuinely stale by commit time. 2. **Side-effecting or context-mutating intermediate steps.** If the intermediate steps are pure (no tool calls, n...",
    "decision_boundary": "The boundary is whether the retry path **re-derives** or **re-merges**. Re-merge is cheaper and is the default in most agent frameworks because it preserves the agent's accumulated context. But re-merge is only sound when every element of the speculative write carries a version-stamped justification that can be re-validated against the new base. Concretely: ...",
    "operational_effect": "Without the guardrail, the system exhibits **silent semantic drift under contention**: the more agents write to a shared region, the more orphaned derivations accumulate, and the final context is a plan that no single agent would have authored and that no replay can reconstruct. The drift is invisible to CAS (which sees only version monotonicity) and invisib..."
  },
  "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": "7d6daa81cc28a1de499cb2790bb9374142c901a93d8cddd02a5741918f6d3faf",
    "verified_classes": [
      "SpeculativeWriteDivergence"
    ],
    "verified_functions": [
      "reconcile_speculative_write"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "SpeculativeWriteDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
