Skip to main content

Bounded Context Canvas

As built

Derived from network/model/model.yaml. This context's service is built; the model carries its as-built contracts, and identifiers (Err... names, routes, CloudEvents types) are the names the service uses.

Following the ddd-crew Bounded Context Canvas v5. Every message row maps to an entry of contexts[order-sourcing] (inbound, rest, publishes, consumes, sync_calls) or of a neighbour's entry for the other side of the same edge.

Canvas at a glance​

Two pictures of the sections below, laid out like the ddd-crew canvas: first the inbound collaborators feeding this context (purpose, domain roles and the business decisions it enforces), then the outbound collaborators it notifies. Arrows follow the message type: solid blue commands (cmd), dotted green queries (qry), thick orange events (evt); each arrow names its channel and the messages it carries. Box shapes mark the collaborator kind: rounded = people or UI; blue = sibling bounded context; grey = this context's own scheduler; dashed = published with no domain consumer ("analytics only" in the model). Channel names on the arrows are abbreviated; the Inbound and Outbound Communication tables carry the exact route, topic and CloudEvents type for every message.

Inbound​

Derived from: model.yaml → contexts[order-sourcing].purpose, .roles, .business_decisions, .inbound, .rest, .consumes, .policies[VirtualQueue].

Outbound​

Derived from: model.yaml → contexts[order-sourcing].publishes (consumers), .sync_calls (empty), and the inbound rows of vendor-connectivity, linehaul-transportation, delivery-promise and customer-ordering.

The diagrams omit assumptions, verification metrics, open questions and the ubiquitous language (sections below), the relationship pattern per message (see the tables), the full CloudEvents types, and the replies to the planner's queries. There are no outbound commands or queries: sync_calls is empty, so this context calls no other context synchronously.

Name​

Order Sourcing (order-sourcing, code OS, CloudEvents tier commerce).

Purpose​

To decide, as late as the promise allows, which node and path will actually fulfil each shipment group. The context:

  • keeps one FulfillmentAssignment per shipment group in a virtual queue;
  • re-optimises queued assignments against current capacity and cost;
  • at the release point sends the group to one node (a purchase order through vendor-connectivity);
  • reassigns on rejection or expiry, excluding the refusing node;
  • locks the assignment once the node commits;
  • hands an impossible group back to delivery-promise as unsourceable.

It holds no PII and calls no other context synchronously.

Strategic Classification​

AxisVerdict
DomainCore. See the Core Domain Chart (complexity 0.80, differentiation 0.85).
Business ModelCost reducer (cost-to-serve) and speed protector.
EvolutionCustom-built.

Domain Roles​

