Commit a shift's headcount split across paths
POST/shift-plans
Commits a human-decided ShiftPlan: one or more PathPlan lines (path, plannedHeads, plannedRate, plannedHours), raising ShiftPlanCommitted. Validates, per line, that plannedHeads does not exceed the caller-supplied installedStations for that path (this context enforces the invariant independently — it has no dependency on Work Planning, which owns installed-station counts — the request carries the number it needs), that plannedHeads does not exceed the LIVE installed capacity fulfillment-execution reports for that path's capability (a SEPARATE, independent check — see ADR-0014; fetched fresh on every commit, and this service fails the entire commit loud, without any fallback, if fulfillment-execution cannot be reached). The capability is resolved through the process-path catalogue, never taken from pathId: a path's live ceiling is the number of stations registered with each of its declared requiredCapabilities (the smallest count when it declares several), so pathId PICK (or pick-zone-a) is checked against stations holding capability pick. A pathId the catalogue does not declare is rejected with 400 unknown-path-id. It also validates that plannedHours does not exceed plannedHeads * the configured max hours per shift. Naturally idempotent by the client-supplied (siteCode, shiftId) key (siteCode is the canonical name of the plan key, buildingId its deprecated alias with the same value and the same stored column; ADR 0035): the underlying repository upserts on that key. A blind retry would nevertheless re-publish ShiftPlanCommitted, so this route is also protected by the Idempotency-Key header (ADR-0027, ADR-0044): a retried request with the same key and body replays the first response without committing or publishing again — unless the first answer was RETRYABLE (e.g. exceeds-installed-capacity, concurrent-modification), which is not stored: the key is released and the retry executes again.
Request
Responses
- 201
- 400
- 409
- 422
- 500
- 503
Shift plan committed.
Response Headers
"true" when this answer is the stored replay of an earlier request with the same Idempotency-Key and fingerprint; absent on the first execution.
URI of the committed shift plan.
Malformed body, an empty required field (siteCode or its deprecated alias buildingId, shiftId, or a line's pathId), no path plan lines supplied (shift-plan-no-path-plans), a line references a path with no installedStations entry (shift-plan-missing-installed-stations), a line's pathId is not declared by the process-path catalogue (unknown-path-id), or the Idempotency-Key header is missing on a deployment with Postgres (idempotency-key-required, ADR-0027).
Conflict — a line's plannedHeads exceeds installedStations (planned-heads-exceed-installed), a line's plannedHeads exceeds the LIVE installed capacity fulfillment-execution reports for that path's capability, resolved from the process-path catalogue's requiredCapabilities (exceeds-installed-capacity — see ADR-0014; this is a SEPARATE, independent check from installedStations), or plannedHours exceeds what plannedHeads can work within the shift's max hours (planned-hours-exceed-capacity). Also returned (idempotency-key-reused) when the Idempotency-Key was already used with a different request (method, path or body).
Unprocessable — siteCode and its deprecated alias buildingId were both sent with DIFFERENT values (conflicting-site-and-building, ADR 0035).
Unclassified failure (e.g. a persistence or event-publish error) — internal-error.
Service unavailable — fulfillment-execution could not be reached to verify installed capacity for one or more path lines (installed-capacity-unavailable). This service fails the ENTIRE commit loud in this case rather than falling back to any assumed capacity, since a shift-plan commit mutates real state — see ADR-0014.