Files
MIS-Contro-Tower/MACHINE_STATE_PROGRESS.md
2026-05-06 00:36:48 +00:00

2.2 KiB

Machine State Progress

Final State Model (5 states + sub-reasons)

State Color Trigger
OFFLINE dark gray Heartbeat dead >2 min
STOPPED red, pulse >5min Active WO + no cycles (regardless of tracking)
- reason machine_fault Tracking on, macrostop event active
- reason not_started Tracking off, has WO
DATA_LOSS red + icon, pulse Tracking off + cycles arriving (>5 cycles or >10 min)
MOLD_CHANGE blue Active mold-change event
- sub at >3h yellow accent (Round 2)
- sub at >5h red accent (Round 2)
IDLE calm gray No tracking, no WO, no cycles
RUNNING green Tracking + WO + recent cycles

Round 1 — Foundation: classifier + IDLE + STOPPED collapse + DATA_LOSS

  • Step 1: Add "idle" and "data-loss" to RecapMachineStatus union
  • Step 2: Create lib/recap/machineState.ts shared classifier with all reasons
  • Step 3: Refactor statusFromMachine in redesign.ts to call classifier
  • Step 4: Plumb new fields (status reason, ongoing min) through types/responses
  • Step 5: UI rendering: IDLE (calm gray) on /recap, /machines, detail
  • Step 6: UI rendering: DATA_LOSS (red + icon) on all surfaces
  • Step 7: STOPPED reason text: show not_started vs machine_fault distinction
  • Step 8: i18n keys (en + es-MX)
  • Step 9: End-to-end verify each state transitions correctly

Round 2 — Mold change duration escalation (CT-only)

  • MOLD_CHANGE >3h yellow accent
  • MOLD_CHANGE >5h red accent
  • i18n strings

Notes / parked items

  • Prisma drift on (orgId,machineId,seq) unique indexes — pre-existing, not related to this work. Address as separate housekeeping task.
  • Node-RED incidentKey rotation behavior verified: 10 distinct keys per real stoppage = correct.

Path A — dead state cleanup (post Round 1)

  • Removed not_started and data-loss branches from classifier
  • Removed RecapStoppedReason and RecapDataLossReason types
  • Simplified RecapStateContext to empty struct (kept for future use)
  • Updated UI rendering: 5 states only (offline/stopped/mold-change/idle/running)
  • i18n: removed dead keys