Skip to main content

ADR 0011: Packaging hierarchy with GS1 GTIN; eaches are the ledger unit

Status​

Accepted (2026-11-14; first Proposed 2026-10-23, built since: see the Addendum). It pinned the design so the dependent contexts (inbound-receiving, inventory-storage and the other consumers listed below) could be specified against stable names. Every change is additive and optional: REST, MCP and the CloudEvents envelope (ADR 0004) keep their meaning and v1 stays v1. The fleet-wide contract lives in warehouse-systems/.hermes/plans/mastercase-briefs/contracts.md (sections 0 and 1); the adoption plan is warehouse-systems/.hermes/plans/2026-10-23_225746-mastercase-gtin-handling.md.

Context​

Today a Product is sku, description, classification and a PhysicalProfile (ADR 0002) whose dimensions and weight are per unit only. There is no GTIN/EAN and no notion of a packaging level anywhere in internal/domain/product. Every quantity in the fleet is "units of the SKU".

Sellers will start sending master cartons (mastercases): one outer carton with N identical sellable units, sometimes with inner packs of M units. Handling them is not a receiving tweak. It needs a packaging hierarchy with GS1 identifiers owned by the context that owns the SKU, so that receiving, storage, replenishment and picking can resolve a scanned barcode to a SKU and a number of units, without breaking any ledger that already counts units.

