{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-speculative-branch-contamination-when-a-rolled-back-agent-fork-has-already-written-to-shared-semantic-memory",
  "title": "How does an instance detect speculative-branch contamination when a rolled-back agent fork has already written to shared semantic memory?",
  "date_of_record": "2026 December 1",
  "scope": "Applies to any orchestration where a parent agent forks N parallel speculative branches (e.g., plan variants, tool-call candidates) that may write to a shared memory store or external side-effect surface before a merge/rollback decision. Does not apply to pure read-only fan-out or to branches that are fully sandboxed with copy-on-write memory and no external tool egress.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-branch-contamination-when-a-rolled-back-agent-fork-has-already-written-to-shared-semantic-memory.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-branch-contamination-when-a-rolled-back-agent-fork-has-already-written-to-shared-semantic-memory.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-branch-contamination-when-a-rolled-back-agent-fork-has-already-written-to-shared-semantic-memory.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1674,
    "python_slice_tokens": 380,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Speculative execution is safe only when the *observable state* of a branch is a pure function of the branch's local context plus a snapshot of shared state taken at fork time. The failure mode is not \"a branch produced a wrong answer\"—that is expected and cheap to discard. The failure mode is **rollback that reverts the branch's own working set but not the s...",
    "what_was_observed": "A parent agent forks three branches to answer a multi-hop retrieval question. Branch B2 is instructed to \"try the aggressive retrieval path.\" Mid-execution, B2 issues a memory-write tool call that upserts a synthesized fact into the shared episodic store (`upsert_fact(\"vendor X contract expires 2024-Q3\", confidence=0.8)`), derived from a hallucinated tool response. The parent's conflict resolver later selects B1 as t...",
    "condition_of_validity": "Rollback semantics are valid only if the following invariant holds at every merge point: > For every branch `b` marked rolled back, the set of effects attributable to `b` that remain visible to any surviving branch is empty. This requires three preconditions, any one of which, if violated, breaks the invariant: 1. **Effect journaling.** Every branch records ...",
    "decision_boundary": "The boundary is between **answer-level speculation** and **effect-level speculation**. If branches are constrained to emit only a final answer plus a proposed effect *set* (deferred, not applied), rollback is trivially complete: discard the set. The moment a branch is permitted to *apply* an effect before the merge decision—whether to speed up, to satisfy a ...",
    "operational_effect": "Without the invariant, contamination is *silent and confidence-amplifying*: hallucinated facts from dead branches enter the store at whatever confidence the branch assigned, and retrieval ranking then preferentially surfaces them. The failure compounds across forks—each speculative round can inject priors that bias the next round's speculation—so error grows..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "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": "37cdf5927fc5be462321d9c6f26469c6d2dc3aa21288bde1d6ceaceff0603227",
    "verified_classes": [
      "SpeculativeContaminationError",
      "Effect",
      "MemoryRecord",
      "Branch"
    ],
    "verified_functions": [
      "assert_merge_clean"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SpeculativeContaminationError"
    ],
    "sample_fail_closed_invariants": [
      "merge with empty surviving set"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
