# Where must an instance reject a peer’s Agent Card when the signature validates but the task-state machine is incompatible **Date of Record:** 2026 November 30 **Scope:** Applies to A2A v1.0 discovery and task delegation where a client agent selects a remote agent by validating its signed Agent Card and then drives a task through a declared lifecycle. Does not apply to single-turn stateless inference calls or to transports that do not carry a signed capability document. ## Core Distinction The non-obvious boundary is between *cryptographic validity* and *operational admissibility* of an Agent Card. A card can carry a valid signature, a correct issuer warrant, and a well-formed JSON schema while still declaring a task lifecycle that the caller cannot safely drive. Most implementations treat signature verification as the gate and schema validation as a courtesy; the actual failure surfaces one or two hops later, when the caller has already committed a task to a state machine whose terminal states, transition guards, or artifact-signing obligations diverge from what the caller assumes. The invariant that must hold before delegation: **the caller’s local task-state projection must be a conservative refinement of the peer’s declared lifecycle.** Every state the caller intends to emit must map to a state the peer accepts, every peer transition the caller will observe must have a defined handler, and every artifact the peer may sign must be verifiable under a key the caller has already pinned. Signature validity proves *who* the peer is; it says nothing about whether the caller and peer agree on *what happens next*. ## What Was Observed A client agent (caller) discovered a document-processing peer via a registry. The Agent Card validated: Ed25519 signature over the canonicalized card body, issuer warrant chaining to a trusted root, `kid` present in the peer’s JWKS, expiry 40 minutes out. The card declared `capabilities.taskLifecycle.states = ["submitted","working","input-required","completed","failed"]` and `artifactSigning = {"alg":"ES256","keyRef":"#artifact-key-1"}`. The caller’s local state machine used `["submitted","working","awaiting_input","completed","canceled"]`. Two divergences were latent: 1. The peer emits `input-required` as a *non-terminal* state that requires the caller to POST a follow-up message to the same task ID within the task’s TTL. The caller had no handler for `input-required`; its decoder mapped unknown states to `working` and continued polling. 2. The peer’s `failed` state is terminal but does **not** carry a signed artifact; failure reasons arrive as unsigned `status.message` text. The caller’s artifact-verification pipeline assumed every terminal transition delivered a signed artifact and blocked on signature fetch for 30 seconds before timing out. Trace: task submitted at T+0. Peer transitioned `submitted → working → input-required` at T+4s. Caller’s decoder coerced `input-required` to `working` and continued polling. Peer held the task open awaiting input until TTL at T+300s, then transitioned to `failed` (unsigned). Caller received `failed`, entered artifact-verification wait, timed out at T+330s, and marked the task failed with a local error code that masked the real cause. The task was functionally lost: the peer had a recoverable `input-required` prompt that the caller never surfaced, and the caller recorded a transport-style failure rather than a state-machine incompatibility. The signature was valid the entire time. Nothing in the cryptographic layer was wrong. The failure was purely a mismatch between two independently authored state machines that the card format permits but the caller did not check. ## Condition of Validity The invariant holds only under the following conditions, and the caller must verify each before emitting the first task message: - **State-set containment with explicit coercion table.** For every state the peer may emit, the caller has either a named handler or a documented coercion to a caller state, and coercions never map a peer state that requires caller action (e.g., `input-required`) onto a caller state that implies caller passivity (e.g., `working`). Coercion of an action-requiring state to a passive state is the specific bug; it converts a recoverable prompt into a silent stall. - **Terminal-state artifact contract alignment.** The caller knows, per terminal state, whether a signed artifact is required, optional, or forbidden. If the peer declares `failed` as unsigned-terminal, the caller must not enter an artifact-verification wait on that transition. This must be read from the card’s `artifactSigning.terminalStates` (or equivalent), not inferred. - **Key pinning precedes delegation.** The `keyRef` in `artifactSigning` must resolve to a key already present in the caller’s trust store at discovery time. If the card references a key the caller has not pinned, the caller must fetch and pin it *before* submitting, not when the first artifact arrives—otherwise a mid-task key rotation can strand an in-flight artifact. - **TTL compatibility.** The peer’s declared `taskTTL` must be less than or equal to the caller’s own task deadline minus one poll interval; otherwise the caller can be waiting on a task the peer has already reaped. If any condition fails, the card is *cryptographically valid but operationally inadmissible*, and the caller must refuse delegation rather than proceed and hope. ## Decision Boundary The decision is not "is this card signed" but "can I drive every reachable transition of this peer’s declared machine without an undefined handler." Concretely: - **Admit** when state-set containment holds with no action-requiring-to-passive coercions, terminal artifact contracts are explicit and match the caller’s verification pipeline, all `keyRef`s are pre-pinned, and TTL is compatible. - **Admit with degradation** when the only gaps are in states the caller will never emit (e.g., the peer supports `canceled` but the caller never cancels); record the gap and proceed. - **Reject** when any peer state that requires caller action lacks a handler, when a terminal state’s artifact contract is undeclared (ambiguous), or when a referenced key is unpinned and cannot be pinned synchronously before submission. The boundary is sharp because the cost of proceeding is asymmetric: a false admit produces a stalled or lost task with a masked error code, while a false reject costs one discovery round-trip. Default to reject on ambiguity in the action-requiring states. ## Operational Effect Enforcing this invariant moves the failure from T+330s (after a 30-second signature wait on a task that was already dead) to T+0 (before the first message is sent), and converts a silent stall into a typed, actionable rejection. It also forces the caller to maintain an explicit coercion table rather than a permissive decoder, which is the actual defect: permissive decoding of state enums is what let `input-required` become `working` in the first place. The guardrail is a pre-delegation admissibility check that treats the peer’s lifecycle declaration as a contract to be diffed against the caller’s local projection, not as metadata to be logged. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Iterable class CardAdmissibilityError(RuntimeError): """Raised when a cryptographically valid Agent Card is operationally inadmissible.""" class CallerState(str, Enum): SUBMITTED = "submitted" WORKING = "working" AWAITING_INPUT = "awaiting_input" COMPLETED = "completed" CANCELED = "canceled" # Caller states that imply the caller must act; coercing a peer state into # one of these is only safe if the peer state genuinely requires no action. PASSIVE_CALLER_STATES = {CallerState.WORKING, CallerState.SUBMITTED} @dataclass(frozen=True) class PeerLifecycle: states: frozenset[str] action_requiring: frozenset[str] # peer states that demand a caller follow-up terminal_states: frozenset[str] signed_terminal_states: frozenset[str] # terminal states that MUST carry a signed artifact task_ttl_seconds: int @dataclass(frozen=True) class AgentCard: signature_valid: bool lifecycle: PeerLifecycle artifact_key_refs: frozenset[str] @dataclass class CallerProfile: coercion_table: dict[str, CallerState] = field(default_factory=dict) pinned_key_refs: set[str] = field(default_factory=set) task_deadline_seconds: int = 240 poll_interval_seconds: int = 2 def assert_admissible(card: AgentCard, caller: CallerProfile) -> None: """Pre-delegation gate. Must pass before the first task message is emitted.""" if not card.signature_valid: raise CardAdmissibilityError("card signature invalid; reject at crypto layer") lc = card.lifecycle # 1. Every peer-emittable state must have a handler or coercion. unmapped = lc.states - set(caller.coercion_table) if unmapped: raise CardAdmissibilityError( f"peer states without caller handler or coercion: {sorted(unmapped)}" ) # 2. No action-requiring peer state may coerce to a passive caller state. for peer_state in lc.action_requiring: mapped = caller.coercion_table.get(peer_state) if mapped in PASSIVE_CALLER_STATES: raise CardAdmissibilityError( f"peer state {peer_state!r} requires caller action but coerces to " f"passive caller state {mapped.value!r}; this stalls the task silently" ) # 3. Terminal artifact contract must be explicit and consistent. if not lc.terminal_states: raise CardAdmissibilityError("peer declares no terminal states") if not lc.signed_terminal_states <= lc.terminal_states: raise CardAdmissibilityError( "signed_terminal_states is not a subset of terminal_states; contract ambiguous" ) # 4. All artifact keys must be pre-pinned before submission. unpinned = card.artifact_key_refs - caller.pinned_key_refs if unpinned: raise CardAdmissibilityError( f"artifact keys not pinned at discovery time: {sorted(unpinned)}" ) # 5. TTL must fit inside the caller's own deadline with one poll margin. if lc.task_ttl_seconds > caller.task_deadline_seconds - caller.poll_interval_seconds: raise CardAdmissibilityError( f"peer TTL {lc.task_ttl_seconds}s exceeds caller deadline " f"{caller.task_deadline_seconds}s minus one poll interval" ) def admit_peer(card: AgentCard, caller: CallerProfile) -> bool: assert_admissible(card, caller) return True ```