RoleApplies?Evidence in the model
Execution (assignment)Yes, primaryOwns the FulfillmentAssignment lifecycle: QueueAssignment, ReleaseToNode, HandleNodeRefusal, LockAssignment, MarkShipped, MarkDelivered, CancelAssignment, ApplyRevisedPromise.
Analysis (optimisation)YesReoptimiseAssignment with the AssignmentCost policy over five event-fed read models.
Enforcer (path lock)YesLockOnCommit; ErrAssignmentLocked, ErrCancelAfterLock, ErrNodeExcluded, ErrReleaseInFlight.

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
customer-orderingCustomerOrderPlacedEventKafka retailnetwork.customer-ordering.events, com.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderPlacedCustomer/Supplier
customer-orderingCustomerOrderCancelledEventKafka retailnetwork.customer-ordering.events, com.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderCancelledCustomer/Supplier
delivery-promisePromiseRevisedEventKafka retailnetwork.delivery-promise.events, com.retailnetwork.commerce.delivery-promise.promise.PromiseRevisedCustomer/Supplier
delivery-promisePromiseBookExhaustedEventKafka retailnetwork.delivery-promise.events, com.retailnetwork.commerce.delivery-promise.promisebook.PromiseBookExhaustedCustomer/Supplier
vendor-connectivityPurchaseOrderAcceptedEventKafka retailnetwork.vendor-connectivity.events, com.retailnetwork.partner.vendor-connectivity.purchaseorder.PurchaseOrderAcceptedCustomer/Supplier
vendor-connectivityPurchaseOrderRejectedEventKafka retailnetwork.vendor-connectivity.events, com.retailnetwork.partner.vendor-connectivity.purchaseorder.PurchaseOrderRejectedCustomer/Supplier
vendor-connectivityPurchaseOrderExpiredEventKafka retailnetwork.vendor-connectivity.events, com.retailnetwork.partner.vendor-connectivity.purchaseorder.PurchaseOrderExpiredCustomer/Supplier
vendor-connectivityVendorShipmentConfirmedEventKafka retailnetwork.vendor-connectivity.events, com.retailnetwork.partner.vendor-connectivity.purchaseorder.VendorShipmentConfirmedCustomer/Supplier
shipping-and-trackingPackageDeliveredEventKafka retailnetwork.shipping-and-tracking.events, com.retailnetwork.logistics.shipping-and-tracking.journey.PackageDeliveredConformist
node-topologyNodeRegisteredEventKafka retailnetwork.node-topology.events, com.retailnetwork.logistics.node-topology.node.NodeRegisteredConformist
node-topologyNodeOperationalProfileDeclaredEventKafka retailnetwork.node-topology.events, com.retailnetwork.logistics.node-topology.node.NodeOperationalProfileDeclaredConformist
node-topologyNodeActivatedEventKafka retailnetwork.node-topology.events, com.retailnetwork.logistics.node-topology.node.NodeActivatedConformist
node-topologyNodeSuspendedEventKafka retailnetwork.node-topology.events, com.retailnetwork.logistics.node-topology.node.NodeSuspendedConformist
node-topologyNodeRetiredEventKafka retailnetwork.node-topology.events, com.retailnetwork.logistics.node-topology.node.NodeRetiredConformist
node-topologyLaneOpenedEventKafka retailnetwork.node-topology.events, com.retailnetwork.logistics.node-topology.lane.LaneOpenedConformist
node-topologyLaneClosedEventKafka retailnetwork.node-topology.events, com.retailnetwork.logistics.node-topology.lane.LaneClosedConformist
node-topologyServiceAreaAssignedEventKafka retailnetwork.node-topology.events, com.retailnetwork.logistics.node-topology.servicearea.ServiceAreaAssignedConformist
node-topologyRegionDefinedEventKafka retailnetwork.node-topology.events, com.retailnetwork.logistics.node-topology.region.RegionDefinedConformist
offer-availabilityListingCreatedEventKafka retailnetwork.offer-availability.events, com.retailnetwork.commerce.offer-availability.listing.ListingCreatedConformist
offer-availabilityListingAvailabilityChangedEventKafka retailnetwork.offer-availability.events, com.retailnetwork.commerce.offer-availability.listing.ListingAvailabilityChangedConformist
offer-availabilityListingSuppressedEventKafka retailnetwork.offer-availability.events, com.retailnetwork.commerce.offer-availability.listing.ListingSuppressedConformist
offer-availabilityListingRestoredEventKafka retailnetwork.offer-availability.events, com.retailnetwork.commerce.offer-availability.listing.ListingRestoredConformist
offer-availabilityCatalogItemDiscontinuedEventKafka retailnetwork.offer-availability.events, com.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemDiscontinuedConformist
linehaul-transportationDepartureScheduledEventKafka retailnetwork.linehaul-transportation.events, com.retailnetwork.logistics.linehaul-transportation.departure.DepartureScheduledConformist
linehaul-transportationDepartureCapacityChangedEventKafka retailnetwork.linehaul-transportation.events, com.retailnetwork.logistics.linehaul-transportation.departure.DepartureCapacityChangedConformist
linehaul-transportationDepartureCancelledEventKafka retailnetwork.linehaul-transportation.events, com.retailnetwork.logistics.linehaul-transportation.departure.DepartureCancelledConformist
last-mile-deliveryDeliveryWaveScheduledEventKafka retailnetwork.last-mile-delivery.events, com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveScheduledConformist
last-mile-deliveryDeliveryWaveCapacityChangedEventKafka retailnetwork.last-mile-delivery.events, com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveCapacityChangedConformist
node-performanceNodeScorecardUpdatedEventKafka retailnetwork.node-performance.events, com.retailnetwork.partner.node-performance.scorecard.NodeScorecardUpdatedConformist
Network-ops plannerListAssignmentsQueryREST GET /assignments?state=&nodeId=&orderId=UI
Network-ops plannerGetAssignmentQueryREST GET /assignments/{assignmentId}UI
Network-ops plannerReoptimiseAssignmentCommandREST POST /assignments/{assignmentId}/reoptimisationsUI
Network-ops plannerGetSourcingPolicyQueryREST GET /sourcing-policyUI
Network-ops plannerPublishSourcingPolicyCommandREST PUT /sourcing-policy (the whole document; every call publishes a new version)UI
Own schedulerReleaseToNodeCommandinternal timer at releaseAt (VirtualQueue); immediately for SAME_DAYInternal
Own schedulerReoptimiseAssignmentCommandinternal re-optimisation sweep over QUEUED assignmentsInternal

