Spensara Spensara Knowledge Base & Documentation Repository

Repository Docs & Knowledge Base

Consolidated Spensara documentation repository (722 Markdown & architecture documents in ../repository)
Built Word Documents (.docx): Spensara Overview (.docx) Capability Assessment (.docx) Brink POS Ingestion Analysis (.docx) The Borg Ingestion Architecture (.docx)

Implementation Specs (157)

Detailed engineering and feature implementation specifications.
implementation-specs/specs/KdsMonitorServingContractMigration/TASK2.2.md 3,816 bytes · Updated Oct 23, 2026 10:44 AM EDT
Raw File

TASK 2.2: Migrate forgotten-items and item-recall-storm

Summary

Migrate the workflow-heavy forgotten-items and item-recall-storm monitor specs to curated.order_items workflow columns.

These monitors previously depended heavily on direct kdsdev.item_bumps joins.

Dependencies

  • TASK 2.1 (slow-kitchen and station-bottleneck migration)

Files to Modify

1. backend/Kds.Ai.Data/MonitorSpecs/forgotten-items.md

Replace source item and item bump workflow logic with curated.order_items.

2. backend/Kds.Ai.Data/MonitorSpecs/item-recall-storm.md

Replace source item recall and item bump confirmation logic with curated.order_items.

Required Behavior

forgotten-items

Target tables:

  • curated.orders
  • curated.order_items

Required curated columns:

  • curated.orders.order_id
  • curated.orders.created_at
  • curated.orders.is_completed
  • curated.orders.item_count
  • curated.order_items.order_item_id
  • curated.order_items.order_id
  • curated.order_items.item_name
  • curated.order_items.category
  • curated.order_items.station_id
  • curated.order_items.preparation_time_seconds
  • curated.order_items.created_at
  • curated.order_items.workflow_status_code
  • curated.order_items.prepared_at
  • curated.order_items.done_at

Migration rules:

  • query curated.order_items directly,
  • do not join to item_bumps,
  • identify pending/stuck items with workflow_status_code = 0,
  • use prepared_at IS NULL and done_at IS NULL as supporting evidence where useful,
  • replace device_id with station_id,
  • replace preparation_time with preparation_time_seconds,
  • remove store_guid and is_deleted,
  • preserve 20-item sample-size rule and forgotten-rate thresholds.

item-recall-storm

Target tables:

  • curated.orders
  • curated.order_items

Required curated columns:

  • curated.orders.order_id
  • curated.orders.created_at
  • curated.orders.is_completed
  • curated.order_items.order_item_id
  • curated.order_items.order_id
  • curated.order_items.item_name
  • curated.order_items.category
  • curated.order_items.station_id
  • curated.order_items.created_at
  • curated.order_items.updated_at
  • curated.order_items.recall_at
  • curated.order_items.workflow_status_code
  • curated.order_items.previous_workflow_status_code
  • curated.order_items.prepared_at
  • curated.order_items.done_at

Migration rules:

  • query recalled items with recall_at IS NOT NULL,
  • use previous_workflow_status_code = 2 and workflow_status_code = 1 as recall confirmation when needed,
  • remove direct item_bumps join,
  • replace device_id with station_id,
  • replace raw epoch fields with timestamp fields,
  • remove store_guid and is_deleted,
  • preserve 15-item sample-size rule and recall-rate thresholds.

Acceptance Criteria

  • [ ] forgotten-items.md references only curated.orders and curated.order_items
  • [ ] forgotten-items.md does not reference kdsdev
  • [ ] forgotten-items.md does not reference item_bumps
  • [ ] forgotten-items.md uses workflow_status_code, prepared_at, and done_at
  • [ ] item-recall-storm.md references only curated.orders and curated.order_items
  • [ ] item-recall-storm.md does not reference kdsdev
  • [ ] item-recall-storm.md does not reference item_bumps
  • [ ] item-recall-storm.md uses recall_at, workflow_status_code, and previous_workflow_status_code
  • [ ] Neither monitor requires store_guid or is_deleted
  • [ ] Existing thresholds and severity guidance are preserved
  • [ ] No runtime code is changed in this task

Notes

  • These are the highest-risk prompt migrations in this slice because workflow events are collapsed into the curated item row.
  • Keep the prompt clear that curated.order_items exposes latest valid workflow state.