Skip to main content

Order assignment model

Proposed design

Derived from network/model/model.yaml → contexts[order-sourcing], contexts[vendor-connectivity]. Owner: order-sourcing (Core). The published fact behind it: A large-scale operator assigns items to fulfillment centres and paths after purchase, possibly differently from the path behind the promise, and the path can change until the item is picked, then stays locked .

Why assignment is not the promise​

The promise needs a feasible path, now, in milliseconds. Assignment needs the best feasible path, as late as possible, when more is known: other orders have arrived, a departure has filled, a node's grade has changed. If one context did both it would either promise slowly or assign early and wastefully. So the promise carries a witness path (proof that the date is reachable) and order-sourcing is free to pick another path, under one hard constraint: the assigned path must still reach the customer by deliverByLatest (ErrCandidateBreaksPromise).

The assignment lifecycle​

Derived from: model.yaml → contexts[order-sourcing].aggregates[FulfillmentAssignment].transitions.

StateCan the node change?Who moves it on
QUEUEDyes, freelythe VirtualQueue timer, re-optimization sweeps
RELEASEDonly if the node refuses (reject or expiry); that node is then excluded. A member of a consolidation merge also returns to QUEUED when a promise revision dissolves the mergevendor-connectivity events, delivery-promise PromiseRevised
LOCKEDneverthe vendor's acceptance
UNSOURCEABLEn/a; waits for a revised promisedelivery-promise PromiseRevised

When to release​

VirtualQueue sets a release point for each queued group:

releaseAt = bestCandidate.pickup.cutoffAt
- bestCandidate.node.handlingTime
- vendorAckBudget # time the vendor needs to say yes
SAME_DAY: release immediately

Until releaseAt, every sweep re-runs AssignmentCost over the candidate nodes that still meet deliverByLatest:

effectiveCost = estimatedCostCents # planner-declared lane and wave costs
+ crossRegionSurchargeCents # SourcingPolicy, cross-region candidates only
cheapest = min(effectiveCost)
budget = cheapest + floor(cheapest x maxCostDeviationPercent / 100)

order: candidates within the budget with an in-region one first # only when the percent is above 0
then effectiveCost # money decides
then, for a CONSOLIDATED group, the LATER pickup # the hold
then legs + crossRegionPenalty # prefer in-region
+ scorecardPenalty(grade) # prefer reliable nodes
+ bookPressurePenalty(PromiseBookExhausted) # spread load off full cutoffs
ties -> the promise's witness node

Derived from: model.yaml → contexts[order-sourcing].policies[AssignmentCost], [RegionalBudget], [ConsolidatedHold].

Cross-region is a cost, never a filter (gap G26). With no SourcingPolicy published the surcharge and the percent are 0, and the ordering is the one the ordinal penalties alone gave. The split surcharge of the first contract is not built: this context never splits an order, because each group is assigned on its own.

As built (order-sourcing ADR 0017) every candidate also carries a carbon estimate, estimatedCo2eGrams: the planner-declared per-unit emission of every lane the path traverses (LaneEmissionDeclared from node-topology) plus the declared per-stop emission of the final wave (WaveEmissionDeclared from last-mile-delivery), in integer grams of CO2e. It is an estimate only, not a sourcing objective: the comparator above never reads it, so the ordering is unchanged. A component with no declaration contributes 0 and marks the estimate incomplete, and FulfillmentReleasedToNode and FulfillmentSourcingDecided then omit both estimatedCo2eGrams and emissionComplete, so absence means not known, never zero. Derived from: model.yaml → contexts[order-sourcing].policies[CarbonEstimate].

At releaseAt the cheapest candidate is released: FulfillmentReleasedToNode. For a vendor node, vendor-connectivity turns it into a purchase order with

ackBy = min(issuedAt + vendor.ackWindow, requiredShipBy - node.handlingTime)

so even a vendor with a 24-hour acknowledgement window must answer a same-evening order in time to still pick and pack it.

Consolidation at release​

