Skip to main content

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​

AxisVerdict
DomainCore (reasoning, chart)
Business modelRevenue generator (a credible early date converts) and cost reducer (no promise the network cannot keep)
EvolutionCustom-built

Domain roles​

RoleAppliesEvidence
Execution (promising)PrimaryMakePromise, ConfirmPromise, ReviseAtRisk, judge; the Promise lifecycle
Analysis (feasibility search)YesQuoteDeliveryOffers, internal/domain/search
Enforcer (capacity holds)YesPromiseBook: provisional + confirmed <= share; ReleaseExpiredHolds
Gateway / ACLNoIt conforms to each upstream's published language and translates nothing at its boundary
SpecificationNoIt publishes promise facts, not capability specifications

Inbound communication​

CollaboratorMessageTypeChannelRelationship
Shopper / storefront (shopping-cart, storefront-bff)quoteQueryREST POST /delivery-quotesOpen Host
customer-orderingquote, make, confirm, cancelQuery, commandsREST POST /delivery-quotes, POST /promises, /confirmations, /cancellationsCustomer/Supplier (this context supplies)
customer-orderingCustomerOrderPlaced, CustomerOrderCancelledEventsretailnetwork.customer-ordering.eventsCustomer/Supplier
order-sourcingFulfillmentLocked, FulfillmentShipped, FulfillmentUnsourceableEventsretailnetwork.order-sourcing.eventsCustomer/Supplier
shipping-and-trackingPackageDelivered, PackageExceptionRaised, PackageLost, PackageReturnedEventsretailnetwork.shipping-and-tracking.eventsConformist
linehaul-transportationDepartureScheduled, DepartureCapacityChanged, DepartureCancelled, BookingMoved, BookingFailed, LoadDeparted, LoadArrivedEventsretailnetwork.linehaul-transportation.eventsConformist
last-mile-deliveryDeliveryWaveScheduled, DeliveryWaveCapacityChanged, DeliveryWaveCancelled, PackageInductionDeferredEventsretailnetwork.last-mile-delivery.eventsConformist
node-topologyNodeRegistered, NodeOperationalProfileDeclared, NodeActivated, NodeSuspended, NodeRetired, LaneOpened, LaneClosed, ServiceAreaAssigned, RegionDefinedEventsretailnetwork.node-topology.eventsConformist
offer-availabilityCatalogItemCreated, CatalogItemDiscontinued, ListingCreated, ListingAvailabilityChanged, ListingSuppressed, ListingRestoredEventsretailnetwork.offer-availability.eventsConformist
node-performanceNodeScorecardUpdated, NodeTierEligibilityChangedEventsretailnetwork.node-performance.eventsConformist
agents, consolethe REST reads, five MCP tools, two A2A skillsQueriesREST GET, MCP, A2Anone 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​

CollaboratorMessageChannel
customer-orderingPromiseAtRisk, PromiseRevised, PromiseKept, PromiseBroken, PromiseUnkeepableretailnetwork.delivery-promise.events
order-sourcingPromiseRevised, PromiseBookExhaustedsame topic
node-performancePromiseKept, PromiseBrokensame topic
nonePromiseMade, PromiseConfirmed, PromiseReleased, PromiseCancelled, DeliveryOfferQuoted, PromisePolicyPublishedretailnetwork.delivery-promise.analytics
(synchronous calls)nonethe 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​

  1. No path, no offer. A tier with no feasible witness path returns no offer and the constraint that blocked it.
  2. Fast tiers are never quoted from nominal times. Only STANDARD may fall back to nominal lane transit and then records basis NOMINAL. A lane that runs late is quoted from its measured transit instead: basis MEASURED (ADR 0014).
  3. A promise holds capacity on the witness node's pickup cutoff; provisional holds expire (holdTtlMinutes).
  4. One promise per shipment group. The cart is grouped onto the fewest nodes (ErrGroupSpansNodes guards a group).
  5. 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_DAY or NEXT_DAY (7-day on-time handover, with hysteresis) is dropped from those tiers' candidates of future quotes and keeps TWO_DAY and STANDARD (ADR 0022).
  6. Kept means on time: delivered on or before deliverByLatest; a lost or returned package breaks the promise.
  7. Dates only move later: a revision never moves deliverByLatest earlier.
  8. 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 MakePromise revalidation as a full book.
  • linehaul-transportation publishes departures ahead (a pickup departure per declared cutoff of every active vendor node) and last-mile-delivery publishes 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​

MetricDefinitionSource
Promise-kept ratePromiseKept / (PromiseKept + PromiseBroken) per tierevents topic
Re-promise ratePromiseRevised / PromiseConfirmedevents and analytics topics
Hold leakagePromiseReleased / PromiseMadeanalytics topic
Make outcomespromising.promises.made by outcome and reasonOpenTelemetry, dashboard warehouse-delivery-promise
Request durationhttp.server.request.duration by routeOpenTelemetry
Outbox backlogSELECT count(*) FROM outbox_events WHERE published_at IS NULLPostgres (no metric exists)
Book exhaustionPromiseBookExhausted per node per dayevents topic

Open questions and known discrepancies​

Recorded from the code, not decided here:

  1. Lost packages are judged. The aggregator's model treated PackageLost and PackageReturned as analytics-only; the service consumes both and judges the group BROKEN with cause LOST or RETURNED (internal/application/usecases/judge.go).
  2. Cancelled waves are handled. DeliveryWaveCancelled marks the wave cancelled and flags promises whose witness wave it is (OnWaveCancelled).
  3. Unkeepable promises stay AT_RISK. PromiseUnkeepable is raised once and RepriceAtRisk keeps retrying; customer-ordering is expected to cancel the group, which then cancels the promise.
  4. Problem slugs. The aggregator's pack names offer-not-found, promise-not-found, invalid-request and stale-write; the service answers not-found (404), validation-failed (422), malformed-request (400) and concurrent-update (409).
  5. The first-line spec text of apis/openapi.yaml still cites retail-network-docs model/model.yaml, a renamed repository.
  6. Alert runbook links in warehouse-infra still point at the pre-move docs/operations/runbook.md.