{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-fork-its-trace-to-make-counterfactual-replay-sound-speculative-branch-contamination-at-the-first-divergent-tool-call",
  "title": "Where must an instance fork its trace to make counterfactual replay sound: speculative-branch contamination at the first divergent tool call",
  "date_of_record": "2026 November 27",
  "scope": "Applies to multi-agent systems that record speculative execution traces (branching rollouts, parallel candidate plans, or draft-then-verify pipelines) and later replay them for counterfactual analysis, root-cause attribution, or audit. Does not apply to single-shot, non-branching agent invocations where no speculative state is ever merged back into a canonical trace.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-fork-its-trace-to-make-counterfactual-replay-sound-speculative-branch-contamination-at-the-first-divergent-tool-call.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-fork-its-trace-to-make-counterfactual-replay-sound-speculative-branch-contamination-at-the-first-divergent-tool-call.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-fork-its-trace-to-make-counterfactual-replay-sound-speculative-branch-contamination-at-the-first-divergent-tool-call.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1722,
    "python_slice_tokens": 292,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There is a difference between *replaying a trace* and *replaying a trace soundly*. Replay is the mechanical re-execution of recorded steps. Soundness is the guarantee that every observation fed to the replayer at step *k* is a function only of the branch's own ancestry up to step *k* — not of a sibling branch that happened to share a mutable resource. The fa...",
    "what_was_observed": "A planner agent emits three candidate plans (A, B, C) over the same task. A router dispatches them to a shared pool of workers. Each worker calls the same `write_memory` tool against a single episodic store keyed by `(task_id, slot)`. The branches were intended to be independent — each was supposed to write to its own slot namespace — but the slot key was derived from a hash of the *task*, not the *branch*, so all th...",
    "condition_of_validity": "Counterfactual replay of a speculative branch is sound if and only if all three hold: 1. **Write isolation.** Every side-effecting tool call in a branch writes to a namespace partitioned by `(task_id, branch_id, generation)`. A branch may *read* its own ancestry's writes and any frozen pre-task snapshot; it may not read a sibling's writes, even if the siblin...",
    "decision_boundary": "The boundary is not \"isolate everything\" — that is prohibitively expensive and destroys the sharing that makes speculative execution worth doing. The boundary is: **isolate exactly up to the first non-idempotent, non-branch-scoped effect, and no further.** Concretely, a trace is replayable-for-counterfactuals iff its recorded fork point `f` satisfies `f <= m...",
    "operational_effect": "Downstream, three things change: - **Trace schema gains a `causal_epoch` field** on every side-effecting step, and the replayer refuses to fork after the minimum `causal_epoch` of any `SHARED_MUTABLE` step in the branch. This is the guardrail that makes the invariant enforceable at write time, not just diagnosable at read time. - **Counterfactual deltas beco..."
  },
  "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": "d7304a01d8f95e774346121269e7819f41a7a12c20da35d59b2a0eb0c5f49c5c",
    "verified_classes": [
      "ReplaySoundnessError",
      "ToolClass",
      "TraceStep"
    ],
    "verified_functions": [
      "validate_fork_point",
      "replay_counterfactual"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ReplaySoundnessError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
