0047. The bin handling unit arrives on two facility-layout events
Status
Accepted (2026-10-24). Amends ADR 0045 section 4 only; the rest of 0045 stands. ADR 0045 is history and is not edited.
Context
ADR 0045 section 4 made StowContainer refuse a sealed case unless the target
bin's handlingUnit is CASE or PALLET, and said the value would come from
facility-layout "once it ships the attribute". The facilitycache consumer read
an optional handlingUnit string from LocationSlotRegistered. facility-layout
published no such field, so a live run showed every stow of a case answered
409 bin-handling-unit-mismatch: no bin could take a case.
facility-layout now ships it (its ADR 0040, additive):
LocationSlotRegisteredgains an optionalhandlingUnit(EACH | CASE | PALLET), omitted when none was recorded.- A new
com.warehouse.wms.facility-layout.locationslot.LocationSlotHandlingUnitDeclaredwithdata{locationCode, handlingUnit, declaredAt}announces a value set or changed later byPUT /locations/{locationCode}/handling-unit.
Both use facility-layout's camelCase (locationCode, handlingUnit), which the
existing consumer tag handlingUnit already matched, so no field was renamed.
Decision
internal/adapters/outbound/facilitycache/consumer.godispatches the new full type on the same topic and the same per-process consumer group (no new consumer, group, env var or chart value). It sets the bin's entry in its event-fed copy: an idempotent last-write-wins upsert keyed bylocationCode, tolerant of unknown fields.- Section 4 of ADR 0045 is otherwise unchanged and still fail-closed: a bin
with no recorded unit (never declared, an unrecognised value, or not yet
replayed) is not case-compatible, so
StowContaineranswers409 bin-handling-unit-mismatch. ALocationSlotRegisteredthat carries no unit still clears a previously held value;LocationSlotDecommissionedstill forgets the bin. - An event with an empty
locationCodeis dead-lettered like any malformed facility event. An unrecognised unit value is not an error: it reads as "none recorded" (fail closed).
Consequences
- Existing bins have no handling unit until facility-layout declares one, so an
operator must declare the case and pallet bins (one
PUTeach there) before sealed cases can be stowed in them; loose-each stow is unaffected. - Declaration order is safe: both events share the
locationCodepartition key in facility-layout, and the cache is replayed from the first offset on every start, so a restart reproduces the same last-write-wins result. - Tested: unit tests on the dispatch (set, change, idempotent redelivery, unknown
fields, bad value, missing code, decommission), a Kafka testcontainers test on
the cache, and the real-Postgres/Kafka end-to-end run (
cmd/inventory), where a stow into a bin without a unit is409and, after the declaration event,200.