Karyo
Documentation/ Architecture

Floor Assessment - design note

Karyo 2.1.1rendered at build time
On this page

Floor Assessment reads a warehouse's open monitor alerts, scores which flow stage is under the most pressure, ranks the alerts, and gives each alert the facts and records behind it. Its route is GET /api/v1/floor-assessment (services/monitoring-service/karyo-monitors-core/src/main/kotlin/com/karyo/monitors/api/v1/FloorAssessmentResource.kt), and the console shows it on the Monitors page (frontend/web/src/pages/monitors/): a header strip with the bottleneck, and the Exceptions card with the ranked alerts and the open alert's record. It is Extended like the rest of the Monitors capability. The bottleneck agent works; the diagnostic agent is intentionally empty. Everything in it is rule-based code: no model and no judgment engine. It does not act on the warehouse and it is not a model of the warehouse.

This note records the first shippable slice's design and the gaps behind it, because no prior decision record for this capability existed when it was built - it is derived from current system truth, not from a pre-existing ADR. Treat it as the seed a fuller design record can grow from, not as a restatement of one.

What it is

An agent pack of read-only, deterministic reasoning agents that sit one altitude above the Monitors detector seam. Detectors turn raw domain state into signals (the alerts the Monitors engine persists). A FloorAssessmentAgent reasons over a snapshot of those signals - the floor's current operational state as the open alerts describe it - to explain and prioritise them:

  • DiagnosticAgent (diagnostic) - placeholder for root-cause correlation: registered in the pack, but it reports no findings in this slice. A diagnosis may only claim a cause when its signals are open on the same scope and independent rather than raised by one underlying event, and no built-in monitor pair meets that bar on open alerts alone (see the gaps below). Until one does, nothing is inferred from co-presence and all signals are left to the alert list.
  • BottleneckAgent (bottleneck) - maps throughput-limiting signals onto the warehouse flow (FlowStage), scores each stage per monitor (not per alert, so detector grain cannot skew it) by severity and capped age, and reports the single highest-pressure stage with its own evidence and actions. It does not claim that other stages depend on that one clearing: the open alerts carry no link between stages (see the gaps below).

The pack contract lives in services/monitoring-service/karyo-monitors-core/src/main/kotlin/com/karyo/monitors/floorassessment/FloorAssessmentAgent.kt; the orchestrator (FloorAssessmentService, beside it) discovers agents as CDI beans and returns one FloorAssessment, exposed at GET /api/v1/floor-assessment: the findings ranked by severity then confidence, and the open alerts themselves (signals) in rank order.

Signal context

Each open alert in the snapshot carries a SignalContext (floorassessment/SignalContext.kt): typed facts about the records the alert is about, and links to those records. One SignalContextReader per monitor (floorassessment/context/) gathers it in one read for all of that monitor's alerts, joined over the ids the modules share. A monitor without a reader, or a scope with no record behind it any more, has an empty context.

Monitor Facts Links (the join)
stuck-order status, priority, customer, idle time, pick order open, lines short, each closed pick order with its state, order notes and shipping hint verbatim the order, its shipments and its open pick orders (delivery order to pick order and shipment; a picked or canceled pick order is listed as a fact with its state, not linked), and the bins its released picks take from (released pick to bin)
putaway-backlog open and paused putaway tasks, how long the oldest has waited, notes on the oldest five the oldest five tasks and their receipts (receipt line to putaway order)
bin-below-reorder bins below reorder point, and how many already have an open replenishment task the first five bins and their SKUs, those without a task first (fix assignment to bin and SKU)
expiry-risk days left on the soonest lot, amount at risk, whether any of it is reserved the item and the stock at each location that holds it (stock unit to location)
shrinkage whether a count was applied in the window, adjustments in the window the item
cycle-count-variance counted locations that are off, whether a recount of the SKU is open (a count order still waiting to be counted) the item and the counted locations (count order to location)

A fact has a stable key, a label, a kind (LEVEL, STATE, FLAG, COUNT, NAME or TEXT), a typed value and its text in words. Every number a rule would compare is bucketed into a named level once, in Levels (an age is under_an_hour, under_a_day, one_to_two_days or over_two_days; days left is expired, today, under_a_week, under_a_month or a_month_or_more; a priority is high, normal or low). A link names a record kind and the record's console id; the console turns it into a route (floor-assessment-api.ts, recordPath). The readers parse an alert's scope with the detectors' own FindingScope, so the scope text has one definition. The readers also keep to the caller's grants, though the endpoint asks only for operations.view: a stuck order's customer, notes and shipping hint appear only when the caller holds orders.read in the Facility, and the putaway tasks' notes only when the caller holds tasks.read there. A caller without the grant gets the rest of the context and no placeholder. A reader that fails is logged and leaves its monitor's alerts without context; the assessment still answers.

Ranking

The open alerts are ranked by one rule a person can check on the screen: higher severity first; at equal severity, an alert in the bottleneck finding's stage first; then the longest open first. The Exceptions card shows them in that order and opens the top one.

Decisions and their rationale

  • Deterministic-first, no frontier-model runtime dependency. Mirrors the Detector SPI's stated extension seam (the built-in detectors are deterministic rules; another detector can "implement the same interface with no change to the alert pipeline"). Every agent in this slice is deterministic code and needs no external model.
  • Housed in karyo-monitors-core. Floor Assessment reasons over monitor alerts, so it is cohesive with the Monitors pack and ships with it. It needs no new SPI/-api module.
  • Contract decoupled from persistence. SignalObservation and FloorAssessment are normalised away from the Alert entity and AlertDto. This lets the pack be promoted into its own service later without reshaping its agents - the intended growth path.
  • Disabled monitors leave the snapshot through the alert lifecycle. Disabling a monitor mutes its open alerts, and the evaluator re-mutes any it finds on every tick. If the monitor is re-enabled within the recent-mute bound (AlertService.RECENT_MUTE, 24 hours) and still finds a scope, that alert reopens silently in its pre-mute status (FIRING or ACK) with its original firstFiredAt. After the bound, the scope fires as a new alert with a fresh start and the usual notifications.

Recorded gaps / follow-ups (not in this slice)

  • Cross-subject correlations. Claims such as a putaway backlog starving forward-pick replenishment, an upstream stage holding up the stages after it, or expiring lots held on stalled orders need a link between the records behind two alerts. The signal context now carries the records behind each alert, but no agent joins them yet, so the diagnostic agent still claims no cause rather than inferring one from co-presence.
  • Inventory-accuracy correlation. Shrinkage and a cycle-count variance on the same SKU are not independent today: applying a count books its delta as the same adjustment the shrinkage detector sums, so one miscount raises both. A control-gap diagnosis needs shrinkage evidence that excludes count-driven adjustments first.
  • Persisted assessments / history / events. This slice computes on demand and returns; it does not persist assessments or emit assessment events.
  • Snapshot breadth. The snapshot is the open monitor alerts and the records behind them. Richer floor state (live KPIs, whole task queues) can be added behind FloorSnapshotProvider without changing agents.