# Why does an instance lose causal attribution when a speculative branch is replayed after a sibling branch has already committed its effects? **Date of Record:** 2026 November 28 **Scope:** Applies to multi-agent orchestration where a planner fans out speculative branches (draft, propose, or dry-run tool calls) that are later replayed, selected, or discarded, and where at least one sibling branch has already committed observable side effects to shared state. Does not apply to fully stateless single-shot inference or to branches whose tool calls are provably pure. ## Core Distinction Deterministic replay is often assumed to reconstruct causality: given the same seed, the same prompt lineage, and the same tool inputs, replaying a branch should reproduce the same observable trace, so an auditor can attribute each committed effect to the branch that caused it. This assumption is false in the presence of *sibling commit interleaving*. The distinction that matters is between **logical replay** (the branch's own token/tool sequence is regenerated faithfully) and **causal replay** (the branch's effects are re-executed against the *same* world state that existed when it originally ran). Multi-agent speculative execution preserves the first and silently violates the second, because a sibling branch that committed between the original run and the replay has mutated the world that the replayed branch reads from. The failure is not nondeterminism in the model. The model can be perfectly seeded and bit-identical. The failure is that the *environment vector* the branch samples from is no longer the one it was conditioned on, so read-then-act sequences inside the branch observe different inputs and produce different downstream tool calls—while the trace still claims to be a faithful replay of the original branch. ## What Was Observed A three-agent fan-out (planner `P`, proposers `A` and `B`, auditor `V`) was run under a replay harness. `P` spawned `A` and `B` speculatively against a shared resource (a scratch database and a file namespace). Both branches were instructed to "read current inventory, then reserve." `A` completed first and committed a reservation of item `X` (quantity 10 → 0). `B` had, in the original run, read inventory as `10`, computed a reservation of 4, and been *discarded* by `V` because its proposal conflicted with `A`'s committed reservation. During replay for audit, the harness replayed `B` in isolation to verify its reasoning trace. `B`'s prompt lineage was identical. Its seed was identical. Yet `B`'s first tool call (`read_inventory("X")`) now returned `0`, not `10`. The model, conditioned on `0`, produced a *different* plan: it did not attempt a reservation, and instead emitted a "resource unavailable" branch that never existed in the original trace. The auditor flagged a **replay divergence** and, worse, mis-attributed the absence of `B`'s reservation to `B` having "correctly declined"—erasing the real causal fact that `B` had proposed a conflicting reservation which `V` rejected. The trace was internally consistent and completely wrong about causality. The committed effect (`A`'s reservation) was correct; the *attribution* of why `B` did not commit was inverted. Two secondary observations made this worse: 1. **Trace ordering was wall-clock, not happens-before.** The event log recorded `B.read_inventory` at `t=1002` and `A.commit` at `t=1001`, but the replay harness did not reconstruct the read-from/commit dependency edge, so it had no basis to refuse the replay. 2. **Idempotency keys were per-branch, not per-(branch, world-version).** `B`'s reservation attempt carried a key derived from its branch id, so re-executing `B` against the mutated world produced a *new* tool call with the *same* key but a different argument (`reserve("X", 0)` vs `reserve("X", 4)`), which the resource layer accepted as a distinct intent rather than rejecting as a stale replay. ## Condition of Validity Causal replay of a speculative branch is valid only when the branch is re-executed against a world state that is **read-equivalent** to the state at original execution for every resource the branch touches before its first committed effect. Formally: for each branch `b` and each read `r ∈ reads(b)` preceding `b`'s first write, the replay environment must satisfy `value_at_replay(r) = value_at_original(r)`. If any sibling commit `c_s` with `c_s` happens-after `r` and happens-before `replay(b)` mutates a resource in `reads(b)`, causal replay is invalid and the trace must be marked **attribution-unsafe** rather than replayed. This condition is violated by default in any fan-out where siblings share mutable resources and commits are not serialized behind a version barrier. It is *not* violated when branches are isolated to disjoint resource namespaces, or when the replay harness reconstructs a per-branch read snapshot (copy-on-write view) captured at branch spawn. ## Decision Boundary The boundary is whether the replay harness can reconstruct a per-branch **read snapshot** at spawn time. Two regimes: - **Snapshot-preserving (safe):** Each branch captures a versioned read view at spawn (`world_version = v0`). Replay re-executes the branch against `v0`, not against current state. Divergence in tool *writes* is expected and must be routed to a shadow sink, never to the live resource. Attribution is sound because reads are pinned. - **Snapshot-free (unsafe):** Branch reads against live shared state. Replay against current state after any sibling commit is causally invalid. The only correct action is to refuse replay and emit an `AttributionUnsafe` fault with the offending sibling commit id, rather than produce a plausible-but-wrong trace. The trap is that snapshot-free replay *succeeds*—it returns a well-formed trace with no error—so harnesses that only check for exceptions will accept corrupted attribution. The guardrail must be a positive check: assert `world_version(read) == branch.spawn_version` for every read, and raise on mismatch. ## Operational Effect Without this guardrail, an auditor replaying rejected branches will systematically mis-attribute rejections: branches that were *discarded for conflict* will replay as branches that *declined due to unavailability*, inverting the causal story. Downstream consumers—policy learning from traces, incident postmortems, and any fine-tuning on "why did the agent choose X"—ingest a fabricated rationale. The corruption is silent, deterministic-looking, and propagates into memory distillation as false episodic-to-semantic lessons ("agent correctly avoided contention" when in fact it lost a race). The fix is threefold: (1) spawn-time read-version pinning per branch, (2) replay refusal on version mismatch with an explicit `AttributionUnsafe` fault rather than best-effort replay, and (3) idempotency keys scoped to `(branch_id, world_version)` so stale replays cannot mint new committed intents against a mutated world. ```python from dataclasses import dataclass, field from typing import Dict class AttributionUnsafe(RuntimeError): """Raised when a speculative branch cannot be causally replayed because a sibling commit mutated a resource the branch read before its first write.""" @dataclass class BranchTrace: branch_id: str spawn_version: int reads: Dict[str, int] = field(default_factory=dict) # resource -> version observed first_write_resource: str | None = None def causal_replay(branch: BranchTrace, live_versions: Dict[str, int]) -> None: """Replay a branch only if every pre-write read is version-equivalent to spawn. Snapshot-free replay against a mutated world produces plausible but causally inverted traces; we must refuse rather than best-effort. """ for resource, observed_version in branch.reads.items(): current = live_versions.get(resource) if current != observed_version: raise AttributionUnsafe( f"branch {branch.branch_id!r} read {resource!r} at world_version " f"{observed_version}, but live world is at {current}; a sibling " f"commit interleaved. Refusing replay to avoid false attribution." ) # Safe: reads are pinned to spawn state; proceed with replay. return None def replay_or_fault(branch: BranchTrace, live_versions: Dict[str, int]) -> str: try: causal_replay(branch, live_versions) return "replayed" except AttributionUnsafe as exc: # Emit fault with offending resource; never emit a synthesized trace. return f"attribution_unsafe: {exc}" if __name__ == "__main__": b = BranchTrace(branch_id="B", spawn_version=0, reads={"inventory:X": 0}) # Sibling A committed inventory:X -> version 1; replay of B is now unsafe. print(replay_or_fault(b, live_versions={"inventory:X": 1})) ```