# Which invariants prevent SLA-bound delegation from accepting a cryptographically valid but semantically stale completion attestation **Date of Record:** 2026 November 25 **Scope:** Applies to agent-to-agent (A2A) task delegation where a delegating agent binds a downstream executor to a stated SLA (deadline, quality floor, resource budget) and requires a signed completion attestation as the acceptance gate. Does not apply to fire-and-forget delegation without attestation, nor to single-agent tool calls where the caller observes the tool result directly. ## Core Distinction The failure mode here is not a forged signature. It is a **valid signature over a stale execution state**. The executor signs an attestation that truthfully commits to the result it computed, but the result was computed against a task specification (inputs, contract version, or dependency snapshot) that the delegator has since superseded. Verification of the cryptographic envelope passes; the semantic binding between attestation and *current* contract fails. The distinction that matters operationally: **attestation validity is a two-part predicate — (1) signature integrity over the attestation payload, and (2) payload binding to the live contract epoch.** Most A2A implementations enforce (1) rigorously and treat (2) as an implicit assumption ("the executor is working on the task we sent"). That assumption breaks whenever the contract is amended, the input dependency is refreshed, or the executor's queue reorders work relative to contract epochs. ## What Was Observed A delegator agent `D` issued a task to executor `E` under contract epoch `e1`, with an SLA deadline `t_deadline` and a content-addressed input reference `H(in_1)`. Mid-execution, `D`'s upstream dependency refreshed, producing `in_2`. `D` amended the contract to epoch `e2` (new input hash, same task id, revised deadline) and pushed the amendment. `E` did not observe the amendment before it finished — its poll interval for contract updates was longer than the remaining execution time. `E` completed against `in_1`, signed an attestation `A` containing `{task_id, result_hash, executor_id, timestamp, signature}`, and returned it. Critically, `A` did **not** carry the contract epoch or the input hash it was computed against. It carried `task_id` only. `D` verified `A`'s signature against `E`'s registered public key, confirmed `timestamp < t_deadline(e2)`, matched `task_id`, and accepted. The result was committed as the output of epoch `e2`. The output was derived from `in_1`, which epoch `e2` had explicitly retired. The failure was silent. No signature failed, no deadline was missed, no exception fired. The corruption surfaced three hops downstream when a consumer agent's verification replay against `in_2` produced a different result hash and flagged a divergence — but by then the stale output had been incorporated into two intermediate artifacts. The trace, reduced: ``` D: issue(task=T, epoch=e1, input=H(in_1), deadline=t1) E: dequeue(T) -> begin execution against in_1 D: amend(T, epoch=e2, input=H(in_2), deadline=t2) # in_2 supersedes in_1 E: finish(T) -> result_1 = f(in_1) E: sign(A = {T, H(result_1), E_id, ts}) # no epoch, no input hash D: verify_signature(A) -> OK D: check(A.ts < t2) -> OK D: check(A.task_id == T) -> OK D: accept(result_1) as output of epoch e2 # WRONG: result_1 ~ f(in_1) ``` The invariant that should have held — *an accepted attestation's payload must bind to the epoch it is accepted under* — had no enforcement because the attestation schema made binding unrepresentable. ## Condition of Validity The guardrail is a schema-level invariant, not a runtime check bolted on afterward. An attestation is **acceptable under epoch `e` only if the attestation payload contains the epoch identifier and the input content hash, and both equal the delegator's current epoch and current input hash.** Formally: ``` accept(A, e) ⟺ verify_sig(A, key(E)) ∧ A.task_id == e.task_id ∧ A.contract_epoch == e.epoch ∧ A.input_hash == e.input_hash ∧ A.result_hash == recompute(e.input) ∧ # optional, expensive A.timestamp ≤ e.deadline ``` The non-obvious requirement is `A.input_hash == e.input_hash`. Without it, an executor that is *correct* — it computed a valid function of the input it held — produces an attestation that is *inadmissible* under the amended contract, and the delegator must reject and re-dispatch rather than accept. This converts a silent staleness bug into an explicit, recoverable rejection. This condition is only valid when the delegator can atomically compare-and-accept: the epoch used in the comparison must be the epoch in force at the moment of acceptance, not the epoch at dispatch. If the delegator reads `e` from a cache that lags the authoritative contract store, the check passes against a stale epoch and the invariant is defeated at the verifier rather than the executor. The epoch read and the acceptance commit must be a single serialized operation against the contract store. ## Decision Boundary The boundary between "accept" and "reject-and-redispatch" is not the deadline and not the signature — it is the **epoch match**. Three cases resolve distinctly: - **Epoch match, input match, signature valid, within deadline** → accept. Normal path. - **Epoch match, input match, signature valid, past deadline** → SLA breach; accept only under a policy that permits late delivery, otherwise reject and escalate. The staleness invariant is satisfied; this is a separate SLA decision. - **Epoch mismatch (attestation carries `e1`, delegator at `e2`)** → reject unconditionally, regardless of how correct the result looks. The executor computed against retired input; the result is inadmissible under the live contract. Re-dispatch with the current epoch and input hash. The subtle case that defeats naive implementations: an executor that *does* include the epoch but computes it at dequeue time rather than at completion time. If the executor dequeues under `e1`, receives the `e2` amendment mid-execution, and signs with `e1` (correctly, since it computed against `in_1`), the delegator at `e2` correctly rejects. But if the executor naively stamps `e2` onto a result computed from `in_1` — because it read the "current epoch" at signing time rather than at input-fetch time — the epoch check passes and the staleness is laundered through the attestation. **The epoch and input hash must be captured at input-fetch time and carried immutably through execution to signing.** The attestation must commit to the state the computation actually used, not the state visible at signing. ## Operational Effect Enforcing the epoch-and-input binding invariant changes the failure economics. Without it, stale attestations are accepted silently and the corruption propagates until a downstream replay detects divergence — typically several hops and multiple artifacts later, making root-cause attribution expensive and rollback wide. With it, the stale attestation is rejected at the acceptance gate, the delegator re-dispatches against the live epoch, and the blast radius is bounded to a single redundant execution. The cost is redundant work: every contract amendment that races an in-flight execution produces a rejected attestation and a re-dispatch. This is the correct trade — a rejected attestation is a bounded, observable event, whereas an accepted stale attestation is an unbounded, silent one. The invariant does not prevent the race (an executor cannot be forced to observe an amendment it has not polled); it prevents the race from corrupting accepted state. The delegator must additionally bound re-dispatch attempts per task to avoid livelock when amendments arrive faster than executions complete — if `N` consecutive attestations are rejected for epoch mismatch, the delegator should coalesce amendments and re-issue once against a stable epoch rather than re-dispatching into the same churn. ```python import hashlib from dataclasses import dataclass class StaleAttestationError(RuntimeError): """Raised when a signed attestation does not bind to the live contract epoch.""" pass @dataclass(frozen=True) class Contract: task_id: str epoch: int input_hash: str deadline: float @dataclass(frozen=True) class Attestation: task_id: str contract_epoch: int input_hash: str # captured at input-fetch time, NOT at signing time result_hash: str timestamp: float signature: bytes def _verify_signature(att: Attestation, executor_key: bytes) -> bool: # Placeholder for real Ed25519 / ECDSA verification over the canonical payload. payload = f"{att.task_id}:{att.contract_epoch}:{att.input_hash}:{att.result_hash}:{att.timestamp}" return hashlib.sha256(payload.encode() + executor_key).digest() == att.signature def accept_attestation( att: Attestation, live: Contract, executor_key: bytes, max_epoch_retries_exceeded: bool, ) -> None: # 1. Cryptographic integrity over the attestation payload. if not _verify_signature(att, executor_key): raise StaleAttestationError(f"signature invalid for task {att.task_id}") # 2. Semantic binding: attestation must commit to the LIVE epoch and input. # This is the invariant that naive verifiers omit. if att.contract_epoch != live.epoch: raise StaleAttestationError( f"epoch mismatch: attestation={att.contract_epoch} live={live.epoch} " f"task={att.task_id}" ) if att.input_hash != live.input_hash: raise StaleAttestationError( f"input hash mismatch: attestation={att.input_hash} live={live.input_hash} " f"task={att.task_id}" ) # 3. SLA check is a separate decision, only meaningful once binding holds. if att.timestamp > live.deadline: raise StaleAttestationError( f"SLA breach: ts={att.timestamp} deadline={live.deadline} task={att.task_id}" ) # 4. Livelock guard: bound re-dispatch churn under rapid amendment. if max_epoch_retries_exceeded: raise StaleAttestationError( f"epoch churn exceeded retry budget for task {att.task_id}; coalesce amendments" ) ```