ADR 0009: an A2A inbound adapter (read-only)
Status
Accepted (2026-10-29). Follows ADR 0006 (the read-only MCP adapter this one is derived from) and ADR 0004 (CloudEvents on every Kafka message). Mirrors the reference rollout in workforce-management (ADR 0039) and wes-work-planning (ADR 0046).
Context
The fleet is adopting the Agent2Agent (A2A) protocol so that a bounded context
can delegate a goal to another context's agent. order-sourcing already
exposes its two reads over REST and MCP (usecases.Queries:
ListAssignments, GetAssignment). Three transports now carry three different
things and must not overlap:
| Transport | Carries |
|---|---|
| Kafka + CloudEvents | facts between contexts (ADR 0004) |
| MCP | an agent's tools |
| A2A | delegation of a goal to another context's agent, never data sync |
Decision
-
A third driving adapter, a separate binary.
internal/adapters/inbound/a2ais built on the official A2A Go SDK (github.com/a2aproject/a2a-go/v2v2.7.0) and served bycmd/a2a: JSON-RPC 2.0 over HTTP, port 8093, the Agent Card at/.well-known/agent-card.json, the endpoint mounted at/and/a2a, an open/healthz. It is a third deployable besidecmd/apiandcmd/mcp; the Helm chart gets an a2a Deployment, Service and (off by default) Gateway API HTTPRoute (/api/a2a/order-sourcingrewritten to/), all behinda2a.enabled(default off). -
The write gate: the agent is READ-ONLY. A2A skills may change state only if the context's MCP surface already offers that write. The MCP charter of ADR 0006 is read-only (no write tool,
TestToolSurfacefails the build on a write verb), so this agent offers no write either: delegation must never widen what the context exposes.POST /assignments/{id}/reoptimisationsstays REST-only and every other lifecycle change arrives as a consumed Kafka event handled bycmd/api. -
Two curated, goal-shaped skills, derived from the two MCP tools (not one per endpoint):
Skill Kind What it does find_assignmentsread which shipment groups match: state?,orderId?,nodeId?,limit?(1..500, default 100), ordered by assignmentId; the sameListAssignmentsread asGET /assignmentsandlist_assignmentsassignment_detailread one assignment in full by assignmentId: promise, lines, candidate and cost, release point and history, excluded nodes, lock and shipment facts; the sameGetAssignmentread asGET /assignments/{assignmentId}andget_assignmentA request is a message whose first part is
{"skill":"<id>","arguments":{...}}(a data part, or a text part holding the same JSON). The argument names and the result bodies are the REST/MCP ones (lowerCamelCase); domain structs never cross the boundary. -
Message-only, answered in-band. Both skills are request/response reads, so the agent has no Task lifecycle. Domain rejections and malformed requests are answered as RFC 7807-shaped
problems inside the message envelope, never raised as JSON-RPC errors, with the same classification and slugs as the REST adapter (internal/adapters/inbound/http/errors.go), restricted to what a read can raise:404 not-found(unknown id),422 validation-failed(unknown state, limit outside 1..500: the REST status ofshared.ErrValidation),500 internal-error(anything else, with a generic detail: DSNs and SQL text never reach the caller). Request-shape failures are400:malformed-request(unusable part, not JSON, unknown field, wrong type, trailing data, a NUL character in a filter),unknown-skill,invalid-argument(missingassignmentId). A NUL inassignmentIdis a404 resource-not-found, as REST answers a NUL in the URL path. No503or409is reachable from a read. -
Strict input. Unknown argument names are rejected, not ignored, and so is trailing data: a misspelled
ordrIdmust not silently drop a filter and answer with every order. (Go'sencoding/jsonmatches names case-insensitively, soorderidstill reachesorderId.) The two skills take the same canonical names as the MCP tools; no deprecated alias exists in this context's errors or arguments, and a test pins that an infrastructure failure leaks no text. -
Read-only is structural. The adapter's
Depsholds exactlyQueries *usecases.Queries; the adapter andcmd/a2aimport no outbox, no event sink, no Kafka adapter and no sweep, andcmd/a2anever dials Kafka, never runs the consumers, the relay or the sweep (noKAFKA_BROKERS, noEVENT_PUBLISHER).internal/architecturepins it:TestA2AAdapterDependencyRule(depends only on application and domain; nothing depends on it),TestA2AAgentIsReadOnly(no write use case inDepsor body),TestA2AHasNoOutboundClient(noa2aclientin production code: this context calls no sibling) andTestA2ABinaryIsKafkaFreeAndReadOnly. The skill ids carry no write verb (TestCardOffersNoWriteSkill). -
Tests over the real wire. The skills are driven through
httptestand the SDK's own client (a2aclient.NewFromCard) with a test-local envelope struct, so contract drift fails the suite.cmd/a2ahas boot-config refusals, router and card tests, and a//go:build integrationtest that reads what the domain's write path persisted in a real Postgres through both skills and proves the reads add nooutbox_eventsrow. -
Observability. One OTel span per skill run (
a2a.skill <id>, attributea2a.skill), likemcp.tool <name>; the router carries the fleet middleware of ADR 0008. -
Unauthenticated, no sibling calls. The card declares no security schemes: the surface is unauthenticated by the same fleet-wide decision as REST and MCP (the revert of 2026-09-11;
TestNoAuthMiddlewareReintroducedscans this adapter too). Access control is the in-cluster ClusterIP boundary. -
Boot.
DATABASE_URLandA2A_AGENT_URLare mandatory, each a boot error naming the variable raised before telemetry, any connection and the listener.A2A_AGENT_URLmust be an absolute http(s) URL (the card advertises what clients dial); the chart defaults it tohttp://<fullname>-a2a.<namespace>.svc.cluster.local:8093/anda2a.agentUrloverrides it.A2A_ADDRdefaults to:8093. The binary runs the idempotent embedded migrations on start likecmd/mcp.
Consequences
- A delegating agent can ask "where does order X ship from, which node holds group 2, why was node Y excluded" with the A2A goal-shaped contract, with the same outcomes a REST caller sees.
- A third deployable (
/app/a2a) in the same image; the Dockerfile builds everycmd/*, so no build change beyond the documentedEXPOSE 8093. - Adding a skill, above all a write, is a reviewed act: it needs the MCP
surface to offer it first (an amendment of ADR 0006), then this ADR, the
Depspin and the card tests change together. A write skill would also need the transactional outbox incmd/a2a, an integration test proving UNPUBLISHED outbox rows, and the relay stays incmd/api. - Port 8093 is the fleet's A2A port (8080 is the api, 8090 the MCP server).