0035. siteCode is the canonical name of the ShiftPlan key; buildingId is a deprecated alias
Status
Accepted. Settles the question ADR 0034
left open ("ShiftPlan stays keyed by buildingId + shiftId (mapping a
building to a site is not decided here)") without editing it; where this record
and ADR 0034 disagree about the name of the plan key, this record wins.
Refines ADR 0029,
ADR 0026 and
ADR 0023 without editing
them.
Context
Two identifiers named one concept. The ShiftPlan was keyed by buildingId;
ADR 0034 added siteCode (the facility-layout Site code, the same value
warehouse-planning carries as site_id) to scope the staffing gap, and
deliberately did not map one to the other. Callers had to pick a consistent
buildingId/siteCode pair themselves. That is a ubiquitous-language defect:
the fleet's term is Site, and "building" names nothing the other contexts
know.
Decision 19 (architect, 2026-10-06, final): converge on siteCode, deprecate
buildingId, and remove buildingId only in a later breaking ADR. This
record is the additive, backward-compatible step.
Decision
- One concept, one name. The term is Site; "building" is deprecated.
siteCodeis the canonical name of the ShiftPlan key.buildingIdis a deprecated alias with the same value and the same stored column (shift_plan.building_id; thepath_plan/shift_plantables are untouched). No migration is needed and none is added. - Write requests (
POST /paths/{pathId}/plan-proposals,POST /shift-plans; MCPpropose_path_heads) acceptsiteCodeorbuildingId. At least one is required (neither →400 missing-building-id; the slug keeps its historic name so clients that match it keep working). Both present and equal is fine; both present and different is422 conflicting-site-and-building(new RFC 7807 slug, documented in the errors page and covered by the problem-catalogue tests). Surrounding whitespace is trimmed and a blank value counts as absent. - Responses that return a ShiftPlan (
POST /shift-plans, MCPpropose_path_heads, MCPget_staffing_gap) carrysiteCodeand keepbuildingId, one value. The by-path / list staffing-gap REST responses keep their ADR 0034 shape:siteCodeis echoed only when the gap was scoped by site (absence still means "unscoped", never a particular site), and they never carriedbuildingId. - Staffing gap by path (
GET /paths/{pathId}/staffing-gap):siteCodeis the canonical plan-lookup parameter and the associate scope (one value);buildingIdstays as the deprecated alias for the plan lookup only. A call that gives only the legacybuildingIdis not auto-scoped by site (callers use ids likebldg-1): behaviour identical to before. A call withsiteCodeis scoped as ADR 0034 defines. One of the two is required. - New canonical route
GET /sites/{siteCode}/shifts/{shiftId}/staffing-gap(operationlistStaffingGapsForSiteShift, same handler core and response shape; the pathsiteCodeis plan key and scope). The oldGET /buildings/{buildingId}/shifts/{shiftId}/staffing-gapkeeps working, unchanged and unscoped, isdeprecated: truein OpenAPI and answersDeprecation: trueon every response, errors included. - MCP.
get_staffing_gapandpropose_path_headstakesiteCodewithbuildingIdas a deprecated alias; their descriptions and argument schemas say so. The staffing-gap resource gains the canonical templatestaffing://sites/{siteCode}/{shiftId}/{pathId}/gap(plan key and scope);staffing://{buildingId}/{shiftId}/{pathId}/gapstays, deprecated and unscoped. Thecover_staffing_gapsprompt namessiteCode. The tool registry and fleet snapshot goldens list tool names and hints only, so they do not change; nothing is removed. - Events.
ShiftPlanCommitted(integrationwarehouse.workforce.eventsand analyticswarehouse.workforce.analytics) andShiftPlanProposed(analytics only: it has never been on the integration topic) gainsite_code, carrying the same value asbuilding_id.building_idstays and is marked deprecated in the AsyncAPI. Additive onv1: no.v2,dataschemaunchanged.site_codeis deliberately notrequired: outbox rows encoded before this change lack it, so consumers fall back tobuilding_idwhen it is absent. The Kafka key and the CloudEventssubject(<buildingId>/<shiftId>) are unchanged — changing either would re-partition and break consumers; their first segment is the site code. - OpenAPI.
buildingIdisdeprecated: trueon every request body, response schema and parameter; "one of the two is required" isanyOfwithrequiredalternatives on the two request bodies (Spectral clean).
Not done here (and why)
buildingIdis not removed, not from REST, MCP, events, the database or the Kafka key. Removing it is a future breaking ADR with its own announcement window (theDeprecationheader and the deprecated flags are that announcement's first step).- No Kafka key / CloudEvents
subjectchange (breaking for partitioning and ordering). - No column rename and no migration (
building_idstays the stored name). - Legacy
buildingId-only staffing-gap calls are not scoped by site. Inventing a building→site mapping would be a new business rule. - No live validation of
siteCodeagainst facility-layout (ADR 0034 point 1 stands: accepted as given). - Decided (2026-10-08) — the
422rule does not apply to staffing-gap reads during the deprecation window. Decision 19 also says a differingsiteCode/buildingIdpair is rejected. ADR 0034 defined the opposite for the three gap-read surfaces (GET /paths/{pathId}/staffing-gap,GET /buildings/…/staffing-gap?siteCode=, MCPget_staffing_gap): the plan is keyed by a building id and the site is the scope, and ADR 0034's own tests and docs use a differing pair (bldg-1+WH1). Rejecting it would break that documented usage, so those reads keep ADR 0034 behaviour for a differing pair (buildingIdis the plan key,siteCodethe scope) for the whole deprecation window. The pair is the only way to scope a gap over plans still stored under a legacy building id such asbldg-1until they are re-committed under a site code, so rejecting it would remove that path with no replacement. The differing pair stops being valid whenbuildingIdis removed (the later, breaking ADR). Every other surface already enforces the 422 rule. No caller outside this repo's tests passes a differing pair (see the ecosystem check).
Consequences
- One name in the ubiquitous language, the ER/class/sequence diagrams, the
canvases and the API reference;
buildingIdis visibly legacy everywhere. - Every existing caller keeps working unchanged: all new request and response fields are optional/additive, and no value, key, subject or column moved.
- A site-scoped gap now needs a plan stored under the site code, so callers
that want per-site gaps commit their plans with
siteCode(ADR 0034's "pick a consistent pair" caveat disappears for them). - Until
buildingIdis removed, every surface carries two names for one value; the deprecation markers are the only guard against new uses. - Ecosystem check (sibling
origin/developgreps): warehouse-ops-agent'smcpclientcallsget_staffing_gapandpropose_path_headswithbuildingIdonly; e2e-tests call/paths/{pathId}/staffing-gap?buildingId=…&shiftId=…only; wes-work-planning and warehouse-planning consumeShiftPlanCommittedthroughDataAs(plainjson.Unmarshal, unknown fields ignored) and readbuilding_id; nothing consumesShiftPlanProposedor the analytics topic outside this repo's projector (which ignores unknown fields). No consumer rejects an extra field and no caller passes both names with different values.