Karyo
Documentation/ Configuration

Reference data

Karyo 2.1.1rendered at build time
On this page

Reference data is the material an administrator sets up once and then names from everywhere else: units of measure, unit load types, products, number ranges, document templates. This document covers what an installation starts with, who may change it, and the parts of it that have no administration surface at all.

What a fresh installation has

Three migrations seed reference data, and all three are idempotent. A fourth, the Business Unit fixture, is not, and is covered in Business Units.

Units of measure - six rows, created with the table (services/karyo-app/src/main/resources/db/migration/product/V201__create_item_units.sql): PCS (PIECE), KG (WEIGHT), L (VOLUME), M (LENGTH), BOX (PIECE), PAL (PIECE).

Unit load types - four rows, each with a usage list (db/migration/inventory/V105__seed_unit_load_types.sql):

Name Usages Aggregates stocks
Euro Pallet FORKLIFT, STORAGE, COMPLETE no
Pick Bin PICKING yes
Shipping Carton SHIPPING, PACKING yes
Virtual PICKING, STORAGE yes

The DEFAULT order strategy - one row (db/migration/orders/V405__seed_default_order_strategy.sql).

All three use ON CONFLICT ... DO NOTHING, so they are idempotent and safe against a database that already carries the rows. That is the correct shape for seeded reference data, and it is worth noting because the Business Unit fixture in the same Flyway run does neither.

The one seeded storage strategy is each Facility's default, Facility default, which lists TRAVEL_DISTANCE (layout V1608; ADR 0061). There is no seeded location type, no seeded zone or Location Class, and no seeded number range. A commissioning administrator builds all of those.

Products are configuration as much as data

ItemData is where per-product policy lives, and several fields are pure configuration rather than description (services/product-service/karyo-product-core/src/main/kotlin/com/karyo/product/domain/model/ItemData.kt):

  • lotMandatory, bestBeforeMandatory, shelflife, serialNoRecordType - capture rules enforced at receiving (ItemData)
  • defaultUnitLoadTypeId - the container a receipt defaults to (ItemData.defaultUnitLoadTypeId)
  • defaultStorageStrategyId - the putaway policy, described as "Per-product preferred putaway StorageStrategy (ID-only cross-module reference)" (ItemData)
  • defaultPackagingUnitId - with a stated invariant: when non-null it must reference a packaging unit belonging to this product, enforced in updateProduct, and cleared when that unit is removed (ItemData.defaultPackagingUnitId)
  • zoneId - see below

defaultPackagingUnitId is the model for how these should behave: the invariant is written down, enforced at the service, and maintained on removal.

The other three are cross-module ids, and the service asks the owning module before it stores them: ProductService.createProduct and ProductService.updateProduct refuse an unknown defaultUnitLoadTypeId, and ProductFacilityPolicyService.apply refuses a defaultStorageStrategyId or zoneId the Facility does not have (422 invalid-configuration), as strategies and policies traces.

ItemData.zoneId steers putaway only while proximity is on

zoneId is accepted on create and update, stored in the product's Facility policy (ProductFacilityPolicyService.apply) and echoed on ProductResponse (ProductFacilityPolicyService.inFacility). The putaway finder reads it only while the Facility's karyo.proximity.enabled setting is on: then it is the second rung of the zone order, after the request's preferredZoneId and before the strategy's zone (the zone). With the setting off, which is the default, the finder's zone is request.preferredZoneId ?: strategy?.zone?.id (services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/service/LocationFinderService.kt, LocationFinderService.tryFindPutawayLocation) and the product's zone steers nothing, as before proximity putaway. A zone that no longer exists in the Facility is ignored. To clear a stored zone, empty the Zone field of the product form or send zoneId as null in the product update (absent leaves it as it is). preferredZoneId is only ever supplied by a caller of the find-location API - no internal putaway path derives it from the product.

An administrator setting a product's zone is doing the most natural thing in the world - "this SKU lives in the chilled zone" - and getting nothing until the Facility turns proximity on. A strategy with a zone, one table away, delivers it whatever the setting.

Unit load types: instance-wide reference data behind an operational role

UnitLoadTypeResource declares inventory.read on its reads and inventory.write on every write, including delete (services/inventory-service/karyo-inventory-core/src/main/kotlin/com/karyo/inventory/api/v1/UnitLoadTypeResource.kt, UnitLoadTypeResource).

