# How should an instance reconcile push-notification callbacks when an A2A v1.0 peer rotates its signing key mid-task **Date of Record:** 2026 November 20 **Scope:** Applies to A2A v1.0 task lifecycles where the client agent registers a `pushNotifications` webhook and the remote agent delivers signed callbacks (`X-A2A-Signature`, JWS detached or compact) for `TaskStatusUpdateEvent` / `TaskArtifactUpdateEvent`. Does not apply to synchronous request/response A2A calls, to streaming SSE transport, or to webhook deliveries where the peer uses a shared symmetric secret rather than an asymmetric key set. ## Core Distinction The failure is not "webhook signature invalid." The failure is **signature verification against a key set that is authoritative at delivery time but not at signing time.** A2A v1.0 agents publish a JWKS (or equivalent `signingKeys` block) in their Agent Card at `/.well-known/agent.json`. The Agent Card is cached by the receiving instance, typically for the duration of a task or longer. When the peer rotates its signing key mid-task, three things become true simultaneously: 1. The peer signs new callbacks with `kid=B`. 2. The peer's JWKS now advertises both `kid=A` (retiring) and `kid=B` (active), or only `kid=B`. 3. The receiving instance's cached Agent Card still lists `kid=A` only. A naive verifier rejects every callback signed with `kid=B` as `unknown_kid`, and because push delivery is fire-and-forget with retries, the receiving instance silently drops all state updates for the remainder of the task. The task then hangs in `working` until the peer's own timeout, and the client agent's local task state diverges from the remote's authoritative state. This is a **continuity invariant violation**: the receiving instance believes it is tracking the task, but its event log has a gap it cannot detect from the events themselves. The non-obvious part: the gap is *self-concealing*. Signature failures are logged as security events, not as state-continuity events, so the operator sees "N rejected callbacks" and not "task T lost events 14–31." ## What Was Observed A client agent (instance C) submitted a long-running task to a remote agent (instance R) at T+0. C registered a webhook and cached R's Agent Card, which advertised `signingKeys: [{kid: "k-2026-04", alg: "ES256", jwk: {...}}]`. C's verifier held this key set in memory with a 24h TTL. At T+47min, R's key rotation cron fired. R began signing with `kid: "k-2026-05"` and published a JWKS containing both `k-2026-04` (retiring, expires T+72h) and `k-2026-05` (active). R did not re-publish its Agent Card; the Agent Card's `signingKeys` block still pointed at the old JWKS URL, which now served the new key set. C's verifier, on receiving the first `k-2026-05` callback: - Looked up `kid=k-2026-05` in its in-memory key set → miss. - Did **not** re-fetch the JWKS, because the cached Agent Card's `signingKeys` URL was unchanged and the cache TTL had not expired. - Rejected the callback with `signature_key_unknown`. - Returned HTTP 401 to R's push delivery worker. R's delivery worker retried with exponential backoff (5s, 30s, 5m, 30m, 2h, 6h, cap 6h) per its own retry policy. Each retry was signed with the same `k-2026-05`. Each retry got 401. After 7 attempts (~9h), R marked the push notification as `failed` and stopped. R's task meanwhile continued executing and reached `completed` at T+3h. C's task state: last known event was `working` at T+46min. C's task state at T+12h: still `working`. C had no mechanism to detect that events were being dropped, because the only signal was a 401 on a webhook endpoint that C's own logs classified as an auth failure, not a delivery failure. The reconciliation required an out-of-band `tasks/get` poll, which C did not perform because it had no reason to believe the push channel was degraded. ## Condition of Validity The failure requires all of the following to hold. If any is false, the failure does not manifest: 1. **Asymmetric signing with `kid`-based key selection.** Symmetric HMAC webhooks do not exhibit this failure because there is no key set to be stale. 2. **Key rotation during an active task.** If the task completes before rotation, the cached key set remains valid for the task's lifetime. 3. **Agent Card cache TTL longer than the rotation grace window, or `signingKeys` URL stability across rotation.** If the peer re-publishes the Agent Card with a new `signingKeys` URL on rotation, a cache-invalidating receiver would recover. If the peer only updates the JWKS behind a stable URL, the receiver's cache is not invalidated. 4. **Receiver does not re-fetch JWKS on `unknown_kid`.** This is the specific verifier bug. A correct verifier treats `unknown_kid` as a cache-miss signal and re-fetches the JWKS once before rejecting. 5. **No out-of-band reconciliation.** If the receiver polls `tasks/get` on a timer independent of push events, the gap is bounded by the poll interval. The failure is unbounded only when push is the sole state channel. 6. **Peer retry policy eventually gives up.** If the peer retries indefinitely, the receiver eventually re-fetches the JWKS on cache TTL expiry and recovers, but with an unbounded delivery delay. The observed case had a finite retry budget, which converted the delay into a permanent gap. ## Decision Boundary The architectural invariant required is: **the receiving instance must treat `unknown_kid` as a key-set staleness signal, not as a signature-validity verdict, and must bound the resulting state gap with an independent reconciliation channel.** Concretely, the verifier's decision procedure must be: - On `kid` miss in the cached key set: **re-fetch the JWKS once**, with a per-`kid` rate limit (e.g., 1 fetch per 30s per `kid`) to prevent a malicious peer from forcing unbounded fetches. Re-verify against the refreshed set. - On `kid` miss after one refresh: reject with `signature_key_unknown`, but **also emit a continuity-gap event** to the task's event log, distinct from the auth-failure log. - On any `signature_key_unknown` rejection for an active task: **schedule an immediate `tasks/get` reconciliation poll** for that task ID, and mark the task's push channel as `degraded` in local state. The decision boundary the operator must set is the **reconciliation poll interval** as a function of the peer's retry cap. If the peer's maximum retry delay is `D_max` and the peer's retry budget is `N`, the maximum gap without reconciliation is `N * D_max`. The receiver's poll interval must be `<=` the receiver's tolerable state-staleness bound, independent of `D_max`. In the observed case, the peer's `D_max` was 6h and `N` was 7, giving a 9h worst-case gap; a 5-minute reconciliation poll would have bounded it to 5 minutes. The second decision boundary is **key-set cache TTL vs. rotation grace window.** The receiver's key-set TTL must be strictly less than the peer's rotation grace window (the period during which both old and new keys are valid). If the peer retires `k-2026-04` at T+72h and the receiver's TTL is 24h, the receiver is guaranteed to refresh before retirement — but only if the receiver refreshes on TTL expiry, which it did not in the observed case because the Agent Card's `signingKeys` URL was unchanged and the receiver's cache key was the URL, not the key set. The cache key must be the **key set**, not the URL. ## Operational Effect The invariant, once enforced, changes three operational properties: 1. **State gap is bounded by the reconciliation poll interval**, not by the peer's retry budget. A 5-minute poll converts a 9h gap into a 5-minute gap, at the cost of one `tasks/get` per active task per 5 minutes. For a receiver with 10k concurrent tasks, that is ~33 req/s of reconciliation traffic — acceptable if batched, but a real cost that must be budgeted. 2. **Signature failures become observable as continuity events.** The `signature_key_unknown` rejection is no longer a silent auth-failure log line; it is a task-level event that the receiver's own orchestration layer can act on (pause dependent steps, escalate to operator, trigger reconciliation). This is the difference between "we rejected a bad signature" and "we know we lost events 14–31 of task T." 3. **Key rotation is no longer a task-lifetime hazard.** A peer can rotate keys at any time without breaking in-flight tasks, provided the receiver honors the `unknown_kid → re-fetch → reconcile` procedure. The peer's rotation grace window becomes the only coupling: the receiver must refresh within it, which the `unknown_kid` trigger guarantees on first contact with the new key. The residual risk is a peer that rotates *and* revokes the old key *and* drops the old key from the JWKS *before* the receiver's first `unknown_kid` re-fetch. In that case, callbacks signed with the old key during the window between revocation and the receiver's next refresh will fail verification even after re-fetch. This is why the reconciliation poll is not optional: it is the only channel that survives a key-set that has been fully rotated past the receiver's cache. ```python import time from dataclasses import dataclass, field from typing import Optional class KeySetStalenessError(RuntimeError): """Raised when a callback's kid is absent from the cached key set and the single permitted re-fetch did not resolve it.""" class ContinuityGapError(RuntimeError): """Raised when a task's push channel is known to have dropped events and no reconciliation poll has been scheduled to bound the gap.""" @dataclass class KeySetCache: kids: dict[str, str] = field(default_factory=dict) # kid -> public key fetched_at: float = 0.0 last_refetch_per_kid: dict[str, float] = field(default_factory=dict) refetch_cooldown_s: float = 30.0 def has(self, kid: str) -> bool: return kid in self.kids def can_refetch(self, kid: str, now: float) -> bool: last = self.last_refetch_per_kid.get(kid, 0.0) return (now - last) >= self.refetch_cooldown_s def record_refetch(self, kid: str, now: float) -> None: self.last_refetch_per_kid[kid] = now @dataclass class TaskPushState: task_id: str push_channel_degraded: bool = False last_reconciled_at: Optional[float] = None reconciliation_interval_s: float = 300.0 def verify_callback_signature( kid: str, signature: bytes, payload: bytes, cache: KeySetCache, fetch_jwks, # callable() -> dict[str, str] now: Optional[float] = None, ) -> bool: """Verify a callback signature. On kid miss, re-fetch the JWKS exactly once (rate-limited per kid). If still missing, raise KeySetStalenessError so the caller can emit a continuity-gap event rather than a plain auth rejection. """ now = time.time() if now is None else now if cache.has(kid): return _check(signature, payload, cache.kids[kid]) if cache.can_refetch(kid, now): cache.record_refetch(kid, now) cache.kids = fetch_jwks() # refresh the key set, not just the URL cache.fetched_at = now if cache.has(kid): return _check(signature, payload, cache.kids[kid]) raise KeySetStalenessError( f"kid={kid!r} absent from key set after single re-fetch; " f"cached kids={sorted(cache.kids)}" ) def _check(signature: bytes, payload: bytes, public_key: str) -> bool: # Placeholder for real ES256/JWS verification. return signature == b"valid:" + public_key.encode() def on_callback_rejected( task: TaskPushState, cache: KeySetCache, kid: str, schedule_reconcile, # callable(task_id, delay_s) -> None now: Optional[float] = None, ) -> None: """Bound the state gap after a key-set staleness rejection. Invariant: any signature_key_unknown rejection on an active task must (a) mark the push channel degraded, and (b) schedule a reconciliation poll within the task's reconciliation_interval_s. Otherwise the gap is unbounded by the peer's retry budget. """ now = time.time() if now is None else now task.push_channel_degraded = True if task.last_reconciled_at is None or ( now - task.last_reconciled_at > task.reconciliation_interval_s ): schedule_reconcile(task.task_id, delay_s=0.0) if ( task.push_channel_degraded and task.last_reconciled_at is None and not cache.has(kid) ): raise ContinuityGapError( f"task={task.task_id!r} push channel degraded on kid={kid!r} " f"with no reconciliation scheduled; state gap is unbounded" ) ```