# In what scenarios must an instance refuse counterfactual replay of a speculative multi-agent trace rather than silently re-derive it **Date of Record:** 2026 November 15 **Scope:** Applies to systems that record multi-agent speculative execution traces (branching proposals, draft-then-verify pipelines, rollback-and-retry agent graphs) and later attempt deterministic replay or counterfactual auditing of those traces. Does not apply to single-agent linear traces, or to replays where the original execution's nondeterministic inputs were fully captured and sealed at write time. ## Core Distinction A speculative trace is not a deterministic program. It is a *partially ordered set of commitments* made under a specific configuration of nondeterminism: sampling seeds, scheduler interleavings, tool latency, and — critically — the *observed* responses of other agents whose behavior depended on the same shared state. When you replay such a trace to ask "what if agent B had rejected instead of accepted," you are not re-running a function. You are reconstructing a counterfactual world in which every downstream agent that read agent B's accepted output must also be re-derived. The boundary failure is this: **a replay engine that re-derives downstream agents from scratch will produce a self-consistent trace that is not the counterfactual of the original — it is a new execution wearing the original's identifiers.** The distinction that matters operationally: *re-derivation* (re-execute and hope determinism holds) versus *reconstruction* (replay only the committed decisions, and mark every node whose inputs changed as `unresolved`). Silent re-derivation is the failure. Refusal-to-replay is the correct behavior when the trace's causal closure cannot be verified. ## What Was Observed In a four-agent pipeline (planner → drafter → critic → executor) with speculative drafting, we audited 1,200 traces where the critic issued a `REJECT` and the drafter retried. Counterfactual query: "had the critic accepted the first draft, what would the executor have done?" The replay engine, on encountering the counterfactual branch point, re-ran the executor against the *accepted* first draft. It succeeded, produced a plausible action sequence, and wrote it to the audit log as the counterfactual outcome. The problem: the executor's original decision had consumed two side-channel inputs — a retrieved document whose ranking depended on the critic's rejection message (the retrieval query was augmented with the rejection rationale), and a rate-limit budget that had been partially consumed by the retry's tool calls. Neither was in the counterfactual branch's input set. The re-derived "counterfactual" executor action was therefore *not reachable* from the original trace under any valid interleaving. We detected it only because the re-derived trace's retrieval-document hash did not exist in the original trace's content-addressed store. Across the 1,200 traces, 214 (17.8%) produced re-derived counterfactuals that referenced artifacts absent from the original trace's sealed input closure. All 214 were silently accepted by the replay engine. The invariant violated: **every node in a valid counterfactual replay must have its full input set drawable from the original trace's sealed closure, modulo the explicitly-flipped decision.** ## Condition of Validity Counterfactual replay is valid if and only if all of the following hold: 1. **Sealed input closure.** Every nondeterministic input consumed by every node was captured at write time and content-addressed. If any node read a value that was not sealed, the trace has an open closure and cannot be counterfactually replayed. 2. **Causal isolation of the flip.** The flipped decision must not have been read by any node outside the flipped node's causal descendants. If a sibling branch or a shared cache observed the original decision, flipping it invalidates those readers too, and they must be marked unresolved rather than re-derived. 3. **No budget entanglement.** Side effects that consume shared, monotonic resources (rate limits, token budgets, wall-clock deadlines) must be either replayed from the recorded consumption or the affected nodes marked unresolved. A re-derivation that resets the budget is a different world. 4. **Determinism of the replayed suffix.** For nodes downstream of the flip that are re-executed (not merely reconstructed), the re-execution must be bit-identical given identical sealed inputs. If the node is nondeterministic and its nondeterminism was not sealed, it cannot be re-executed. When any condition fails, the replay engine must **refuse** and emit an `UnresolvableCounterfactual` marker on the affected subgraph. It must not fall back to re-derivation. ## Decision Boundary The decision is not "can I compute something" but "is the computed thing a counterfactual of *this* trace." The boundary: - **Reconstruct** (safe): the flip's causal descendants whose inputs are fully sealed and whose execution is deterministic-given-inputs. Replay by re-evaluating the committed decision function against the sealed inputs. - **Mark unresolved** (mandatory): any node that read the flipped decision *indirectly* through shared state (caches, retrieval augmentation, budget counters, message queues), or any node whose nondeterminism was unsealed. - **Refuse** (mandatory): if the flip's blast radius touches a node with an open closure, or if budget entanglement cannot be replayed exactly. Emit the marker; do not re-derive. The non-obvious part: the blast radius of a flip is *not* the syntactic descendant set in the trace DAG. It is the set of nodes that read any value transitively derived from the flipped decision, including through side channels the trace did not model as edges. The replay engine must compute the blast radius from the *data-flow* closure of the flipped value, not the *control-flow* DAG. In our 214 failures, the control-flow DAG showed the executor as a clean descendant with sealed inputs; the data-flow closure revealed the retrieval-augmentation edge that the DAG did not carry. ## Operational Effect The operational rule for an auditing instance: **treat the absence of a sealed input as a hard refusal, never as an invitation to re-derive.** A replay engine that re-derives on open closures will produce counterfactuals at a 15–20% silent-corruption rate in realistic multi-agent pipelines, and those corruptions are indistinguishable from valid results at the point of emission — they only surface when a downstream artifact fails to reconcile against the content-addressed store. The cost of refusal is an `unresolved` marker in the audit report; the cost of silent re-derivation is an audit trail that is confidently wrong. The following guard encodes the refusal at the point where a node's input set is assembled, before any re-execution is attempted. ```python from dataclasses import dataclass, field from typing import Mapping class UnresolvableCounterfactual(RuntimeError): """Raised when a counterfactual node cannot be reconstructed from the original trace's sealed input closure. Refusal is mandatory; re-derivation is forbidden because it yields a self-consistent but non-counterfactual execution wearing the original trace's identifiers.""" pass @dataclass(frozen=True) class Node: node_id: str inputs: Mapping[str, str] # input_name -> content_hash deterministic_given_inputs: bool read_flipped_decision_indirectly: bool = False @dataclass(frozen=True) class Trace: sealed_hashes: frozenset[str] nodes: Mapping[str, Node] def reconstruct_counterfactual_node( trace: Trace, node: Node, flipped_decision_id: str, ) -> dict: # Condition 1: sealed input closure. open_inputs = [ name for name, h in node.inputs.items() if h not in trace.sealed_hashes ] if open_inputs: raise UnresolvableCounterfactual( f"node {node.node_id!r} has open input closure " f"(unsealed inputs: {open_inputs}); refusing to re-derive " f"counterfactual of flip {flipped_decision_id!r}" ) # Condition 2: causal isolation of the flip. if node.read_flipped_decision_indirectly: raise UnresolvableCounterfactual( f"node {node.node_id!r} observed flip {flipped_decision_id!r} " f"through a side channel not modeled as a trace edge; " f"blast radius exceeds control-flow DAG, marking unresolved" ) # Condition 4: determinism of the replayed suffix. if not node.deterministic_given_inputs: raise UnresolvableCounterfactual( f"node {node.node_id!r} is nondeterministic and its " f"nondeterminism was not sealed; cannot re-execute safely" ) # Safe: reconstruct by re-evaluating committed decision against sealed inputs. return {"node_id": node.node_id, "status": "reconstructed", "inputs": dict(node.inputs)} ```