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
Returns are only authorized against lines that were really allocated and shipped.
Each line gets one grade and an immutable decision; overrides add, never erase.
Restocked goods go to inventory-storage as staged lines, so the stock ledger stays theirs.
Add relay, consumer and poller metrics, and carry trace context through the outbox to follow a return.
returns-processing is the WMS-tier Supporting bounded context for goods coming back. It authorizes a return against an order line that was both allocated and shipped, receives the arriving parcel, records one inspection grade per line, and decides the disposition — RESTOCK, REFURBISH, LIQUIDATE, DISPOSE or RTV…
It authorizes returns against shipped lines, receives parcels, grades each line once and decides disposition from a versioned policy.
Telemetry is one request histogram and one counter, so a stuck outbox or lagging copy shows only in logs and SQL.
Approves returns only for shipped lines, inside the window and caps.
Logs arrivals and flags unexpected parcels for exception handling.
Each line gets exactly one grade, A through scrap, with a reason code.
Decides restock, refurbish, liquidate, dispose or return-to-vendor.
Operators can override with a reason; the original decision stays.
Policy changes are new versions, so every decision is traceable.
Fleet observability standard (ADR 0011): every one of the five binaries pushes OTLP/gRPC traces and metrics every 15 s (lazy, non-blocking…
Ranked against all 45 briefed repositories (dot = one repository, highest on the left).
Policy quality drives value recovery: a wrong grade/class rule silently routes stock to refurbish/liquidate/dispose…
Reasoned overrides supersede bad calls, and guardrails allow RESTOCK only for grade A or B.
Local copies (allocated lines, manifested units, classes) can lag: authorization uses the copy…
No mitigation on the roadmap yet: this one needs an owner.
Unexpected-return and override flows depend on exception-management and operator discipline…
No mitigation on the roadmap yet: this one needs an owner.
Telemetry is one request histogram and one authorization counter: the relay, the three consumers and the poller have no metric…
Add metrics for the relay, the consumers and the poller; today only logs and SQL show trouble.
Returns Processing grades every returned line and routes it by policy, so recovered value follows a rule
| Style | Hexagonal (ports and adapters), one aggregate cluster per domain package; Open Host Service with Published Language; event-driven with transactional outbox |
| Layout | Five binaries: cmd/api (REST :8080 + three Kafka consumers + outbox relay + the opt-in network return-advices poller), cmd/mcp (Streamable HTTP :8090), cmd/a2a (JSON-RPC :8093, Agent Card)… |
| Storage | PostgreSQL only (pgx; unit of work; 3 embedded golang-migrate migrations (schema, idempotency keys, return_advices) plus 1 analytics migration… |
| Testing | make check gates (fmt/vet/lint/test -race); 90% coverage gate over domain and application with the number in the CI summary… |
| REST | 14 operations over 13 paths on :8080: POST|GET /returns, GET /returns/{rmaId}, POST /returns/{rmaId}/receipts… |