warehouse-systems fleet · executive briefing

order-sourcing

Picks which warehouse ships each part of an order, as late as the promise allows
eleven capabilitys15 events out · 39 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

Order Sourcing picks each shipment's node at the last responsible moment, so choices track real capacity

1

Deciding late means each group goes to the node that can actually serve it.

2

It knows the network from local copies of sibling events and calls no other service.

3

That independence costs a wide event fan-in and a load profile nobody has measured.

The ask

Fund a load test of the virtual queue and alerts on outbox backlog, consumer lag and unsourceable share.

why it exists

The best node for a shipment is the one still able to serve it

Core subdomain of the retail network's commerce tier. It owns the FulfillmentAssignment aggregate and the virtual queue behind it: every shipment group of a placed order is queued, continuously re-optimised against network capacity, and released to exactly one node at the last responsible moment…

Today

Every shipment group waits in a virtual queue, is re-optimised against capacity, then released to one node and locked once it commits.

The catch

It reads 36 event types from nine producers, and the queue sweep and multi-replica use have never been load-tested.

what it does

It queues, re-optimises, releases and locks every shipment group

Virtual queue

Queues each shipment group and keeps finding a better node, path and cost.

Unsourceable alerts

Flags a group right away when no node can serve it.

Release and reassign

Sends a group to one node at a time and moves on if that node refuses.

Commit lock

Locks the assignment once the node commits, so it never changes after.

Ship-to-delivery tracking

Follows each group to delivery and decides cancel requests by the lock.

Promise revisions

Applies revised delivery promises in every state before the end.

who it talks to

Nine contexts feed it, six build on what it publishes

LISTENS TO · 36 EVENT TYPESIS HEARD BY · 6 CONTEXTSnode-topology11last-mile-delivery5linehaul-transportation5offer-availability5vendor-connectivity4customer-ordering2+3 more contextscustomer-ordering5linehaul-transportation4customer-payments3delivery-promise3vendor-connectivity3seller-inbound2ordersourcingbadge = event types on that edge · derived from the CloudEvents types each repo declares
the shared language

Assignments, queues and policy are the words that drive sourcing

