45. GS1 location identity (gln) and yard spot kind (spotKind)
Status
Accepted (2026-11-10). Additive: no existing event, route, column or payload changes meaning, and every new field is optional. Reuses the Published Language rules of ADR 0013 and the CloudEvents envelope of ADR 0024. It follows the additive-field pattern of ADR 0040 and ADR 0037.
Context
Trading partners and the GS1 standards speak location identity as a Global
Location Number (GLN). This context is the system of record for where things
physically are, but a Site, a Zone or a slot (a dock door, a yard spot) could
only be named by this service's own codes, so every partner integration needed a
translation table. Separately, the yard keeps its holding spots in its own
policy and has no notion of what a spot is for; the location model already has a
Yard role (ADR 0016) but no kind of yard
spot.
Decision
-
Model.
Site,ZoneandLocationSlotcarry an optionalgln(shared.GLN). The zero value means "none recorded" and is exactly today's behaviour; every location registered before this ADR has none. ALocationSlotalso carries an optionalspotKind(shared.SpotKind):PARKING,HOLDING,REEFER_PLUG,HAZMAT,STAGING_LANE.HAZMATis new relative to the four kinds of the earlier model. -
The GS1 rule. A GLN is exactly 13 ASCII digits whose last digit is the GS1 mod-10 check digit of the first twelve: from the right, over those twelve digits, multiply alternately by 3 and 1 (the rightmost by 3), add them up, and the check digit is the amount that rounds the sum up to the next multiple of ten (
(10 - sum mod 10) mod 10). Example:4006381333931(weighted sum 89, check digit 1). The optional GLN extension component is not modelled. The rule lives in the domain (shared.ParseGLN); the database only guards the shape (13 digits). -
Uniqueness. A GLN identifies exactly one location. It is unique across sites, zones and slots of the service, which is stricter than "per site tree" and matches what a GLN means: the same number on two locations is a data error whichever tree they sit in. One aggregate cannot see its siblings and the three kinds live in three tables, so the claim goes through a small port,
ports.GLNRegistry, backed by one tablelocation_glns (gln PRIMARY KEY, owner UNIQUE). The claim is made inside the same unit of work as the aggregate save and the outbox insert, so a refused registration leaves nothing behind and two concurrent claims of one number cannot both commit (the second waits on the primary key, then sees the conflict). A location without a GLN never touches the registry. -
Spot kind is Yard-only. The repo tells a yard slot from a dock slot by the
LocationRoleof its LocationType (a Zone has no kind).spotKindis legal only when that role isYard; on any other role (a dock door, a storage bin) the registration is refused. The rule is the aggregate's (LocationSlot.AssignSpotKind) and a database CHECK repeats it (spot_kind IS NULL OR role = 'Yard'). -
REST (OpenAPI first,
apis/openapi.yaml).POST /sites,POST /sites/{siteCode}/zonesandPOST /locationsaccept an optionalgln;POST /locationsalso accepts an optionalspotKind. Every site, zone and slot representation (single reads, lists,GET /sites/{siteCode}/layout,GET /sites/{siteCode}/locations?role=) includesglnandspotKindwhen set and omits them otherwise, so a response for an old location is byte-identical to before. Problems (RFC 7807, ADR 0004):Slug Status When invalid-gln422 not 13 digits, or the check digit is wrong gln-already-assigned409 another site, zone or slot already holds it unknown-spot-kind422 not one of the five kinds spot-kind-not-allowed422 spotKindon a slot whose role is notYardAn old request without the fields behaves exactly as before.
-
Events (AsyncAPI first,
apis/asyncapi.yaml). The existingSiteRegistered,ZoneRegisteredandLocationSlotRegisteredevents gaingln(andLocationSlotRegisteredgainsspotKind). Both are omitted when none was recorded, so the payload of every existing location is byte-identical to before; the AsyncAPI schemas declare them nullable (type: [string, 'null']) and optional, never required, so a consumer may also tolerate an explicitnull. No new event type and no.v2: an additive optional field is not a breaking change under ADR 0024. The AsyncAPI carries examples copied byte-for-byte from the wire goldens, and an architecture test (TestIdentityExamplesMatchTheWireGoldens) fails when they drift, so a consumer's contract test can use them. The analytics twin (warehouse.facility.analytics) encodes through the sameWireDatamapping: its goldens differ from the integration ones only indataschema, and the projector reads only the fields it needs, so it ignores the new ones. -
Reads beyond REST. The MCP read tools return the fields too (
list_sites,get_site_layoutfor the site and each zone,list_functional_locationsfor each location), as does the A2Asite_layoutskill. Both omit them when none was recorded. -
Storage. Migration
0013: nullablesites.gln,zones.gln,location_slots.glnandlocation_slots.spot_kindwith shape CHECKs, pluslocation_glns. -
Change after registration. Both fields are set at registration. This version adds no update route:
glnandspotKindare immutable once registered. The repo does have slot update routes (PUT /locations/{code}/geometry,PUT /locations/{code}/handling-unit), and the pattern for a change is aPUTplus a dedicated event (LocationSlotHandlingUnitDeclared). Following it would add routes and new event types for three aggregates; that is a decision of its own and is left to a follow-up.ImportFacilityLayoutrows do not carry the fields yet either (same boundary as ADR 0040).
Consequences
- Consumers that ignore unknown fields are unaffected. A consumer keeping a copy of a location applies the fields from the registered event when present.
yard-managementwill consumespotKindfromLocationSlotRegisteredin a later item, replacing the spot kinds it holds in its own policy; nothing in this change touches that service.- Locations that existed before this ADR have no GLN, and with no update route they cannot get one until the follow-up above ships (or they are registered again under a new code). A deployment that wants GLNs on existing sites must wait for that item.
- Uniqueness is global and enforced by a table the three registrations write to, so a decommissioned location keeps its GLN claimed (a retired location is never resurrected, ADR 0005, and neither is its number).
- The check digit is verified by the service, not the database, so a row written by hand can hold a well-shaped but wrong GLN.
- The GLN extension component, GLN lookup by number (
GETby GLN) and a GLN on an Aisle are out of scope.