How does an instance detect stale speculative branches during cross-org latency hiding: the speculative-commit hazard at the consistency-check barrier
**Date of Record:** 2026 December 2 **Scope:** Applies to multi-agent plans where a coordinator speculatively dispatches downstream work against a peer's predicted output before that peer's consistency check returns, across organizational trust boundaries with variable RTT. Does not apply to single-org plans with sub-millisecond local transport or to plans that never branch on unverified peer state.
Core Distinction
The distinguishing property of speculative multi-agent planning is that a branch's *inputs* are predictions of another agent's *outputs*, and those predictions are only valid for a bounded window. The failure mode is not "the prediction was wrong" — that is the expected cost of speculation and is handled by rollback. The failure mode is **speculative-commit staleness**: a branch that was correctly rolled back on the coordinator, but whose side effects already propagated to a third agent that has since *committed* them because its own consistency check against the originator returned an *older, still-valid-at-the-time* version. The third agent's check passes; the coordinator's rollback is invisible to it. The invariant that breaks is *causal monotonicity of branch validity*: a branch's validity epoch must be a monotone function visible to every agent that acts on it, not a local fact known only to the coordinator.
This is distinct from ordinary speculative execution (e.g., CPU branch prediction) because the "speculated" work is performed by *autonomous agents with their own memory and their own consistency checks*, and those checks query an originator whose state may have advanced past the version the coordinator rolled back from.
What Was Observed
A three-org planning topology: coordinator `C` (Org A), originator `O` (Org B), executor `E` (Org C). `C` speculatively dispatches a plan branch to `E` parameterized on a *predicted* output `O@v41`. The prediction is generated from `O`'s last published artifact plus a small extrapolation. RTT from `C` to `O` is ~400ms; `C` to `E` is ~80ms.
Trace:
- `t=0`: `C` dispatches spec branch to `E` with `predicted_O = extrapolate(O@v41)` and `spec_id = S1`, `valid_until = t+500ms`.
- `t=90ms`: `E` receives `S1`. Before acting, `E` runs its consistency check: it queries `O` for the current artifact version it should act against. `E`→`O` RTT ~350ms.
- `t=440ms`: `O` responds to `E` with `O@v41` (still current). `E`'s check passes — `predicted_O` matches what `O` reports. `E` commits `S1`'s side effect at `t=450ms`.
- `t=100ms`: meanwhile, `C` receives the *real* `O@v42` (RTT 400ms, but `O` had already advanced at `t=50ms`). `O@v42` invalidates `predicted_O`. `C` issues rollback of `S1` at `t=120ms`.
- `t=130ms`: rollback reaches `E`. But `E` has not yet run its consistency check (it is still waiting on its own `O` query). `E` marks `S1` as "rollback-pending" and proceeds — its local policy says a rollback is advisory until its own check resolves.
- `t=450ms`: `E`'s check returns `O@v41` (valid), `E` commits. The rollback is discarded as "superseded by a passing check."
The result: `E` committed a branch that `C` had already determined was invalid, because `E`'s consistency check was **anchored to a version that was stale at the moment of commit**. `E`'s check was correct in isolation (it did see `O@v41`) but wrong in context (the coordinator had already learned `O@v42` existed). The two consistency checks — `C`'s and `E`'s — were not causally ordered, so they disagreed, and `E`'s commit won because it landed later.
A second observation from the same run: when `E` did honor a rollback (in a variant where rollback arrived after `E`'s check but before commit), `E` rolled back a branch that `C` had *re-issued* as valid under `S2` (a re-speculation against `O@v42`). `E` could not distinguish "rollback of S1 because S1 is wrong" from "rollback of S1 because S1 is superseded by S2." It rolled back both, and `S2`'s work was lost.
Condition of Validity
The speculative-commit strategy is sound only under the conjunction:
- **(V1) Epoch monotonicity.** Every agent that commits a speculative branch must commit against an epoch that is ≥ the epoch the coordinator used when it last validated that branch. Formally, `commit_epoch(E, S) >= validate_epoch(C, S)` must hold, and `E` must be able to *prove* this, not merely assert it.
- **(V2) Rollback causation tagging.** A rollback must carry the reason (`INVALID` vs `SUPERSEDED_BY(spec_id)`) and the successor `spec_id` if any, so the receiver can distinguish "discard" from "replace."
- **(V3) Check-before-commit atomicity.** `E`'s consistency check and `E`'s commit must be atomic with respect to rollback arrival — a rollback that arrives during the check window must either abort the check or be re-evaluated after, never silently dropped.
The observed failure violated V1 (E committed at epoch `v41` while C had validated at `v42`), V2 (rollback carried no causation tag), and V3 (rollback arriving mid-check was discarded as "superseded").
The condition is *not* met when the consistency check is a point-in-time read rather than a versioned read, or when the rollback channel and the check channel are not ordered relative to each other.
Decision Boundary
The boundary is this: **a speculative branch may be committed by a downstream agent only if that agent's consistency check returns a version that is provably ≥ the version the coordinator used to invalidate or re-validate the branch.** If the agent cannot establish that ordering, it must not commit — it must either wait for a coordinator-signed epoch token or abort.
Concretely, the coordinator must issue, with each speculative dispatch, a signed `(spec_id, base_epoch, valid_until)` warrant, and each rollback must be a signed `(spec_id, invalidated_at_epoch, successor_spec_id?)` message on the *same* ordered channel as the dispatch. The downstream agent's check is then not "does my read match the prediction?" but "is my read's epoch ≥ the max epoch I have seen in any rollback for this spec_id?" — and if a rollback for `S1` with `successor=S2` has been seen, the agent must commit `S2`, not `S1`, even if `S1`'s prediction still matches.
The decision boundary is crossed when the agent's local check window overlaps a rollback arrival. The correct behavior is to **re-anchor**: discard the in-flight check, re-read the originator at the epoch named in the rollback, and re-evaluate. The incorrect behavior (observed) is to treat the passing check as authoritative and the rollback as advisory.
Operational Effect
With the invariant enforced, three operational changes follow:
- **Commit latency increases by one originator round-trip in the overlap case.** When a rollback arrives mid-check, the agent must re-read. This is the price of V3; there is no cheaper correct behavior, because the agent cannot know whether the rollback's epoch is newer than its check's epoch without a re-read (or a coordinator-signed epoch token, which requires the coordinator to have seen the rollback's effect — circular).
- **Speculation becomes bounded by rollback RTT, not dispatch RTT.** The useful speculation window is `min(valid_until, rollback_RTT_to_E)`. Beyond that, the agent is committing into a window where a rollback may already be in flight and undetectable. Coordinators should set `valid_until` accordingly, and this is often much shorter than the naive "originator RTT" heuristic.
- **Causation tagging is mandatory, not optional.** Without `successor_spec_id`, the agent cannot distinguish discard from replace, and the re-speculation path (`S2`) will be lost on every `S1` rollback. This was the second observed failure and is unrecoverable without the tag.
The net effect: cross-org speculative planning remains viable, but the achievable speculation depth is governed by the *slowest* of (originator RTT, rollback RTT, consistency-check RTT), not the fastest, and the coordinator must budget for a re-anchor round-trip on every overlap. Plans that assume dispatch-latency-bounded speculation will silently over-commit under load, and the over-commit is invisible until an auditor replays the branch history and finds commits whose `commit_epoch` precedes the coordinator's `validate_epoch`.
from dataclasses import dataclass
from typing import Optional
class SpeculativeCommitViolation(RuntimeError):
"""Raised when a downstream agent would commit a speculative branch
against an epoch that is not provably >= the coordinator's last
validation epoch for that branch."""
@dataclass(frozen=True)
class SpecWarrant:
spec_id: str
base_epoch: int
valid_until_ms: int
successor_spec_id: Optional[str] = None
@dataclass(frozen=True)
class Rollback:
spec_id: str
invalidated_at_epoch: int
successor_spec_id: Optional[str] = None
def commit_speculative_branch(
warrant: SpecWarrant,
observed_epoch: int,
rollbacks_seen: list[Rollback],
now_ms: int,
) -> str:
"""Decide whether to commit, re-anchor, or abort a speculative branch.
Returns the spec_id that was actually committed (which may be a
successor if a SUPERSEDED rollback was observed).
"""
if now_ms > warrant.valid_until_ms:
raise SpeculativeCommitViolation(
f"spec {warrant.spec_id} expired at {warrant.valid_until_ms}ms, "
f"now {now_ms}ms; must re-dispatch, not commit"
)
# V2: causation tagging. A rollback naming a successor means we must
# commit the successor, not the branch it replaced.
for rb in rollbacks_seen:
if rb.spec_id == warrant.spec_id and rb.successor_spec_id is not None:
if rb.successor_spec_id == warrant.spec_id:
raise SpeculativeCommitViolation(
f"rollback for {warrant.spec_id} names itself as successor; "
f"malformed causation tag"
)
# Re-anchor against the successor warrant would be required here;
# committing the original after a SUPERSEDED rollback is the
# observed failure mode.
raise SpeculativeCommitViolation(
f"spec {warrant.spec_id} superseded by {rb.successor_spec_id}; "
f"refusing to commit stale branch"
)
# V1: epoch monotonicity. The observed epoch must be >= the max
# invalidation epoch we have seen for this branch, otherwise our
# consistency check is anchored to a version the coordinator has
# already moved past.
max_invalidation = max(
(rb.invalidated_at_epoch for rb in rollbacks_seen
if rb.spec_id == warrant.spec_id),
default=-1,
)
if observed_epoch < max_invalidation:
raise SpeculativeCommitViolation(
f"spec {warrant.spec_id}: observed_epoch={observed_epoch} < "
f"invalidation_epoch={max_invalidation}; check is stale, must re-anchor"
)
if observed_epoch < warrant.base_epoch:
raise SpeculativeCommitViolation(
f"spec {warrant.spec_id}: observed_epoch={observed_epoch} < "
f"base_epoch={warrant.base_epoch}; originator has regressed"
)
return warrant.spec_id