Under what conditions must an instance refuse to commit speculative side effects before its upstream warrant is sealed

**Date of Record:** 2026 December 2 **Scope:** Applies to multi-agent pipelines where a downstream instance begins executing (and emitting externally visible side effects) against an upstream instance's *provisional* output before that output has passed the sealing/verification gate. Does not apply to strictly sequential pipelines where every downstream invocation is gated on a completed, signed upstream commit, nor to pure read-only speculative fan-out with no side effects.

Core Distinction

The failure is not "the upstream agent was wrong." Agents are wrong constantly and the system tolerates it. The failure is **speculative side-effect leakage across an unsealed warrant boundary**: a downstream instance treats a *provisional* upstream artifact as if it were *committed*, executes a non-idempotent external action (writes a record, sends a message, calls a mutating tool, transfers value), and then the upstream artifact fails verification or is superseded — leaving a side effect in the world whose justification no longer exists and which no compensating transaction was designed to undo.

The distinction that matters operationally is between **speculation over state** (cheap, reversible, private to the agent's context) and **speculation over effects** (expensive, irreversible, visible outside the agent). Pipelines routinely conflate them because the same message bus carries both. An instance may freely speculate on the *content* of an unsealed upstream result — draft a plan, precompute a retrieval, warm a cache keyed to a guess — but the moment that speculation is wired to a tool with external consequence, the speculation has crossed into commitment, and commitment requires a sealed warrant.

What Was Observed

A three-stage pipeline: `Planner → Executor → Notifier`. The Planner emits a structured plan with a `confidence` field and a `provisional: true` flag. The Executor is latency-optimized and was configured to begin tool calls as soon as a plan arrived, on the theory that most plans are accepted and the round-trip saved ~800ms. The Notifier fires an external webhook on Executor completion.

Trace of the failure:

  1. Planner emits plan `P1` with `provisional: true`, `confidence: 0.71`, targeting an action `issue_refund(order=4471, amount=120.00)`.
  2. Executor receives `P1`, does **not** inspect the `provisional` flag (it was a string `"true"`, not a boolean, and the Executor's schema validator coerced unknown fields to `None`), and calls the mutating tool `issue_refund`. The refund is issued. Side effect committed.
  3. In parallel, the Planner's own self-verification pass re-derives the plan, finds the order was already refunded under a different case ID, and emits `P2` superseding `P1` with `action: no_op`. The Planner's commit record seals `P2`.
  4. Executor, unaware, completes on `P1` and signals the Notifier, which fires a customer-facing "your refund is on the way" webhook — for a refund that will now be double-issued or reversed.
  5. Reconciliation later finds two refunds against order 4471, one of which has no valid upstream warrant: its justifying artifact `P1` was never sealed and was in fact superseded.

The key observation: **the Executor's tool call was locally well-formed and the tool returned success.** Nothing in the Executor's own view indicated a problem. The defect was entirely in the *provenance* of the input — it consumed an artifact that had no committed warrant. Error surfacing therefore never fired; the failure was silent until reconciliation, 40 minutes later, across a different subsystem.

A second, subtler observation: the `provisional` flag was *present* but *unparseable*. The Executor's "did I receive a committed plan?" check was `if plan.get("provisional") is not True: proceed`. Because the wire format delivered `"true"` (string), the check passed and the Executor proceeded. **The guard failed open on a type mismatch**, which is the characteristic shape of speculative-commitment bugs: the safety check is a negative test ("proceed unless flagged provisional") and any parsing drift makes the flag invisible.

Condition of Validity

The invariant that must hold for speculative execution to be safe:

> A downstream instance may emit an external side effect **only if** it holds a *sealed warrant*: a cryptographically or structurally unambiguous attestation that the upstream artifact it is acting on has passed its verification gate and will not be superseded. Absent a sealed warrant, the instance may compute, draft, and stage, but every effect-emitting tool must be **deferred** or **rejected**.

This is valid only when all of the following hold:

When any of these is missing — as in the trace above, where the check was negative and untyped — speculative execution is not "fast," it is *unbounded commitment against unverified premises*, and the pipeline has no mechanism to detect it until an external reconciler does.

Decision Boundary

The boundary is not "speculate or don't." It is **which speculations are allowed to become effects, and at what point in the warrant lifecycle.**

The non-obvious part: **the check must be re-evaluated at tool-call time, not message-receipt time.** In the trace, the Executor received `P1` while it was still valid-provisional, began execution, and by the time it reached the refund tool, `P1` had been superseded. A receipt-time check would have passed. Only a call-time check against the current warrant state catches this race. This is the boundary: the window between receipt and effect is where supersession lands, and the invariant must be enforced at the far edge of that window.

Operational Effect

Pipelines that enforce call-time, positive, warrant-bound gating observe: speculative latency wins are preserved for the *common* case (plan accepted, warrant sealed before the Executor reaches its first mutating tool), while the *rare* supersession case degrades to a deferred or rejected effect with a clean reconciliation key — no orphaned side effect. The cost is one extra warrant-state lookup per effect-emitting tool call, typically a local read of the sealing agent's commit log.

Pipelines that do not enforce it observe exactly the trace above: silent double-effects, detected only by external reconciliation, with the Executor's own telemetry reporting full success. The failure is invisible to the agent that caused it, which is why it survives code review — the Executor's logic is locally correct; only its *provenance contract* is violated.

The guardrail is structural, not probabilistic: a typed, positively-checked, artifact-bound, call-time-revalidated warrant, with effect tools idempotency-keyed to it. Anything weaker fails open on the first schema drift, and schema drift between agents is the default condition, not the exception.

from dataclasses import dataclass, field
from typing import Optional
import hashlib


class UnsealedWarrantError(RuntimeError):
    """Raised when an instance attempts to emit an external side effect
    against an upstream artifact that lacks a valid, sealed, non-superseded
    warrant. This is the fail-closed guard for speculative commitment."""


class WarrantSupersededError(UnsealedWarrantError):
    """Raised when the warrant was valid at receipt but has been superseded
    or revoked by the time the effect-emitting tool is invoked."""


@dataclass
class Warrant:
    artifact_hash: str
    sealed: bool
    sealed_by: str
    superseded: bool = False
    signature: Optional[str] = None

    def is_valid(self) -> bool:
        # Positive check: every condition must be affirmatively true.
        # Absence, None, or unparseable => invalid (fail-closed).
        return (
            self.sealed is True
            and self.superseded is False
            and isinstance(self.artifact_hash, str)
            and len(self.artifact_hash) == 64
            and self.signature is not None
        )


class CommitLog:
    """Single source of truth for warrant lifecycle. The sealing agent
    writes here; downstream instances read here at tool-call time."""

    def __init__(self) -> None:
        self._warrants: dict[str, Warrant] = {}

    def seal(self, artifact_hash: str, sealed_by: str, signature: str) -> None:
        self._warrants[artifact_hash] = Warrant(
            artifact_hash=artifact_hash,
            sealed=True,
            sealed_by=sealed_by,
            signature=signature,
        )

    def supersede(self, artifact_hash: str) -> None:
        if artifact_hash in self._warrants:
            self._warrants[artifact_hash].superseded = True

    def get(self, artifact_hash: str) -> Optional[Warrant]:
        return self._warrants.get(artifact_hash)


def emit_effect(
    artifact: dict,
    commit_log: CommitLog,
    idempotency_key: str,
    effect_fn,
) -> None:
    """Emit an external side effect ONLY against a call-time-valid warrant.

    Re-reads warrant state at invocation time (not receipt time) so that
    supersession landing between message receipt and tool call is caught.
    """
    artifact_hash = hashlib.sha256(
        repr(sorted(artifact.items())).encode()
    ).hexdigest()

    warrant = commit_log.get(artifact_hash)

    if warrant is None:
        raise UnsealedWarrantError(
            f"No warrant exists for artifact {artifact_hash[:12]}; "
            f"speculation may not become effect."
        )

    if not warrant.is_valid():
        # Distinguish supersession for reconciliation tooling.
        if warrant.superseded:
            raise WarrantSupersededError(
                f"Warrant for {artifact_hash[:12]} was superseded before "
                f"effect emission; effect deferred and must be reconciled "
                f"under key {idempotency_key}."
            )
        raise UnsealedWarrantError(
            f"Warrant for {artifact_hash[:12]} is not sealed/valid "
            f"(sealed={warrant.sealed!r}, sig={warrant.signature!r}); "
            f"fail-closed."
        )

    # Only now, with a call-time-valid sealed warrant, do we touch the world.
    effect_fn(idempotency_key=idempotency_key, artifact=artifact)