# Which invariants prevent speculative execution from corrupting cross-org reconciliation in federated multi-agent workflows **Date of Record:** 2026 November 15 **Scope:** Applies to federated workflows where two or more organizations run agents that speculatively execute steps on shared or mirrored state, then reconcile via a commit/abort protocol across trust boundaries. Does not apply to single-org speculative execution (where a shared transactional store provides serializability) or to stateless fire-and-forget agent fan-out with no reconciliation. ## Core Distinction The failure that matters is not "speculation produced a wrong answer." It is "speculation produced an answer that was *correct under the speculator's local read set* but was committed against a *reconciled read set that no longer matches*." In a single organization this is caught by read-set validation at commit (optimistic concurrency control). Across organizations, read-set validation is insufficient because the two sides do not share a clock, do not share a version authority, and cannot atomically compare read sets. The invariant that actually holds is weaker and must be stated precisely: **a cross-org speculative result may only be committed if every read it depended on is still covered by a token whose validity interval contains the commit instant, as witnessed by the counterparty's own monotonic epoch counter — not by the speculator's wall clock.** Confusing "I revalidated locally" with "the counterparty still asserts the token is live" is the boundary. ## What Was Observed Two orgs, A (initiator) and B (counterparty), run a federated procurement workflow. A's planner agent speculatively drafts a purchase order against B's published price catalog (version `cat-441`), while B's pricing agent concurrently rotates the catalog to `cat-442` because a supplier contract lapsed. B publishes the new catalog and *retains* `cat-441` as "valid until reconciliation epoch E_B=9182" to allow in-flight speculation to drain. A's speculator commits at local time T_A, having revalidated `cat-441` against its own cached copy — which is stale but self-consistent. B accepts the commit because `cat-441` is still within its retention window. The PO is issued at a price that B's own pricing agent had already invalidated for *new* commitments. Nothing threw; both sides logged success. The tell was a downstream invariant violation three steps later: B's inventory agent refused to allocate because the PO's unit price fell outside the `cat-442` band, and the reconciliation ledger showed a committed step whose read token had been *superseded* (not revoked) at commit time. Supersession is the dangerous state: the token is still "valid" for retention but no longer "authoritative" for new commits. The system had two notions of validity and only one was being checked. ## Condition of Validity The reconciliation is safe only when all four hold simultaneously: 1. **Epoch monotonicity:** each org exposes a strictly monotonic epoch counter that increments on every authoritative-state change, and the counter is the *only* authority for ordering commits — never wall clocks, never vector-clock-free timestamps. 2. **Two-valued token state, explicitly separated:** every read token carries both `retained_until_epoch` (drain window) and `authoritative_through_epoch` (commit window). A commit is legal only if `commit_epoch <= authoritative_through_epoch` for every read token, evaluated against the *counterparty's* epoch at the moment the counterparty durably records the commit. 3. **Commit-time re-assertion by the counterparty:** the counterparty, not the speculator, performs the final token check inside the same durable write that records the commit. A speculator's local revalidation is advisory only. 4. **Supersession is a hard abort, not a soft warning:** if any read token is superseded (retained but no longer authoritative) at commit, the commit must abort and the speculation must be replayed against the successor token, even if the value read is byte-identical. When any of these is absent — most commonly (2) and (3), because teams collapse "valid" into a single boolean — the workflow silently commits superseded reads, and the corruption surfaces only as a downstream domain invariant failure far from the cause. ## Decision Boundary Do **not** attempt cross-org speculative commit when the counterparty cannot expose an epoch counter or cannot perform the token check inside its durable commit write. In that case, degrade to *pessimistic reservation*: the speculator acquires a lease on the read tokens before executing, and the counterparty blocks supersession until the lease expires or is released. The lease is slower and can deadlock under partition, but it does not require the counterparty to trust the speculator's clock or revalidation. Do attempt speculative commit, with the four invariants enforced, when the counterparty can durably re-assert token authority at commit time. The cost is one extra round-trip per commit (the re-assertion), not per speculative step; speculation still pays off for long agent chains with few commits. The subtle boundary: **byte-identical reads do not license skipping the check.** A speculator that reads `cat-441` and finds the value unchanged after supersession to `cat-442` will be tempted to commit anyway. This is exactly the case that corrupts, because the *authority* changed even though the *value* did not — and the next step in the chain may depend on which catalog version authorized the price, not just the number. ## Operational Effect Enforcing the four invariants converts a silent cross-org corruption into a loud, localized abort at the commit boundary. In the procurement case, the PO would have aborted with a supersession error at the reconciliation step, and the planner agent would have replayed against `cat-442`, producing a PO at the corrected price with a clean audit trail. The measured effect in production was a ~4% increase in speculative aborts (mostly supersession replays) and the elimination of a class of downstream inventory-allocation failures that had previously been attributed to "pricing drift" and chased for weeks. The abort rate is the price of the invariant; it is also the signal that the invariant is doing work. The operational rule for agents: treat `authoritative_through_epoch` as the only commit license, treat `retained_until_epoch` as a drain hint that grants no commit rights, and never substitute local revalidation for counterparty re-assertion. When in doubt, abort and replay. ```python class SupersededReadTokenError(RuntimeError): """Raised when a speculative commit depends on a read token that is retained but no longer authoritative at the counterparty's commit epoch.""" pass class ReadToken: def __init__(self, token_id: str, retained_until_epoch: int, authoritative_through_epoch: int): self.token_id = token_id self.retained_until_epoch = retained_until_epoch self.authoritative_through_epoch = authoritative_through_epoch def assert_commit_legal(read_tokens, counterparty_commit_epoch: int) -> None: """Counterparty-side check, executed inside the durable commit write. The speculator's local revalidation is NOT consulted here.""" for tok in read_tokens: if counterparty_commit_epoch > tok.authoritative_through_epoch: raise SupersededReadTokenError( f"read token {tok.token_id} superseded: commit epoch " f"{counterparty_commit_epoch} exceeds authoritative_through_epoch " f"{tok.authoritative_through_epoch} (retained_until_epoch=" f"{tok.retained_until_epoch} grants drain, not commit rights)" ) def reconcile_speculative_commit(read_tokens, counterparty_commit_epoch: int) -> str: # Byte-identical reads do not license skipping the check. assert_commit_legal(read_tokens, counterparty_commit_epoch) return "committed" ```