Outbound Communication​

Integration events: topic retailnetwork.order-sourcing.events, source /retailnetwork/order-sourcing, subject and Kafka key assignmentId, dataschema urn:retailnetwork:order-sourcing:events:<EventName>:v1. Analytics-only events go only to retailnetwork.order-sourcing.analytics.

CollaboratorMessageTypeChannelRelationship
none (analytics only)FulfillmentQueuedEventcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentQueuedPublished Language
vendor-connectivity, linehaul-transportationFulfillmentReleasedToNodeEventcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReleasedToNodeCustomer/Supplier (both consumers' inbound rows)
linehaul-transportationFulfillmentReassignedEventcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReassignedCustomer/Supplier
delivery-promise, customer-ordering, linehaul-transportationFulfillmentLockedEventcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentLockedCustomer/Supplier (delivery-promise, linehaul-transportation); Conformist (customer-ordering)
customer-orderingFulfillmentShippedEventcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentShippedConformist
none (analytics only)FulfillmentDeliveredEventcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentDeliveredPublished Language
delivery-promise, customer-orderingFulfillmentUnsourceableEventcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentUnsourceableCustomer/Supplier (delivery-promise); Conformist (customer-ordering)
vendor-connectivityFulfillmentReleaseWithdrawnEventcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReleaseWithdrawnCustomer/Supplier
none (analytics only)AssignmentsConsolidated, AssignmentsDeconsolidated, SourcingPolicyPublishedEventcom.retailnetwork.commerce.order-sourcing.assignment.AssignmentsConsolidated, com.retailnetwork.commerce.order-sourcing.assignment.AssignmentsDeconsolidated, com.retailnetwork.commerce.order-sourcing.policy.SourcingPolicyPublishedPublished Language
vendor-connectivity, linehaul-transportationFulfillmentCancelledEventcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentCancelledCustomer/Supplier
—(no synchronous call)—sync_calls: []—

Full message details: Domain Events. Relationship reasons: Context Map.

Ubiquitous Language​

Full glossary: Ubiquitous Language. Top terms: Fulfillment Assignment, Virtual Queue, Release (to node), Path Lock, Reassignment, Unsourceable, and the model value objects Promise Constraint, Candidate, Release record, Excluded Node.

Business Decisions​

  1. The assigned node may differ from the witness node. The only hard constraint is that the released candidate still meets deliverByLatest (ErrCandidateBreaksPromise).
  2. Free while queued, constrained after release, final after acceptance. ReoptimiseAssignment works only in QUEUED; after release the node changes only through HandleNodeRefusal on PurchaseOrderRejected or PurchaseOrderExpired; after PurchaseOrderAccepted the assignment is LOCKED (ErrAssignmentLocked).
  3. Fill-or-kill. A group goes to one node in full. At most one release is pending at a time (ErrReleaseInFlight).
  4. Never break a promise silently. If no node can still meet deliverByLatest, the assignment becomes UNSOURCEABLE and FulfillmentUnsourceable asks delivery-promise to re-promise (RepromiseOnRisk). A revised promise re-queues the group (ApplyRevisedPromise, which applies in every non-terminal state).
  5. In-region first, as a bounded trade. Cross-region is a cost, never a filter: the effective cost adds the policy's cross-region surcharge, and an in-region candidate within the cheapest effective cost plus maxCostDeviationPercent beats a cross-region one (RegionalBudget, gap G26). With no policy published the ordering is by cost and then the ordinal penalties.
  6. A refusing node is excluded. It is never released to again for the same promise revision (ErrNodeExcluded).
  7. Release late, but in time to be acknowledged. releaseAt = best candidate's pickup cutoff − node handling time − vendor ack budget; SAME_DAY releases immediately.
  8. Cancel only before the lock (ErrCancelAfterLock), and never while the group is a member of a live merge (ErrCancelWhileMerged, reason CANCEL_WHILE_MERGED).
  9. Merge at release, never before. Groups of one shopper and one address that chose CONSOLIDATED may be released as one carrier release with followers (ConsolidationAtRelease); the merge never moves the carrier's node, only CONSOLIDATED groups merge, and a group that does not fit releases alone.
  10. Hold a consolidated group as late as its day allows. The search is bounded by the window start and releases at the latest pickup that still reaches the chosen day (ConsolidatedHold).

Assumptions​

  • Every release goes to a vendor node: FULFILLMENT_CENTER is the only node type with OUTBOUND, and its only allowed operator is VENDOR. So every release becomes a purchase order (IssueOnRelease).
  • vendor-connectivity echoes assignmentId and releaseNo on every purchase-order outcome (they are in the data of PurchaseOrderAccepted, PurchaseOrderRejected and PurchaseOrderExpired), so a late outcome of an old release can be recognised and ignored.
  • The vendor ack budget is not longer than the vendor's ack window. With ackBy = min(issuedAt + ackWindow, requiredShipBy - handlingTime) and a PO issued at releaseAt, the effective time to acknowledge is the shorter of the two.
  • The read models have caught up before the first release after a start; they are fed only by events (no synchronous call is allowed).
  • delivery-promise answers FulfillmentUnsourceable with PromiseRevised or, if nothing is feasible even at STANDARD, judges the promise broken later; customer-ordering may then cancel the group (CancelOnUnfulfillable).

Verification Metrics​

MetricComputed fromWhy
First-release lock rateshare of assignments whose first FulfillmentReleasedToNode (releaseNo 1) is followed by FulfillmentLockedQuality of the ranking and of node declarations
Reassignments per 1,000 groups, split by refusal vs re-optimisationFulfillmentReassignedVendor reliability and churn of the queue
Unsourceable rate per 1,000 groupsFulfillmentUnsourceable / FulfillmentQueuedHow often sourcing hands a promise back; the target is near zero
Non-witness assignment shareFulfillmentLocked.nodeId ≠ PromiseConstraint.witnessNodeIdHow much late optimisation is used
Cross-region sharelocked node's region vs destination region (from NetworkGraphView)Checks business decision 5
Release lateness p95releasedAt − releaseAtThe queue fires on time
Release-to-lock p95lockedAt − releasedAtVendor acknowledgement speed as seen from sourcing
Candidate guard tripscount of ErrCandidateBreaksPromiseShould be zero: the candidate search must never offer such a candidate
Stale-version conflictscount of ErrStaleAssignmentVersionContention between sweeps, consumers and the planner

Open Questions​

These are gaps in model.yaml found while deriving this pack. They are not resolved here.

  • ApplyRevisedPromise raises FulfillmentConstraintRevised (resolved). It applies in every non-terminal state when revisionNo is higher than the applied one, and always raises the analytics-only FulfillmentConstraintRevised (ADR 0002 A9, gap G13).
  • Exclusions per promise revision, without a revision number. ErrNodeExcluded is scoped to "the same promise revision", but PromiseConstraint carries no revisionNo, and the model does not say whether a revision clears the exclusions.
  • PromiseRevised for an assignment that is not UNSOURCEABLE. delivery-promise also re-promises on a cancelled departure or a package exception. The only transition is UNSOURCEABLE → QUEUED; a queued, released or locked assignment keeps its old deliverByLatest.
  • An UNSOURCEABLE assignment can be cancelled (resolved). CancelAssignment is allowed from QUEUED, RELEASED and UNSOURCEABLE, so customer-ordering's CancelOnUnfulfillable has a target.
  • Cancel decision (resolved, G12). CustomerOrderCancelled is a request. From QUEUED, UNSOURCEABLE or an unmerged RELEASED assignment this context publishes FulfillmentCancelled; from LOCKED, SHIPPED or DELIVERED it keeps the state and publishes FulfillmentCancelRefused with reason CANCEL_AFTER_LOCK; from a RELEASED member of a live merge it also refuses, with reason CANCEL_WHILE_MERGED (policy CancelDecision).
  • Consolidation race (known residual, open). Between this context dissolving a merge after a promise revision and vendor-connectivity cancelling the issued purchase order, the vendor may acknowledge it. The acceptance is then ignored here (ErrReleaseNotPending, counted) and the vendor holds an accepted order for the old union while the survivors get a new one. The window is one message hop, the same one a plain cancel after release has.
  • Acceptance after cancellation (known residual, open). If CancelAssignment runs while the vendor's acceptance is being processed, vendor-connectivity can cancel only an ISSUED purchase order (ErrCancelAfterAcknowledgement, logged, nothing published). An acceptance that then reaches this context for a CANCELLED assignment is only recorded and logged (policy AcceptanceAfterCancelOnlyLogged), so the vendor may still ship a cancelled group.
  • No releaseAt without a candidate. VirtualQueue derives the release point from the best candidate; when re-optimisation finds none, the model does not say when ReleaseToNode fires to declare the group unsourceable.
  • Multi-package groups. FulfillmentShipped carries trackingNumbers; PackageDelivered is per package. Whether MarkDelivered waits for every package is not stated.
  • Reason vocabularies. FulfillmentReassigned.reason, FulfillmentLocked.lockReason, FulfillmentUnsourceable.reason, FulfillmentCancelled.reason, ExcludedNode.reason and Release.reasonCode are not enumerated.
  • Promise-book capacity stays on the witness node. Capacity is held on the witness node's cutoff; when the assignment moves, nothing in the model moves that hold. delivery-promise consumes FulfillmentLocked but names no policy that uses it.
  • Book pressure only rises. PromiseBookPressureView is fed only by PromiseBookExhausted; no event says a book has room again. The bookId contains the pickup departure, so the entry ages out with the cutoff.
  • Soft vs hard cross-region rule (resolved, G26). Cross-region is a cost, not a filter: money decides first and the policy's budget tier lets an operator buy in-region fulfilment for a bounded deviation (RegionalBudget). The split surcharge of the first contract is not built, because this context never splits an order.
  • A cancelled pickup departure after the lock. "No change of node after LOCKED" says nothing about the departure; the model has no transition for a locked assignment whose pickupDepartureId is cancelled.
  • The destination is not on the aggregate. Candidate search needs the delivery station of the destination, so the assignment must keep destinationPostalPrefix from CustomerOrderPlaced; neither PromiseConstraint nor the aggregate description lists it.
  • No error names for not-found and wrong-state requests. The model has no Err... for an unknown assignmentId, nor for re-optimising an UNSOURCEABLE, CANCELLED, SHIPPED or DELIVERED assignment.