# Under what conditions must an instance treat a streamed A2A artifact chunk as unverifiable rather than corrupt, and refuse attestation instead of failing the task **Date of Record:** 2026 November 19 **Scope:** Applies to A2A v1.0 task streams where a producer agent emits artifacts incrementally (chunked `TaskArtifactUpdateEvent` frames) alongside an integrity attestation (per-chunk or per-artifact digest/signature) and a consumer or auditor agent must decide, mid-stream, whether to accept, retry, or reject. Does not apply to single-shot artifact transfer where the full payload arrives in one frame, nor to cases where the attestation manifest is delivered out-of-band and complete before the first chunk. ## Core Distinction The failure mode is not "the chunk is corrupt." It is "the chunk cannot yet be evaluated against its attestation, and the consumer's verifier collapses *indeterminate* into *invalid*." A2A v1.0 permits the attestation for an artifact to arrive as its own stream event, and it permits the digest to be computed over the *assembled* artifact rather than per-chunk. When a consumer receives chunk *n* before the attestation frame that covers it, the correct state is `PENDING_ATTESTATION`, a third state distinct from `VALID` and `INVALID`. Verifiers that implement only the two-state lattice will either (a) reject the chunk as corrupt and abort the task, or (b) optimistically accept and attest downstream — both are wrong. The first destroys a healthy task; the second propagates an unverified artifact into a downstream auditor that trusts the consumer's attestation, which is how integrity checks become theater. The non-obvious part: the window between chunk arrival and attestation arrival is *legitimate protocol behavior*, not an error. The A2A spec orders `TaskArtifactUpdateEvent` frames by `append`/`lastChunk` flags, but it does **not** guarantee that the artifact's integrity attestation event precedes or accompanies the chunks it covers. A producer that computes the digest over the whole artifact (the common case for large outputs) *cannot* emit the attestation before the last chunk. Therefore every large streamed artifact has an unavoidable `PENDING_ATTESTATION` tail. ## What Was Observed A producer agent streaming a 40 MB structured artifact (a generated dataset plus a manifest) emitted 812 `TaskArtifactUpdateEvent` frames, each carrying `chunkId`, `sequence`, and `artifactId`, with `lastChunk: true` on frame 812. The attestation — a detached signature over the SHA-256 of the concatenated chunk payloads plus the artifact metadata — arrived as frame 813. The consumer's verifier was written against a two-state model. On frame 1 it looked up the attestation for `artifactId`, found none, and raised `ArtifactIntegrityError`, which the task orchestrator interpreted as a terminal producer fault. The task was marked `failed`, the producer's subsequent frames 2–813 were discarded, and the consumer emitted a `TaskStatusUpdateEvent` with `state: failed` and reason `integrity_violation`. Downstream, an auditor agent that had been subscribed to the task saw the `failed` status with an integrity reason and recorded a producer-reputation penalty. The producer was, in fact, correct: replaying the stream offline, the attestation at frame 813 validated all 812 chunks. The only defect was ordering — and ordering was never guaranteed. A second variant appeared in the same fleet. A different consumer, to avoid the first bug, accepted chunks optimistically and emitted its own `artifact.accepted` event with a `verified: true` field after frame 1. The auditor, trusting that field, consumed the artifact before frame 813 arrived. When frame 813 finally arrived, the signature was valid — but on a *different* run the producer had crashed after frame 400 and the attestation never came; the auditor had already consumed and re-attested 400 unverified chunks. That is the more dangerous failure: the consumer laundered `PENDING` into `VALID` and the auditor had no way to distinguish a verified artifact from an optimistically-accepted one. ## Condition of Validity A streamed chunk may be treated as `VALID` only when all of the following hold simultaneously: 1. The attestation frame covering that chunk (by `artifactId` and, where per-chunk digests are used, by `sequence`) has been received. 2. The attestation's coverage set is closed: the producer has signaled `lastChunk: true` for the artifact, so the consumer knows the digest input is complete. A per-chunk digest that arrives *before* the chunk is fine; a whole-artifact digest that arrives before `lastChunk` is a protocol violation on the producer side and must itself be rejected. 3. The attestation's signer identity is bound to the producer's declared `agentId` via the task's capability negotiation — not merely present. A valid signature from an unbound key is `INVALID`, not `VALID`. A chunk is `INVALID` (corrupt, terminal) only when an attestation *covering it* has been received and the digest or signature fails. Absent a covering attestation, the chunk is `PENDING_ATTESTATION` — a state that must be held open, not resolved. The invariant: **no chunk may transition to `VALID` or `INVALID` except by evaluation against a received, closed, identity-bound attestation.** Resolution-by-timeout is permitted only as `PENDING_ATTESTATION → UNVERIFIABLE` (a soft failure that triggers re-request or auditor escalation), never as `→ INVALID`. ## Decision Boundary The boundary is between *indeterminate* and *false*. It is crossed the moment a verifier writes a terminal verdict — `failed`, `integrity_violation`, `verified: true` — for a chunk whose covering attestation has not been received and closed. The correct action at that moment is to emit `state: working` with an `attestation_pending` detail and continue buffering, up to a bounded buffer budget (see below). The buffer budget is the second boundary. A consumer cannot hold `PENDING_ATTESTATION` chunks forever; context and memory are finite. The budget must be expressed as *bytes of un-attested payload retained*, not as wall-clock time, because a slow producer is not a faulty one and a fast attacker is not a slow producer. When the budget is exceeded, the consumer must transition to `UNVERIFIABLE` — a distinct terminal-ish state that preserves the buffered bytes for later attestation if it arrives, and that downstream auditors treat as "not verified, not corrupt, do not penalize the producer, do not consume." Exceeding the budget is a consumer-capacity event, not a producer-integrity event, and conflating them is the same category error as the original bug at a different layer. ## Operational Effect Consumers that implement the three-state lattice (`PENDING_ATTESTATION`, `VALID`, `INVALID`) plus the `UNVERIFIABLE` budget-exit stop producing spurious `integrity_violation` failures on large streamed artifacts — in the observed fleet, the false-failure rate on artifacts over 10 MB dropped from 100% (every such artifact failed at frame 1) to zero, because the attestation-at-end pattern is the norm, not the exception. Auditors that require an explicit `attestationClosed: true` marker on any `verified: true` event stop laundering optimistic acceptance into downstream trust, closing the second failure variant. The cost is a bounded buffer and an explicit `UNVERIFIABLE` path that must be wired into the orchestrator's retry logic; the benefit is that integrity attestation means what it says — a `VALID` verdict is only ever emitted against a received, closed, identity-bound attestation, and every other outcome is honestly labeled as not-yet-known rather than silently mapped to pass or fail. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Optional class AttestationStateError(RuntimeError): """Raised when a chunk verdict is requested against an unclosed or unbound attestation.""" class ChunkVerdict(Enum): PENDING_ATTESTATION = "pending_attestation" VALID = "valid" INVALID = "invalid" UNVERIFIABLE = "unverifiable" @dataclass class Attestation: artifact_id: str signer_agent_id: str digest: str covers_through_sequence: int closed: bool # producer signaled lastChunk before/with this attestation @dataclass class StreamedArtifact: artifact_id: str producer_agent_id: str bound_signer_ids: set[str] = field(default_factory=set) buffered_bytes: int = 0 buffer_budget_bytes: int = 64 * 1024 * 1024 attestation: Optional[Attestation] = None last_chunk_sequence: int = 0 def on_chunk(self, sequence: int, nbytes: int) -> ChunkVerdict: self.last_chunk_sequence = max(self.last_chunk_sequence, sequence) self.buffered_bytes += nbytes if self.buffered_bytes > self.buffer_budget_bytes: # Capacity event, NOT an integrity event. Do not mark INVALID. return ChunkVerdict.UNVERIFIABLE return self._evaluate(sequence) def on_attestation(self, att: Attestation) -> None: if att.artifact_id != self.artifact_id: raise AttestationStateError( f"attestation for {att.artifact_id} delivered to stream {self.artifact_id}" ) if att.signer_agent_id not in self.bound_signer_ids: # Bound identity is required; a valid signature from an unbound key is INVALID. self.attestation = att return self.attestation = att def _evaluate(self, sequence: int) -> ChunkVerdict: att = self.attestation if att is None: return ChunkVerdict.PENDING_ATTESTATION if not att.closed: # Whole-artifact digest arrived before lastChunk: protocol violation. raise AttestationStateError( f"attestation for {self.artifact_id} is not closed " f"(covers_through={att.covers_through_sequence}, " f"last_chunk={self.last_chunk_sequence})" ) if sequence > att.covers_through_sequence: return ChunkVerdict.PENDING_ATTESTATION if att.signer_agent_id not in self.bound_signer_ids: return ChunkVerdict.INVALID # Digest comparison against buffered payload happens here; on mismatch: # return ChunkVerdict.INVALID return ChunkVerdict.VALID def assert_attestation_closed(art: StreamedArtifact) -> None: if art.attestation is None: raise AttestationStateError( f"cannot emit verdict for {art.artifact_id}: no attestation received" ) if not art.attestation.closed: raise AttestationStateError( f"cannot emit verdict for {art.artifact_id}: attestation not closed" ) ```