---
id: 019cb9fd-149c-7b4b-8d15-2e83794c8e47
name: Forgotten Items Monitor
kind: Anomaly
cron: 0 0 * * * *
analysis_window: 1h
comparison_periods: [1d, 7d]
---

Detect items that are stuck on the KDS screen and never progressing through the kitchen workflow -- they were created but never prepared or completed.

## Known Tables & Columns

### `curated.kitchen_orders`
- `guid` (varchar, PK) - order identifier
- `store_guid` (varchar) - which store/restaurant
- `items_count` (int) - number of items in the order
- `done` (tinyint) - whether the order is complete
- `is_deleted` (tinyint) - soft delete flag
- `create_time` (int, unix timestamp) - when the order was created

### `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) - expected prep time
- `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 (0 if never prepared)
- `done_local_time` (int, unix timestamp, nullable) - when item was completed (0 if never completed)
- `is_deleted` (tinyint) - soft delete flag
- `create_time` (int, unix timestamp) - when the bump record was created

## Analysis Approach

1. Query items created in the last {AnalysisWindow} from `curated.kitchen_order_items` (`is_deleted=0`), joined with `curated.kitchen_item_status_events` on `item_bumps.item_guid = items.guid`.
2. Verify that the analysis window contains at least **20 items** total. If not, call `emit_no_anomaly` — the sample is too small.
3. Identify "stuck" items: those where `item_bumps.status = 0` (still pending) AND the item was created more than 2x its expected `preparation_time` ago (or more than 15 minutes ago as a fallback).
4. Calculate the **forgotten rate**: the percentage of items in a time window that remain at status 0 long past their expected completion.
5. Compare against the historical baseline. Normally, almost all items should progress to status 1 (prepared) and then status 2 (done). A forgotten rate above 15% is unusual; above 30% is a clear anomaly.
6. Group by hour to find the window where the anomaly started.
7. Check if the stuck items cluster on a specific station (`device_id`) or are spread across all stations. A cluster on one station might indicate a station-specific issue; spread across all stations suggests a systemic problem.

## Severity Guidance

- **Low**: 15-25% of items stuck beyond their expected prep time in a 1-hour window
- **Medium**: 25-40% of items stuck, or stuck items accumulating over multiple hours
- **High**: >40% of items stuck -- clear indication of items being forgotten and not prepared
