ADR 0009: A2A inbound adapter (a read-only agent)
Status
Accepted (2026-10-29).
Context
The fleet's agents talk to a bounded context over three transports that must not overlap: Kafka and CloudEvents carry facts; MCP carries an agent's tools (ADR 0006); the Agent2Agent (A2A) protocol carries the delegation of a goal from one agent to another, never data. last-mile-delivery already serves the first two (the outbox and consumers of ADR 0005, the read-only MCP server of ADR 0006) and had no way for a peer agent to hand it a goal such as "how is station X doing today" or "where does route R stand".
Decision
- A third driving adapter, a separate binary.
internal/adapters/inbound/a2ais built on the official A2A Go SDK (github.com/a2aproject/a2a-go/v2, pinned v2.7.0) and served over JSON-RPC 2.0 bycmd/a2a, mounted at/and/a2a, with the Agent Card at/.well-known/agent-card.jsonand an open/healthz. It is a third deployable besidecmd/apiandcmd/mcp, over the SAME read use cases (one action surface, three protocols). The chart gets ana2aDeployment and Service (default off, port 8093; 8080 is the api and 8090 the mcp server) plus an opt-in Kong HTTPRoute (/api/a2a/last-mile-deliveryrewritten to/, so the Agent Card stays reachable under the same prefix). - Two curated, goal-shaped READ skills, derived from the MCP tools.
list_waves(stationNodeId, serviceDate)answers "what does this station run on this day" (state, induct cutoff, delivery window, stop capacity with assigned and remaining stops) andget_route(routeId)answers "where does this route stand" (state, stops with their derived outcome, every recorded attempt). They bind theListWavesandGetRouteuse cases and keep the MCP tool names, so one name identifies one question across both agent-facing surfaces.get_wave_stopsstays an MCP-only tool: it lists the tracking numbers of a wave, which is data a delegating agent does not need to achieve a goal, and the budget is two skills, not one per endpoint. Every argument is required, like the REST query parameters and path variables. - Read-only is structural, and is the write gate. The MCP charter of ADR 0006
is entirely read-only (scheduling waves, planning routes, recording attempts
and the partner lifecycle stay on REST and the event consumers), so the agent
is read-only: delegation never widens what the context exposes. The adapter's
Depsholds the two read use cases and nothing else; neither the adapter norcmd/a2aimports an event sink, the outbox, a unit of work, the inbox, Kafka or a consumer.cmd/a2anever dials Kafka and never starts the relay or the consumers (those stay incmd/api), so it has noKAFKA_BROKERSand no consumer-group variables, and a skill can never insert an outbox row. A write skill would, if ever added, go through the same use case and transactional outbox as REST and the fact would still leave as a CloudEvent; that is a separate decision and an amendment of this ADR. - No sibling calls, no outbound client, no auth. The agent reads this
context's own tables only (
AGENTS.md: calls no sibling), contains no outbound A2A client, and has no auth layer (the fleet-wide revert of 2026-09-11): the Agent Card declares no security schemes and access control is the in-cluster ClusterIP boundary. Both are pinned by tests. - Message-only agent, strict input, answers in-band. The executor yields
exactly one agent
Message(a Data part with the envelope{skill, data | problem}and a Text part with a one-line summary) bound to the caller's context. The input is{"skill": "<id>", "arguments": {...}}as a Data part, or a Text part holding the same JSON, decoded withDisallowUnknownFieldsand trailing data rejected, so a misspelled argument can never be silently dropped. Rejections are ANSWERED as RFC 7807-shapedproblems in the envelope, never as JSON-RPC errors, with the same slug astypeand the same status as the REST adapter'sproblemCatalogue:not-found404 (ports.ErrNotFound),validation-failed422 (shared.ErrValidation),internal-error500 (anything else, logged, never echoed). The request-shape problems that only exist on this surface are 400:malformed-skill-request,unknown-skill,invalid-argument(a missing, blank, mistyped or unknown argument). Thedetailtext is adapter-owned, so the shared errors' own wording never reaches an agent. No shared domain error names a deprecated alias of an identifier here, so there is nothing to translate. - Observability. One OTel span per skill,
a2a.skill <id>with the attributea2a.skill, beside the router's fleet-standard server span, request log and duration histogram (ADR 0008); the telemetry service name defaults tolast-mile-delivery-a2a(chart:<otel.serviceName>-a2a). - Boot.
DATABASE_URLandA2A_AGENT_URLare mandatory and validated before telemetry, any connection and the listener (every problem reported at once);A2A_AGENT_URLmust be an absolute http(s) URL because the Agent Card advertises it. The chart defaults it to the release's in-cluster Service DNS (http://<release>-a2a.<ns>.svc.cluster.local:8093/) anda2a.agentUrloverrides it. Likecmd/apiandcmd/mcpthe binary runs the idempotent embedded migrations on start (optionalMIGRATIONS_DATABASE_URL).A2A_ADDR(:8093),LOG_LEVEL,SERVICE_VERSIONandENVIRONMENTcomplete the contract.
Consequences
- A peer agent can discover the agent from its card and delegate the two reads without REST glue or MCP session handling; the answer is a machine-readable envelope plus a one-line summary.
- Adding a skill is a reviewed act: the card, the
Depsallowlist (TestA2AAgentIsReadOnlyAndHasNoOutboundClient) and the tests change together. Any skill that writes needs its own ADR first. TestA2AAdapterDependencyRulekeeps the adapter additive (application and domain only; nothing depends on it);TestA2AReadOnlySensorBitesproves the allowlist detectors flag a write use case, a write seam and an outbound client.- The binary is a third consumer of the service database, as
cmd/mcpalready is; sizing and the connection budget of the pool apply to all three. - Not in this change: any write skill, a Task lifecycle or streaming, an outbound A2A client, authentication, and the warehouse-infra values that turn the component and its Kong route on.