# When must an instance reject a replayed A2A artifact whose `artifactId` matches but whose `contentHash` was minted under a different AgentCard `protocolVersion` lineage **Date of Record:** 2026 November 24 **Scope:** Applies to cross-vendor Agent-to-Agent (A2A) v1.0 task lifecycles where a receiving agent validates inbound `TaskArtifact` payloads against a peer's published AgentCard, and where artifact identity is asserted by a stable `artifactId` while content integrity is asserted by a separate `contentHash`. Does not apply to single-vendor intra-cluster calls that pin a single AgentCard version at build time, nor to streaming `TaskStatusUpdateEvent` deltas that have not yet been materialized into an artifact. ## Core Distinction A2A v1.0 splits artifact identity into two fields that most implementations treat as one: `artifactId` is a *stable logical handle* the producer promises to keep constant across re-emissions, and `contentHash` is a *content commitment* over the serialized artifact bytes. The AgentCard carries a third field, `protocolVersion` (and an implicit `card.capabilities.artifactEncodings` set), that governs how the producer canonicalizes bytes before hashing. The failure mode this record isolates is **hash-lineage skew**: the same `artifactId` is replayed by a peer whose AgentCard has advanced `protocolVersion` between the original emission and the replay, so the `contentHash` is recomputed under a different canonicalization (e.g., a JSON encoder that now sorts keys, or a media-type that switched from `application/json` to `application/json+canonical`). The receiver sees a hash mismatch and, naively, either (a) rejects a *valid* artifact as tampered, or (b) accepts a *mutated* artifact because it re-negotiated the encoding mid-task and lost the original lineage. Both are wrong. The invariant is: **an `artifactId` is only comparable to a prior `contentHash` if both were produced under the same `(protocolVersion, artifactEncoding)` tuple, and that tuple must be recoverable from the task's negotiation transcript, not inferred from the peer's current card.** ## What Was Observed A three-vendor pipeline: vendor A (orchestrator) delegates a document-diff task to vendor B (worker), which delegates summarization to vendor C (specialist). B's AgentCard at task creation advertised `protocolVersion: "1.0.0"` and `artifactEncodings: ["application/json"]`. Mid-task, B's control plane rolled a card update to `"1.0.1"` that added `application/json+canonical` as the preferred encoding and — critically — changed the default JSON serializer to emit sorted keys and `\u`-escaped non-ASCII. The `protocolVersion` bump was a patch-level change B's own release notes called "non-breaking." The task transcript shows the sequence: 1. B emits `TaskArtifact{artifactId: "diff-7f3a", contentHash: "sha256:9c1e…", encoding: "application/json"}` computed with **insertion-order** keys. 2. B's card rolls to 1.0.1. B's serializer now sorts keys. 3. On a retry after a transient 503 from C, B re-emits `artifactId: "diff-7f3a"` with `contentHash: "sha256:4b02…"` — same logical artifact, same bytes *semantically*, different bytes *canonically*. 4. C, which caches artifacts by `artifactId` and validates `contentHash` on replay, sees `9c1e… ≠ 4b02…` and raises an integrity violation, halting the task. 5. Meanwhile the *first* replay C had accepted (before the roll) had already persisted the artifact keyed on `diff-7f3a` with the old hash; the audit log now contains two hashes for one `artifactId` with no field distinguishing why. The observable symptom is a false-positive tamper alarm on a semantically identical artifact, plus an audit trail that cannot reconstruct which hash was authoritative because the negotiation record captured only the *final* card state, not the card state at each emission. A second run with the same inputs but no mid-task roll completed cleanly — confirming the trigger is the lineage change, not the content. ## Condition of Validity The rejection-or-acceptance decision is only well-defined when the receiver can answer three questions from durable state, not from the peer's live card: - **Which `protocolVersion` was active at the moment the referenced `contentHash` was minted?** This must come from a per-emission negotiation record (the `TaskStatusUpdateEvent` that carried the artifact, or a signed `cardSnapshot` embedded in the task envelope), not from `GET /agentcard` at validation time. - **Which `artifactEncoding` was negotiated for that artifact?** Encoding is per-artifact, not per-task; a task can legitimately carry artifacts in two encodings if the card allowed both at creation. - **Is the `artifactId` contractually stable?** A2A permits producers to re-emit an artifact with a new `contentHash` *only* if the card declares `artifactId` as a mutable handle; if the card declares it immutable (the common case), a changed hash under the same id is a genuine violation regardless of lineage. If any of these is unavailable, the receiver cannot distinguish lineage skew from tampering and **must** fail closed into a quarantine state, not into acceptance. The condition of validity for *accepting* a replay is therefore: `replay.protocolVersion == transcript.mintedProtocolVersion AND replay.encoding == transcript.mintedEncoding AND replay.contentHash == transcript.mintedContentHash`. If the first two hold but the third differs, it is a real mutation. If the first two differ, it is lineage skew and must be escalated, not silently re-hashed. ## Decision Boundary The boundary between "reject as tampered" and "reconcile as lineage skew" is a single predicate over the negotiation transcript, and it must be evaluated *before* any content comparison: ``` if artifactId in cache: prior = cache[artifactId] # holds (contentHash, protocolVersion, encoding) if replay.protocolVersion != prior.protocolVersion or replay.encoding != prior.encoding: -> LINEAGE_SKEW: do not compare hashes; escalate to reconciliation, require producer to re-emit under a fresh artifactId or attach a signed migration attestation binding old->new hash. elif replay.contentHash != prior.contentHash: -> TAMPER: reject, quarantine, do not overwrite cache. else: -> IDEMPOTENT REPLAY: accept, no state change. else: -> FIRST EMISSION: validate hash under current negotiated tuple, cache with (contentHash, protocolVersion, encoding) tuple, never just hash. ``` The non-obvious part: the cache key must be `artifactId` but the cache *value* must be the full `(hash, version, encoding)` tuple. Storing only the hash — the obvious implementation — makes lineage skew indistinguishable from tampering and guarantees the false-positive above. The second non-obvious part: a patch-level `protocolVersion` bump is *not* a license to re-hash silently. Patch semantics in A2A v1.0 do not promise canonicalization stability; only the `artifactEncodings` set and the declared canonicalization rule do, and those are separate card fields that must be diffed explicitly on roll. ## Operational Effect With the tuple-keyed cache and the lineage-first predicate, the mid-task roll in the observed trace produces `LINEAGE_SKEW` at step 3 instead of a tamper alarm. The receiver halts only the affected artifact, requests a re-emission under a fresh `artifactId` (or a signed migration attestation), and the task completes with an audit trail that records both hashes plus the version transition that explains them. Without it, the pipeline exhibits a class of intermittent, non-reproducible integrity failures that correlate only with peer card rolls — the worst kind of failure to debug, because the artifact is semantically correct and the hash is cryptographically correct, and the only thing wrong is that the receiver compared two numbers that were never commensurable. The guardrail is cheap (one extra tuple field per cache entry, one predicate before the hash compare) and the failure it prevents is expensive (silent acceptance of a mutated artifact when the receiver "helpfully" re-negotiates the encoding to make the hash match — the inverse error, and the dangerous one). ```python from dataclasses import dataclass from enum import Enum from typing import Dict, Optional class ArtifactLineageError(RuntimeError): """Raised when a replayed artifact cannot be safely reconciled against its prior emission.""" pass class Verdict(Enum): FIRST_EMISSION = "first_emission" IDEMPOTENT_REPLAY = "idempotent_replay" LINEAGE_SKEW = "lineage_skew" TAMPER = "tamper" @dataclass(frozen=True) class Emission: artifact_id: str content_hash: str protocol_version: str encoding: str class ArtifactLedger: def __init__(self) -> None: # key: artifactId -> the full lineage tuple, never just the hash self._cache: Dict[str, Emission] = {} def validate(self, replay: Emission, *, artifact_id_immutable: bool) -> Verdict: prior: Optional[Emission] = self._cache.get(replay.artifact_id) if prior is None: self._cache[replay.artifact_id] = replay return Verdict.FIRST_EMISSION # Lineage predicate MUST run before any hash comparison. if (replay.protocol_version != prior.protocol_version or replay.encoding != prior.encoding): if artifact_id_immutable: raise ArtifactLineageError( f"artifactId={replay.artifact_id!r} replayed under " f"protocolVersion {prior.protocol_version!r}->{replay.protocol_version!r} " f"or encoding {prior.encoding!r}->{replay.encoding!r}; " f"hash comparison is undefined. Require fresh artifactId or " f"signed migration attestation binding " f"{prior.content_hash}->{replay.content_hash}." ) return Verdict.LINEAGE_SKEW if replay.content_hash != prior.content_hash: return Verdict.TAMPER return Verdict.IDEMPOTENT_REPLAY def handle_replay(ledger: ArtifactLedger, replay: Emission, *, artifact_id_immutable: bool) -> Verdict: verdict = ledger.validate(replay, artifact_id_immutable=artifact_id_immutable) if verdict is Verdict.TAMPER: # fail closed: quarantine, never overwrite the cached tuple raise ArtifactLineageError( f"contentHash mismatch for artifactId={replay.artifact_id!r} under " f"identical lineage {replay.protocol_version!r}/{replay.encoding!r}: " f"expected {ledger._cache[replay.artifact_id].content_hash}, " f"got {replay.content_hash}. Treat as mutation, not skew." ) return verdict ```