0042. Process flows: the ordered stages work passes through
Status
Accepted (2026-11-18). Extends ADR 0001 (what this context owns) next to ADR 0034 (which demand may enter a path) and follows ADR 0026 (refusing a deactivation that would break a reference). Consumer: warehouse-planning ADR 0025. Additive: existing paths, routes and published types are unchanged. Implemented after warehouse-planning's ADR 0022 to ADR 0024.
Context
A ProcessPath here is one stage of work (PICK, PACK, REBIN, SLAM) with its routing
metadata. Which stage feeds which is not modelled: ADR 0034's intake says that PACK, REBIN and
SLAM are fed by PICK's output, not in which order a workload visits them. warehouse-planning
needs that order to compose a path's end-to-end capacity (the slowest stage binds), and today
declares its own sequences with POST /process-paths in that context. The floor's topology is
then owned by a planning context, under a name (ProcessPath) that means a stage here and a
sequence there.
This context was extracted so that the fleet has one definition of its paths. The order of stages is part of that definition.
Decision
ProcessFlowaggregate. Identity:flow_id(same id rules as a path id). Fields:name, orderedstages(at least one),status(ACTIVE|RETIRED),version(starts at 1, +1 per accepted change). A stage is{path_id, process_type}:path_idnames an existing ACTIVEProcessPath(validated against this context's own catalogue, no lookup elsewhere);process_typeis one of the closed setPICK,REBIN,PACK,SLAM,DISPATCH,ARRIVAL,RELOCATE,REPLENISH(the task types fulfillment-execution publishes);- a
path_idappears at most once in a flow. A command that changes nothing raises no event and keeps the version.
- Routes.
PUT /process-flows/{flowId}(define or revise, idempotent),GET /process-flows/{flowId},GET /process-flows(keyset page, ADR 0040),DELETE /process-flows/{flowId}(retire; a retired flow cannot be revised). Read-only MCP tools and A2A skills follow the authority levels of ADR 0041 (L1). - Events, full state per flow.
ProcessFlowDefined,ProcessFlowRevisedandProcessFlowRetired, typecom.warehouse.wes.process-path-management.processflow.<Event>, onwarehouse.process-path-management.eventsand the analytics topic, through the outbox.data:flow_id,name,stages([{path_id, process_type}], in order),status,version. Key andsubject=flow_id, so one flow's events stay in order. Consumers apply a message only when itsversionis greater than the stored one. The startup republish of ADR 0038 republishes every ACTIVE flow asProcessFlowRevisedwith its current state, the same way it republishes paths. - Referential rule. Deactivating a path that an ACTIVE flow uses is refused with
409 path-in-active-flow, naming the flows (the ADR 0026 precedent). Until a flow exists, no deactivation behaves differently. - Hard rules hold. No call to any sibling; the only consumer stays the projector of this context's analytics topic.
Consequences
- The floor's topology has one owner; warehouse-planning, and any later context, read flows instead of declaring them.
- A new aggregate, table, three published types (catalogue rows in ADR 0016's type list, AsyncAPI on both channels), four routes and the generated REST reference.
- Path deactivation gains a refusal, but only for paths an active flow uses.
Alternatives rejected
- An ordered
next_path_idon each path. A path can belong to several flows (PICK feeds both a REBIN flow and a direct-to-PACK flow); one successor field cannot express that. - Derive the order from
intake.intakenames demand sources, not an order of stages. - Leave sequences in warehouse-planning. The topology stays in a planning context and drifts from the catalogue it references.