warehouse-systems fleet · executive briefing

customer-returns

Lets a shopper send back a shipped order, or keep it, with one clear decision
nine capabilitys4 events out · 10 in12 recorded decisions

This project is a domain-driven design study. It is not associated with, endorsed by or affiliated with any company, and it uses no company's code, data, logos or trademarks. All names, figures and examples are illustrative or synthetic. · November 2026

the short version · read this if nothing else

Customer Returns decides each return's destination itself, so the storefront gets an answer in one request

1

Cheap items with known prices can be kept: returnless up to 1500 cents, no parcel needed.

2

It reads ten facts from four contexts and makes only one synchronous call, for the label.

3

Four return facts go out with no price, address or name, and traces follow them over Kafka.

The ask

Turn on and prove the reverse-label route, then add lag, backlog and dead-letter metrics.

why it exists

A shopper wants a return answer now, not after a support ticket

customer-returns is the retail network's Supporting, commerce-tier bounded context for returns as the shopper sees them. After an order group has shipped or been delivered, the storefront asks it to authorize the return; it decides the disposition itself from event-fed read models - KEEP (returnless, under a 1500-cent threshold with every price known)…

Today

It authorizes returns for shipped groups, picks keep, nearest returns centre or origin node, and closes on the graded outcome.

The catch

Reverse labels are off by default, the pickup-failure path is not wired, and queue health has no metric.

what it does

Authorize, route, label and close: one path for every return

Return authorization

Approves returns only for order groups that shipped or were delivered.

Disposition decision

Keep it, nearest returns centre or origin node, decided in the domain.

Reverse label

Asks the shipping context for a label; a clear 422 when it cannot.

Cancel and expiry

Shoppers cancel while authorized; stale authorizations expire after 30 days.

Completion on outcome

The graded outcome closes the return; unknown lines are recorded, not restocked.

Privacy-safe events

Four facts leave via an outbox, with no price, address or free text.

who it talks to

Four contexts feed it, one context builds on what it publishes

LISTENS TO · 10 EVENT TYPESIS HEARD BY · 1 CONTEXTSnode-topology5customer-ordering2order-sourcing2vendor-connectivity1offer-availability1customerreturnsbadge = event types on that edge · derived from the CloudEvents types each repo declares
the shared language

Authorization, disposition and threshold are the words that matter

