37. Site role: an explicit network role on the Site aggregate
Status
Accepted (2026-10-13, final-gaps wave decision E2). Extends
ADR 0035: the transfer
capability stays a per-site, explicit, revisioned command; this record adds
the fact that tells an operator (and a seed) WHICH capability a site should
have. Reuses the Site version guard of
ADR 0025 as extended by
ADR 0035.
Context
Inter-site stock transfers (network-inventory-planning) rebalance inventory
between nodes that hold inventory. ADR 0035 made the capability an explicit
opt-in per site, but nothing said which sites the ecosystem needs enabled.
The kind of node a building is (a Non-Sortable Fulfillment Center, a
Delivery Station, an Inbound Cross-Dock) existed only inside the seeded
display name, for example ABE8 - Non-Sortable Fulfillment Center (Breinigsville, PA). Deriving behaviour from a display name is wrong: a name
is free text, can be edited, and is not a contract.
The ecosystem decision (E2) fixes the capability each role needs:
Role (siteRole) | Origin | Destination | Why |
|---|---|---|---|
ROBOTICS_SORTABLE_FC | yes | yes | stores ambient inventory |
NON_SORTABLE_FC | yes | yes | stores ambient inventory |
TRADITIONAL_SORTABLE_FC | yes | yes | stores ambient inventory |
SUB_SAME_DAY_FC | yes | yes | stores ambient inventory |
FRESH_GROCERY_FC | no | no | perishable, short shelf life: no rebalancing between FCs |
XL_FC | yes | yes | stores ambient inventory |
SOFT_LINES_SORTABLE_FC | yes | yes | stores ambient inventory |
MICRO_FC | no | yes | urban forward node replenished from FCs, never a source |
SIMULATED_FC | yes | yes | the simulation FC behaves like an ambient FC |
INBOUND_CROSS_DOCK | yes | no | pushes inbound stock into FCs |
NATIONAL_INBOUND_CROSS_DOCK | yes | no | pushes inbound stock into FCs |
RETURNS_CENTER | yes | no | resellable returns go back to FCs |
SORTATION_CENTER | no | no | parcel network, no storage |
DELIVERY_STATION | no | no | parcel network, no storage |
AIR_HUB_GATEWAY | no | no | parcel network, no storage |
Decision
-
siteRolelives on the Site aggregate as thesite.Rolevalue: the 15 roles above as stable UPPER_SNAKE wire values, plusUNSPECIFIEDfor a site nobody classified.site.ParseRoleis exact (case and spelling); anything else isErrInvalidSiteRole, REST/MCP sluginvalid-site-role(422). -
Set at registration.
POST /sitestakes an optionalsiteRole; omitted meansUNSPECIFIED.SiteRegisteredcarries it as an additivesiteRolefield (camelCase, like the rest of that payload). A site created by the bulk import (POST /location-imports) isUNSPECIFIED. -
Changed by command.
PUT /sites/{siteCode}/rolewith{"siteRole": "<ROLE>"}.Site.ChangeRole:- rejects
UNSPECIFIED, an unknown or a missing role (invalid-site-role); - treats the current role as an idempotent no-op (200, no event, so no Idempotency-Key);
- rejects a decommissioned site (
site-not-active, as ADR 0035); - otherwise sets the role, and the use case saves the row and publishes
SiteRoleChanged(siteCode,siteRole,previousSiteRole; camelCase) through the transactional outbox in one unit of work. Kafka key and CloudEvents subject are the site code, so one site's changes stay ordered. Thesites.versionguard serialises concurrent writers; the loser gets 409concurrent-modificationand its outbox row rolls back.
- rejects
-
A role never flips capability. Neither registration nor a role change touches the transfer capability or publishes
SiteCapabilityChanged. Capability stays the explicit ADR 0035 command. -
One source of truth for the defaults. The table above lives in the domain (
site.TransferDefaults()) and is exposed read-only asGET /site-roles/transfer-defaults(one row per assignable role, stable order;UNSPECIFIEDhas no row, so an unclassified site's capability is left as it is). The warehouse-infra seed reads it and PUTs the capability once per Active site (decision E2); operators read the same endpoint instead of a copied table. -
Exposed on every site read.
GET /sites,GET /sites/{siteCode}, the site header ofGET /sites/{siteCode}/layout, and the MCPlist_sites/get_site_layouttools carrysiteRole. -
One-time backfill (migration 0009). The migration adds
sites.site_role TEXT NOT NULL DEFAULT 'UNSPECIFIED'with a CHECK of the 16 values, then classifies the rows that already exist from the seeded name pattern<CODE> - <Role words> (<city>). The role words are the name with its leading<CODE> -removed; a role matches only when its exact phrase is followed by(:Role words siteRoleRobotics Sortable Fulfillment Center (…ROBOTICS_SORTABLE_FCNon-Sortable Fulfillment Center (…NON_SORTABLE_FCTraditional Sortable Fulfillment Center (…TRADITIONAL_SORTABLE_FCSub-Same-Day Fulfillment Center (…SUB_SAME_DAY_FCFresh Grocery Fulfillment Center (…FRESH_GROCERY_FCXL (Extra-Large) Fulfillment Center (…XL_FCSoft-Lines Sortable Fulfillment Center (…SOFT_LINES_SORTABLE_FCMicro-Fulfillment Center (…(incl.(store-attached))MICRO_FCSimulated FC (…, or the whole nameSimulated FC(siteSIM1)SIMULATED_FCInbound Cross-Dock (…INBOUND_CROSS_DOCKNational Inbound Cross-Dock (…NATIONAL_INBOUND_CROSS_DOCKReverse Logistics / Returns Center (…RETURNS_CENTERSortation Center (…SORTATION_CENTERDelivery Station (…DELIVERY_STATIONAir Hub Gateway (…AIR_HUB_GATEWAYanything else UNSPECIFIEDThe backfill does not bump
sites.versionand publishes noSiteRoleChanged: it records what the names already said, once. From then on the name is display text only and the role changes only by command.
CloudEvents type catalogue entry
This record adds one type to this service's catalogue (the table in ADR 0024, whose body stays as written):
CloudEvents type | Kafka key | subject |
|---|---|---|
com.warehouse.wms.facility-layout.site.SiteRoleChanged | siteCode | siteCode |
dataschema is urn:warehouse:facility-layout:events:SiteRoleChanged:v1;
the payload is camelCase (siteCode, siteRole, previousSiteRole).
SiteRegistered keeps its type and v1 dataschema: siteRole is an
additive field.
Consequences
- The capability decision becomes reviewable data: a seed or an operator
reads
GET /site-roles/transfer-defaultsandGET /sitesand applies the difference with the ADR 0035 command; no repo hard-codes the table. - A new role needs a code change (domain table, OpenAPI/AsyncAPI enums) and a new migration extending the CHECK. That is deliberate: a role is a contract value.
- Consumers that cached sites before migration 0009 never saw a
SiteRoleChangedfor the backfill; they read the role fromGET /sites. No consumer reads the role today. - A site registered without a role stays
UNSPECIFIEDuntil an operator classifies it; the seed leaves its capability untouched. - Contract changes are additive:
siteRoleonSite,RegisterSiteRequestandSiteRegistered; newSiteRoleChangedmessage,PUT /sites/{siteCode}/roleandGET /site-roles/transfer-defaults.