Returns Processing
returns-processing is the bounded context that owns the reverse flow: goods coming back. It
authorizes a return against an order line that was both allocated (order-management) and
shipped (fulfillment-execution's manifest), receives the arriving parcel, records one inspection
grade per line, and decides the disposition — RESTOCK, REFURBISH, LIQUIDATE, DISPOSE
or RTV — from a versioned DispositionPolicy keyed on grade and product classification. It
never writes the stock ledger: a RESTOCK disposition hands the goods to inventory-storage as a
staged line (ReturnLineStaged), and the stow stays an RF action there.
| Tier | WMS (CloudEvents type segment wms, source /warehouse/returns-processing) |
| Subdomain class | Supporting (reasoning) |
| Binaries | two: cmd/api (REST, outbox relay and three Kafka consumers in one process, all always on) and cmd/mcp (read-only MCP over Streamable HTTP, default-off chart component) |
| Datastore | PostgreSQL (required: there is no in-memory mode) |
| Messaging | Kafka, CloudEvents 1.0 structured mode, transactional outbox (ADR 0005) |
| Auth | none (fleet decision 2026-09-11) |
| Repository | IQVO/returns-processing, site https://iqvo.github.io/returns-processing/ |
What it owns
- ReturnAuthorization (RMA): permission to send one shipped order line back, in the states
REQUESTED → AUTHORIZED | REJECTED → RECEIVED → CLOSED. One open RMA per order line. - ReturnReceipt: the physical arrival, opened against an RMA or, for a parcel with no RMA, with
explicitly
UNEXPECTEDlines. A line is inspected exactly once (gradeA/B/C/SCRAP + reason codes). - Disposition: the immutable decision per inspected line —
f(grade, classification, policy version). An operator override is a NEW disposition carryingsupersedesand a mandatory reason. - DispositionPolicy: the versioned operator table (grade × product class → outcome, return window days, max units per line, veto outcome). Data, not code: a change is a new version.
It does not own orders, shipments, classifications or stock. Those arrive as events into local
copies (allocated_lines, manifested_units, product_classes); the service
never calls a sibling context over REST or MCP (ADR 0003).
Main capabilities
- Authorize returns with
POST /returns, against the local copy of the manifested work unit{order_id}-line-{line_no}, inside the policy window, quantity capped bymax_units_per_line— or reject with a code (LINE_NOT_MANIFESTED,RETURN_WINDOW_EXPIRED,OPEN_RMA_EXISTS,QUANTITY_EXCEEDS_POLICY). - Receive parcels with
POST /returns/{rmaId}/receipts; a line with no RMA is received as explicitly UNEXPECTED and raisesUnexpectedReturnReceivedfor exception-management. - Inspect lines with
POST /receipts/{receiptId}/lines/{lineNo}/inspections; the grade is recorded and the disposition decided by the current policy in the same transaction. - Override a disposition with
POST /dispositions/{id}/overrides(reason mandatory); the original stays immutable. - Declare policy versions with
PUT /disposition-policies/{version}(append-only). - Publish
ReturnAuthorized,ReturnAuthorizationRejected,ReturnReceiptOpened,ReturnLineInspected,UnexpectedReturnReceived,DispositionDecidedandReturnLineStagedonwarehouse.returns-processing.eventsthrough the transactional outbox. - Answer read-only questions over MCP:
get_return,list_returns_by_order,get_disposition_policy(MCP tools).
Status of the chain
Checked on each sibling's origin/develop (2026-10-21): the three upstream feeds are live —
product-master publishes ProductClassified, order-management publishes OrderAllocated /
OrderPartiallyAllocated, fulfillment-execution publishes PackageManifested — and both downstream
edges are built: inventory-storage consumes ReturnLineStaged into its staged-receipt use case (its
ADR 0044) and exception-management consumes UnexpectedReturnReceived to open a problem-solve case.
Two gaps are recorded as roadmap, never faked: order-management's allocated lines carry
no quantity, so the authorized quantity is capped by policy only; and inventory-storage's
ItemStowed is on its integration topic (its ADR 0043) but this service does not consume it yet, so a
staged line's stow is invisible here (ADR 0003).
The service is packaged (Helm chart with an api component and a default-off read-only mcp component)
but not yet registered in warehouse-infra and has cut no release
(Runbook).
Where to go next
| I want to | Page |
|---|---|
| understand the layout and the moving parts | Architecture |
| know why the flow exists, business-first | Business context |
| run it and make the first calls | Quickstart |
| configure it | Configuration |
| deploy, migrate and operate it | Runbook |
| watch it | Observability |
| debug it | Troubleshooting |
| read the language term by term | Ubiquitous language |
| read the REST and event contracts | API reference, Event catalogue |
| call it from an agent | MCP tools |
| see why it was built this way | ADR index, Bounded context canvas |
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.