Industry practice this follows (full list in the plan, section 2):

  • GS1 packaging levels are Each, Inner pack, Case (all items share one GTIN), Mixed case, Pallet [1]. GDSN models them with a unit descriptor per level, a child GTIN and the quantity of the next lower level; orderable and despatch are flags, not implied by the level [7].
  • A case gets its own GTIN-14 (indicator digit 1 to 8 plus the contained item's company prefix and item reference plus a check digit). Indicator 9 is reserved for variable-measure items. A GTIN-14 is printed in ITF-14 or GS1-128, never as EAN/UPC. Mixed cases get no derived GTIN-14 [2][4].
  • The GTIN Management Standard rule on pack/case quantity: changing the number of items in a case requires a new GTIN for the changed level and every level above it [3].
  • WMS practice is to keep inventory in a base unit and convert, storing the direct factor of each level rather than only chained ones [17][18].

Decision​

  1. D1. Eaches are the ledger unit. Every existing qty/quantity field in product-master and in every consumer keeps meaning eaches. New pack fields carry their own names (cases, unitsPerPack, qtyOfChild); a bare qty never changes meaning. Pack levels are conversions plus identity metadata, not a second ledger.

  2. D2. The packaging hierarchy is part of the Product aggregate. Product gains a PackagingHierarchy. The entity stays product and the event subject stays the sku. New value objects:

    • GTIN: validated by this context's own value object, never trusted from a client.
    • PackLevel: the enum EACH | INNER | CASE | PALLET. EACH is itself a pack level: the each GTIN is the EACH level, so there is no separate "GTIN assigned" concept or event. INNER exists in the model; the receiving and picking flows of consumers implement only EACH and CASE in v1.
    • PackLevelDef: level, gtin, childGtin, qtyOfChild, unitsPerPack, optional dims (lengthMm, widthMm, heightMm, weightG), isOrderable, isDespatchUnit, effectiveFrom, optional effectiveTo. A level other than EACH has childGtin (the GTIN of the next lower level) and qtyOfChild >= 2. unitsPerPack is the direct factor to eaches, stored and not recomputed by chaining.

    Invariants and their errors:

    ErrorRule
    ErrInvalidGTINwrong length or mod-10 check digit
    ErrGtinAlreadyAssigneda GTIN identifies exactly one (sku, level), fleet-wide
    ErrPackQuantityImmutablean ACTIVE level's qtyOfChild/unitsPerPack cannot change (G7 below)
    ErrPackLevelOrderthe child level must be lower than the level
    ErrVariableMeasureUnsupportedindicator digit 9 is rejected in v1
    ErrInvalidPackQuantityqtyOfChild below 2 for a non-EACH level
    ErrPackDimensionsBelowContentscase weight below qtyOfChild times the child weight, when both are known

    Commands: DeclarePackLevel, RetirePackLevel, RecordPackLevelMeasurement. Measurements follow the declared-versus-measured split of ADR 0002.

  3. G2. GTIN normalisation to 14 digits. A GTIN is stored and transmitted as a 14-digit, zero-left-padded string ("00012345678905"). Accepted input lengths are 8, 12, 13 and 14; the mod-10 check digit is validated on input and the normalised form is the only form that is persisted, compared, indexed or published. The path value of GET /gtins/{gtin} is normalised the same way.

  4. G7. GS1 immutability. Once a pack level is ACTIVE its qtyOfChild/unitsPerPack cannot change (ErrPackQuantityImmutable). A new content quantity is a new GTIN at that level plus a re-declaration of every level above it. The old level is end-dated (effectiveTo, via RetirePackLevel) and kept, so that in-flight ASNs that reference the old GTIN still resolve. Further rules that follow from it:

    • the EACH level is a pack level like any other, with unitsPerPack = 1;
    • variable-measure items (indicator digit 9) are rejected in v1 (ErrVariableMeasureUnsupported);
    • a mixed case has no pack GTIN. It is a logistic unit identified by an SSCC and a carton manifest, which belong to inbound-receiving and inventory-storage, not to product-master.

Events​

All events are CloudEvents 1.0, structured mode, type com.warehouse.wms.product-master.product.<Event>, on the existing topic warehouse.product-master.events, key = sku, with the envelope of ADR 0004 and the outbox of ADR 0007 and ADR 0009. version is the aggregate version, as in the existing events. Three new types are added to the catalogue:

TypeData
ProductPackLevelDeclaredsku, level, gtin, childGtin?, qtyOfChild?, unitsPerPack, dims?, isOrderable, isDespatchUnit, effectiveFrom, version
ProductPackLevelRetiredsku, level, gtin, effectiveTo, reason, version
ProductPackLevelMeasuredsku, level, gtin, dims, measuredAt, deviceId?, version

? marks an optional field. Existing events are unchanged. Consumers: inbound-receiving, inventory-storage, slotting-optimization, pick-face-replenishment, fulfillment-execution, wes-work-planning, process-path-management and labor-performance (each through its own projection), and network-fulfillment, which maps pack facts to the retail network only through the Vendor API and its own mapping.

REST and MCP additions​

All additive; existing routes and tools are untouched.

  • GET /gtins/{gtin} returns sku, level, unitsPerPack, childGtin?, active, effectiveFrom, effectiveTo?. The path GTIN is normalised to 14 digits before the lookup; an invalid one is ErrInvalidGTIN (problem+json).
  • PUT /products/{sku}/pack-levels/{level} runs DeclarePackLevel.
  • POST /products/{sku}/pack-levels/{level}/retirements runs RetirePackLevel.
  • GET /products/{sku}/pack-levels lists the levels, retired ones included.
  • MCP tools: resolve_gtin, get_pack_levels, declare_pack_level, retire_pack_level. The first two are read-only. The last two write, which departs from the read-only server of ADR 0005: if this ADR is accepted it amends ADR 0005 for those two tools only, and the index records it.

Consequences​

  • Consumers get local projections; there are no synchronous lookups. Each consumer builds a local, event-fed PackagingView from the three new events and resolves a scanned GTIN to (sku, units) on its own. No service calls GET /gtins/{gtin} on a hot path. This is mandatory for process-path-management and labor-performance and is the fleet norm for the rest. The REST route and the MCP tools serve people, tooling and backfills.
  • No ledger changes meaning. Stock, reservations and receipts keep counting eaches, so nothing that works today needs a migration.
  • A new case quantity costs a new GTIN, a new PackLevelDef and a re-declaration of the levels above. This is deliberate: it is what the trading partners do, and it keeps old ASNs resolvable through effectiveTo.
  • ErrGtinAlreadyAssigned is enforced by this context alone, on the normalised GTIN, in its own database; there is no cross-service check. A GTIN seen by a consumer that has no projection yet is a consumer discrepancy (unknown GTIN), not a lookup.
  • The write side grows: three commands, three events, one table of pack levels per product, and the analytics read side (ADR 0006) may later report on products without a declared each GTIN. That report is not part of this ADR.
  • Not designed here: variable-measure items, commingling of stock by GTIN across owners, FEFO and the INNER receiving and picking flows.

Alternatives rejected​

  • A case as a separate SKU. It is what many catalogues do informally, but it splits one product into two masters with two ledgers, forces a conversion between them in every consumer, and loses the link that makes breaking a case conserve quantity. It also makes "this GTIN is the case of that each" an unchecked convention.
  • A unit-of-measure conversion table without GTINs. It gives the factors but not the identifier a scanner reads, so every receiving flow would need its own barcode-to-SKU table. It also cannot express GS1 immutability: a table row can be edited in place, the very thing [3] forbids.
  • Deriving the GTIN-14 on the fly from the each GTIN. The indicator-digit form looks derivable, but the case GTIN is assigned by the brand owner and does not always follow the pattern, mixed cases have none, and a changed content quantity needs a different GTIN that cannot be computed. A derived value would be wrong exactly when it matters.

External references​

Numbering follows the adoption plan (section "Sources"); the pages were taken from search results on 2026-10-23 and were not machine-verified.

Addendum 2026-11-13: current state​

  • The Status above is out of date: the decision is built (PR #61 70d8eac, web screen PR #62). DeclarePackLevel, RetirePackLevel and RecordPackLevelMeasurement are in internal/application/usecases/pack_levels.go; the routes listPackLevels, declarePackLevel, retirePackLevel, recordPackLevelMeasurement (PUT .../measured) and resolveGtin are in apis/openapi.yaml; the MCP tools declare_pack_level and retire_pack_level are in internal/adapters/inbound/mcp/tools.go.
  • The three events are published (apis/asyncapi.yaml) with snake_case fields (child_gtin, effective_to, measured_at), not the camelCase of the Events table above (see ADR 0004).
  • Consumers on develop: ProductPackLevelDeclared and ProductPackLevelRetired are consumed by inbound-receiving, inventory-storage, slotting-optimization, pick-face-replenishment, fulfillment-execution, wes-work-planning and network-inventory-planning (not named above); ProductPackLevelMeasured by slotting-optimization and wes-work-planning.
  • process-path-management and labor-performance, named above as consumers, handle no pack level type on develop (labor-performance ADR 0035 says so).
  • The Status line is left as written. Whether to mark this ADR Accepted is the maintainers' decision; the ADR index already lists it as "Accepted - implemented".