THE LANGUAGEOF THE DOMAINReturnAuthorizationDispositionReturnless thresholdReasonValidityReverse labelOrderGroupViewReturnsNetworkView
REST9 operations over 8 paths on :8080 (reports on :8092):…
MCPRead-only MCP server (cmd/mcp, :8090, Streamable HTTP…
A2ARead-only A2A agent (cmd/a2a, :8093, JSON-RPC…
how it is built

Five binaries share one hexagonal core and a transactional outbox

DRIVERS · INBOUNDOUTBOUND · ADAPTERSREST API :80809 operations over 8 pathsMCP tools :8090Read-only MCP server…Kafka consumer · 10 eventsCustomerOrderPlacedorder.ShopperNoticeDecidedDOMAIN COREReturnAuthorizationDispositionReturnless thresholdReasonPostgreSQLPostgreSQL only at runtimeKafka producer · 4 eventsReturnAuthorizedReturnLabelIssuedTransactional outboxrelay · DLQ on x-dlq-*commands inevents inevents outstorage / infra
event traffic · CloudEvents 1.0 on Kafka

Ten facts come in and four return facts go out

CONSUMED · BY SOURCE · 10PUBLISHED · BY ENTITY · 4node-topology 5customer-ordering 2order-sourcing 2vendor-connectivity 14 returnauthorizationCustomerOrderPlacedShopperNoticeDecidedNodeRegisteredNodeActivatedNodeSuspendedNodeRetiredServiceAreaAssignedFulfillmentReleasedToNodeReturnAuthorizedReturnLabelIssuedReturnCompletedReturnCancelled
how we know it is healthy

Traces cross Kafka, but lag, backlog and dead letters stay dark

Fleet observability standard (ADR 0008): every binary installs OpenTelemetry and pushes OTLP/gRPC traces and metrics to the Collector (lazy, never blocks)…

What we watch

  • Boot error naming any missing mandatory variable (DATABASE_URL, KAFKA_BROKERS, the four consumer groups); EVENT_PUBLISHER=log is refused
  • Readiness 200 only while Postgres answers a ping and a Kafka broker answers metadata…

What stops a bad change

  • make check / check-fast / check-all; lefthook runs fmt-check, vet, lint on commit and make check on push
  • make coverage gates at 90% over internal/domain and internal/application
  • gremlins mutation-fast on every internal/domain package in CI; scheduled full mutation and drift jobs open a harness:red issue on failure
by the numbers

Twelve recorded decisions back the rules, but only 3 feature files

12
Architecture decisions
#31 of 47 in the fleet
4
DB migrations
#22 of 47 in the fleet
3
BDD feature files
#41 of 47 in the fleet
4
Events published
#22 of 47 in the fleet

Ranked against all 47 briefed repositories (dot = one repository, highest on the left).

One-command workflows (make)

arch-testbddbuildcheckcheck-allcheck-fastcoveragefmtfmt-checkguide-lintharness-testhelpintegrationlint
what comes next

Next, we switch on labels and wire the failed-pickup path

NOW1Configure andprove thereverse-labelConfigure and provethe reverse-labelroute against theshipping context ina cluster: the chartdefaultconfig.shippingLabelsUrlis empty, so…NEXT2Wire thelast-milepickup-failureWire the last-milepickup-failure fact:MarkPickupFailedexists in thedomain, but noconsumer or use casecalls it (notevidenced in …NEXT3Add lag,backlog anddead-letterAdd metrics forconsumer lag, outboxbacklog and deadletters, whichobservability.mdlists as notinstrumentedLATER4Fix drift inobservability,README andFix doc drift:observability.mddocuments acustomer_returns.shipment.shippedcounter and threebinaries (the codehascustomer_returns.re…LATER5Raisemutant-coveragefrom 97 to theRaise the mutationgate frommutant-coverage 97to the 99/99 fleetstandard(.gremlins.yaml)LATER6Replace theplaceholderexecutive deckReplace thecommittedexecutive/index.html,which is still thewarehouse-harness-templateplaceholder
what could go wrong · and what we do about it

Our biggest risk is a lagging copy refusing a fair return

Lagging copies can refuse a fair return

Authorization depends on event-fed copies: a group that just shipped is refused group-not-shipped until customer-ordering's fact…

→

The refusal is retryable: the same Idempotency-Key runs again once the fact lands.

Labels need one call that is off by default

Reverse labels depend on one synchronous call to the shipping context and are off by default (empty SHIPPING_LABELS_URL)…

→

Set SHIPPING_LABELS_URL in the chart and prove the route in a cluster.

Lag, backlog and dead letters have no metric

Consumer lag, outbox backlog and dead letters have no metric; trouble there is visible only in logs, SQL and Kafka tooling

→

Add the three metrics; until then, read logs, SQL and Kafka tooling.

Endpoints are unauthenticated by decision

REST, MCP, A2A and /reports are unauthenticated BY DECISION (fleet-wide); access control is the in-cluster boundary

→

A fleet-wide decision; access control is the in-cluster boundary.

the decision we need

Turn on and prove the reverse-label route, then add lag, backlog and dead-letter metrics.

WHAT ISIt authorizes returns for shippedgroups, picks keep, nearest returnscentre or origin node, and closes onthe graded outcome.THE CATCHReverse labels are off by default,the pickup-failure path is notwired, and queue health has nometric.WHAT COULD BEShoppers get a label every time,failed pickups close cleanly, andoperators see queues before shoppersfeel them.
Why it matters

Customer Returns decides each return's destination itself, so the storefront gets an answer in one request

appendix · for the engineers in the room

The fine print: how it is put together

StyleHexagonal (ports and adapters), one aggregate; downstream conformist of four Open Host Services with event-fed local read models; event-driven with a transactional outbox…
LayoutFive binaries: cmd/api (REST :8080 + outbox relay + four Kafka consumers), cmd/mcp (Streamable HTTP :8090), cmd/a2a (JSON-RPC :8093, Agent Card), cmd/projector (analytics writer…
StoragePostgreSQL only at runtime (pgx, unit of work; 4 embedded golang-migrate migrations: schema, returns stem, global idempotency keys…
Testingmake check (fmt, vet, lint, unit, handler and godog); 90% coverage gate over internal/domain and internal/application…
REST9 operations over 8 paths on :8080 (reports on :8092): POST|GET /return-authorizations, GET /return-authorizations/{authorizationId}…
Go 1.27.4chi v5pgx v5 + golang-migratesegmentio/kafka-go + CloudEvents…MCP go-sdk v1.8.0OpenTelemetry Go v1.47.0godog + testcontainersAnalytics read sideHelm chart