Skip to main content

Bounded Context Canvas

Synced from network-fulfillment

This page is a copy of docs/docs/ddd/bounded-context-canvas.md on develop, derived from that repository's code. Edit it there, then re-sync.

Following the ddd-crew Bounded Context Canvas v5. Every message row maps to a real route, MCP tool, port call or Kafka topic in the code on develop.

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 calls or 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, UI or any client; blue = sibling bounded context; double border = external system or platform; grey = this context's own projector, reports or dead-letter path; dashed = published today with no consumer. Channel names on the arrows are abbreviated (REST, MCP, Kafka, HTTP, port); the Inbound and Outbound Communication tables carry the exact route, tool, topic and CloudEvents type for every message.

Inbound​

Source: internal/adapters/inbound/http/server.go, internal/adapters/inbound/mcp/, internal/adapters/inbound/kafka/ and internal/adapters/inbound/poller/poller.go (the Inbound Communication table below maps each arrow to its route, tool or topic).

Outbound​

Source: the Inbound Communication and Outbound Communication tables of this page, which map to internal/adapters/inbound/{http,kafka,mcp,poller} and internal/adapters/outbound/. The diagram omits assumptions, verification metrics, open questions and the ubiquitous language (sections below), the relationship pattern per message (OHS, ACL, Conformist, Customer/Supplier - see the tables) and anything the tables mark as deprecated or platform-only (health probes).

Name​

Network Fulfillment (network-fulfillment, CloudEvents subdomain wes).

Purpose​

To be the one place where the fleet meets an external retail fulfillment network. Since ADR 0009 the counterpart is the fleet's own retail-network service; the original learning target was a large retailer's vendor platform API. The context:

  • receives the network's demand by polling;
  • answers it inside the network's 24-hour window, acknowledged in full or rejected in full, using order-management's feasibility verdict;
  • reconciles each asynchronous submission before it releases any work;
  • confirms shipment when it is told one happened;
  • computes the throughput-constrained quantity it would advertise (CapabilityOffer).

The network's vocabulary never reaches the rest of the fleet, and no ship-to PII enters this context at all.

Strategic Classification​

AxisVerdict
DomainSupporting Subdomain (ADR 0001). See core-domain-chart.md.
Business ModelRevenue-channel enabler: it lets the building's fulfillment capability be sold through an external network without any other context knowing the network exists.
EvolutionCustom-built (the ACL and the acknowledgement protocol). CapabilityOffer is Genesis → Custom. The counterpart's API is a Product that this context conforms to.

Domain Roles​

RoleApplies?Evidence
Gateway / Anti-Corruption LayerYes, primaryThe network vocabulary stops at internal/adapters/outbound/retailnetwork/. ports.NetworkGateway and contract.* are expressed in our terms, and NetworkOrder.SKUQuantities() is the only shape sent to order-management.
Execution (protocol)Yes, narrowOwns the answer, the 24h clock (acknowledgeBy, the sweep, RejectOverdueOrders) and reconciliation. It does not own the fulfillment work, which belongs to order-management.
AnalysisYes, always onRecomputeCapabilityOffers derives advertised availability from inventory, the CPT schedule and path capacity (wired at boot; CAPABILITY_OFFER_ENABLED is only a boot guard, ADR 0025).
Published Language / Open HostPartlyPublishes 6 CloudEvents types on warehouse.network-fulfillment.events (documented in apis/asyncapi.yaml). No other fleet context was found consuming them. Read-only REST and MCP are exposed for operators and agents.

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
External network (retail-network; stub by default, live opt-in, ADR 0026)Inbound demand (contract.InboundDemand)Query (poll)ports.NetworkGateway.PollDemand, driven by internal/adapters/inbound/pollerConformist (we are downstream)
Operator / upstream callerConfirm shipmentCommandREST POST /network-orders/{networkRef}/shipment-confirmation (ADR 0014)Open Host (unauthenticated)
Operators, web/ remote in warehouse-consoleList unanswered ordersQueryREST GET /network-ordersOpen Host
OperatorsGet one orderQueryREST GET /network-orders/{networkRef}Open Host
Operators, web/ remoteInbound leg healthQueryREST GET /inbound-statusOpen Host
OperatorsCapability offersQueryREST GET /capability-offersOpen Host
Kubernetes / PrometheusLiveness, readiness, metricsQueryREST GET /healthz, GET /readyz, GET /metrics—
MCP clients (AI agents)Get / list network ordersQueryMCP get_network_order, list_network_orders, resource network-order://network-fulfillment/{networkRef}Open Host (read-only)
MCP clientsList capability offersQueryMCP list_capability_offersOpen Host (read-only)
MCP clientsAcknowledgement reportQueryMCP get_acknowledgement_report (when REPORTS_BASE_URL is set)Open Host (read-only)
Report consumersAcknowledgement & Translation reportQueryREST (cmd/netfulfil-reports) GET /reports/acknowledgement, GET /reports/acknowledgement/freshnessOpen Host
process-path-managementPath catalogue + CPT scheduleEventKafka warehouse.process-path-management.events: com.warehouse.wes.process-path-management.processpath.ProcessPathCreated, ...processpath.ProcessPathUpdated, ...processpath.ProcessPathDeactivated, com.warehouse.wes.process-path-management.cptschedule.CPTScheduleChangedConformist (always-on cache)
wes-work-planningRemaining path capacityEventKafka warehouse.work-planning.events: com.warehouse.wes.work-planning.workpool.PathCapacityChangedConformist (always-on cache)
Itself (analytics projector)Own events, for the reportEventKafka warehouse.network-fulfillment.analytics: ...networkorder.NetworkOrderReceived, ...NetworkOrderSubmitted, ...NetworkOrderAcknowledged.v2 (and the historic ...NetworkOrderAcknowledged v1), ...NetworkOrderRejectedInternal

