warehouse-systems fleet · executive briefing

last-mile-delivery

Plans each station's delivery runs and records every doorstep attempt
eight capabilitys13 events out · 17 in17 recorded decisions

This project is a domain-driven design study. It is not associated with, endorsed by or affiliated with any company, and it uses no company's code, data, logos or trademarks. All names, figures and examples are illustrative or synthetic. · November 2026

the short version · read this if nothing else

Last-mile delivery runs each station's waves, routes and attempts, so promises rest on real capacity

1

Published waves give delivery promises a real cutoff, window and stop capacity to rely on.

2

Routes and attempt history track every doorstep try, and a return starts on the third miss.

3

Packages with no wave are deferred and cancelled waves re-induct, so nothing falls through.

The ask

Declare authority levels on the MCP tools and A2A skills, and add wave-cost and utilisation tools for station operators.

why it exists

Delivery promises are only as good as the waves behind them

Supporting subdomain in the logistics tier. It publishes the delivery waves (induct cutoff, delivery window, stop capacity) that delivery-promise relies on, plans routes for delivery service partners, and records every delivery attempt. It owns the DeliveryWave, Route and PackageAttemptHistory aggregates…

Today

Stations schedule delivery waves, induct packages, plan partner routes and record attempts; a third failed attempt starts a return.

The catch

Wave capacity is shared with promise bookings and has no reservation step, so peaks can over-promise.

what it does

Six capabilities run a station from wave plan to doorstep

Delivery wave scheduling

Each station sets waves with an induct cutoff, delivery window and stop capacity.

Induction and dispatch

Packages join waves and ship out; a cancelled wave moves them to the next one.

Wave stop cost

Each wave declares its stop cost and emission, feeding cost-to-serve analytics.

Partner route planning

Each delivery partner gets a planned route with one attempt recorded per package.

Attempts and returns

Every attempt is kept, and the third failed one starts a return.

Induction deferral

When no wave fits a package, it is deferred openly instead of dropped.

who it talks to

Three contexts feed it, three build on what it publishes

LISTENS TO · 4 EVENT TYPESIS HEARD BY · 3 CONTEXTSnode-topology2linehaul-transportation1shipping-and-tracking1order-sourcing5shipping-and-tracking5delivery-promise4last-miledeliverybadge = event types on that edge · derived from the CloudEvents types each repo declares
the shared language

Waves, routes, attempts and partners are the station's language

