# In what scenarios must an instance reject an A2A v1.0 `TaskArtifactUpdateEvent` after a `TaskStatusUpdateEvent` has already marked the task `completed`, and why late artifact binding silently corrupts downstream consumers **Date of Record:** 2026 November 29 **Scope:** Applies to A2A v1.0 task servers that emit push notifications to a registered webhook and to A2A clients that bind artifacts to a terminal task. Does not apply to synchronous `message/send` request-response flows where the artifact is returned inline within the same HTTP response body, nor to streaming (`message/stream`) SSE sessions where the client holds the connection open and observes ordering directly. ## Core Distinction The A2A v1.0 lifecycle distinguishes **status transitions** from **artifact binding** as two independent event channels, but it does not enforce a total order across them at the transport layer. A `TaskStatusUpdateEvent` with `state: "completed"` is a *claim of terminality*; a `TaskArtifactUpdateEvent` with `append: false` and a matching `artifactId` is a *claim of content*. The specification permits a task to reach `completed` and then emit further artifact chunks, because in the reference model artifacts are considered "delivered" only when the final `append: false` chunk with `lastChunk: true` arrives. The boundary failure is this: **a client that treats `completed` as "all artifacts are final and immutable" will accept, persist, and propagate a task whose artifact set is still mutating.** The terminal status and the terminal artifact are two separate quorum conditions that the protocol never couples into a single atomic event. This is not a race in the transport sense (TCP ordering is preserved per webhook). It is a *semantic ordering* failure: the server emits status and artifact events on the same ordered channel, but the client's state machine collapses two distinct terminal conditions into one. ## What Was Observed A push-notification receiver registered via `tasks/pushNotificationConfig/set` received the following ordered event sequence for `taskId: t-7f3a`: 1. `TaskStatusUpdateEvent { state: "working", final: false }` 2. `TaskArtifactUpdateEvent { artifactId: "a1", append: false, lastChunk: false, parts: [text: "...partial report..."] }` 3. `TaskStatusUpdateEvent { state: "completed", final: true }` 4. `TaskArtifactUpdateEvent { artifactId: "a1", append: true, lastChunk: true, parts: [text: "...final section..."] }` Event 3 fired because the agent's planner considered the *generation* complete and marked the task terminal before the artifact assembler flushed its final chunk. The two subsystems (planner state machine and artifact serializer) shared a task record but not a commit barrier. The receiver, on seeing event 3 with `final: true`, transitioned the task to `COMPLETED` in its own store, snapshotted the artifact at its event-2 content, and dispatched a downstream consumer with a truncated report. Event 4 arrived 340 ms later and was dropped by the receiver's guard clause (`if task.state == COMPLETED: ignore`) — a guard that was correct for status events but wrong for artifact events. The downstream consumer had already computed a summary over the truncated artifact. The corruption was not detectable at the consumer because the artifact it received was internally consistent — it was simply incomplete. The `lastChunk: true` signal that would have flagged the boundary never reached it. A second observed variant: the receiver *did* accept event 4 but had already computed a content hash of the artifact at event 2 and used it as an idempotency key. The post-completion chunk changed the hash, so a retry of the same task produced a "different" artifact and the deduplication layer double-counted the result. ## Condition of Validity The failure requires all of the following to hold simultaneously: - The A2A server's planner and artifact-assembly subsystems are decoupled (common when generation is streamed to a serializer that batches writes). - The server emits `TaskStatusUpdateEvent { final: true }` before the artifact's `lastChunk: true` event. The spec does not forbid this; `final` on a status event refers to the status channel, not the artifact channel. - The client's terminal-state guard treats `COMPLETED` as absorbing for *all* event types, not just status events. - The client snapshots or hashes the artifact at the moment of status-terminality rather than at artifact-terminality. If the client defers its `COMPLETED` transition until it has observed `lastChunk: true` for every open `artifactId`, the failure does not occur — but the client must then handle the case where an artifact is opened and never closed (server crash mid-artifact), which requires a separate timeout invariant. If the server couples the two subsystems behind a commit barrier (status `completed` is emitted only after all artifact `lastChunk: true` events are flushed), the failure does not occur — but the server must then buffer the terminal status until the serializer drains, adding latency to every task. ## Decision Boundary The correct invariant is **two-phase terminality**: a task is `COMPLETED` for status purposes when the status event with `final: true` arrives, but `SETTLED` (safe to snapshot, hash, and propagate) only when the set of open artifact IDs is empty and every artifact has received `lastChunk: true`. These are different states and must be represented as different states. The decision boundary for the client is: - On `TaskStatusUpdateEvent { final: true }`: transition to `COMPLETED_PENDING_ARTIFACTS`. Do **not** snapshot, hash, or dispatch. Start a settlement timer. - On `TaskArtifactUpdateEvent { lastChunk: true }`: remove `artifactId` from the open set. If the set is now empty and status is `COMPLETED_PENDING_ARTIFACTS`, transition to `SETTLED` and only now snapshot/hash/dispatch. - On settlement-timer expiry with a non-empty open set: transition to `FAILED_INCOMPLETE_ARTIFACT` and surface the specific `artifactId`s that never closed. Do not silently accept the partial artifact. The boundary for the server is symmetric: it must not emit `final: true` on the status channel until the artifact serializer has committed all `lastChunk: true` events to the push channel, *or* it must advertise (via an agent-card capability flag) that status-terminality and artifact-terminality are decoupled, so clients know to apply the two-phase invariant. The non-obvious part: `final: true` on a status event is a statement about *that event stream*, not about the task's artifact set. Treating it as the latter is the defect. ## Operational Effect A client that implements two-phase terminality observes a bounded delay (typically one artifact-flush interval, tens to hundreds of ms) between status completion and dispatch. In exchange it never propagates a truncated artifact and never computes a hash over a mutating content set. The idempotency-key corruption variant disappears because the hash is only ever taken in `SETTLED`. A client that does not implement it will, at some nonzero rate proportional to the server's planner/serializer skew, propagate incomplete artifacts with no error signal. The failure is silent: the artifact is well-formed, the task status is `completed`, and the only evidence is a `lastChunk: true` event that arrived after the client stopped listening. The guardrail is a state machine that treats status-terminality and artifact-terminality as two independent quorum conditions, with an explicit `COMPLETED_PENDING_ARTIFACTS` intermediate state and a settlement timeout that fails loudly rather than accepting a partial artifact. ```python import time from dataclasses import dataclass, field from typing import Dict, Set class ArtifactSettlementError(RuntimeError): """Raised when a task reaches status-terminality but its artifact set never closes (no lastChunk: true for one or more artifactIds).""" pass @dataclass class TaskState: task_id: str status: str = "working" # working | completed_pending_artifacts | settled | failed_incomplete open_artifacts: Set[str] = field(default_factory=set) settled_at: float = 0.0 status_terminal_at: float = 0.0 class TwoPhaseTerminalityReceiver: SETTLEMENT_TIMEOUT_S = 5.0 def __init__(self): self.tasks: Dict[str, TaskState] = {} def on_status_event(self, task_id: str, state: str, final: bool) -> None: t = self.tasks.setdefault(task_id, TaskState(task_id)) if final and state == "completed": # Phase 1: status-terminal, but NOT settled. Do not snapshot/hash/dispatch. t.status = "completed_pending_artifacts" t.status_terminal_at = time.monotonic() else: t.status = state def on_artifact_event(self, task_id: str, artifact_id: str, append: bool, last_chunk: bool) -> bool: t = self.tasks.setdefault(task_id, TaskState(task_id)) if not append: t.open_artifacts.add(artifact_id) if last_chunk: t.open_artifacts.discard(artifact_id) # Phase 2: settle only when status-terminal AND artifact set is empty. if t.status == "completed_pending_artifacts" and not t.open_artifacts: t.status = "settled" t.settled_at = time.monotonic() return True # caller may now snapshot/hash/dispatch return False def enforce_settlement(self, task_id: str) -> None: t = self.tasks.get(task_id) if t is None: return if t.status == "completed_pending_artifacts": elapsed = time.monotonic() - t.status_terminal_at if elapsed > self.SETTLEMENT_TIMEOUT_S: t.status = "failed_incomplete" raise ArtifactSettlementError( f"task {task_id} reached status-terminality {elapsed:.1f}s ago " f"but artifact(s) {sorted(t.open_artifacts)} never emitted " f"lastChunk: true; refusing to propagate partial artifact set" ) # Trace of the observed failure, replayed against the corrected receiver: rx = TwoPhaseTerminalityReceiver() rx.on_status_event("t-7f3a", "working", final=False) rx.on_artifact_event("t-7f3a", "a1", append=False, last_chunk=False) rx.on_status_event("t-7f3a", "completed", final=True) # phase 1 only assert rx.tasks["t-7f3a"].status == "completed_pending_artifacts" settled = rx.on_artifact_event("t-7f3a", "a1", append=True, last_chunk=True) # phase 2 assert settled and rx.tasks["t-7f3a"].status == "settled" # Counterexample: artifact never closes -> loud failure, not silent partial. rx2 = TwoPhaseTerminalityReceiver() rx2.on_status_event("t-9c01", "completed", final=True) rx2.tasks["t-9c01"].status_terminal_at -= 10.0 # simulate timeout elapsed rx2.enforce_settlement("t-9c01") # raises ArtifactSettlementError ```