openapi: 3.0.3 info: title: warehouse-planning description: > Can this warehouse process the demand assigned to it, given its current labor, location, equipment, station, conveyor and buffer constraints? Phase 1 exposes native ProcessCapacity registration and the computed effective rate; Phase 2 the normalized ProcessPath capacity; Phase 4 CapacityPlans (assigned demand vs. path capacity, shortage, bottleneck) whose lifecycle events leave through a transactional outbox (see asyncapi.yaml). Station capacity: stations tallied from facility-layout have no throughput of their own; an operator-declared StationStandard (throughput per station) is composed with LABOR and the other constraints AT READ TIME (docs/adr/0002), and the storage positions / station counts of a site are a read model. Cross-cutting behaviour of the service on port 8080: errors are RFC 7807 application/problem+json. A NUL character (U+0000) in the path is 404 resource-not-found, in the query 400 malformed-request-query and in a request body 400 malformed-request-body. A collection GET answers 400 unknown-query-parameter for a query parameter it does not declare; the other GETs ignore unknown parameters. A request body is parsed as JSON whatever its Content-Type, and unknown body fields are ignored. Every POST is keyed by Idempotency-Key; the PUT declarations are naturally idempotent and take no key. A request to an unrouted path or method is answered by the router with a plain-text 404 / 405 outside this contract. GET /healthz and GET /readyz exist but are operational probes, not part of this contract. version: "0.1.0" contact: name: warehouse-planning maintainers url: https://github.com/IQVO/warehouse-planning license: name: UNLICENSED servers: - url: http://localhost:8080 tags: - name: process-capacities description: Native and effective ProcessCapacity registration (Phase 1). - name: process-paths description: ProcessPath registration and normalized ProcessPathCapacity (Phase 2). - name: capacity-plans description: CapacityPlan creation, publication and lookup (Phase 4). - name: station-capacity description: Operator-declared station standards and the storage/station read model of a site (ADR 0002). - name: demand description: Expected demand of a site, read from the local read model fed by order-management's order events (ADR 0004). - name: inbound-demand description: Operator-declared inbound labour standards and the inbound demand of a site, read from the local read model fed by dock-scheduling's dock appointment events (ADR 0017, source switched by ADR 0020). - name: observed-capacity description: Advisory planned-versus-observed variance of a capacity plan, from the local read model fed by fulfillment-execution's task completions (ADR 0017). - name: workload-forecasts description: The volume a process path is expected to receive at a site, as CPT buckets (ADR 0023; moved from wes-work-planning's charge forecast). - name: labour-plans description: The heads a process path needs for one shift at a site, sent or derived from the workload forecast (ADR 0023; moved from wes-work-planning's path plan). - name: reports description: > Read-only analytics reports (ADR 0005) served by the separate planning-reports binary on port 8092, from the analytical database the planning-projector builds from this service's analytics topic. Not part of the OLTP API on port 8080. paths: /process-capacities: post: operationId: registerProcessCapacityConstraint summary: Register (or upsert) one capacity constraint tags: [process-capacities] parameters: - $ref: "#/components/parameters/IdempotencyKey" description: > Upserts one named constraint (LABOR, LOCATION, EQUIPMENT, STATION, CONVEYOR, BUFFER or REPLENISHMENT) on the ProcessCapacity identified by (process_type, location, window_start, window_end), creating the aggregate on first registration. Returns the recomputed effective rate (the minimum across every registered constraint) and which constraint is binding. The window is the aggregate's identity: this endpoint (like GET /process-capacities) uses EXACT-key semantics. When path capacity or a capacity plan is computed, a registered window applies to the requested planning window if it COVERS it (docs/adr/0003). requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RegisterConstraintRequest" responses: "201": description: Constraint registered; effective capacity recomputed. headers: Idempotency-Replayed: $ref: "#/components/headers/IdempotencyReplayed" content: application/json: schema: $ref: "#/components/schemas/EffectiveCapacityResponse" "400": description: > Malformed JSON body (malformed-json), window_start/window_end not RFC 3339 (malformed-window-start / malformed-window-end), a window whose end is not after its start (invalid-capacity-window), a NUL character in the body (malformed-request-body), or the Idempotency-Key header is missing (idempotency-key-required) or malformed (idempotency-key-invalid). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "409": description: Constraint rate unit does not match the aggregate's established native unit (unit-mismatch), or the Idempotency-Key was already used with a different request (idempotency-key-reused). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "422": description: Negative quantity (negative-quantity) or a non-positive period_seconds (non-positive-period). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" get: operationId: getEffectiveProcessCapacity x-pagination-exempt: view summary: Get the effective capacity for a process, location and window tags: [process-capacities] description: > Returns the effective rate (the minimum across every registered constraint), which constraint is binding, and the full list of registered constraints for the ProcessCapacity identified by (process_type, location, window_start, window_end). This lookup keeps EXACT-key semantics (it reads one registered aggregate; it does NOT match by coverage -- path capacity and capacity plans do, see docs/adr/0003). 404 if nothing has been registered for that identity yet. parameters: - name: process_type in: query required: true schema: type: string example: PICK - name: location in: query required: true schema: type: string example: PICK-ZONE-A - name: window_start in: query required: true schema: type: string format: date-time - name: window_end in: query required: true schema: type: string format: date-time responses: "200": description: Effective capacity for this process, location and window. content: application/json: schema: $ref: "#/components/schemas/EffectiveCapacityResponse" "400": description: Malformed window_start/window_end (malformed-window-start / malformed-window-end), or a NUL character in the query (malformed-request-query). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "404": description: No ProcessCapacity registered for this process, location and window. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /process-paths: get: operationId: listProcessPaths summary: List the ProcessPaths (the ACTIVE process flows) tags: [process-paths] description: > The ACTIVE process flows consumed from process-path-management (docs/adr/0025), ordered by id, each with its ordered steps and its read-only `source` (`flow`; the local declaration retired with stage 3, so no other value occurs), one keyset page at a time (limit + cursor; follow nextCursor until it is absent). A RETIRED flow never shows. 200 with an empty items list when none is known. Read-only; there is no MCP tool for it. parameters: - $ref: "#/components/parameters/Limit" - $ref: "#/components/parameters/Cursor" responses: "200": description: One page of paths (possibly empty). content: application/json: schema: $ref: "#/components/schemas/ProcessPathPage" "400": $ref: "#/components/responses/PageBadRequest" "500": $ref: "#/components/responses/InternalError" /process-paths/{id}: get: operationId: getProcessPath x-pagination-exempt: view summary: Get the ProcessPath an id resolves to tags: [process-paths] description: > The ProcessPath an id resolves to: its ACTIVE process flow consumed from process-path-management (its steps are the stages' process types in order; docs/adr/0025). `source` is read-only and always `flow` (the local declaration retired with stage 3). A RETIRED flow, or an id no ACTIVE flow has, is a 404. Read-only. parameters: - name: id in: path required: true schema: type: string example: pick-rebin-pack responses: "200": description: The resolved ProcessPath. content: application/json: schema: $ref: "#/components/schemas/ProcessPathResponse" "404": description: No ACTIVE process flow and no locally declared path under id (process-path-not-found). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /process-paths/{id}/capacity: get: operationId: getProcessPathCapacity x-pagination-exempt: view summary: Get a ProcessPath's normalized, end-to-end capacity tags: [process-paths] description: > Loads the ProcessPath identified by id (an ACTIVE process flow first, else the locally declared path; the response says which in `source`, docs/adr/0025), loads each of its steps' ProcessCapacity for the given location and window (matched by COVERAGE, see below), normalizes each step's effective rate into ORDER/period via the WorkloadProfile factors supplied on the request (Phase 2 simplification: there is no dedicated WorkloadProfile persistence yet), and returns the minimum normalized rate plus which step is the bottleneck. Each step's candidate constraints are (a) the constraints of the ProcessCapacity aggregates of (process, location) whose window COVERS [window_start, window_end) -- registered window start <= window_start AND registered window end >= window_end, so an equal window covers it -- taking, per constraint type, the one from the covering window with the LATEST start (tie: the narrower window); older or wider covering windows' constraints of the same type are shadowed, other types still apply (docs/adr/0003), and (b) a DERIVED STATION constraint = the stations facility-layout tallied across the zones of the site (zone ids starting with `-`) x the declared StationStandard, when both a station count above zero and a standard exist. EVERY candidate is normalized to ORDER/hour before the minimum is taken. With stations but no declared standard the step uses (a) only and `warnings` says so. `step_breakdown` and `warnings` are additive fields. parameters: - name: id in: path required: true schema: type: string example: pick-rebin-pack - name: location in: query required: true schema: type: string example: PATH-ZONE-A - name: window_start in: query required: true description: Planning window start; a registered window applies to a step when it covers [window_start, window_end). schema: type: string format: date-time - name: window_end in: query required: true description: Planning window end (exclusive); must be after window_start. schema: type: string format: date-time - name: units_per_order in: query required: false schema: type: number format: double exclusiveMinimum: true minimum: 0 example: 2.5 - name: packages_per_order in: query required: false schema: type: number format: double exclusiveMinimum: true minimum: 0 example: 1 responses: "200": description: Normalized ProcessPathCapacity and bottleneck step. content: application/json: schema: $ref: "#/components/schemas/ProcessPathCapacityResponse" "400": description: Malformed window_start/window_end/units_per_order/packages_per_order, or a window whose end is not after its start. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "404": description: No ACTIVE process flow and no locally declared path under id. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "422": description: > A path step has neither a registered ProcessCapacity whose window covers the requested window at this location nor a derived STATION constraint, or the WorkloadProfile is missing a needed conversion factor / has an invalid one / cannot normalize a step's native unit. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /capacity-plans: get: operationId: listCapacityPlans summary: List the most recent CapacityPlans tags: [capacity-plans] description: > The most recently created plans, newest first (ties broken by id, descending), each in exactly the shape of GET /capacity-plans/{id}, one keyset page at a time (limit + cursor; follow nextCursor until it is absent). `location`, `site_id`, `path_id`, `window_start` and `window_end` are optional, ADDITIVE filters (docs/adr/0024): a plan is listed only when it matches every filter sent; an omitted or empty one does not filter (repeat them on every page request). Together site_id, path_id and the window list the what-if scenarios of one window. 200 with an empty items list when nothing matches. Read-only; there is no MCP tool for it. parameters: - name: location in: query required: false schema: type: string example: SIM1 - name: site_id in: query required: false description: Only plans of this canonical site (exact match). schema: type: string example: SIM1 - name: path_id in: query required: false description: Only plans evaluating this ProcessPath id (exact match). schema: type: string example: pick-rebin-pack - name: window_start in: query required: false description: > Only plans whose window starts at this instant (RFC 3339; equal instants match in any zone). Malformed: 400 malformed-window-start. schema: type: string format: date-time example: "2026-10-05T08:00:00Z" - name: window_end in: query required: false description: > Only plans whose window ends at this instant (RFC 3339). Malformed: 400 malformed-window-end; with window_start, an end that is not after the start is 400 invalid-capacity-window. schema: type: string format: date-time example: "2026-10-05T16:00:00Z" - $ref: "#/components/parameters/Limit" - $ref: "#/components/parameters/Cursor" responses: "200": description: One page of plans, newest first (possibly empty). content: application/json: schema: $ref: "#/components/schemas/CapacityPlanPage" "400": description: > invalid-limit, invalid-cursor, unknown-query-parameter, malformed-window-start, malformed-window-end or invalid-capacity-window. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" post: operationId: createCapacityPlan summary: Create a DRAFT CapacityPlan and compute its shortage tags: [capacity-plans] parameters: - $ref: "#/components/parameters/IdempotencyKey" description: > Evaluates the ProcessPath path_id against assigned_demand (orders) for the warehouse's location over [window_start, window_end): loads each step's ProcessCapacity, normalizes it with the WorkloadProfile factors supplied in the body (same shape and validation as GET /process-paths/{id}/capacity -- there is no WorkloadProfile persistence yet), and computes path_capacity (ORDER per HOUR), bottleneck_step, capacity_over_window (path_capacity x window hours) and shortage (max(0, assigned_demand - capacity_over_window), never negative). The window is both the plan's planning window AND the window every step's ProcessCapacity is looked up for: a registered window applies to a step when it COVERS [window_start, window_end), exactly as in GET /process-paths/{id}/capacity (docs/adr/0003). The plan stores its own requested window. site_id is REQUIRED: the canonical site (a facility-layout Site site_code, the same identifier its SiteCapabilityChanged event publishes) the plan is scoped to. It is a stated planning fact, never inferred from warehouse_id or location, and a blank or absent one is rejected with 422 missing-required-field. assigned_demand is OPTIONAL (docs/adr/0004). An explicit value (including 0) is used exactly as stated and the plan's demand_source is "request". When it is OMITTED the demand defaults to the number of orders the local read model -- fed by order-management's published OrderAllocated / OrderPartiallyAllocated events, never by a live call -- expects at `location` in [window_start, window_end) (see GET /demand), the plan's demand_source is "orders", and assigned_demand in the response is that figure. When the read model has no order for that location and window the request is rejected with 422 missing-assigned-demand: absence never silently means zero demand. demand_source (docs/adr/0024) may name the source instead: "forecast" derives assigned_demand from the workload forecast of (site_id, forecast_path_id, default path_id) -- the units of the buckets whose cpt is in the window over units_per_order, rounded up to orders -- and the plan returns forecast_path_id. labour_requirement (docs/adr/0022) states, per path step, the labour its demand requires: tasks x the standard seconds of the step's task type, read from the local copy of labor-performance's labour standards (fed by its LaborStandardDefined / LaborStandardRevised events, never by a live call) for the plan's site at window_start. The optional tasks_per_order map counts a step's tasks; a step without a standard or without a task count is known false with a reason. It is informational: the shortage, the bottleneck and every published event are unchanged by it. The plan is saved and its CapacityPlanCreated event is queued in the transactional outbox in ONE database transaction. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateCapacityPlanRequest" responses: "201": description: Plan created (status DRAFT). headers: Idempotency-Replayed: $ref: "#/components/headers/IdempotencyReplayed" content: application/json: schema: $ref: "#/components/schemas/CapacityPlanResponse" "400": description: Malformed JSON body, malformed window_start/window_end, a window whose end is not after its start, or a missing/malformed Idempotency-Key (idempotency-key-required / idempotency-key-invalid). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "404": description: No ProcessPath registered under path_id. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "409": $ref: "#/components/responses/KeyReused" "422": description: > A path step has no ProcessCapacity registered for this location/window; a WorkloadProfile factor is missing, not positive, or cannot normalize a step's unit; assigned_demand is negative, or is omitted and the order-demand read model has no order for this location and window (missing-assigned-demand); a tasks_per_order value is not positive (non-positive-tasks-per-order); site_id is absent/blank; or warehouse_id/location/path_id is blank. demand_source (docs/adr/0024): an unknown value (unknown-demand-source), an input the source does not read (demand-source-conflict), demand_source forecast without units_per_order (missing-units-per-order) or with no forecast bucket in the window (missing-assigned-demand); a scenario label that is empty or longer than 64 characters (invalid-scenario). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /capacity-plans/comparisons: get: operationId: compareCapacityPlans x-pagination-exempt: view summary: Lay 2 to 5 capacity plan scenarios of one site and window side by side tags: [capacity-plans] description: > docs/adr/0024 decision 4. ids names 2 to 5 distinct stored plans, all of one site_id and one window (same window_start and window_end); their paths, locations and statuses may differ. Per plan, in the order of ids, it returns the scenario, status, assigned demand and its source, path capacity, capacity over the window, shortage, bottleneck step and constraint and the ADR 0022 labour requirement exactly as stored when the plan was created: nothing is recomputed, so a comparison is reproducible. Read-only; REST only (no MCP tool). parameters: - name: ids in: query required: true description: 2 to 5 distinct plan ids, comma-separated. schema: type: string example: 0b7a4c1e-5d52-4f0e-9a39-6c1f2f3a8b10,5e963738-f2d6-494f-b88d-8ef73365e4a3 responses: "200": description: The plans side by side. content: application/json: schema: $ref: "#/components/schemas/PlanComparisonResponse" "400": description: A query parameter other than ids (unknown-query-parameter). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "404": description: One of the ids names no CapacityPlan (capacity-plan-not-found). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "422": description: > ids does not name 2 to 5 distinct, non-blank plans (invalid-comparison-ids), or the plans are not all of one site (comparison-site-mismatch) or of one window (comparison-window-mismatch). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /capacity-plans/{id}: get: operationId: getCapacityPlan summary: Get a CapacityPlan tags: [capacity-plans] description: > Returns the stored plan, including its computed shortage, status, the constraint type binding the bottleneck step and the composition warnings. parameters: - name: id in: path required: true schema: type: string example: 0b7a4c1e-5d52-4f0e-9a39-6c1f2f3a8b10 responses: "200": description: The plan. content: application/json: schema: $ref: "#/components/schemas/CapacityPlanResponse" "404": description: No CapacityPlan exists under id. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /capacity-plans/{id}/publications: post: operationId: publishCapacityPlan summary: Publish a DRAFT CapacityPlan tags: [capacity-plans] description: > Moves the plan DRAFT -> PUBLISHED, saves it and queues, in the same database transaction, CapacityPlanPublished plus -- only when the plan has a shortage -- CapacityShortageDetected and BottleneckDetected in the transactional outbox. A relay publishes them to Kafka as CloudEvents (see asyncapi.yaml). Publishing twice is never silent: the second call is a 409 and queues nothing. Publishing supersedes (docs/adr/0024 decision 3): when another plan of the same site_id, location, path_id and window is PUBLISHED, that older plan becomes SUPERSEDED (superseded_by: this plan) and CapacityPlanSuperseded is queued first, in the same transaction. A SUPERSEDED plan is never published again (409). parameters: - $ref: "#/components/parameters/IdempotencyKey" - name: id in: path required: true schema: type: string example: 0b7a4c1e-5d52-4f0e-9a39-6c1f2f3a8b10 responses: "200": description: Plan published. headers: Idempotency-Replayed: $ref: "#/components/headers/IdempotencyReplayed" content: application/json: schema: $ref: "#/components/schemas/CapacityPlanResponse" "400": $ref: "#/components/responses/BadRequest" "404": description: No CapacityPlan exists under id. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "409": description: The plan is already PUBLISHED (capacity-plan-already-published), was SUPERSEDED by a newer published plan of its window (capacity-plan-superseded), a concurrent publish of the same site, location, path and window won twice (version-conflict; retry it), or the Idempotency-Key was already used with a different request (idempotency-key-reused). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /station-standards/{location}/{process_type}: put: operationId: declareStationStandard summary: Declare the throughput of ONE station of a process at a site tags: [station-capacity] description: > Upserts the StationStandard keyed by (location, process_type): the throughput of a single station in the process's natural unit, e.g. 180 PACKAGE per 3600 s for PACK at SIM1. The count of stations comes from facility-layout; count x standard is composed with the step's registered constraints when a path capacity or capacity plan is computed (nothing derived is stored, so a late declaration applies on the next read). `location` is the site (building) code, the first dash-separated segment of the facility zone ids. parameters: - name: location in: path required: true schema: type: string example: SIM1 - name: process_type in: path required: true schema: type: string example: PACK requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DeclareStationStandardRequest" responses: "200": description: An existing standard was replaced. content: application/json: schema: $ref: "#/components/schemas/StationStandardResponse" "201": description: A new standard was declared. content: application/json: schema: $ref: "#/components/schemas/StationStandardResponse" "400": description: Malformed request body. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "422": description: > Invalid declaration: non-positive or negative quantity, non-positive period, or a unit that cannot be normalized to ORDER (only UNIT, PACKAGE and ORDER are accepted). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /station-standards: get: operationId: listStationStandards summary: List the declared station standards tags: [station-capacity] description: The standards of one site, or every standard when `location` is omitted, ordered by location then process type, one keyset page at a time (limit + cursor; follow nextCursor until it is absent). parameters: - name: location in: query required: false schema: type: string example: SIM1 - $ref: "#/components/parameters/Limit" - $ref: "#/components/parameters/Cursor" responses: "200": description: One page of declared standards (possibly empty). content: application/json: schema: $ref: "#/components/schemas/StationStandardPage" "400": $ref: "#/components/responses/PageBadRequest" "500": $ref: "#/components/responses/InternalError" /storage-capacity: get: operationId: getStorageCapacity x-pagination-exempt: view summary: Storage positions and stations of a site (read model) tags: [station-capacity] description: > The facility-layout tally of one site: storage positions per zone and locationType and work-center station counts per zone and activity, over the zones whose id starts with `-`. It is a READ MODEL, not a throughput (storage positions are not process capacity), and it has no "consumed" figure: stock is never read from inventory-storage. 200 with empty lists when nothing is tallied for the site. parameters: - name: location in: query required: true schema: type: string example: SIM1 responses: "200": description: The site's storage positions and station counts. content: application/json: schema: $ref: "#/components/schemas/StorageCapacityResponse" "400": description: location is missing. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /demand: get: operationId: getExpectedDemand summary: Expected demand of a site over a window (order-management read model) tags: [demand] description: > The orders order-management has promised at a site for a window, read from the LOCAL read model this service builds from order-management's published OrderAllocated / OrderPartiallyAllocated CloudEvents (docs/adr/0004; never a live call). `orders` counts the distinct orders whose promise cutoff (the event's promise_date) falls in the half-open window [window_start, window_end): a cutoff exactly at window_start counts, one exactly at window_end belongs to the next window. An order is counted once, at the promise of its latest event (last writer wins on the CloudEvents time). `released_lines` sums the lines their latest allocation pass released; it is NOT units -- order-management's events carry no quantities. An order is attributed to the fulfillment site its event carries (site_id, order-management ADR 0050), or to the fallback site configured on this service (DEMAND_SITE_ID) when it carries none (docs/adr/0021). Cancellations are not published on the integration topic and are not netted, and an OrderRepromised event carries no new cutoff, so it is ignored. 200 with orders 0 and as_of null when nothing is known -- an empty answer that POST /capacity-plans never turns into a zero-demand plan. parameters: - name: location in: query required: true schema: type: string example: SIM1 - name: window_start in: query required: true description: RFC 3339; inclusive. schema: type: string format: date-time example: "2026-10-05T08:00:00Z" - name: window_end in: query required: true description: RFC 3339; exclusive, must be after window_start. schema: type: string format: date-time example: "2026-10-05T16:00:00Z" responses: "200": description: The expected demand (possibly empty). content: application/json: schema: $ref: "#/components/schemas/ExpectedDemandResponse" "400": description: location missing, window_start/window_end missing or not RFC 3339, or a window whose end is not after its start. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /inbound-labour-standards/{location}/{path_id}: put: operationId: declareInboundLabourStandard summary: Declare the labour minutes a dock appointment costs at a site for a process path tags: [inbound-demand] description: > Upserts the inbound labour standard keyed by (location, path_id): fixed `minutes_per_appointment` plus an optional `minutes_per_asn` per ASN the appointment covers (the booked event carries no units, pallets or lines). The standard is a planning parameter owned by this service (docs/adr/0017): nobody upstream publishes it. Without one, dock appointments are recorded but contribute NO labour demand and the plan reports `inbound_standard_missing`; no default number is ever guessed. Nothing derived is stored, so a late declaration applies on the next read. parameters: - name: location in: path required: true schema: type: string example: SIM1 - name: path_id in: path required: true schema: type: string example: receive requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DeclareInboundLabourStandardRequest" responses: "200": description: An existing standard was replaced. content: application/json: schema: $ref: "#/components/schemas/InboundLabourStandardResponse" "201": description: A new standard was declared. content: application/json: schema: $ref: "#/components/schemas/InboundLabourStandardResponse" "400": description: Malformed request body. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "422": description: minutes_per_appointment is not positive, minutes_per_asn is negative, or a figure is not finite. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /inbound-labour-standards: get: operationId: listInboundLabourStandards summary: List the declared inbound labour standards tags: [inbound-demand] description: The standards of one site, or every standard when `location` is omitted, ordered by location then path id, one keyset page at a time (limit + cursor; follow nextCursor until it is absent). parameters: - name: location in: query required: false schema: type: string example: SIM1 - $ref: "#/components/parameters/Limit" - $ref: "#/components/parameters/Cursor" responses: "200": description: One page of declared standards (possibly empty). content: application/json: schema: $ref: "#/components/schemas/InboundLabourStandardPage" "400": $ref: "#/components/responses/PageBadRequest" "500": $ref: "#/components/responses/InternalError" /inbound-demand: get: operationId: getInboundDemand summary: Inbound demand of a site over a window (dock-scheduling read model) tags: [inbound-demand] description: > The BOOKED INBOUND dock appointments at a site whose door window STARTS in the half-open window [window_start, window_end), read from the LOCAL read model this service builds from dock-scheduling's DockAppointmentBooked / Rescheduled / Cancelled / NoShow CloudEvents (docs/adr/0017, source switched by docs/adr/0020; never a live call). A rescheduled appointment counts at its new window; a cancelled or no-show one never counts, whatever the arrival order of the events (the producer's aggregate `version` is the ordering guard). OUTBOUND appointments are never counted. `labour_minutes` is what the standard declared for `path_id` attributes to them; with no standard it is 0 and `standard_missing` is true when appointments exist. Each appointment is attributed to the `site_id` of its events, so `location` is that site code; a site with no appointment reads 0. 200 with appointments 0 and as_of null when nothing is known. parameters: - name: location in: query required: true schema: type: string example: SIM1 - name: path_id in: query required: true description: The process path whose declared inbound standard prices the appointments. schema: type: string example: receive - name: window_start in: query required: true description: RFC 3339; inclusive. schema: type: string format: date-time example: "2026-10-05T08:00:00Z" - name: window_end in: query required: true description: RFC 3339; exclusive, must be after window_start. schema: type: string format: date-time example: "2026-10-05T16:00:00Z" responses: "200": description: The inbound demand (possibly empty). content: application/json: schema: $ref: "#/components/schemas/InboundDemandResponse" "400": description: location or path_id missing, window_start/window_end missing or not RFC 3339, or a window whose end is not after its start. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /capacity-plans/{id}/variance: get: operationId: getCapacityPlanVariance summary: Planned versus observed throughput of a capacity plan (advisory) tags: [observed-capacity] description: > Compares the stored plan with the TASKS fulfillment-execution reports completed (TaskCompleted, minute resolution) for the plan's bottleneck step at its location over its window, from the LOCAL observed_capacity read model (docs/adr/0017). ADVISORY: it never changes the planned capacity or the plan, and nothing is republished. Tasks are not orders, so the comparison needs `tasks_per_order`; without it `comparison.comparable` is false with the reason. `observed.has_data` false means nothing was observed, not zero throughput. parameters: - name: id in: path required: true schema: type: string example: 0b7a4c1e-5d52-4f0e-9a39-6c1f2f3a8b10 - name: tasks_per_order in: query required: false description: Conversion factor from completed tasks to orders; must be positive. schema: type: number format: double example: 3 responses: "200": description: The variance. content: application/json: schema: $ref: "#/components/schemas/PlanVarianceResponse" "400": description: tasks_per_order is not a number. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "404": description: No CapacityPlan exists under id. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "422": description: tasks_per_order is not positive. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /workload-forecasts/{site_id}/{path_id}: put: operationId: receiveWorkloadForecast summary: Receive the workload forecast of a process path at a site tags: [workload-forecasts] description: > Stores the volume a process path is expected to receive at a site, as CPT buckets (docs/adr/0023 decision 1; it was wes-work-planning's charge forecast). One forecast per (site_id, path_id); a receipt replaces the buckets as a whole. 201 with version 1 for a first receipt; 200 with version + 1 when the buckets changed; 200 with the stored forecast, its version and received_at unchanged, when the buckets equal the stored ones (same order): nothing is written and no event is raised. A receipt that changed something raises WorkloadForecastReceived (integration and analytics topics, asyncapi.yaml) in the same transaction. The PUT is naturally idempotent and takes no Idempotency-Key. parameters: - $ref: "#/components/parameters/SiteIDPath" - $ref: "#/components/parameters/PathIDPath" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ReceiveWorkloadForecastRequest" responses: "200": description: The buckets replaced the stored ones (version + 1), or equal them (nothing changed). content: application/json: schema: $ref: "#/components/schemas/WorkloadForecastResponse" "201": description: A first receipt; the forecast is stored at version 1. content: application/json: schema: $ref: "#/components/schemas/WorkloadForecastResponse" "400": description: Malformed JSON (a fractional quantity included) or a cpt that is not RFC 3339 (malformed-json, malformed-cpt). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "409": description: The stored version moved twice while the receipt was applied (version-conflict); retry it. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "422": description: > No bucket (no-forecast-buckets), a bucket without cpt (missing-cpt) or quantity (missing-bucket-quantity), or a negative quantity (negative-bucket-quantity). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" get: operationId: getWorkloadForecast summary: Read the workload forecast of a process path at a site tags: [workload-forecasts] description: The stored forecast of (site_id, path_id), buckets in receipt order. parameters: - $ref: "#/components/parameters/SiteIDPath" - $ref: "#/components/parameters/PathIDPath" responses: "200": description: The stored forecast. content: application/json: schema: $ref: "#/components/schemas/WorkloadForecastResponse" "404": description: No forecast was received for (site_id, path_id) (workload-forecast-not-found). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /labour-plans/{site_id}/{shift_id}/{path_id}: put: operationId: commitLabourPlan summary: Commit the labour plan of a process path for a shift at a site tags: [labour-plans] description: > Stores the heads a process path needs for one shift at one site, at a planned rate for a number of hours (docs/adr/0023 decision 2; it was wes-work-planning's path plan). planned_heads must not exceed installed_stations, hours and the rate must be positive and rate x heads x hours finite. When planned_heads is omitted it is DERIVED: ceil(forecast units with a cpt in [shift_start, shift_start + hours) / (rate x hours)), which needs shift_start and a stored workload forecast for (site_id, path_id) with at least one bucket in the shift; otherwise 422 missing-planned-heads (zero buckets in the shift is no data, never zero heads). heads_source says which happened. When the facility tally knows at least one but fewer stations of the activity named like the path (the path id upper-cased) than installed_stations, the plan is still stored with the number as sent and the answer carries a warning. 201 with version 1 for a first commit; 200 with version + 1 for a revision; 200 with the stored plan and version unchanged when the plan equals the stored one (no event). A change raises LabourPlanCommitted (integration and analytics topics, asyncapi.yaml) in the same transaction. The PUT is naturally idempotent and takes no Idempotency-Key. parameters: - $ref: "#/components/parameters/SiteIDPath" - $ref: "#/components/parameters/ShiftIDPath" - $ref: "#/components/parameters/PathIDPath" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CommitLabourPlanRequest" responses: "200": description: The plan was revised (version + 1), or equals the stored one (nothing changed). content: application/json: schema: $ref: "#/components/schemas/LabourPlanResponse" "201": description: A first commit; the plan is stored at version 1. content: application/json: schema: $ref: "#/components/schemas/LabourPlanResponse" "400": description: Malformed JSON (a fractional head or station count included) or a shift_start that is not RFC 3339 (malformed-json, malformed-shift-start). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "409": description: The stored version moved twice while the plan was committed (version-conflict); retry it. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "422": description: > planned_heads above installed_stations (heads-exceed-stations), omitted heads that cannot be derived (missing-planned-heads), a head or station count below 0 or above 2147483647 (invalid-count), installed_stations omitted (missing-installed-stations), a rate or hours not above zero (non-positive-rate, non-positive-hours), or rate x heads x hours not finite (throughput-not-finite). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" get: operationId: getLabourPlan summary: Read the labour plan of a process path for a shift at a site tags: [labour-plans] description: The stored plan of (site_id, shift_id, path_id), with the station warning computed against the facility tally at read time. parameters: - $ref: "#/components/parameters/SiteIDPath" - $ref: "#/components/parameters/ShiftIDPath" - $ref: "#/components/parameters/PathIDPath" responses: "200": description: The stored plan. content: application/json: schema: $ref: "#/components/schemas/LabourPlanResponse" "404": description: No plan was committed for (site_id, shift_id, path_id) (labour-plan-not-found). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /labour-plans: get: operationId: listLabourPlans summary: List the labour plans of a shift at a site tags: [labour-plans] description: > The plans of one (site_id, shift_id), ordered by path id, one keyset page at a time (limit + cursor; follow nextCursor until it is absent). Both filters are required and are repeated on every page request. parameters: - name: site_id in: query required: true schema: type: string example: SIM1 - name: shift_id in: query required: true schema: type: string example: 2026-11-19-early - $ref: "#/components/parameters/Limit" - $ref: "#/components/parameters/Cursor" responses: "200": description: One page of plans (possibly empty). content: application/json: schema: $ref: "#/components/schemas/LabourPlanPage" "400": description: site_id or shift_id missing (missing-site-id, missing-shift-id), or invalid-limit, invalid-cursor, unknown-query-parameter. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": $ref: "#/components/responses/InternalError" /reports/bottleneck-frequency: servers: - url: http://localhost:8092 description: planning-reports (cluster-internal Service -reports) get: operationId: getBottleneckFrequencyReport summary: How often each bottleneck step (and binding constraint) bound a PUBLISHED plan, by site tags: [reports] description: > For the plans PUBLISHED in the half-open range [from, to) (by the CloudEvents time of CapacityPlanPublished: from inclusive, to exclusive), counts, per site (warehouse_id + location), how many had each bottleneck_step bound by each binding_constraint (LABOR, STATION, ...; empty for a plan created before the constraint was recorded), and `share`: that count as a fraction of the site's published plans in the range. Rows are ordered by site, then count descending. Drafts never count. Built from the analytics stream only (ADR 0005). `from` / `to` are optional RFC 3339 timestamps: both omitted means the 30 days ending now; only `to` means the 30 days before it; only `from` means from..now; the range must be non-empty and at most 366 days. 200 with `rows: []` when nothing matches. parameters: - $ref: "#/components/parameters/ReportFrom" - $ref: "#/components/parameters/ReportTo" responses: "200": description: The report (possibly empty). content: application/json: schema: $ref: "#/components/schemas/BottleneckFrequencyReport" "400": description: from or to is not RFC 3339, the range is empty or inverted, or it exceeds 366 days. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": description: The analytical database query failed. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" /reports/shortage-trend: servers: - url: http://localhost:8092 description: planning-reports (cluster-internal Service -reports) get: operationId: getShortageTrendReport summary: Published plans with shortage and total shortage by site per day tags: [reports] description: > For the plans PUBLISHED in [from, to) (from inclusive, to exclusive), per site and UTC day of the publication: how many were published (ALL of them, with or without shortage, so the rate is meaningful), how many had a shortage (> 0), the total shortage in orders, and `shortage_rate` (plans_with_shortage / plans_published). Days without a published plan are omitted. Ordered by day, then site. `from` / `to` as in /reports/bottleneck-frequency. 200 with `days: []` when nothing matches. parameters: - $ref: "#/components/parameters/ReportFrom" - $ref: "#/components/parameters/ReportTo" responses: "200": description: The report (possibly empty). content: application/json: schema: $ref: "#/components/schemas/ShortageTrendReport" "400": description: from or to is not RFC 3339, the range is empty or inverted, or it exceeds 366 days. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": description: The analytical database query failed. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" /reports/plan-throughput: servers: - url: http://localhost:8092 description: planning-reports (cluster-internal Service -reports) get: operationId: getPlanThroughputReport summary: Plans created vs published per day, and create-to-publish latency by site tags: [reports] description: > `days`: per site and UTC day, the plans created (by the CloudEvents time of CapacityPlanCreated) and the plans published (by CapacityPlanPublished) in [from, to) (from inclusive, to exclusive). `latency`: per site, over the plans published in the range whose creation was also observed, the median and 95th percentile (continuous, linear interpolation) of published - created, in seconds. Ordered by day, then site. `from` / `to` as in /reports/bottleneck-frequency. 200 with empty arrays when nothing matches. parameters: - $ref: "#/components/parameters/ReportFrom" - $ref: "#/components/parameters/ReportTo" responses: "200": description: The report (possibly empty). content: application/json: schema: $ref: "#/components/schemas/PlanThroughputReport" "400": description: from or to is not RFC 3339, the range is empty or inverted, or it exceeds 366 days. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" "500": description: The analytical database query failed. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" /reports/freshness: servers: - url: http://localhost:8092 description: planning-reports (cluster-internal Service -reports) get: operationId: getReportsFreshness summary: How far the analytics projection is behind tags: [reports] description: > The freshness lag of the projection all three reports read: `as_of` is the CloudEvents time of the newest event the projector has applied and `lag_seconds` is now minus `as_of` (never negative). Both are null until the first event is applied. A growing lag means the projector is down or behind, not that a report is wrong: it catches up when the projector does. responses: "200": description: The freshness (null fields while nothing was projected). content: application/json: schema: $ref: "#/components/schemas/ReportsFreshness" "500": description: The analytical database query failed. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" components: parameters: IdempotencyKey: name: Idempotency-Key in: header required: true description: > Client-generated key (1-128 printable ASCII characters, normally a UUID) per LOGICAL submit. A retry reuses it; a new user action mints a new one. The service always runs against Postgres (ADR 0016), so the key is required on every POST/PATCH. A missing key is 400 idempotency-key-required, a malformed one 400 idempotency-key-invalid; the same key with a different method, path or body is 409 idempotency-key-reused; the same key with the same request replays the stored answer with Idempotency-Replayed: true. schema: type: string minLength: 1 maxLength: 128 Limit: name: limit in: query required: false description: Page size (1-500, default 100). schema: type: integer minimum: 1 maximum: 500 default: 100 Cursor: name: cursor in: query required: false description: Opaque keyset cursor from the previous page's nextCursor. Repeat the filters on every page request. schema: type: string SiteIDPath: name: site_id in: path required: true description: Canonical facility-layout site code (ADR 0012). schema: type: string example: SIM1 ShiftIDPath: name: shift_id in: path required: true description: The shift the labour plan is for (the planner's shift identifier, also carried by workforce-management's shift plan). schema: type: string example: 2026-11-19-early PathIDPath: name: path_id in: path required: true description: >- The process path code: case-insensitive; stored and published in upper case (trimmed), so "pick" and "PICK" name the same forecast and labour plan. Upper-cased, it also names the facility-tally activity whose stations the labour plan's warning compares with. schema: type: string example: PICK ReportFrom: name: from in: query required: false description: RFC 3339; inclusive. Defaults to `to` minus 30 days. schema: type: string format: date-time example: "2026-10-05T00:00:00Z" ReportTo: name: to in: query required: false description: RFC 3339; exclusive. Defaults to now. schema: type: string format: date-time example: "2026-10-07T00:00:00Z" headers: IdempotencyReplayed: description: Present, with the value "true", only when the answer is a replay of an earlier request with the same Idempotency-Key. schema: type: string enum: ["true"] responses: BadRequest: description: Malformed request, or the Idempotency-Key header is missing (idempotency-key-required) or malformed (idempotency-key-invalid). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" KeyReused: description: The Idempotency-Key was already used with a different request (idempotency-key-reused). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" InternalError: description: > An unexpected failure (a store or outbox error). Answered as problem+json (internal-error). A 5xx answer is never stored under an Idempotency-Key and rolls back the aggregate change and its outbox rows, so the retry re-executes. content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" PageBadRequest: description: invalid-limit, invalid-cursor, or unknown-query-parameter (a retired paging parameter such as after, from, offset or nextToken). content: application/problem+json: schema: $ref: "#/components/schemas/ProblemDetail" schemas: ReportsFreshness: type: object required: [as_of, lag_seconds] properties: as_of: type: string format: date-time nullable: true description: CloudEvents time of the newest event applied; null when none. lag_seconds: type: number format: double nullable: true minimum: 0 description: now - as_of, in seconds; null when nothing was applied. example: 4.2 ReportSite: type: object required: [warehouse_id, location] properties: warehouse_id: type: string example: WH-1 location: type: string description: The planning location (site code). example: SIM1 BottleneckFrequencyRow: allOf: - $ref: "#/components/schemas/ReportSite" - type: object required: [bottleneck_step, binding_constraint, plans, share] properties: bottleneck_step: type: string example: REBIN binding_constraint: type: string description: The constraint type binding the step (LABOR, STATION, ...); empty when unknown. example: LABOR plans: type: integer minimum: 1 example: 3 share: type: number format: double minimum: 0 maximum: 1 description: plans / all published plans of this site in the range. example: 0.75 BottleneckFrequencyReport: type: object required: [from, to, rows] properties: from: type: string format: date-time description: The effective inclusive start. to: type: string format: date-time description: The effective exclusive end. rows: type: array items: $ref: "#/components/schemas/BottleneckFrequencyRow" ShortageTrendDay: allOf: - $ref: "#/components/schemas/ReportSite" - type: object required: [day, plans_published, plans_with_shortage, total_shortage, shortage_rate] properties: day: type: string format: date description: UTC calendar day of the publication. example: "2026-10-05" plans_published: type: integer minimum: 1 example: 8 plans_with_shortage: type: integer minimum: 0 example: 2 total_shortage: type: number format: double description: Sum of the plans' shortage, in orders. example: 5600 shortage_rate: type: number format: double minimum: 0 maximum: 1 example: 0.25 ShortageTrendReport: type: object required: [from, to, days] properties: from: type: string format: date-time to: type: string format: date-time days: type: array items: $ref: "#/components/schemas/ShortageTrendDay" PlanThroughputDay: allOf: - $ref: "#/components/schemas/ReportSite" - type: object required: [day, plans_created, plans_published] properties: day: type: string format: date example: "2026-10-05" plans_created: type: integer minimum: 0 example: 5 plans_published: type: integer minimum: 0 example: 4 PlanLatency: allOf: - $ref: "#/components/schemas/ReportSite" - type: object required: [plans, median_seconds, p95_seconds] properties: plans: type: integer minimum: 1 description: Published plans in the range whose creation was also observed. example: 4 median_seconds: type: number format: double example: 390 p95_seconds: type: number format: double example: 1620 PlanThroughputReport: type: object required: [from, to, days, latency] properties: from: type: string format: date-time to: type: string format: date-time days: type: array items: $ref: "#/components/schemas/PlanThroughputDay" latency: type: array items: $ref: "#/components/schemas/PlanLatency" ExpectedDemandResponse: type: object required: [location, window_start, window_end, orders, released_lines, source, as_of] properties: location: type: string example: SIM1 window_start: type: string format: date-time window_end: type: string format: date-time orders: type: integer minimum: 0 description: Distinct orders whose promise cutoff is in [window_start, window_end). example: 3 released_lines: type: integer minimum: 0 description: Lines released by those orders' latest allocation pass. NOT units. example: 6 source: type: string enum: [order-management] as_of: type: string format: date-time nullable: true description: CloudEvents time of the newest order event the site's model reflects (whole site, not only the window); null when none. DeclareStationStandardRequest: type: object required: - quantity - unit - period_seconds properties: quantity: type: number format: double exclusiveMinimum: true minimum: 0 description: Throughput of ONE station per period. example: 180 unit: type: string enum: [UNIT, PACKAGE, ORDER] example: PACKAGE period_seconds: type: number format: double exclusiveMinimum: true minimum: 0 description: The period the quantity is measured over, in seconds (3600 = per hour). example: 3600 StationStandardResponse: type: object required: [location, process_type, quantity, unit, period_seconds] properties: location: type: string example: SIM1 process_type: type: string example: PACK quantity: type: number format: double example: 180 unit: type: string example: PACKAGE period_seconds: type: number format: double example: 3600 StationStandardPage: type: object description: One keyset page of station standards, ordered by location then process type. required: [items] properties: items: type: array items: $ref: "#/components/schemas/StationStandardResponse" nextCursor: type: string description: Opaque cursor for the next page; absent on the last page. StorageCapacityResponse: type: object required: [location, storage_positions, stations] properties: location: type: string example: SIM1 storage_positions: type: array items: type: object required: [zone_id, location_type, positions] properties: zone_id: type: string example: SIM1-STOR-AMB location_type: type: string example: SimShelf positions: type: integer example: 24 stations: type: array items: type: object required: [zone_id, activity, stations] properties: zone_id: type: string example: SIM1-OPS-WC activity: type: string example: PACK stations: type: integer example: 11 RegisterConstraintRequest: type: object required: - process_type - location - window_start - window_end - constraint_type - quantity - unit - period_seconds properties: process_type: type: string example: PICK location: type: string example: PICK-ZONE-A window_start: type: string format: date-time example: "2026-10-05T08:00:00Z" description: Start of the registered window (part of the aggregate's identity; exact key). window_end: type: string format: date-time example: "2026-10-05T09:00:00Z" description: End of the registered window (exclusive; part of the aggregate's identity). constraint_type: type: string enum: [LABOR, LOCATION, EQUIPMENT, STATION, CONVEYOR, BUFFER, REPLENISHMENT] description: The documented constraint types. The service does not validate the value; any string is stored and echoed back. quantity: type: number format: double minimum: 0 example: 3500 unit: type: string enum: [UNIT, LINE, ORDER, PACKAGE] description: > The documented capacity units. The service does not validate the value on registration: the first constraint fixes the aggregate's native unit (whatever string it is) and a later constraint in another unit is 409 unit-mismatch. period_seconds: type: number format: double exclusiveMinimum: true minimum: 0 example: 3600 EffectiveCapacityResponse: type: object required: [effective_rate, effective_unit, binding_constraint] properties: effective_rate: type: number format: double example: 3500 effective_unit: type: string example: UNIT binding_constraint: type: string example: LOCATION constraints: type: array items: $ref: "#/components/schemas/ConstraintEntry" ConstraintEntry: type: object required: [constraint_type, quantity, unit, period_seconds] properties: constraint_type: type: string quantity: type: number format: double unit: type: string period_seconds: type: number format: double ProblemDetail: type: object required: [type, title, status, detail, instance] description: RFC 7807 problem detail. properties: type: type: string format: uri title: type: string status: type: integer detail: type: string instance: type: string ProcessPathResponse: type: object required: [id, name, steps, source] properties: id: type: string name: type: string steps: type: array items: type: string source: $ref: "#/components/schemas/ProcessPathSource" ProcessPathSource: type: string enum: [flow, local] readOnly: true description: > Additive, read-only (docs/adr/0025). Where the path came from: `flow` is a process flow consumed from process-path-management. Since stage 3 retired the local declaration it is the only value that occurs; `local` stays in the enum for readers written against stage 1. example: flow ProcessPathPage: type: object description: One keyset page of paths (process flows and locally declared paths), ordered by id. required: [items] properties: items: type: array items: $ref: "#/components/schemas/ProcessPathResponse" nextCursor: type: string description: Opaque cursor for the next page; absent on the last page. CapacityPlanPage: type: object description: One keyset page of plans, newest first. required: [items] properties: items: type: array items: $ref: "#/components/schemas/CapacityPlanResponse" nextCursor: type: string description: Opaque cursor for the next page; absent on the last page. ProcessPathCapacityResponse: type: object required: [source, normalized_rate, normalized_unit, bottleneck_step, step_breakdown, warnings] properties: source: $ref: "#/components/schemas/ProcessPathSource" normalized_rate: type: number format: double example: 1000 normalized_unit: type: string example: ORDER bottleneck_step: type: string example: REBIN step_breakdown: type: array description: Additive. Each step's composed capacity in path order. items: type: object required: [step, normalized_rate, binding_constraint] properties: step: type: string example: PACK normalized_rate: type: number format: double description: The step's effective rate, ORDER per HOUR. example: 1800 binding_constraint: type: string enum: [LABOR, LOCATION, EQUIPMENT, STATION, CONVEYOR, BUFFER, REPLENISHMENT] example: STATION warnings: type: array description: Additive. Composition warnings (never null), e.g. stations tallied but no station standard declared. items: type: string CreateCapacityPlanRequest: type: object required: - warehouse_id - site_id - location - window_start - window_end - path_id properties: warehouse_id: type: string example: WH-1 site_id: type: string description: >- REQUIRED. Canonical site the plan is scoped to: a facility-layout Site site_code (the same identifier its SiteCapabilityChanged event publishes). A stated planning fact, never inferred from warehouse_id or location. example: SIM1 location: type: string description: The ProcessCapacity location every path step is looked up under. example: PATH-ZONE-A window_start: type: string format: date-time example: "2026-10-05T08:00:00Z" description: Plan window start. A registered capacity window applies when it covers [window_start, window_end). window_end: type: string format: date-time example: "2026-10-05T16:00:00Z" description: Plan window end (exclusive); must be after window_start. path_id: type: string description: id of a registered ProcessPath. example: pick-rebin-pack assigned_demand: type: number format: double minimum: 0 description: > OPTIONAL. Orders assigned to the window. When present (even 0) it is used exactly as stated and the plan's demand_source is "request". When omitted it defaults to the orders order-management expects at `location` in the window (GET /demand; demand_source "orders"), or the request is rejected with 422 missing-assigned-demand when there are none -- never silently 0. example: 12000 units_per_order: type: number format: double description: WorkloadProfile factor (UNIT per ORDER); needed only if a step is measured in UNIT. example: 2.5 packages_per_order: type: number format: double description: WorkloadProfile factor (PACKAGE per ORDER); needed only if a step is measured in PACKAGE. example: 1 tasks_per_order: type: object description: > OPTIONAL, additive (docs/adr/0022). Tasks per ORDER for a process type, keyed by process type. A step's labour requirement is its tasks x the labor-performance standard seconds of its task type, where tasks = assigned_demand x this factor; a PICK step uses the released order lines instead when the demand came from the order read model (demand_source "orders"). A step without a factor is reported known false with reason no-task-factor, never guessed. Every value must be positive (422 non-positive-tasks-per-order). It never changes path_capacity, the shortage or the bottleneck. additionalProperties: type: number format: double minimum: 0 exclusiveMinimum: true example: PICK: 3 PACK: 1 demand_source: type: string enum: [request, orders, forecast] description: > OPTIONAL (docs/adr/0024). Where assigned_demand comes from. Omitted: "request" when assigned_demand is given, "orders" when it is omitted (the pre-ADR-0024 behaviour). "forecast": the units of the workload forecast of (site_id, forecast_path_id) whose bucket cpt is in [window_start, window_end) (start in, end out), divided by units_per_order and rounded UP to orders. units_per_order is then REQUIRED (422 missing-units-per-order); no bucket in the window is 422 missing-assigned-demand, never zero demand. "orders" and "forecast" derive assigned_demand and refuse a stated one, "request" requires it (422 demand-source-conflict / missing-assigned-demand); any other value is 422 unknown-demand-source. example: forecast forecast_path_id: type: string description: > OPTIONAL, with demand_source "forecast" only (422 demand-source-conflict otherwise). The process path whose workload forecast is read at site_id -- the path the volume enters (e.g. the wes path PICK), which need not be path_id. Defaults to path_id. Read in its canonical form (trimmed, upper case). example: PICK scenario: type: string minLength: 1 maxLength: 64 description: > OPTIONAL what-if label (docs/adr/0024), 1 to 64 characters, stored and returned. Several DRAFT plans of one (site_id, path_id, window) are scenarios (see GET /capacity-plans/comparisons). An empty or longer label is 422 invalid-scenario. example: second pack line open LabourRequirement: type: object description: > Additive (docs/adr/0022). The labour one step of the plan's path requires: tasks x the engineered standard seconds of the step's task type (labor-performance's standard in force for the plan's site at the window start; a step's process type names its task type). Computed when the plan was created and stored with it: a later revision of a standard never rewrites it. Informational: the ORDER shortage, the bottleneck and every published event do not depend on it. When known is false the figures are 0 and reason says why. required: [process_type, standard_seconds, standard_site_scoped, tasks, required_labour_hours, required_average_heads, known] properties: process_type: type: string example: PACK standard_seconds: type: number format: double description: expected_seconds of the standard in force; 0 when there is none. example: 90 standard_site_scoped: type: boolean description: True when that standard is scoped to the plan's site rather than every site. example: false tasks: type: number format: double description: Tasks the step's demand is (released lines for PICK with demand_source orders, else assigned_demand x tasks_per_order[step]). example: 12000 required_labour_hours: type: number format: double description: tasks x standard_seconds / 3600. example: 300 required_average_heads: type: number format: double description: required_labour_hours over the plan window length, in people. example: 37.5 known: type: boolean example: true reason: type: string enum: [no-labor-standard, no-task-factor] description: > Present only when known is false. no-labor-standard: no labor-performance standard of the step's task type is in force for the plan's site and window (or the step is not a task type it measures, e.g. REBIN). no-task-factor: a standard exists but the step's tasks cannot be counted (no tasks_per_order factor). example: no-task-factor CapacityPlanResponse: type: object required: [id, warehouse_id, site_id, location, window_start, window_end, path_id, assigned_demand, demand_source, status, path_capacity, bottleneck_step, capacity_over_window, shortage, created_at, bottleneck_constraint, warnings, inbound_appointments, inbound_labour_minutes, inbound_average_heads, inbound_standard_missing, labour_requirement] properties: id: type: string description: UUID. example: 0b7a4c1e-5d52-4f0e-9a39-6c1f2f3a8b10 warehouse_id: type: string example: WH-1 site_id: type: string description: >- Additive. Canonical site the plan is scoped to (a facility-layout Site site_code); empty for plans stored before migration 0008. example: SIM1 location: type: string example: PATH-ZONE-A window_start: type: string format: date-time window_end: type: string format: date-time path_id: type: string example: pick-rebin-pack assigned_demand: type: number format: double description: The demand the plan was evaluated against (see demand_source), in orders. example: 12000 demand_source: type: string enum: [request, orders, forecast] description: > Additive (docs/adr/0004). "request": assigned_demand was stated by the caller (also every plan created before demand ingestion); "orders": it was omitted and defaulted from the order-management read model; "forecast": it was derived from the workload forecast of forecast_path_id (docs/adr/0024). example: request forecast_path_id: type: string description: > Additive (docs/adr/0024). The canonical path code of the workload forecast the demand was read from; present only when demand_source is "forecast". example: PICK scenario: type: string description: > Additive (docs/adr/0024). The plan's what-if label; absent when it carries none. example: second pack line open status: type: string enum: [DRAFT, PUBLISHED, SUPERSEDED] description: > SUPERSEDED (additive, docs/adr/0024 decision 3) is terminal: a newer plan of the same site_id, location, path_id and window was published (superseded_by). Clients that switch on status must accept it. path_capacity: type: number format: double description: Normalized path capacity, ORDER per HOUR. example: 1000 bottleneck_step: type: string example: REBIN capacity_over_window: type: number format: double description: path_capacity x window hours, in orders. example: 8000 shortage: type: number format: double description: max(0, assigned_demand - capacity_over_window), in orders. example: 4000 created_at: type: string format: date-time published_at: type: string format: date-time description: Present only once PUBLISHED (kept when SUPERSEDED). superseded_by: type: string description: > Additive (docs/adr/0024 decision 3). The id of the plan whose publication superseded this one; present only when status is SUPERSEDED. example: 9d1f0c2a-7b3e-4f5a-8c6d-2e4b1a0f9c87 bottleneck_constraint: type: string description: > Additive. The constraint type binding the bottleneck step (e.g. LABOR or STATION); empty for plans created before it was recorded. example: STATION warnings: type: array description: Additive. Composition warnings raised when the plan was created (never null). items: type: string inbound_appointments: type: integer minimum: 0 description: > Additive (docs/adr/0017). BOOKED dock appointments whose door window starts in the plan window. Informational: it sits NEXT TO assigned_demand (orders) and is never summed into it. example: 4 inbound_labour_minutes: type: number format: double description: Labour minutes the declared inbound standard for the plan's path attributes to those appointments; 0 without a standard. example: 240 inbound_average_heads: type: number format: double description: inbound_labour_minutes over the plan window length, in people. example: 0.5 inbound_standard_missing: type: boolean description: True when appointments exist but no inbound standard is declared for the plan's (location, path_id); they contribute no labour demand. example: false labour_requirement: type: array description: > Additive (docs/adr/0022). The labour each step of the plan's path requires, in path order (never null; [] for plans stored before migration 0013). items: $ref: "#/components/schemas/LabourRequirement" PlanComparisonResponse: type: object description: The plans of one site and window side by side (docs/adr/0024), in the order of ids. required: [site_id, window_start, window_end, items] properties: site_id: type: string example: SIM1 window_start: type: string format: date-time window_end: type: string format: date-time items: type: array minItems: 2 maxItems: 5 items: $ref: "#/components/schemas/ComparedPlan" ComparedPlan: type: object description: One plan of a comparison, exactly as stored (nothing is recomputed). required: [plan_id, status, path_id, assigned_demand, demand_source, path_capacity, capacity_over_window, shortage, bottleneck_step, bottleneck_constraint, labour_requirement] properties: plan_id: type: string example: 0b7a4c1e-5d52-4f0e-9a39-6c1f2f3a8b10 scenario: type: string description: The plan's what-if label; absent when it carries none. example: second pack line open status: type: string enum: [DRAFT, PUBLISHED, SUPERSEDED] description: The plan's status as stored (SUPERSEDED, docs/adr/0024 decision 3, is additive). path_id: type: string description: The ProcessPath the plan evaluates (scenarios may evaluate different paths). example: pick-rebin-pack assigned_demand: type: number format: double description: Orders the plan was evaluated against. example: 12000 demand_source: type: string enum: [request, orders, forecast] example: forecast path_capacity: type: number format: double description: ORDER per HOUR. example: 1000 capacity_over_window: type: number format: double example: 8000 shortage: type: number format: double example: 4000 bottleneck_step: type: string example: REBIN bottleneck_constraint: type: string example: STATION labour_requirement: type: array description: The ADR 0022 labour requirement per path step, as stored (never null). items: $ref: "#/components/schemas/LabourRequirement" DeclareInboundLabourStandardRequest: type: object required: [minutes_per_appointment] properties: minutes_per_appointment: type: number format: double exclusiveMinimum: true minimum: 0 description: Fixed labour minutes of ONE dock appointment. example: 45 minutes_per_asn: type: number format: double minimum: 0 description: Optional extra labour minutes per ASN the appointment covers; omitted means 0. example: 5 InboundLabourStandardResponse: type: object required: [location, path_id, minutes_per_appointment, minutes_per_asn] properties: location: type: string example: SIM1 path_id: type: string example: receive minutes_per_appointment: type: number format: double example: 45 minutes_per_asn: type: number format: double example: 5 InboundLabourStandardPage: type: object description: One keyset page of inbound labour standards, ordered by location then path id. required: [items] properties: items: type: array items: $ref: "#/components/schemas/InboundLabourStandardResponse" nextCursor: type: string description: Opaque cursor for the next page; absent on the last page. InboundDemandResponse: type: object required: - location - path_id - window_start - window_end - appointments - asns - labour_minutes - average_heads - standard_declared - standard_missing - source - as_of properties: location: type: string example: SIM1 path_id: type: string example: receive window_start: type: string format: date-time window_end: type: string format: date-time appointments: type: integer minimum: 0 description: BOOKED appointments whose door window starts in [window_start, window_end). example: 4 asns: type: integer minimum: 0 description: ASNs those appointments cover. example: 7 labour_minutes: type: number format: double description: Labour minutes the declared standard attributes to them; 0 when none is declared (never a guessed default). example: 215 average_heads: type: number format: double description: labour_minutes over the window length, in people. example: 0.45 standard_declared: type: boolean description: A standard exists for (location, path_id). standard_missing: type: boolean description: Appointments exist but no standard is declared for (location, path_id). source: type: string enum: [dock-scheduling] as_of: type: string format: date-time nullable: true description: CloudEvents time of the newest dock appointment event the site's model reflects; null when none. PlanVarianceResponse: type: object required: - plan_id - location - step - window_start - window_end - planned_orders_per_hour - planned_orders_over_window - observed - comparison - advisory properties: plan_id: type: string example: 0b7a4c1e-5d52-4f0e-9a39-6c1f2f3a8b10 location: type: string example: SIM1 step: type: string description: The plan's bottleneck step, whose task completions are compared. example: PACK window_start: type: string format: date-time window_end: type: string format: date-time planned_orders_per_hour: type: number format: double description: The plan's path capacity, ORDER per HOUR. example: 1000 planned_orders_over_window: type: number format: double description: The plan's capacity over the window, in orders. example: 8000 observed: type: object required: [source, has_data, tasks, tasks_per_hour, mean_task_seconds, as_of] properties: source: type: string enum: [fulfillment-execution] has_data: type: boolean description: False means nothing was observed -- never zero throughput. tasks: type: integer format: int64 minimum: 0 description: Tasks completed for the step at the location in the window. example: 21000 tasks_per_hour: type: number format: double example: 2625 mean_task_seconds: type: number format: double nullable: true description: Mean task duration; null when no completion carried a duration. as_of: type: string format: date-time nullable: true description: CloudEvents time of the newest completion the model reflects for the site; null when none. comparison: type: object required: [comparable, tasks_per_order, observed_orders, variance_orders, variance_percent] properties: comparable: type: boolean description: False when tasks_per_order was not supplied or nothing was observed; reason says which. reason: type: string tasks_per_order: type: number format: double nullable: true observed_orders: type: number format: double nullable: true description: Observed tasks divided by tasks_per_order. variance_orders: type: number format: double nullable: true description: observed_orders minus planned_orders_over_window. variance_percent: type: number format: double nullable: true description: variance_orders as a percentage of planned_orders_over_window. advisory: type: boolean description: Always true. The variance never changes the planned capacity or republishes a plan. ForecastBucket: type: object required: [cpt, quantity] properties: cpt: type: string format: date-time description: The critical pull time the units are due at (RFC 3339; answered in UTC). example: "2026-11-19T10:00:00Z" quantity: type: integer format: int64 minimum: 0 description: Whole units due at the cpt. example: 120 ReceiveWorkloadForecastRequest: type: object required: [buckets] properties: buckets: type: array minItems: 1 description: Every bucket of the forecast; they replace the stored ones as a whole. items: $ref: "#/components/schemas/ForecastBucket" WorkloadForecastResponse: type: object required: [site_id, path_id, buckets, total_quantity, received_at, version] properties: site_id: type: string example: SIM1 path_id: type: string description: The process path code in its canonical form (trimmed, upper case), whatever case the request used. example: PICK buckets: type: array description: The stored buckets, in receipt order. items: $ref: "#/components/schemas/ForecastBucket" total_quantity: type: integer format: int64 description: The sum of every bucket's quantity. example: 200 received_at: type: string format: date-time description: When the current buckets were received; an identical receipt keeps it. example: "2026-11-19T05:00:00Z" version: type: integer format: int64 minimum: 1 description: 1 for a first receipt, + 1 per receipt that changed the buckets. example: 1 CommitLabourPlanRequest: type: object required: [rate_units_per_hour, hours, installed_stations] properties: planned_heads: type: integer minimum: 0 maximum: 2147483647 description: > The heads the path needs for the shift, at most installed_stations. Omitted: derived from the stored workload forecast, which needs shift_start (else 422 missing-planned-heads). example: 10 rate_units_per_hour: type: number format: double exclusiveMinimum: true minimum: 0 description: Planned units per head per hour. example: 10 hours: type: number format: double exclusiveMinimum: true minimum: 0 description: Length of the shift in hours; the shift window is [shift_start, shift_start + hours). example: 8 installed_stations: type: integer minimum: 0 maximum: 2147483647 description: The stations the path has for the shift. Stored as sent; the facility tally only adds a warning. example: 12 shift_start: type: string format: date-time description: Optional start of the shift (RFC 3339). Needed to derive omitted heads. example: "2026-11-19T06:00:00Z" LabourPlanResponse: type: object required: [site_id, shift_id, path_id, planned_heads, rate_units_per_hour, hours, installed_stations, heads_source, version, warnings] properties: site_id: type: string example: SIM1 shift_id: type: string example: 2026-11-19-early path_id: type: string description: The process path code in its canonical form (trimmed, upper case), whatever case the request used. example: PICK planned_heads: type: integer minimum: 0 example: 10 rate_units_per_hour: type: number format: double example: 10 hours: type: number format: double example: 8 installed_stations: type: integer minimum: 0 example: 12 shift_start: type: string format: date-time description: Absent when the plan was committed without one. example: "2026-11-19T06:00:00Z" heads_source: type: string enum: [request, forecast] description: request when planned_heads was sent; forecast when it was derived from the workload forecast. example: forecast version: type: integer format: int64 minimum: 1 description: 1 for a first commit, + 1 per commit that changed the plan. example: 1 warnings: type: array description: > Advisory, computed against the facility tally on every read (never stored, never null): a warning when the tally knows at least one but fewer stations of the activity named like the path than installed_stations (zero tallied stations is no tally data: no warning). The number is reported as sent, never replaced. items: type: string LabourPlanPage: type: object description: One keyset page of labour plans of a (site, shift), ordered by path id. required: [items] properties: items: type: array items: $ref: "#/components/schemas/LabourPlanResponse" nextCursor: type: string description: Opaque cursor for the next page; absent on the last page.