Outbound Communication​

CollaboratorMessageTypeChannelRelationship
order-managementRaise held order + feasibility verdictCommandREST POST /orders (releaseOnAllocation: false, allowPartialShipment: false, requiredShipBy)Customer/Supplier (we are the Customer; OM ADR 0020)
order-managementRelease held orderCommandREST POST /orders/{id}/releasesCustomer/Supplier
order-managementCancel held orderCommandREST DELETE /orders/{id} (also the orphaned-hold sweep, which reads 404 and 409/422 as answers)Customer/Supplier
inventory-storageUsable quantity per SKUQueryREST GET /inventory/{sku}/usable (always on)Conformist to its Open Host
External networkAcknowledge / reject in fullCommandports.NetworkGateway.SubmitAcknowledgement(ref, accepted) (stub)Conformist
External networkTransaction statusQueryports.NetworkGateway.SubmissionStatus(ref) (stub)Conformist
External networkShipment confirmationCommandports.NetworkGateway.SubmitShipmentConfirmation(ref) (stub)Conformist
External networkNode operational profileCommandports.NetworkGateway.DeclareNodeProfile(profile) from DeclareNodeProfiles (live mode; ADR 0027 part 1; the stub records it and sends nothing)Conformist
External networkInventory feedCommandports.NetworkGateway.SubmitInventoryFeed(feed) from FeedInventory (live mode; ADR 0027 part 2; replaces SubmitAvailability; the stub sends nothing)Conformist
External networkLabelCommand / QueryRequestLabel, called by ConfirmNetworkOrderShipmentConformist
Any subscriberNetworkOrderReceived, NetworkOrderSubmitted, NetworkOrderAcknowledged (v2, .v2 type), NetworkOrderRejected, NetworkOrderShipmentConfirmed, AcknowledgementDeadlineAtRisk, OrphanedHoldCancelledEventKafka warehouse.network-fulfillment.events, type com.warehouse.wes.network-fulfillment.networkorder.<Event> (published through the outbox relay, always on)Open Host / Published Language
Analytics projectorThe same 7 events (it ignores NetworkOrderShipmentConfirmed, AcknowledgementDeadlineAtRisk and OrphanedHoldCancelled)EventKafka warehouse.network-fulfillment.analyticsInternal

Full message details: domain-events.md. Relationship evidence: context-map.md.

Ubiquitous Language​

Full glossary: ubiquitous-language.md. Top terms: NetworkOrder, NetworkRef, NetworkProductId (≠ SKU), LocalOrderId, requiredShipBy, acknowledgeBy, held order, Submitted (accepted-for-processing, not yet a commitment), CapabilityOffer with Basis PHYSICAL / THROUGHPUT_CONSTRAINED, RejectionReason.

