Bounded context canvas
Following the ddd-crew Bounded Context Canvas v5. Every message row below is backed by code on this branch: internal/adapters/inbound/kafka/dispatch.go (consumed), internal/adapters/outbound/kafka/encoder.go and apis/asyncapi.yaml (published), apis/openapi.yaml (REST).
Source: internal/adapters/inbound/kafka/dispatch.go, internal/adapters/outbound/kafka/encoder.go, apis/openapi.yaml, apis/asyncapi.yaml. Solid arrows are commands, dotted queries, thick events.
Name
Delivery Promise (delivery-promise, CloudEvents tier commerce, network area).
Purpose
Tell a shopper, before and at purchase, the date a package will arrive, and make that date true by construction: quote only from a feasible witness path (node cutoff, scheduled departures, delivery wave) with remaining capacity; hold that capacity on the witness node's pickup cutoff until the order is placed or the hold expires; revise a broken promise only to a later window; judge every promise kept or broken at delivery.
Strategic classification
| Axis | Verdict |
|---|---|
| Domain | Core (reasoning, chart) |
| Business model | Revenue generator (a credible early date converts) and cost reducer (no promise the network cannot keep) |
| Evolution | Custom-built |
Domain roles
| Role | Applies | Evidence |
|---|---|---|
| Execution (promising) | Primary | MakePromise, ConfirmPromise, ReviseAtRisk, judge; the Promise lifecycle |
| Analysis (feasibility search) | Yes | QuoteDeliveryOffers, internal/domain/search |
| Enforcer (capacity holds) | Yes | PromiseBook: provisional + confirmed <= share; ReleaseExpiredHolds |
| Gateway / ACL | No | It conforms to each upstream's published language and translates nothing at its boundary |
| Specification | No | It publishes promise facts, not capability specifications |
Inbound communication
| Collaborator | Message | Type | Channel | Relationship |
|---|---|---|---|---|
| Shopper / storefront (shopping-cart, storefront-bff) | quote | Query | REST POST /delivery-quotes | Open Host |
| customer-ordering | quote, make, confirm, cancel | Query, commands | REST POST /delivery-quotes, POST /promises, /confirmations, /cancellations | Customer/Supplier (this context supplies) |
| customer-ordering | CustomerOrderPlaced, CustomerOrderCancelled | Events | retailnetwork.customer-ordering.events | Customer/Supplier |
| order-sourcing | FulfillmentLocked, FulfillmentShipped, FulfillmentUnsourceable | Events | retailnetwork.order-sourcing.events | Customer/Supplier |
| shipping-and-tracking | PackageDelivered, PackageExceptionRaised, PackageLost, PackageReturned | Events | retailnetwork.shipping-and-tracking.events | Conformist |
| linehaul-transportation | DepartureScheduled, DepartureCapacityChanged, DepartureCancelled, BookingMoved, BookingFailed, LoadDeparted, LoadArrived | Events | retailnetwork.linehaul-transportation.events | Conformist |
| last-mile-delivery | DeliveryWaveScheduled, DeliveryWaveCapacityChanged, DeliveryWaveCancelled, PackageInductionDeferred | Events | retailnetwork.last-mile-delivery.events | Conformist |
| node-topology | NodeRegistered, NodeOperationalProfileDeclared, NodeActivated, NodeSuspended, NodeRetired, LaneOpened, LaneClosed, ServiceAreaAssigned, RegionDefined | Events | retailnetwork.node-topology.events | Conformist |
| offer-availability | CatalogItemCreated, CatalogItemDiscontinued, ListingCreated, ListingAvailabilityChanged, ListingSuppressed, ListingRestored | Events | retailnetwork.offer-availability.events | Conformist |
| node-performance | NodeScorecardUpdated, NodeTierEligibilityChanged | Events | retailnetwork.node-performance.events | Conformist |
| agents, console | the REST reads, five MCP tools, two A2A skills | Queries | REST GET, MCP, A2A | none negotiated |
39 consumed types in total. The relationship column states the pattern the aggregator's model assigns; this repository only records that it conforms to each upstream vocabulary (tolerant local copies in apis/asyncapi.yaml).
Outbound communication
| Collaborator | Message | Channel |
|---|---|---|
| customer-ordering | PromiseAtRisk, PromiseRevised, PromiseKept, PromiseBroken, PromiseUnkeepable | retailnetwork.delivery-promise.events |
| order-sourcing | PromiseRevised, PromiseBookExhausted | same topic |
| node-performance | PromiseKept, PromiseBroken | same topic |
| none | PromiseMade, PromiseConfirmed, PromiseReleased, PromiseCancelled, DeliveryOfferQuoted, PromisePolicyPublished | retailnetwork.delivery-promise.analytics |
| (synchronous calls) | none | the promise hot path calls no sibling |
Ubiquitous language
Full glossary: Ubiquitous language. Core terms: Delivery Offer, Service Tier, Promise, Ship-By, Deliver-By Window, Witness Path, Promise Basis, Promise Book, Capacity Hold, Handicap, Re-promise, Promise Kept or Broken, Shipment Group.
Business decisions
- No path, no offer. A tier with no feasible witness path returns no offer and the constraint that blocked it.
- Fast tiers are never quoted from nominal times. Only
STANDARDmay fall back to nominal lane transit and then records basisNOMINAL. A lane that runs late is quoted from its measured transit instead: basisMEASURED(ADR 0014). - A promise holds capacity on the witness node's pickup cutoff; provisional holds expire (
holdTtlMinutes). - One promise per shipment group. The cart is grouped onto the fewest nodes (
ErrGroupSpansNodesguards a group). - Handicap, never silent exclusion. A weak node's ship-by moves later by its scorecard grade. The one exclusion is node-performance's own: a node it declares ineligible for
SAME_DAYorNEXT_DAY(7-day on-time handover, with hysteresis) is dropped from those tiers' candidates of future quotes and keepsTWO_DAYandSTANDARD(ADR 0022). - Kept means on time: delivered on or before
deliverByLatest; a lost or returned package breaks the promise. - Dates only move later: a revision never moves
deliverByLatestearlier. - Peak control by deadline: per tier and region, a policy-versioned local order deadline stops quoting that tier (
PAST_ORDER_DEADLINE).
Assumptions
- Upstream events arrive within seconds; the read models are only as fresh as the slowest topic, so a stale departure row can be quoted and is refused at
MakePromiserevalidation as a full book. linehaul-transportationpublishes departures ahead (a pickup departure per declared cutoff of every active vendor node) andlast-mile-deliverypublishes waves for every delivery station with a service area; without them there is no witness path.- Every destination postal prefix maps to one delivery station (
rm_areas). - Customer-ordering normally confirms before the hold expires; the hold is a guard, not the main path.
Verification metrics
| Metric | Definition | Source |
|---|---|---|
| Promise-kept rate | PromiseKept / (PromiseKept + PromiseBroken) per tier | events topic |
| Re-promise rate | PromiseRevised / PromiseConfirmed | events and analytics topics |
| Hold leakage | PromiseReleased / PromiseMade | analytics topic |
| Make outcomes | promising.promises.made by outcome and reason | OpenTelemetry, dashboard warehouse-delivery-promise |
| Request duration | http.server.request.duration by route | OpenTelemetry |
| Outbox backlog | SELECT count(*) FROM outbox_events WHERE published_at IS NULL | Postgres (no metric exists) |
| Book exhaustion | PromiseBookExhausted per node per day | events topic |
Open questions and known discrepancies
Recorded from the code, not decided here:
- Lost packages are judged. The aggregator's model treated
PackageLostandPackageReturnedas analytics-only; the service consumes both and judges the groupBROKENwith causeLOSTorRETURNED(internal/application/usecases/judge.go). - Cancelled waves are handled.
DeliveryWaveCancelledmarks the wave cancelled and flags promises whose witness wave it is (OnWaveCancelled). - Unkeepable promises stay
AT_RISK.PromiseUnkeepableis raised once andRepriceAtRiskkeeps retrying; customer-ordering is expected to cancel the group, which then cancels the promise. - Problem slugs. The aggregator's pack names
offer-not-found,promise-not-found,invalid-requestandstale-write; the service answersnot-found(404),validation-failed(422),malformed-request(400) andconcurrent-update(409). - The first-line spec text of
apis/openapi.yamlstill citesretail-network-docs model/model.yaml, a renamed repository. - Alert runbook links in
warehouse-infrastill point at the pre-movedocs/operations/runbook.md.