---
id: 019cb9fd-1498-7b73-8fc0-6861ae86b223
name: Slow Kitchen Monitor
kind: Anomaly
cron: 0 0 * * * *
analysis_window: 1h
comparison_periods: [1d, 7d]
---

Detect when the entire kitchen is running slow -- all preparation times are significantly elevated across every station.

## Known Tables & Columns

### `curated.kitchen_orders`
- `guid` (varchar, PK) - order identifier
- `store_guid` (varchar) - which store/restaurant
- `preparation_time` (int, seconds, nullable) - total order preparation time
- `items_count` (int) - number of items in the order
- `order_type` (varchar) - DINE_IN, TO_GO, DELIVERY
- `destination` (varchar) - Kitchen, Bar, Window, Expo
- `done` (tinyint) - whether the order is complete
- `is_deleted` (tinyint) - soft delete flag
- `create_time` (int, unix timestamp) - when the order was created
- `update_time` (int, unix timestamp) - last update

### `curated.kitchen_order_items`
- `guid` (varchar, PK) - item identifier
- `order_guid` (varchar, FK) - parent order
- `name` (varchar) - menu item name
- `category` (varchar) - Grill, Fryer, Salads, Drinks, Desserts
- `device_id` (int) - KDS station ID (1=Grill, 2=Fryer, 3=Salad, 4=Drinks, 5=Desserts)
- `preparation_time` (int, seconds, nullable) - how long the item took to prepare
- `is_deleted` (tinyint) - soft delete flag
- `create_time` (int, unix timestamp) - when the item was created

### `curated.kitchen_item_status_events`
- `guid` (varchar, PK) - bump identifier
- `item_guid` (varchar, FK) - parent item
- `status` (tinyint) - 0=pending, 1=prepared, 2=done
- `prepared_local_time` (int, unix timestamp, nullable) - when item was prepared
- `done_local_time` (int, unix timestamp, nullable) - when item was completed
- `is_deleted` (tinyint) - soft delete flag

## Analysis Approach

1. Query the last {AnalysisWindow} of completed orders (`done=1`, `is_deleted=0`, `preparation_time IS NOT NULL`).
2. Join with `curated.kitchen_order_items` and aggregate average item-level `preparation_time` by hour and by station.
3. Verify that each station has at least **15 items** in the analysis window. Ignore stations with fewer data points.
4. Compare the per-hour averages against the historical baseline (same hour-of-day {ComparisonPeriods}).
5. A **global** slowdown affects ALL stations simultaneously -- check whether the elevated prep times span Grill, Fryer, Salad, Drinks, and Desserts uniformly rather than being isolated to one station.
6. Flag hours where the average prep time across all stations is >3 standard deviations above baseline AND the absolute elevation is at least **90 seconds** above the baseline average.
7. To confirm this is a kitchen-wide issue (not a single-station bottleneck), verify that at least **4 out of 5** stations show elevated prep times in the same time window. If only 1-2 stations are elevated, call `emit_no_anomaly` (it may be a station bottleneck, not a slow kitchen).

## Severity Guidance

- **Low**: 3-4 sigma deviation, at least 4/5 stations elevated by 90s+
- **Medium**: 4-5 sigma deviation, or prep times 3x above baseline across 4+ stations
- **High**: >5 sigma deviation, or prep times 5x+ above baseline across all stations