Business Decisions​

  1. Answer once, in full or not at all. Submit and Reject are each allowed only once (ErrAlreadyAnswered). There is no partial acknowledgement, and the held order is raised with allowPartialShipment: false.
  2. One unknown product rejects the whole order inside the window, and the refusal is recorded (ReceiveUntranslatable, RejectionReasonUntranslatableSKU), not dropped.
  3. Feasibility is asked, never computed. A null promiseDate from POST /orders is the verdict "not feasible" (ADR 0001 §7).
  4. Hold, submit, reconcile, then release. Work reaches the floor only after SubmissionStatus reports SUCCESS (ReconcileSubmittedOrders). FAILURE cancels the hold and rejects (SUBMISSION_FAILED).
  5. Free the hold first. Every rejection path cancels the held order before it mutates the aggregate, and records the outcome in the same save as the rejection. A hold nobody decided is cancelled by a backstop sweep (SweepOrphanedHolds) once acknowledgeBy + ORPHAN_HOLD_GRACE has passed, because order-management has no timeout of its own and a second TTL there would race the clock this context owns (ADR 0024). A hold found already released is not cancelled and is never retried.
  6. A missed deadline is reported, then refused, and never answered late. The sweep only publishes AcknowledgementDeadlineAtRisk. RejectOverdueOrders rejects with ACKNOWLEDGEMENT_DEADLINE_MISSED.
  7. Correlation is a persisted mapping (local_order_id, recorded when the hold is raised; the hold's outcome is hold_outcome, guarded by CHECK constraints). It is never a string convention, and that is why shipment confirmation is an explicit call (ADR 0014), not a PackageManifested join.
  8. Advertise what the floor can move. advertisedQuantity is min(physical, throughputFeasible) and is never above physical (ErrAdvertisedExceedsPhysical). If capacity is unknown, the offer falls back to physical.
  9. NETWORK_MODE defaults to stub. live refuses to boot until an adapter exists, and the chosen mode is logged and exposed on /inbound-status.

Assumptions​

  • order-management remains the single authority on promises, and its ADR 0020 hold contract (releaseOnAllocation, ship-complete) stays stable.
  • The counterpart's inbound model stays poll-only, and its submissions stay asynchronous with a transaction-status query.
  • A curated PRODUCT_TRANSLATION_FILE is present wherever demand should be accepted. Without it, every order is rejected.
  • Single site: RecomputeCapabilityOffers targets one SITE_ID, the same simplification as order-management ADR 0014.
  • The always-on caches can fully replay their topics within WaitReadyTimeout (60s each) at boot.

Verification Metrics​

  • GET /inbound-status: failed poll count, unanswered and overdue counts. An overdue order is a missed external SLA.
  • The AcknowledgementDeadlineAtRisk rate, and rejections split by RejectionReason.
  • Acknowledgement report: average acknowledgement latency, received vs acknowledged, and rejections by cause (acknowledgement_rollup, including ordersRejectedSubmissionFailed).
  • Share of THROUGHPUT_CONSTRAINED offers per recompute pass (logged as throughput_constrained).
  • circuit_breaker_state gauge for the order-management dependency.
  • network_fulfillment.orphaned_holds.swept by outcome, and any OrphanedHoldCancelled event: a hold that leaked and had to be swept.
  • network_fulfillment.node_profile.declarations by outcome and network_fulfillment.node_profile.revision by site (live mode, ADR 0027): a site stuck in a skipped_* or failed outcome has no current profile on the network.
  • Engineering gates: arch-go hexagonal tests, 90% coverage, gremlins on ./internal/domain/networkorder.

Open Questions​

  • Decided 2026-10-25: CapabilityOffer is submitted outward by FeedInventory (ADR 0027 part 2), in live mode only, as one feed per site built from the persisted offers. The live retail-network adapter landed with ADR 0026.
  • Decided 2026-10-06: Submitted at SUBMITTED, Acknowledged only on settle (ADR 0016). NetworkOrderSubmitted is raised when the order goes SUBMITTED; NetworkOrderAcknowledged is raised only when reconciliation settles it ACKNOWLEDGED, published as the .v2 type and dataschema. No fleet consumer exists, and the projector still replays historic v1 messages with the same report numbers.
  • Decided 2026-10-17: the orphaned hold is recorded and swept (ADR 0024, gap OM-0020). The hold id is stored on the order as soon as RaiseHeldOrder returns, and SweepOrphanedHolds cancels a hold nobody decided once acknowledgeBy + ORPHAN_HOLD_GRACE has passed (OrphanedHoldCancelled), so RejectOverdueOrders' cancel now has a hold to find. What stays open by design: a hold never named because the process stopped between order-management's commit and the id being saved (only when the window closes before a re-delivery repeats the raise), a SUBMITTED order whose network status stays PENDING, and an ACKNOWLEDGED order whose release failed (not a cancel case; release it by hand, see the runbook).
  • Decided 2026-10-06: cycle time gates eligibility (ADR 0017). A path is eligible for a cutoff only if CycleTimeP95 <= cutoff - now; a missing or zero cycle time stays eligible (fail-open); capacity is not scaled.
  • Decided 2026-10-30: the next feasible cutoff (ADR 0031). When no path can make the next cutoff, the offer is computed against the first one a path can make, up to 7 days ahead; only none in that bound is a zero.
  • Contract drift (fixed 2026-10-06, ADR 0015). CORS now allows GET/POST/OPTIONS, ErrConfirmBeforeAcknowledge maps to a 409, apis/openapi.yaml documents GET /capability-offers and the shipment-confirmation POST, and the acknowledgement report counts SUBMISSION_FAILED rejections.