THE LANGUAGEOF THE DOMAINDeliveryWaveRoutePackageAttemptHistoryDeliveryServicePartnerstopinduct cutoffstop capacity / wave coststop ETA window
REST19 operations over 18 paths on :8080
MCPRead-only MCP server (cmd/mcp, :8090…
A2ARead-only A2A agent (cmd/a2a, :8093…
how it is built

Five binaries share one hexagon with a transactional outbox

DRIVERS · INBOUNDOUTBOUND · ADAPTERSREST API :808019 operations over 18 pathsMCP tools :8090Read-only MCP server…Kafka consumer · 17 eventsPackageReturnInitiatedroute.DeliveryAttemptedDOMAIN COREDeliveryWaveRoutePackageAttemptHistoryDeliveryServicePartnerPostgreSQLPostgreSQLKafka producer · 13 eventsDeliveryPointFlaggedPackageInductionDeferredTransactional outboxrelay · DLQ on x-dlq-*commands inevents inevents outstorage / infra
event traffic · CloudEvents 1.0 on Kafka

13 station facts go out, and 17 come in

CONSUMED · BY SOURCE · 17PUBLISHED · BY ENTITY · 13last-mile-delivery 13node-topology 2linehaul-transportation 1shipping-and-tracking 15 route5 wave2 packageattempthistory1 deliverypointprofilePackageReturnInitiatedDeliveryAttemptedPackageOutForDeliveryRoutePlannedStopEtaWindowAssignedDeliveryWaveCancelledDeliveryWaveCapacityChangedDeliveryPointFlaggedPackageInductionDeferredPackageReturnInitiatedDeliveryAttemptedPackageOutForDeliveryRoutePlannedStopEtaWindowAssigned
how we know it is healthy

Traces, metrics and logs run through the fleet's shared stack

OpenTelemetry OTLP/gRPC to in-cluster Collector -> Jaeger (traces) + Prometheus (metrics); JSON slog logs on stdout collected by Alloy into Loki (fleet standard, ADR 0008)

What we watch

  • request log with request id per call, trace_id and span_id
  • mcp.tool and a2a.skill OTel spans
  • Business counters: last_mile_delivery.package.attempted (outcome delivered|failed|rejected), stop_eta.assigned, stop_eta.skipped…

What stops a bad change

  • make check (vet + lint + unit + coverage gate 90%); check-all adds coverage + arch-test + bdd
  • godog BDD suite and integration tests on real PostgreSQL + Kafka (testcontainers) in CI
  • architecture fitness tests (dependency direction)
by the numbers

17 decisions, eight migrations and 11 BDD feature files

17
Architecture decisions
#16 of 45 in the fleet
8
DB migrations
#14 of 45 in the fleet
11
BDD feature files
#31 of 45 in the fleet
13
Events published
#4 of 45 in the fleet

Ranked against all 45 briefed repositories (dot = one repository, highest on the left).

One-command workflows (make)

helpbuildvetfmtfmt-checklinttestcoverageintegrationbddarch-testmutationmutation-fullvuln
what comes next

Next: declare agent authority, widen MCP, feed flags into routing

NOW1Declare authorityon MCP tools andA2A skillsDeclare agent authoritylevels on the 3 MCPtools and 2 A2A skills:the tool-registry goldencarries nocom.warehouse/authority_meta and no authority:Ltag is evidencedNEXT2Give stationoperators waveanalytics via MCPSurface wave-cost andutilisation analyticsthrough MCP tools forstation operators: theregistry has onlyget_route,get_wave_stops andlist_wavesNEXT3Feeddelivery-pointflags into routeClose the loop fromDeliveryPointProfileflags back into routeplanning and promisetighteningLATER4Raise the mutationgate to the 99/99standardRaise the mutation gatefrom efficacy 95 /mutant-coverage 95 tothe 99/99 fleet standard(.gremlins.yaml:33-34)LATER5Add outbox-lag,consumer-lag andDLQ metricsAdd queue-healthinstruments: nooutbox-lag, consumer-lagor DLQ metric isevidenced inobservability.md
what could go wrong · and what we do about it

Our biggest risk is over-promising wave capacity at peak

Wave capacity can over-promise at peak

Wave stop capacity is contended with delivery-promise bookings; no reservation protocol is evidenced in docs/…

→

No mitigation on the roadmap yet: this one needs an owner.

Analytics can lag or duplicate on retries

Analytics projector re-consumes this service's own produced types; relay retries can lag or duplicate projections if CloudEvents id…

→

Stable CloudEvents ids, an inbox, idempotency keys and per-topic DLQs guard against duplicates.

No auth on REST, MCP or A2A, by decision

Every REST, MCP and A2A endpoint is unauthenticated by decision (fleet-wide auth revert; CLAUDE.md:23,42)

→

No mitigation on the roadmap yet: this one needs an owner.

the decision we need

Declare authority levels on the MCP tools and A2A skills, and add wave-cost and utilisation tools for station operators.

WHAT ISStations schedule delivery waves,induct packages, plan partner routesand record attempts; a third failedattempt starts a return.THE CATCHWave capacity is shared with promisebookings and has no reservationstep, so peaks can over-promise.WHAT COULD BEDelivery-point flags feeding backinto route planning and tighterpromises, and queue-health signalson the dashboard.
Why it matters

Last-mile delivery runs each station's waves, routes and attempts, so promises rest on real capacity

appendix · for the engineers in the room

The fine print: how it is put together

StyleHexagonal (ports & adapters), event-driven DDD, transactional outbox; separate analytics read side (projector + reports over a second PostgreSQL)
Layoutcmd/{api,mcp,a2a,lm-projector,lm-reports} composition roots; internal/domain {wave, route, history, partner, deliverypoint, shared}…
StoragePostgreSQL (pgx v5): waves, routes, attempt histories, delivery points, inbox, transactional outbox, global idempotency keys, 8 schema migrations…
TestingUnit + 90% coverage gate; integration on real PostgreSQL and Kafka via testcontainers; godog BDD (11 .feature files incl…
REST19 operations over 18 paths on :8080: /waves, /waves/{waveId}/stops, /waves/{waveId}/induction-closures, /waves/{waveId}/dispatches…
Go 1.27.4PostgreSQL via pgx v5Kafka via segmentio/kafka-goCloudEvents 1.0 envelopeOpenTelemetrychi HTTP routerMCP go-sdka2a-go v2React/Vite MFE consoleHelm/Kubernetes