Karyo
Documentation/ Decision records

ADR 0065: The floor is drawn from the layout: the building, dock doors and rooms are layout rows, the rest is derived

Karyo 2.1.1rendered at build time
On this page

Status: Accepted

Context

The owner picked a 3D floor as Karyo's floor view: the building drawn to scale from the layout, quiet by default, with every figure behind a hover or a tap. The design review listed what such a drawing needs and compared it with what layout stores (ADR 0060 stores the hierarchy, the floor point of every location and three sizes). Seven things were missing: the building's length, depth and wall height; rack depth; cross-aisles other than the front and back ones; dock door positions; pack stations and dispatch lanes as shapes; cold-room enclosures and set points; and live data (worker positions, temperatures, decisions), which is not layout.

Karyo 2.0.0 is released. The Home page already draws a warehouse from its locations, and says in its own code that nothing records the building's footprint.

The owner approved the floor view as four pull requests in a delivery order (this change is the first) and approved the recommendations of the design plan, including that a Facility needs no setup for the floor view to work.

Decision

Store a field only where the floor cannot be derived from what Karyo already stores.

  • The building is one row for each Facility, facility_buildings: length, depth and wall height in metres. It stands on the floor's own axes: it spans 0 to length along and 0 to depth across, the coordinates every Area, zone and location already uses. A saved building must hold the whole plan, and every stored dock door must still stand inside it.
  • Dock doors are rows, dock_doors: a name, a direction, one of four walls (WEST and EAST at along 0 and along length, NORTH and SOUTH at across 0 and across depth), a position along the wall, a width and an optional location the door serves, referenced by id (ADR 0007). The two door counts in the arrangement stay.
  • A room is an enclosed zone. zones.enclosed and a set point range, both ends or neither and only on an enclosed zone, are columns of the zone. The room's walls stand on the zone's own extent, so the room cannot disagree with the plan. There is no second geometry.
  • Rack depth is a fourth size beside aisle spacing, bay width and level height: a Facility setting that an Area, a zone or an aisle overrides. It moves no location. It lets the floor view draw the rack faces and leave the walking aisle between them. The catalogue's 1.1 m is the figure ADR 0060 already gives (a 4.5 m spacing is a 2.3 m walking aisle and two 1.1 m racks). The walking aisle of an aisle is its spacing less one rack depth for each face, two when it is double-sided. No write is refused for a rack depth: the floor plan serves each aisle's walkingAisleMetres, clamped at zero when that sum is negative, so a read never fails on a layout whose sizes leave no room.
  • Cross-aisle width is one Facility setting. The cross-aisles stay the front and the back one of each zone that ADR 0060 models; the floor view draws exactly those. The cross-aisle width and the optional link from a dock door to the location it serves come from the approved floor view plan.
  • Pack stations and dispatch lanes have no rows. A station is a pack staging location and a lane is a ship staging location, drawn at its floor point with its location type's size.

Derive the rest, and say so. The floor plan response always carries a building when the plan has an extent, and the dock doors. While no building is stored, it is worked out from the plan: the end of its longest zone and of its last Area, or of a location placed by a floor point of its own if that lies further, 6 m of apron, rounded up to a whole metre, and a 4.4 m wall. While no dock door is stored, doors are worked out from the arrangement's flow and counts: THROUGH puts goods in on the west wall and out on the east wall, U puts both on the west wall, and CORNER puts goods out on the south wall; AUTO works out none. Each part says source: STORED or DERIVED. The first stored door ends the estimate for doors, so a person's doors and estimated ones are never mixed. There is no backfill: an installation that upgrades has a floor view with no setup, and an administrator replaces estimates with measured values where they matter.

The write contract. PUT and DELETE /api/v1/floor-plan/building; POST, PUT and DELETE /api/v1/floor-plan/docks, the last stored door deleted returning the plan to derived doors; the room and the rack depth through the existing zone, Area and aisle writes. They need layout.write and the read needs layout.read, the actions the floor plan already uses, so no action is added. A rule broken is 422 invalid-floor. A location that a door names is not deleted from under it.

Consequences

The Locations page, the distances and the flow model do not change: nothing here moves a location, and a rack depth or a room changes only what is drawn. Every read of the floor plan now does three more reads (building, doors, arrangement), each of one row or one Facility's few rows, and one more of the locations placed by a floor point, because the extent counts them. Only the floor plan read and the building save read the extent, so the distance and route lookups do not load those locations.

A derived building is an estimate and is labelled so. A building drawn from the plan's extent cannot be smaller than the plan, but it is not the measured building; a Facility that wants the real walls enters them.

A stored building does not follow the plan after it is saved. A zone moved or lengthened later can reach past the walls: saving the building checks the plan and its stored doors at that moment, and no later write is refused for outgrowing it. A dock door write is checked only against a stored building; with none stored a door is not bounded, and the derived building grows to hold every stored door, an axis the plan does not reach getting the apron alone. A door must start on its wall: its position is at least half its width. The floor plan read never fails. It serves the stored building unchanged and sets building.holdsPlan to false when a zone, a location placed by a floor point or a stored dock door lies outside the building served, so the floor view can say so. Deleting the building returns to the derived one, which also grows to hold every stored door.

A replace of a zone that leaves enclosed out makes it open floor again, like every other field of that request. A client written before this change that replaces a zone therefore clears a room, which is the same behaviour as the size overrides it already clears.

Nothing records why the walls are four named walls and not polygons. The floor view of this change needs a rectangle; an L-shaped building is not modelled.

Alternatives considered

  • Columns on the Facility row. The Facility belongs to another module, so the building would be a cross-module column; a table in layout keeps the hierarchy together.
  • A room as its own geometry. A cold room with its own rectangle could be drawn freely, and could stand where no zone does. One extent for a zone and its walls cannot disagree.
  • Stations and lanes as new tables. They would duplicate staging locations that already have floor points and sizes.
  • Storing the building only, with no derivation. A floor view then needs setup before it shows anything, and every installation upgraded to 2.1 would see an empty page.
  • Rack depth as a Facility setting alone. Simpler, but a narrow-aisle zone or a mezzanine then draws the wrong racks; the three sizes of ADR 0060 already override this way.

Evidence

  • services/karyo-app/src/main/resources/db/migration/layout/V1617__floor_building_docks_rooms.sql
  • services/karyo-app/src/main/resources/db/migration/common/R__explicit_facility_writes.sql
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/service/DerivedFloor.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/service/FloorPlanService.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/service/FloorBuildingService.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/service/DockDoorService.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/service/ZoneService.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/api/v1/FloorPlanResource.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/domain/model/FacilityBuilding.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/domain/model/DockDoor.kt
  • services/warehouse-layout-service/karyo-layout-api/src/main/kotlin/com/karyo/layout/dto/FloorPlanDtos.kt
  • services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/config/SystemPropertyCatalog.kt
  • services/karyo-app/src/test/kotlin/com/karyo/layout/api/v1/FloorBuildingResourceTest.kt
  • services/karyo-app/src/test/kotlin/com/karyo/layout/service/DerivedFloorTest.kt