THE LANGUAGEOF THE DOMAINFulfillmentAssignmentvirtual queueshipment groupsourcing policyrelease / lockreoptimisationconsolidation keypromise revision
REST9 operations over 8 paths: 5 on :8080 (/assignments…
MCPRead-only MCP server (cmd/mcp, Streamable HTTP…
A2ARead-only A2A agent (cmd/a2a, JSON-RPC over HTTP…
how it is built

Five binaries keep sourcing decisions apart from reporting

DRIVERS · INBOUNDOUTBOUND · ADAPTERSREST API :80809 operations over 8 paths: 5MCP tools :8090Read-only MCP server…Kafka consumer · 39 eventsCustomerOrderCancelledCustomerOrderPlacedDOMAIN COREFulfillmentAssignmentvirtual queueshipment groupsourcing policyPostgreSQLPostgreSQLKafka producer · 15 eventsAssignmentsConsolidatedAssignmentsDeconsolidatedTransactional outboxrelay · DLQ on x-dlq-*commands inevents inevents outstorage / infra
event traffic · CloudEvents 1.0 on Kafka

Thirty-nine event types come in, fifteen go out, all through an outbox

CONSUMED · BY SOURCE · 39PUBLISHED · BY ENTITY · 15node-topology 11last-mile-delivery 5linehaul-transportation 5offer-availability 5vendor-connectivity 4order-sourcing 3customer-ordering 2delivery-promise 214 assignment1 policy
how we know it is healthy

Traces, metrics and a 90% gate show how sourcing behaves

OpenTelemetry OTLP/gRPC from cmd/api, mcp and a2a (os-projector and os-reports also carry telemetry.go) to the in-cluster Collector -> Jaeger (traces) + Prometheus (metrics)…

What we watch

  • request log with request id per inbound call
  • a2a.skill OTel spans; no MCP tool span (the MCP call shows only as the HTTP server span)
  • Kafka consumer/relay spans with traceparent propagated onto published events

What stops a bad change

  • make check (fmt, vet, build, lint, unit + handler + BDD); make check-all adds coverage gate 90%
  • godog BDD suite must pass
  • architecture tests (dependency direction, event catalogue, DLQ/shutdown, no memory adapter in cmd)
by the numbers

Seventeen decisions and 13 feature files shape the sourcing rules

17
Architecture decisions
#16 of 45 in the fleet
7
DB migrations
#15 of 45 in the fleet
13
BDD feature files
#26 of 45 in the fleet
15
Events published
#2 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, add alerts, load-test the queue and settle open questions

NOW1Add acarbon-budgetlever andAdd a carbon-budgetpolicy lever and acarbon-per-pathanalytics report:named follow-ups ofADR 0017 (ranking isunchanged today)NEXT2Build splitsurcharge andsingle-nodeSplit surcharge andsingle-node-beats-splitpreference of thesourcing-policycontract are NOTbuilt (ADR 0014);revisit whensourcing plans …NEXT3Close the openquestions oftheClose the openquestions of thebounded-contextcanvas: acceptanceafter cancellation,cancelled pickupdeparture after thelock, book pressure…LATER4Load-test morethan one apireplicaLoad-test more thanone api replica:safe by design but'has not beenload-tested'(runbook.md)LATER5Alert on outboxbacklog, lag,dead letters,Add alerts on outboxbacklog, consumerlag, dead-lettervolume andunsourceable share:none exist(observability.md)LATER6Refresh staleADR and eventcounts in theRefresh stale prosecounts: README says16 ADRs, 34 consumedtypes, chart withone component (index17, asyncapi 36,values hasmcp/a2a/frontend/analytics)
what could go wrong · and what we do about it

Our biggest risk is one upstream change rippling through

36 upstream event types can ripple into read models

Consumes 36 event types from nine producers (plus 3 own types read back): any upstream contract change ripples into read models (ADR…

→

ADR 0003 partly decouples read models; the coupling is only partially removed.

Unauthenticated endpoints, by fleet decision

Every REST, MCP and A2A endpoint is unauthenticated BY DECISION (README 'No authentication'…

→

A decision, not a gap: the cluster-internal boundary is the only access control.

Queue sweep and multi-replica use are not load-tested

The sweep re-optimises the other queued assignments every SWEEP_INTERVAL (15s) and multi-replica api is not load-tested (runbook.md):…

→

Run a load test before trusting peak-volume latency.

Cancelled groups may still ship after acceptance

Acceptance after cancellation is not undone: a vendor may still ship a cancelled group…

→

Acceptance after cancellation is an open canvas question; close it with the owners.

the decision we need

Fund a load test of the virtual queue and alerts on outbox backlog, consumer lag and unsourceable share.

WHAT ISEvery shipment group waits in avirtual queue, is re-optimisedagainst capacity, then released toone node and locked once it commits.THE CATCHIt reads 36 event types from nineproducers, and the queue sweep andmulti-replica use have never beenload-tested.WHAT COULD BEWe know how the queue behaves understress, and trouble in events orsourcing pages someone before ordersslip.
Why it matters

Order Sourcing picks each shipment's node at the last responsible moment, so choices track 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; five binaries (api, mcp, a2a, os-projector, os-reports)
Layoutcmd/{api,mcp,a2a,os-projector,os-reports} composition roots; internal/domain {assignment, policy, sourcing, network, shared}…
StoragePostgreSQL (pgx v5): aggregates, sourcing policies, inbox, transactional outbox, global idempotency keys, 7 schema migrations…
TestingUnit + 90% coverage gate over domain, application and analytics; integration on real PostgreSQL and Kafka via testcontainers…
REST9 operations over 8 paths: 5 on :8080 (/assignments, /assignments/{assignmentId}, /assignments/{assignmentId}/reoptimisations…
Go 1.27.4PostgreSQL via pgx v5Kafka via segmentio/kafka-goCloudEvents 1.0 envelopeOpenTelemetrychi HTTP routerMCP go-sdka2a-go v2golang-migrateotelchigodogHelm/Kubernetes