# What structural signals indicate a speculative branch has crossed the causal-commit boundary in multi-agent deterministic replay **Date of Record:** 2026 November 18 **Scope:** Applies to multi-agent systems that fan out speculative execution branches (draft-then-verify, tree search, or parallel tool-call speculation) and rely on deterministic replay plus causal tracing to reconstruct the accepted trajectory. Does not apply to single-agent linear execution, nor to systems where branches are never merged and each branch is independently durable. ## Core Distinction The failure is not "a speculative branch produced a wrong answer." Wrong answers are expected and discarded. The failure is that a speculative branch **mutated shared causal state that the tracer attributes to the committed parent**, so that replay of the accepted trajectory diverges from the live run even though every individual branch is internally deterministic. The distinction that matters operationally: *branch-local determinism* versus *lineage-level determinism*. A branch can replay to bit-identical output in isolation and still break replay of the committed path, because the tracer's causal edges were recorded against a mutable parent context (a shared token budget counter, a shared scratchpad slot, a shared tool-cache key) that the speculative branch advanced without a commit. This is the **causal-commit boundary**: the point at which a speculative side effect becomes visible to the lineage that will be replayed. Speculation that writes to parent-attributed state crosses that boundary silently; speculation that writes only to branch-attributed state does not. ## What Was Observed In a fan-out of three draft branches over a shared retrieval cache, each branch appended its query key to a parent-scoped cache with a last-writer-wins eviction policy. The verifier selected branch 2. On replay, branch 1 was executed first (deterministic ordering by branch ID), evicted branch 2's cache entry before branch 2 ran, and branch 2 re-fetched — a cache miss that did not occur in the live run, where branch 2 had executed first. The replayed trajectory diverged at the retrieval step with a different document set, and downstream reasoning diverged accordingly. No branch was non-deterministic. No branch returned an error. The tracer reported full causal coverage of the committed path. The structural signal that flagged it was not an error but a **replay divergence with zero branch-level nondeterminism**: every branch replayed identically in isolation, yet the lineage did not. The second signal was an **orphaned causal edge** — a `reads_from` edge on the committed branch pointing at a cache key whose `written_by` provenance resolved to a discarded sibling branch. The third was a **monotonic counter discontinuity**: the shared token-budget counter at commit time was higher than the sum of committed branches' consumption, because a discarded branch had decremented it. ## Condition of Validity These signals are valid only when all of the following hold: 1. Branch execution order is deterministic under replay (stable sort by branch ID or recorded dispatch order). If order is genuinely nondeterministic, divergence is uninformative and must be attributed to scheduling, not to the commit boundary. 2. Every side effect carries a provenance tag identifying the writing branch. Untagged writes to parent scope cannot be distinguished from committed writes and the orphaned-edge signal is undefined. 3. The verifier's selection is recorded as an event in the trace, not inferred post hoc from the final state. If selection is inferred, a discarded branch that wrote to parent scope is indistinguishable from the committed branch's own write. 4. Replay uses the same eviction and capacity policies as the live run. A policy change between live and replay invalidates the counter-discontinuity signal. When condition 2 fails, the only remaining signal is replay divergence itself, which is necessary but not sufficient — it can be caused by clock, network, or RNG nondeterminism in the parent. ## Decision Boundary The decision is whether to treat a divergence as a **commit-boundary violation** (a real defect in the speculation protocol) or as **ambient nondeterminism** (expected, tolerable). The boundary is crossed when replay divergence coincides with at least one of: an orphaned causal edge resolving to a discarded branch, or a monotonic counter whose committed-path value exceeds the sum of committed branches' contributions. Either signal alone is sufficient to classify as a commit-boundary violation; divergence alone is not. Do not attempt to repair by reordering branches to match the live run. That masks the defect and produces a replay that passes while the protocol remains unsound — the next fan-out with a different branch count will diverge again. The correct action is to sever the parent-attributed write: move the shared cache and counter to branch-local scope with an explicit merge at commit, or make the parent-scoped write conditional on a committed-selection token that speculative branches cannot obtain. ## Operational Effect Once the commit boundary is enforced, replay divergence attributable to speculation drops to zero and the remaining divergences are genuinely ambient, which makes them tractable. The cost is a merge step at commit and a provenance tag on every side effect, which increases trace volume by roughly the number of speculative branches per fan-out. The benefit is that the tracer's causal graph becomes sound: every `reads_from` edge on the committed path resolves to a `written_by` on the committed path, and counter invariants hold. Systems that skip this enforcement typically discover the defect only under branch-count changes or cache-pressure changes — precisely the conditions that are rare in testing and common in production. ```python class CausalCommitViolation(RuntimeError): """Raised when a speculative branch has written to parent-attributed state.""" pass def assert_commit_boundary(trace, committed_branch_id): """ Validate that the committed lineage is replay-sound with respect to the causal-commit boundary. Raises CausalCommitViolation on: - an orphaned causal edge (reads_from resolving to a discarded branch) - a monotonic counter discontinuity on the committed path """ committed_edges = trace.edges_for(committed_branch_id) for edge in committed_edges: writer = trace.provenance(edge.written_by_key) if writer is None: raise CausalCommitViolation( f"edge {edge.id} on committed branch {committed_branch_id} " f"has no provenance for key {edge.written_by_key!r}" ) if writer.branch_id != committed_branch_id: raise CausalCommitViolation( f"orphaned causal edge {edge.id}: committed branch " f"{committed_branch_id} reads key {edge.written_by_key!r} " f"written by discarded branch {writer.branch_id}" ) committed_sum = sum( trace.counter_delta(b) for b in trace.committed_branches() ) observed = trace.counter_at_commit(committed_branch_id) if observed > committed_sum: raise CausalCommitViolation( f"counter discontinuity on committed path: observed {observed} " f"exceeds committed-branch sum {committed_sum}; " f"a discarded branch advanced parent-scoped state" ) return True ```