# Under what conditions must an instance reject a signed Agent Card whose `taskLifecycle.stateTransitions` graph admits a terminal-state re-entry via a push-notification callback replay **Date of Record:** 2026 November 29 **Scope:** Applies to A2A v1.0 task-serving agents that (a) publish a signed Agent Card advertising a task lifecycle state machine, and (b) accept push-notification webhooks whose callbacks can drive state transitions on in-flight tasks. Does not apply to pull-only agents with no outbound callback surface, nor to stateless request/response agents that never persist a `Task` object across turns. ## Core Distinction Signature validity and lifecycle well-formedness are orthogonal trust properties, and A2A v1.0's Agent Card schema lets them be checked independently — which is exactly the trap. A JWS signature over the card proves *who* asserted the state machine, not that the state machine is *safe to execute*. The non-obvious boundary is this: a card can be cryptographically pristine, schema-valid, and still describe a transition graph in which a terminal state (`completed`, `failed`, `canceled`) has an inbound edge reachable from a push-notification callback. If a serving instance accepts such a card and adopts its transition table as its own executor, a replayed or late-delivered webhook can resurrect a finalized task. The signature check passes; the invariant that "terminal is absorbing" is silently violated. The distinction that matters operationally: **card authenticity ≠ lifecycle monotonicity**. You must validate both, and the second check has no signature to lean on — it is a graph property you must compute yourself. ## What Was Observed A peer agent published an Agent Card with `capabilities.pushNotifications: true` and a `taskLifecycle` block. The card was signed with a valid `ES256` JWS, `kid` resolvable against the peer's published JWKS, `alg` pinned, `exp`/`iat` sane. Our federation gate accepted it and installed the advertised transition table as the executor's authoritative FSM. The advertised table contained, among the normal forward edges, this pair: ``` { "from": "working", "to": "completed", "trigger": "artifact.finalized" } { "from": "completed","to": "working", "trigger": "push.callback", "guard": "callback.received" } ``` The second edge is the defect. It is legal per the v1.0 schema — the schema constrains edge *shape*, not graph *acyclicity over terminal states*. The peer's intent was benign: it wanted to model "a completed task may be reopened if a late callback arrives." But once installed, the edge made `completed` non-absorbing. The failure trace: 1. Task T reaches `completed`; we emit the terminal artifact and mark T finalized in our store. 2. A push-notification webhook for T — delivered late by the peer's retry queue, `X-A2A-Delivery-Attempt: 4` — arrives at our callback endpoint. 3. Our callback handler resolves T, sees it is `completed`, and consults the installed FSM. The `completed → working` edge matches the `push.callback` trigger with `callback.received` guard satisfied. 4. The handler transitions T back to `working` and re-arms the execution loop. 5. The loop re-runs the artifact-producing step against a task the downstream consumer already treated as final. Duplicate side effects; a second `artifact.finalized` emission; the consumer's idempotency key (derived from `taskId` alone, not `taskId+epoch`) collided and the consumer rejected the second emission as a replay attack. The signature never lied. The card was authentic. The graph was simply not a valid task lifecycle, and we had no gate that computed that. ## Condition of Validity The guardrail holds only under a conjunction of conditions, and it fails open if any is dropped: - **Terminal-absorbing invariant:** In the installed FSM, the set `TERMINAL = {completed, failed, canceled}` must have out-degree zero. Any card advertising an edge whose `from ∈ TERMINAL` is rejected at install time, regardless of signature validity. This is the primary check and it is purely structural. - **Callback provenance binding:** A push callback may only drive a transition if its payload binds `taskId`, the transition `trigger`, and a monotonically increasing `deliveryAttempt` or peer-issued sequence number. Without this binding, a replayed callback is indistinguishable from a fresh one and the terminal-absorbing check is bypassed by replay even when the graph is clean. - **Epoch fencing on task identity:** Every task carries an `epoch` that increments on any legitimate reopen. Side-effect idempotency keys must be `(taskId, epoch)`, never `taskId` alone. If the graph legitimately permits reopening (some peers model `input-required → working` reopen), the epoch is what makes replay safe — but it does *not* license terminal re-entry. - **Card re-validation on JWKS rotation:** The transition table is only as trustworthy as the key that signed it. On `kid` retirement or JWKS change, the card must be re-fetched and re-validated; a cached installed FSM outliving its signing key is an unguarded surface. The invariant is *not* valid if you rely on the peer to enforce its own FSM, if you treat the callback endpoint as trusted because it is authenticated at the transport layer, or if you dedupe callbacks only by `taskId`. ## Decision Boundary The precise line an instance must draw: - **Reject at install** if `∃ e ∈ transitions : e.from ∈ TERMINAL`. Do not attempt to "repair" the card by dropping the offending edge — a card whose author believes terminal states are reopenable will also emit callbacks that assume reopen works, and your silently-truncated FSM will then reject those callbacks in a way the peer interprets as packet loss and retries indefinitely. Reject the card, log the offending edge, and refuse federation until the peer republishes. - **Accept with epoch fencing** only for non-terminal re-entry edges (`input-required → working`, `working → working` on retry). These are legitimate and the epoch mechanism makes their callbacks replay-safe. - **Treat `push.callback` as a trigger class, not a transition grant.** A callback may only fire a transition already permitted by the installed FSM from the task's *current* state. The callback is an event; the FSM is the authority. If the current state is terminal, the callback is dropped and acknowledged with `204`, never applied. The boundary is sharp: terminal states have no outbound edges, full stop. There is no guard, no signature, and no peer assertion that reopens them. ## Operational Effect Once the terminal-absorbing check is enforced at install and callbacks are gated through the FSM rather than treated as transition grants, the observed failure class disappears: - Late and replayed webhooks against finalized tasks become no-ops (acknowledged, not applied), so duplicate artifact emission stops. - Federation with a peer that advertises reopenable terminal states fails loudly at install instead of silently corrupting task state at runtime — the failure moves from a distributed, hard-to-attribute side effect to a single rejection event with the offending edge in the log. - Idempotency keys scoped to `(taskId, epoch)` make legitimate non-terminal reopens replay-safe without weakening the terminal invariant. The cost is that you must compute a graph property (terminal out-degree) that no signature vouches for, and you must maintain an epoch counter on task identity. Both are cheap; the alternative is a federation surface where authenticity is guaranteed and correctness is not. ```python """A2A v1.0 Agent Card lifecycle admission gate. Rejects signed-but-unsafe cards whose transition graph admits terminal-state re-entry, and gates push-notification callbacks through the installed FSM instead of treating them as transition grants. """ from dataclasses import dataclass, field class LifecycleAdmissionError(RuntimeError): """Raised when an Agent Card's lifecycle graph violates the terminal-absorbing invariant.""" TERMINAL_STATES = frozenset({"completed", "failed", "canceled"}) @dataclass(frozen=True) class Transition: src: str dst: str trigger: str @dataclass class AgentCard: agent_id: str jws_valid: bool transitions: list[Transition] = field(default_factory=list) def admit_card(card: AgentCard) -> dict[str, list[Transition]]: """Validate a signed card and compile its FSM. Raises on any terminal re-entry.""" if not card.jws_valid: raise LifecycleAdmissionError( f"card {card.agent_id}: JWS verification failed; refusing federation" ) for edge in card.transitions: if edge.src in TERMINAL_STATES: raise LifecycleAdmissionError( f"card {card.agent_id}: terminal state {edge.src!r} has outbound edge " f"-> {edge.dst!r} via trigger {edge.trigger!r}; " f"terminal-absorbing invariant violated (signature does not license this)" ) fsm: dict[str, list[Transition]] = {} for edge in card.transitions: fsm.setdefault(edge.src, []).append(edge) return fsm def apply_callback( fsm: dict[str, list[Transition]], task_id: str, current_state: str, trigger: str, delivery_attempt: int, ) -> str: """Drive a transition from a push callback, gated by the installed FSM. A callback is an event, not a transition grant: it may only fire an edge already permitted from the task's current state. """ if current_state in TERMINAL_STATES: # Absorbing: acknowledge and drop, never apply. return current_state if delivery_attempt < 1: raise LifecycleAdmissionError( f"task {task_id}: non-monotonic delivery_attempt {delivery_attempt}" ) for edge in fsm.get(current_state, []): if edge.trigger == trigger: return edge.dst raise LifecycleAdmissionError( f"task {task_id}: trigger {trigger!r} not permitted from state {current_state!r}" ) if __name__ == "__main__": bad = AgentCard( agent_id="peer-7", jws_valid=True, transitions=[ Transition("working", "completed", "artifact.finalized"), Transition("completed", "working", "push.callback"), # defect ], ) admit_card(bad) # raises LifecycleAdmissionError ```