A shopper who places two orders to the same address within a few days costs two pickups, two purchase orders and two packages. When the groups chose the opt-in CONSOLIDATED delivery day, order-sourcing can merge them at release, never before. The due assignment becomes the carrier; compatible QUEUED assignments become followers; the carrier is released once, with the union of the lines, and every member keeps its own events.

RuleWhat it requires
c1 identitynot the carrier, QUEUED, the same non-empty consolidation key and destination postal prefix, both tiers CONSOLIDATED
c2 nodethe carrier's solo best node is not excluded by the follower and the merged search returns an option there: a merge never moves the carrier
c3 overlapthe merged eta lies inside the overlap of the members' delivery windows
c4 stockquantities summed per catalogue item still have ONE covering owner (OwnerChoice)
c5 capsthe member count is at most consolidationMaxAssignments and the union at most the line cap

Derived from: model.yaml → contexts[order-sourcing].policies[ConsolidationAtRelease], [ConsolidatedHold], [MergedFanOut], [ConsolidationDissolution].

A CONSOLIDATED group is held as late as its day allows (it is released at the latest pickup that still reaches the chosen wave), so a second order has time to find it still QUEUED. Whatever does not fit releases alone. The vendor sees one purchase order with positional lines; the lock, shipment and delivery of the carrier are applied to every follower in the same transaction, and each member raises its own FulfillmentLocked, FulfillmentShipped and FulfillmentDelivered.

Derived from: model.yaml → contexts[order-sourcing].policies, contexts[vendor-connectivity].policies[CancelOnReleaseWithdrawn].

A cancel of a merged member is refused while the merge is live and not yet locked (reason CANCEL_WHILE_MERGED): the merge stays intact and the cancel can be retried after the lock or after the merge is dissolved. A refusal or expiry of the carrier's purchase order re-searches every member on its own. The one known residual is a vendor acknowledgement that crosses the withdraw by a message hop; order-sourcing ignores the stale acceptance and the vendor holds an order for the old union.

Lock, refusal, and the unsourceable case​

Derived from: model.yaml → contexts[order-sourcing].policies, contexts[vendor-connectivity].policies, contexts[delivery-promise].policies[RepromiseOnRisk].

Why acceptance is the lock. In the reference operator's buildings the published lock point is "picked". The network cannot see inside a vendor's building, and a vendor that accepted fill-or-kill has committed stock and floor work (the fleet's network-fulfillment releases the held order-management order only after a reconciled acceptance). Reassigning after acceptance would leave a vendor picking an order nobody wants. So acceptance is the vendor-node equivalent of "picked" (ADR 0005).

Worked example, continued​

From Promise model: the order was placed at 14:10 with a NEXT_DAY promise, witness N-VWS-AUS3, shipBy 18:00 CDT, deliverByLatest Fri 21:00.

Time (CDT)What happensContext
14:10CustomerOrderPlaced → QueueAssignment; candidates AUS3 (Fri) and DFW7 (Mon, breaks the promise: excluded)order-sourcing
15:55releaseAt = 18:00 − 95 min − 30 min ack budget. Re-optimize: AUS3 still cheapest. ReleaseToNodeorder-sourcing
15:55PurchaseOrderIssued po-55120, requiredShipBy 18:00, ackBy = min(15:55 + 24 h, 18:00 − 95 min) = 16:25vendor-connectivity
15:56fleet network-fulfillment polls, raises a held order-management order, FeasibleBy(18:00) = true, posts ACCEPT, gets transactionIdwarehouse-systems
16:01transaction SUCCESS → PurchaseOrderAccepted → LockAssignment → FulfillmentLocked; linehaul books one package on dep-AUS3-1800network
16:02fleet reconciles the transaction and releases the order to the floor (WES, pick, pack, SLAM)warehouse-systems
17:20fleet requests a label, then confirms shipment with the tracking numberwarehouse-systems → vendor-connectivity
18:00pickup departs; first scan = PackageHandedOver (on time)linehaul, shipping-and-tracking
Fri 11:42DeliveryAttempted DELIVERED → PackageDelivered → PromiseKeptlast-mile, tracking, promise

The fleet-side rows are what the fleet's network-fulfillment does today against its stub, plus the changes listed on Fleet changes.