Karyo
Documentation/ Decision records

ADR 0033: Slotting advice requires Loci; Karyo keeps its facts and constraints but no analysis of its own

Karyo 2.1.1rendered at build time
On this page

Status: Accepted. Supersedes in part ADR 0031 (the built-in reference advisor that answered without Loci, and the SlottingStrategy SPI behind it).

Context

ADR 0031 made Loci the slotting engine behind Karyo's facts and constraints, and kept a second source of slotting analysis inside Karyo: when no karyo.slotting.loci.base-url resolved for a goods owner, the built-in abc-proximity reference advisor (AbcProximitySlottingStrategy, behind the SlottingStrategy SPI) ranked ABC velocity against location order index and answered through the same advice envelope, labelled engine.kind = reference. The Items page's class chips and the Slotting page showed that advice on every installation without Loci.

The product decision is that slotting requires Loci: SlottingService stays, as the Karyo service that collects the warehouse facts and enforces Karyo's own constraints, and the built-in analysis goes. No further reason is recorded.

Two constraints from ADR 0031 still bind:

  • Nothing may become an always-enabled fiction. An installation without Loci must not be shown invented advice, an empty list that reads as nothing to move, or advice left over from an earlier answer.
  • The boundary with Loci stays exact. Karyo keeps the facts, the constraints, authorization, review, applying changes and the UI; Loci keeps analysis and advice and stays independently deployable.

Decision

  • Loci is the only source of slotting analysis. AbcProximitySlottingStrategy and the SlottingStrategy SPI are deleted, with the SPI's row in the admin's live registry and static catalogue and the karyo.slotting.mismatch-threshold setting only the advisor read. SkuSlot, a fact the reader produces and the contract builder reads, moves from the SPI package into karyo-slotting-core's reader package beside FixedLocation.
  • SlottingService stays and needs a Loci base URL first. It resolves karyo.slotting.loci.base-url for the goods owner (client row, SYS row, configuration) before it reads any fact. Unset, it refuses the request as SlottingException.EngineNotConfigured; set, it reads the facts, sends the neutral contract, and applies the fixed-location hold exactly as before, including level = none when there is nothing to rank.
  • No Loci is a 503 problem that names the setting. SlottingExceptionMapper maps EngineNotConfigured to 503 slotting-engine-not-configured, whose detail says that slotting advice requires Loci and names KARYO_LOCI_BASE_URL and karyo.slotting.loci.base-url, as a label printer that is not configured is a 503 (no-printer-configured). A configured Loci that fails keeps its 502 problems (slotting-engine-unavailable, slotting-snapshot-rejected).
  • The console states it rather than failing on it. The Slotting page shows a Slotting advice requires Loci state that names the setting, with no engine strip, table or error panel, and neither toasts nor retries that answer; it hides any earlier advice still in the cache. The Items page shows no velocity classes and says they need Loci, never that a call failed.
  • The advice envelope keeps its shape. SlottingAdviceDto is served only by a configured Loci, so engine.kind is loci and level is never reference; the fields stay for the console and any integration that reads them.

Consequences

  • An installation without Loci has no slotting advice and says so on the Slotting page, on the Items page and in the 503 body, instead of showing a Karyo ranking. Every other capability is unaffected; Loci stays a separate deployment, now required for this one answer.
  • The demo warehouse shows slotting advice only with a Loci connected; without one its Slotting page shows the not-configured state.
  • Karyo's own responsibilities are unchanged: tenant-scoped facts, the fixed-location hold, VIEWER authorization, the review vocabulary and applying accepted moves through ordinary Karyo workflows.
  • The admin's SPI registry lists one seam fewer, and EngineRouteAuthorizationTest checks the slotting route's 503 problem as its handler's answer on a test stack without Loci.
  • An integration that read the reference envelope now receives a 503 problem where it received engine.kind = reference. The route is in no consumer contract.

Alternatives considered

  • Answer 200 with an empty envelope marked as not configured. Rejected: a client that reads only suggestions would take an empty list for "nothing to move", and the Items page would show every SKU as having no class yet, which is the empty success the change must not produce.
  • Keep the SlottingStrategy SPI with no built-in implementation. Rejected: a seam with no path behind it would list in the registry as an extension point that nothing calls, and a custom bean behind it would be the in-Karyo analysis this decision removes.
  • Keep the reference advisor as a fallback. Rejected by the product decision above; ADR 0031 records why it had been kept.

Evidence

  • services/slotting-service/karyo-slotting-core/src/main/kotlin/com/karyo/slotting/service/SlottingService.kt, SlottingService.advice
    • the base URL checked before any fact is read; SlottingService.holdFixed; SlottingService.NOT_CONFIGURED, the refusal's detail
  • services/slotting-service/karyo-slotting-core/src/main/kotlin/com/karyo/slotting/exception/SlottingException.kt, SlottingException, SlottingExceptionMapper - the 503 problem
  • services/slotting-service/karyo-slotting-core/src/main/kotlin/com/karyo/slotting/reader/SlotReader.kt
    • SkuSlot beside the reader that produces it
  • services/karyo-app/src/test/kotlin/com/karyo/slotting/SlottingServiceTest.kt, SlottingApiTest.kt - no Loci is refused as not configured, over HTTP and with no fact read
  • services/karyo-app/src/test/kotlin/com/karyo/security/EngineRouteAuthorizationTest.kt, EngineRouteAuthorizationTest.NOT_CONFIGURED_HERE - the slotting route's not-configured answer in the role table
  • frontend/web/src/pages/insights/slotting-api.ts, isLociNotConfigured, retrySlotting - isLociNotConfigured, retrySlotting
  • frontend/web/src/pages/insights/slotting-page.tsx, SlottingPage - the Slotting advice requires Loci state
  • frontend/web/src/pages/items/use-item-analytics.ts, useItemAnalytics - slottingNotConfigured