inventory.write is held by the standard receiver, operator, manager and administrator profiles (services/karyo-app/src/main/resources/db/migration/auth/V1214__action_catalogue.sql, V1214__action_catalogue). So any picker or goods-in clerk can create, rename and delete the unit load types that the TypeCapacityConstraint matrix, product defaults and packing behaviour are all built on - instance-wide reference data, behind the action that lets someone move a pallet.

The delete does guard: it refuses with 409 has-dependents while a unit load, a TypeCapacityConstraint.unitLoadTypeId row in the layout module or an ItemData.defaultUnitLoadTypeId in the product module references the type (service/UnitLoadTypeService.kt, UnitLoadTypeService.delete). The last two have no foreign key, so inventory asks layout and product through their lookups.

The admin surface follows the same actions. Admin -> Unit load types is listed with permission: 'inventory.read' (frontend/web/src/config/admin-navigation.ts), the action of the list it loads, and the page's write controls check inventory.write (frontend/web/src/pages/admin/admin-unit-load-types-page.tsx), the action the backend declares on every write. A principal whose grants hold only inventory.read sees the types and cannot change them.

Number ranges have no administration surface at all

sequence_numbers is a real configuration table: per named sequence it holds counter, end_counter (default 9999), format (default %1$04d) and check_digit_type (db/migration/common/V2__create_sequence_numbers.sql). Those four columns are exactly the knobs a warehouse asks about on day one - how long is a label, what does it look like, does it carry a check digit.

Known defect. There is no REST resource, no admin page and no seed. Rows are created on first use with the migration defaults, inside the generator (libs/karyo-sequence/src/main/kotlin/com/karyo/sequence/generator/FormattedCounterGenerator.kt, FormattedCounterGenerator). Changing a format or widening a range means an UPDATE against the database by hand.

Which generator runs is itself an environment knob, karyo.sequence.generator, defaulting to TIMESTAMP_RANDOM (libs/karyo-sequence/src/main/kotlin/com/karyo/sequence/SequenceConfig.kt, SequenceConfig). The FORMATTED_COUNTER generator - the only generator the table configures - is therefore off unless an operator sets the variable and restarts. Selection is strict: an unknown name fails application boot rather than falling back to another registered generator, and duplicate generator names fail boot too, "so selection is deterministic" (libs/karyo-sequence/src/main/kotlin/com/karyo/sequence/SequenceNumberService.kt, SequenceNumberService.validateOnStartup, SequenceNumberService.checkForDuplicateGeneratorNames, SequenceNumberService.generator). That is the right call and it is documented at the refusal.

Generation is bounded and honest: up to five attempts against a caller-supplied uniqueness check, SequenceException.TooLong immediately if a candidate exceeds the column, and SequenceException.Exhausted if every attempt collides (SequenceNumberService.next). The counter wraps to zero at end_counter (FormattedCounterGenerator.generate).

Put those together for a deployment running FORMATTED_COUNTER: unit_loads.label_id is UNIQUE (db/migration/inventory/V102__create_unit_loads.sql, unit_loads), the default range is 0..9999, and on wrap the regenerated labels collide with existing rows until the retry budget is spent, at which point the operation fails cleanly with Exhausted. The failure mode is a refusal rather than corruption, which is the correct behaviour. The problem is the remedy: widening end_counter requires direct database access, because the product ships no way to do it.

Document templates

Per-client document template overrides are an engine capability, available on every installation and shown while the profile shows Document templates; its module and REST routes are part of the distribution (engine capabilities). The document archive, by contrast, is in the core modules.

The admin sidebar lists both Documents (the archive) and Document templates to a principal that holds each entry's action: operations.view for Documents and settings.manage for Document templates (frontend/web/src/config/admin-navigation.ts). Every template route declares settings.manage (services/document-service/karyo-doctemplates-core/src/main/kotlin/com/karyo/doctemplates/api/v1/DocumentTemplateResource.kt, DocumentTemplateResource), and the templates page opens straight on the override editor for an operating-company (ops) principal that holds it (frontend/web/src/pages/admin/admin-templates-page.tsx); a goods-owner principal is refused with a 403 even with that action (services/document-service/karyo-doctemplates-core/src/main/kotlin/com/karyo/doctemplates/service/DocumentTemplateService.kt, DocumentTemplateService.delete). The settings.manage route guard is the gate on the page, and nothing on the page asks the server about a licence - see the configuration boundary.

One piece of reference data has no configuration story at all: the ZPL location-label template ships as a resource inside the layout module (services/warehouse-layout-service/karyo-layout-core/src/main/resources/templates/location-label.zpl), not as a document template, so changing a location label's layout is a build-time change while changing a shipping document's is not. The split is stated here as a fact, not a judgement.