0010. Process paths publish a fulfillment capability contract (cycle time, eligibility, CPT schedule)
Status
Accepted. Companion to order-management ADR 0014 (promise derived from fulfillment capability), accepted together.
Context
In a real fulfillment centre the customer-facing delivery promise and the building's process paths are one mechanism seen from two sides. The promise engine offers a date only if some path inside the building can carry the order to a truck that leaves before that date; the process path selection then constrains routing so the committed orders actually fit. The coupling point is the Critical Pull Time (CPT): the last moment a package can be manifested and still make a given departure. A major e-commerce retailer's process-path model publishes, per building, which paths exist, how long each takes end to end, what each may carry, and which CPTs each can hit; the promise is derived from that, never guessed independently of it.
This fleet has the skeleton of that coupling but not the substance:
order-managementcomputespromiseDate = now + leadTime(order.LeadTimePolicy), whereleadTimecomes from the environment variablePROMISE_PATH_LEAD_TIMES(e.g.pick=24h,singles=6h) with a 48h default. The promise is a configuration guess made outside every bounded context that knows anything about the floor.wes-work-planningconsumesOrderAllocated.promise_dateand uses it literally as the work unit's CPT (shared.NewCPT(data.PromiseDate)). Because the promise is a continuous timestamp, two orders placed one minute apart get two different "CPTs" instead of the same truck, and the per-CPTChargeForecastbuckets WES already models cannot line up with the CPTs real work carries.- This service's
ProcessPathaggregate holds identity,matchPrefix,direct,requiredCapabilities, and an optionaldestinationLocationRole(ADR 0009). It says nothing about how long a path takes, what it may carry, or which departures it can feed. There is no bounded context anywhere in the fleet that owns a CPT schedule; the word "CPT" exists only as a value object in WES and fulfillment-execution, both of which receive it and neither of which defines it. order-management'sPathSelectionPolicy(its ADR 0013) resolves every line toPICKbecause, as that ADR states, "process-path- management'sRequiredCapabilitiesfield has no real fleet data to route against today". Routing needs eligibility facts a path declares about the work it accepts, not only the capabilities a worker must hold.
The consequence is exactly the failure mode the reference model exists to prevent: the building absorbs the promise error as missed CPTs, and nothing measures it. Fixing it requires one context to own and publish the static half of path capability. This service is the fleet's Open Host Service for the process-path Published Language (ADR 0001, 0002, 0003) with four Conformist consumers already replaying its topic, so it is the natural owner. The alternative owners were considered and rejected below.
What is static capability and what is not
Two distinct things are easy to conflate:
- Capability — facts an operator declares and that change on the order of days or weeks: how long a path takes at p95, what a path may carry, which CPTs a path can feed. Reference configuration.
- Capacity — how many more units a path can absorb before a given CPT right now. Changes every second with every enqueue, release and completion. Operational state.
This ADR covers capability only. Capacity is operational state that
wes-work-planning already tracks (WorkPool WIP and rates,
ChargeForecast per CPT) and will publish under its own ADR; this
service must not become a mirror of WES state.
Decision
We will make process-path-management the fleet's source of truth for
process-path capability, published on the existing
warehouse.process-path-management.events topic through the existing
transactional outbox (ADR 0003), so every current consumer receives it
with no new subscription.
1. ProcessPath gains two revisable capability facts
cycleTimeP95(duration, required, positive). The end-to-end time from release into the path to manifest, at the 95th percentile, as the operator declares it. It is a declared standard, not a measured value:labor-performancemeasures, this service declares, and the gap between the two is a finding forlabor-performance's analytics, not a reason to couple the two contexts. Used by the promise engine to decide whether an order released now can make a CPT.eligibility(value object, required, may be permissive). Rules a unit of work must satisfy to be routed to this path, expressed over attributes the fleet already carries on the wire:maxUnitsPerLine(nil = unbounded;1is how a singles path is declared),requiredProductAttributesandexcludedProductAttributes(sets over the existing product classification vocabulary —hazmat,fragile— plusgiftWrap), andnonSortable(bool). A permissive eligibility ({}) is valid and is whatPICKgets on migration, so today's behaviour is preserved exactly until an operator narrows it.
Both are revisable via Revise while Active, raise ProcessPathUpdated
when they change, and are frozen on deactivation, exactly like
matchPrefix and requiredCapabilities. Both are additive fields on
the existing ProcessPathCreated/ProcessPathUpdated payloads; the
migration backfills cycleTimeP95 with a flat 2-hour default (no
single value was universal in the retired YAML's implied
PROMISE_PATH_LEAD_TIMES, so operators revise per path after the
migration) so no existing row is invalid.
2. A new CPTSchedule aggregate, site-scoped
A CPT is a property of a departure, not of a path: several paths feed the same truck, and a slow path simply cannot make the later ones. So the schedule is modelled once per site rather than duplicated on every path:
CPTSchedule (aggregate root, id = siteId)
timezone IANA zone, e.g. America/Sao_Paulo
cutoffs[] CPTCutoff (entity)
cptId stable id within the site, e.g. "sp1-1500"
localTime "15:00" — recurring daily cutoff
daysOfWeek subset of Mon..Sun
shipMethod free-form label ("ground", "same-day"); no
carrier integration exists in this fleet
eligiblePathIds the path families that can make this cutoff
Invariants: at least one cutoff; cptIds unique within a site; every
eligiblePathIds entry names an Active ProcessPath in this service's
own store (checked at write time — this is the one cross-aggregate rule,
and it is inside one bounded context, so it is enforced in the use
case, not by a foreign key). Revising a schedule raises a new event,
CPTScheduleChanged, carrying the full schedule (a snapshot, like the
existing path events, so a fresh consumer replaying from FirstOffset
needs no prior state). The next concrete occurrence of a cutoff is
computed by consumers from (localTime, daysOfWeek, timezone); this
service never publishes absolute timestamps for a recurring rule.
siteId uses facility-layout's site identifier vocabulary but is not
validated against it: this service has zero inbound dependencies (ADR
0001) and that posture is kept. A schedule for an unknown site is an
operator error that shows up as an unroutable order in
order-management, not a coupling here.
3. REST and MCP surfaces
PUT /sites/{siteId}/cpt-schedule,GET /sites/{siteId}/cpt-scheduleon the existing REST adapter, RFC 7807 errors as today.cycleTimeP95andeligibilityon the existing path create/revise DTOs and onprocess-path-mfe.- Two read-only MCP tools (
get_cpt_schedule,list_process_pathswidened), consistent with ADR 0006's curated intent-level tool posture. No write tools.
4. What is explicitly out of scope here
- Publishing remaining capacity per CPT. That is
wes-work-planning's operational state and will be its own ADR there (working titlePathCapacityChanged). - Carrier or ship-method integration.
shipMethodis a label. - Rewriting how
wes-work-planningmaps promise to CPT. That changes when order-management ADR 0014 starts sending acptIdinstead of a bare timestamp; WES's change is recorded in that ADR's rollout.
Alternatives considered
- A new
transportation/outbound-schedulingbounded context owning the CPT schedule. This is where a CPT schedule lives in a full production estate, next to carrier lanes and trailer plans, and it is the answer if this fleet ever gets a real transportation context. Rejected for now because a ninth-plus service whose only content is one aggregate with one event, consumed by one service, is a bounded context with no domain to bound; the placement here is recorded as provisional, and the aggregate is designed to lift out unchanged. - CPT cutoffs as a list on each
ProcessPath. Simplest, but it denormalises one departure onto N paths and makes "the 15:00 truck" a coincidence of N operator edits agreeing. Rejected. - Keeping the promise as
PROMISE_PATH_LEAD_TIMESand just widening the durations. Leaves the promise a guess and leaves nothing to measure it against. Rejected; this is the status quo. - Letting
order-managementown capability facts about paths. It is the consumer of that information, not its author, and it does not own the path catalogue. Rejected as a boundary inversion.
Consequences
Easier
- A delivery promise can be derived from declared path feasibility and a real departure schedule, which is the precondition for every promise KPI (on-time-to-CPT, re-promise rate) meaning anything.
order-management'sPathSelectionPolicyfinally has declared eligibility data to route against, unblocking the attribute-driven routing its ADR 0013 deferred.wes-work-planning'sChargeForecastCPT buckets and the CPTs on real work units can share identifiers, making charge planning per-CPT rather than per-order-timestamp.- Existing consumers need no new topic, consumer group or readiness
gate: the same replay-from-
FirstOffsetcache pattern (per-instance consumer group, offset-target readiness) picks up the new payload fields and the new event type.
Harder
- Two more things operators must configure correctly before the promise
is better than the lead-time fallback. A wrong
cycleTimeP95produces confidently wrong promises; that is the same trade a real building makes, and the KPIs are what expose it. - A provisional placement:
CPTSchedulesits in a Generic Subdomain service because there is no Transportation context. If one appears, this aggregate and its event move, andorder-managementchanges its subscription. That cost is accepted knowingly. - Every consumer's
kafkacatalogdecoder must ignore the unknown event type and the new fields until it opts in. Verifying this acrossorder-management,wes-work-planning,fulfillment-executionandworkforce-managementis part of the rollout, not an afterthought: a strict decoder that fails on an unknownevent_typewould stall its readiness gate on the firstCPTScheduleChangedmessage. eligibilityreferences the product classification vocabulary owned elsewhere in the fleet (hazmat,fragile). Adding a new attribute means agreeing on the name in two places. The vocabulary is small and changes rarely; a shared enum package was rejected as cross-repo coupling for the same reason the fleet already rejected shared code forOrderRef.
Rollout (Phase 1 of the promise plan)
- Migration
0005_capability.up.sql:cycle_time_p95(interval, NOT NULL, backfilled with a flat'2 hours'default — no YAML-derived per-path backfill shipped; no single value was universal across the retired catalogue's path families, so the conservative flat default this service's own validation accepts was chosen and operators revise per path via PUT),eligibility(jsonb, NOT NULL, default{}), newcpt_schedulestable. - Domain + use cases + tests (90% gate, gremlins baseline held).
apis/openapi.yaml,apis/asyncapi.yaml(new message, widened payloads), regenerate docs.- Decoder tolerance test in each of the four consumers, then this service's PR merges first.
- Seed the real site schedule and per-path cycle times through the
REST API against the cluster with
EVENT_PUBLISHER=kafkalive, so the outbox carries them; this also closes the still-open seeding gap from ADR 0002's cutover.