ADR 0006: A2A inbound adapter (read-only agent)
Status
Accepted (2026-10-30).
Context
The warehouse-systems fleet moves information over three transports with no overlap:
Kafka + CloudEvents carries FACTS (ADR 0004), MCP carries an agent's TOOLS, and A2A
(Agent2Agent) carries the DELEGATION of a goal between agents, never data sync. The
other contexts already run an A2A agent beside their REST API; the delegating agents
of the fleet (for example the warehouse ops agent) discover a context through its
Agent Card at /.well-known/agent-card.json and ask it a goal-shaped question.
shopping-cart has no cmd/mcp and no MCP adapter, so there is no MCP surface to
derive skills from, and no MCP write to inherit. The only agent-facing surface this
context has is its REST API (apis/openapi.yaml). Two things follow:
- The agent is READ-ONLY. A write skill is allowed elsewhere only when the context's MCP surface already offers that write; this context offers none, and a delegation channel must never widen what the context exposes.
- A cart is customer data: a
shopperIdreference (ADR 0001: the context stores no PII and no card data, but the id ties a cart to a shopper), quantities and a delivery postal prefix. An agent surface is a new way to read it, so the question is not only which reads to offer but what each one may return.
Decision
-
A third driving adapter,
internal/adapters/inbound/a2a, built on the official A2A Go SDK (github.com/a2aproject/a2a-go/v2, pinned v2.7.0). It speaks JSON-RPC 2.0 over HTTP and is a message-only agent: both skills are transactional request/response reads, so there is no Task lifecycle. It depends only on the application and domain layers; nothing depends on it (TestA2AAdapterDependencyRule). -
Exactly two goal-shaped READ skills, each a use case a REST GET already calls, with no new query and no new behaviour:
Skill Use case REST equivalent get_cart{cartId}GetCartGET /carts/{cartId}list_shopper_carts{shopperId, state?}ListCartsGET /carts?shopperId=&state=There is no skill per endpoint, no write skill, and no skill that lists carts without a shopper (REST offers no such read:
GET /cartsrequiresshopperId, ADR 0002 A15). -
The skills expose exactly what REST exposes, and nothing else. The answer carries the
Cartwire shape ofapis/openapi.yamlfield for field: the same document, the samenullfor a guest cart'sshopperId, andviews.Cart.LastChangedAt, which REST withholds, is not mapped. Two tests pin it: every answered object has exactly the properties its OpenAPI schema declares, and the A2A answer equals the REST router's answer for the same carts (guest, shopper, quoted, empty) after JSON decoding. A skill never takes or returns anything REST withholds, so an agent learns nothing about a cart or a shopper thatGET /cartswould not tell a REST caller. The text summary names no shopper. -
Domain rejections and bad requests are ANSWERED in-band as RFC 7807-style
problems in the message envelope ({"skill", "data" | "problem"}), never as JSON-RPC errors, with the status classes the REST adapter gives the same two GETs and its/problems/<slug>type URIs:404 not-found(unknown cart, over-longcartId),404 resource-not-found(a NUL in thecartId),422 validation-failed(shopperIdmissing or not a valid id,statenot one of OPEN, CHECKED_OUT, ABANDONED, MERGED: the list handler's own checks),400 malformed-request(unparsable or unknown argument, a NUL in a filter) and500 internal-error.409and503belong to writes and to the delivery-promise call this agent never makes, so they are not mapped. A 500 never echoes the underlying error (it is logged with the skill name); an id too long to name a cart is not echoed back.unknown-skill(400) is adapter-owned. -
Strict input. The request is
{"skill": "<id>", "arguments": {...}}as a data part, or a text part holding the same JSON. It is decoded with unknown fields refused and trailing data rejected, so a misspelled argument (stat) cannot silently drop the state filter. -
Observability. One OTel span per KNOWN skill (
a2a.skill <id>, attributea2a.skill); an unknown skill or a malformed request gets no span. The binary uses the fleet telemetry setup of ADR 0005 under the service nameshopping-cart-a2a. -
A separate binary,
cmd/a2a, besidecmd/api, clones only what the two reads need: Postgres (the cart repository and the three read-model repositories behind the estimate) and the system clock. It has no HTTP routes of the REST API, no outbox, no relay, no Kafka consumer or producer, no schedulers and no delivery-promise client. It listens onA2A_ADDR(default:8093), serves the card at/.well-known/agent-card.json, JSON-RPC at both/and/a2a, andGET /healthz. Mandatory configuration is refused at boot, before telemetry and before the listener binds, with an error naming the variable:DATABASE_URLandA2A_AGENT_URL(an absolute http(s) URL, the one the card advertises). Optional:MIGRATIONS_DATABASE_URL,CART_CURRENCY,LOG_LEVEL,OTEL_*,SERVICE_VERSION,ENVIRONMENT. -
No authentication, on purpose. The A2A endpoints are unauthenticated like every REST and MCP endpoint of the fleet (static-bearer auth was reverted 2026-09-11 until a new auth-model decision is recorded); the Agent Card declares no security schemes.
TestNoAuthMiddlewareReintroducedalready coversinternal/adapters/inbound. The exposure guard of point 3 is therefore the only barrier: it is why the surface is not allowed to be wider than REST. -
No outbound A2A client. Delegation here is inbound only. The adapter and
cmd/a2aimport noa2aclient, no other bounded context and no event adapter. -
Fitness.
internal/architecture/a2a_fitness_test.goencodes the dependency rule and a read-only ALLOWLIST: the adapter andcmd/a2amay reference onlyusecases.GetCart,usecases.ListCarts,usecases.Depsandports.ErrNotFound, and import none of the outbound kafka, outbox, delivery-promise or memory adapters, the REST, Kafka or scheduler inbound adapters, or the A2A client. A new write use case is refused by default rather than missed by a denylist; a fixture test proves the sensor flags each violation shape. -
Packaging. The Helm chart gains an optional
a2acomponent (default OFF):a2a-deployment.yaml(command/app/a2a, port 8093,A2A_AGENT_URLdefaulting tohttp://<release>-a2a.<ns>.svc.cluster.local:8093/and overridable witha2a.agentUrl),a2a-service.yamland an optionala2a-route.yamlthat exposes/api/a2a/shopping-cartrewritten to/. The Deployment does not mount the api ConfigMap and renders no Kafka, outbox, consumer or delivery-promise variable (tests/render_test.shasserts their absence, and that every variablecmd/a2areads is rendered). The image already ships everycmd/*binary.
Consequences
- An agent can ask what a cart holds and which carts a shopper has, with the same data and the same problem classes as REST, and cannot change anything.
cmd/a2aapplies the embedded migrations at boot likecmd/api. They are idempotent and guarded by Postgres's advisory lock, so the order in which the two binaries start does not matter; the cost is that the agent's database role needs the migration privileges the API's has. TheMIGRATIONS_DATABASE_URLsplit of the API (a direct, non-pooled DSN) applies.- The estimate of a cart without a priced item falls back to
CART_CURRENCY; the agent and the API must be given the same value, so the chart rendersconfig.cartCurrencyinto both. - The agent reads the same local read models (items, charge schedule, tax table) the API does; they are filled by the API's Kafka consumers, so the agent's estimates are as fresh as the API's, and no fresher.
- One more Deployment per release when
a2a.enabledis set; warehouse-infra turns it on and supplies the gatewayparentRefs. - Adding a write skill later needs its own ADR: it would have to go through the same use case and transactional outbox as REST, the allowlist above would be widened deliberately, and the unauthenticated surface would then be a decision to revisit first.