Shift Plans
The ShiftPlan aggregate: proposing and committing the headcount split across process paths for one site's shift (keyed by the canonical siteCode; buildingId is the deprecated alias, ADR 0035).
Propose planned heads for a path (pure computation, not committed)
Two forms (ADR 0043). FROM THE LABOUR PLAN: omit `charge` and name `shiftId` (with `siteCode`): `proposedHeads` is the `planned_heads` warehouse-planning published for (siteCode, shiftId, pathId) in LabourPlanCommitted (this service keeps a local copy), `resolvedRate` its `rate_units_per_hour`, `rateSource` is `labour-plan` and NO idle-share trim applies; nothing published is 404 labour-plan-not-found, never zero heads. CHARGE-BASED (DEPRECATED, unchanged; removed only by a later ADR once no caller sends a charge): a request with `charge`, even one that also names `shiftId`, works as described below. Neither `charge` nor `shiftId` is 400 missing-charge. Both forms raise ShiftPlanProposed. Computes `heads = ceil(charge / plannedRate)` for one path and raises ShiftPlanProposed for visibility — it persists nothing and commits nothing. A human must still call POST /shift-plans to commit an actual ShiftPlan. This is why the response is 200, not 201: no resource is created. When a high observed idle share (idleness-as-staffing-signal, fed back from labor-performance via `LABOR_PERFORMANCE_MODE=kafka-cache`) is available for this path's task type and exceeds `IDLE_SHARE_TRIM_THRESHOLD` (default 0.30), the computed heads are further trimmed (floored at 1 head minimum) and `trimReason` explains why — fail-open: no idle-share signal available applies no trim.
Commit a shift's headcount split across paths
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.