0044. An order may carry an optional, caller-assigned fulfillment site
Status
Accepted — implemented by the change that introduces this record. Amends
ADR 0035 §4 (the site of a
SiteSkuDemandChanged) and lifts the deferral recorded in
ADR 0031 ("a fulfillment
site on the order"). The owner took the decision; this record writes it down.
Amended by ADR 0047: the
site is no longer read by the demand projection only — the CPT promise (intake and
every re-promise) and the planned-capacity annotation use it too, falling back to
DEFAULT_SITE_ID / PLANNED_CAPACITY_SITE_ID. The "assigned, never inferred" rule
below is unchanged.
Additively superseded by ADR 0050:
§7's freeze is lifted for exactly one additive member — OrderAllocated /
OrderPartiallyAllocated now carry the optional top-level site_id (omitempty;
an order without a site still publishes byte-identical bytes).
Context
ADR 0035 projects every SiteSkuDemandChanged to ONE static site,
DEMAND_PROJECTION_SITE_ID, through usecases.DemandProjectionPolicy{SiteID, AssignmentVersion} with StaticDemandAssignmentVersion = "static-site-v1". It
deliberately kept the site off the Order aggregate, and ADR 0031 deferred "a
fulfillment site on the order" as an order-model change that would get its own ADR.
That seam is now the bottleneck. Because orders carry no site, every demand fact goes to the single configured site, so:
network-inventory-planning, which needs demand facts at BOTH the origin and the destination site of a transfer, can never see demand at a second site, and a real transfer approval cannot happen outside injected test data;slottinglikewise only ever sees one site.
The information is not ours to produce. Which site should fulfil an order is a
sourcing decision made by whoever places the order — customer-ordering for a retail
order, network-fulfillment for network-originated demand (ADR 0020) — and this
bounded context has no sourcing logic and must not grow any.
Decision
-
The order MAY carry a fulfillment site, assigned by the caller.
POST /ordersaccepts an optionalfulfillmentSiteId. It applies to ordinary orders and to the ADR-0020 network-originated hold alike: the hold is not a separate request, it is the sameReceiveOrderRequestwithreleaseOnAllocation: false(and usuallyrequiredShipBy), so one field covers both. The order and hold read responses (GET /orders/{id}, the201, the retry/release200s) echofulfillmentSiteId, and omit it when the caller named none. -
Assigned, never inferred. This service does not look a site up, default one, derive one from an SKU, a reservation, the promise, or
DEFAULT_SITE_ID, and makes no call tofacility-layout. It carries what the caller sent. No sourcing logic belongs here: if a future requirement is "pick the best site", that isnetwork-fulfillment's orcustomer-ordering's context, and arrives here as afulfillmentSiteId. -
A value object with the fleet's site-code shape, mirrored not called.
shared.FulfillmentSiteIDaccepts exactly facility-layout's pattern^[A-Z0-9]+$: non-empty, uppercase ASCII letters and digits only (WH1,ABE8,123are valid;"",wh1,WH-1,WH 1are not). facility-layout imposes no maximum length, so none is invented here. Existence is NOT checked — a well-formed code for a site we have never heard of is accepted; the rule is copied, there is no cross-service call. A malformed value — including an explicit""or JSONnull— is rejected with 400application/problem+json, problem typeinvalid-fulfillment-site-id(an explicitnullis the existingmalformed-request-body). Nothing is persisted and no event is raised for a rejected request. -
Immutable.
Order.AssignFulfillmentSitesets it once, on the freshly constructed order at intake (a second call returnsErrFulfillmentSiteAlreadyAssigned). Allocation, retry, release, re-promise and cancel never touch it. In storage it is a nullableorders.fulfillment_site_id(migration0013, with a CHECK mirroring the pattern), written only by theINSERTof a new order — the version-guardedUPDATEdoes not set it, so no later save can rewrite it. Rows written before the migration readNULL= no site. -
Projection (amends ADR 0035 §4). The site of a
SiteSkuDemandChangedis resolved per order:Order has FulfillmentSiteIDStatic policy configured site_id assignment_version yes either the order's site order-site-v1no yes ( DEMAND_PROJECTION_SITE_ID)the static site static-site-v1no no — nothing is emitted — The order's site wins even when no static site is configured, so a deployment can serve multiple sites with
DEMAND_PROJECTION_SITE_IDunset.static-site-v1's meaning is unchanged andorder-site-v1is a NEW value, as ADR 0035 requires of any new assignment regime. The decision lives in one place,DemandProjectionPolicy.resolve, which every projecting use case already goes through (allocateAndRelease,RepromiseOrder,CancelOrder), so ACTIVE and REMOVED facts for one order always agree on the site. -
The seam stays.
DemandProjectionPolicyandDEMAND_PROJECTION_SITE_IDremain for orders without a site (every existing caller). No new environment variable and no new chart value are introduced (INFRA VALUES REQUIRED: none). -
Frozen contracts are byte-identical.
OrderAllocated,OrderPartiallyAllocatedandOrderRepromised(shared with wes-work-planning) do not carry the site and do not change by a byte; a use-case test asserts the non-demand events of an order with a site areDeepEqualto those of the same order without one, and a Postgres + Kafka integration test compares the wire payload shape. The analytics topic is untouched.SiteSkuDemandChanged's payload shape anddataschema(…SiteSkuDemandChanged:v1) are unchanged: only theassignment_versionenum gainsorder-site-v1— additive for a consumer that already treats it as an opaque regime tag.
Consequences
network-inventory-planningandslottingcan receive demand facts at more than one site as soon as the callers send a site;assignment_versiontells them whether the site was the caller's (order-site-v1) or the deployment's (static-site-v1).- Behaviour, events and tests are unchanged for every order without a site.
- Callers must follow up for any of this to matter in a running fleet:
customer-orderingandnetwork-fulfillmenteach have to sendfulfillmentSiteIdonPOST /orders(network-fulfillment on the hold request). Until they do, every order projects to the static site as before. - A caller can name a site that does not exist; downstream consumers own that
judgment. We accept this rather than couple intake to
facility-layout's availability. - Not changed: the planned-capacity annotation of ADR 0031 still matches on
PLANNED_CAPACITY_SITE_ID, not on the order's site. Matching on the order's site is now possible and is a deliberate follow-up with its own decision, because moving the annotation would alter the read-time behaviour that ADR 0031 pinned as advisory. - The same-site rule is strict by construction: a split-shipment order's lines all project to the one site on the order. Per-line sites are out of scope.
- The
fulfillmentSiteIdis a caller-visible input on the public intake DTO; it is a site code, not PII, and does not appear on the analytics topic.