Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Model Line Changeover as a State Machine So the Next SKU Cannot Start Before Clearance

By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at factoraerp.com . If you build production or MES/ERP software for food manufacturers, here is a failure mode worth designing out: the next product's production order can start on a line while the previous product is still, in practice, on it. In small and mid-sized food and agro factories in Kenya, where I work,…

In the food manufacturing industry, particularly in small and mid-sized factories in Kenya, product changeovers on production lines can lead to a failure mode where the next product's production order starts while the previous product is still present on the line. This issue arises due to residue, leftover labels, work in progress, and stale machine settings from the previous product. To address this problem, a line clearance checklist and software modification are needed.

Currently, production orders are often modeled with a status (planned, in_progress, completed) and a line_id. However, this design does not prevent two orders from being in_progress on the same line or starting a new order before the previous one is fully cleared. The solution is to model each line with its own state machine, making orders depend on the line's state.

Key states in the line state machine include RUNNING (for an active order), CLOSED_OUT (when the order is completed with all relevant data recorded), CLEANED (after the cleaning process), and CLEARED (after verification that the line is clear of the previous product). A transition from RUNNING to RUNNING is not allowed, even for administrators, ensuring that no order can start until the previous one has been properly cleared.

The system enforces several rules through code. Only one active order per line is allowed, and start_order can only be triggered when the line is in SETUP state and first-off QC has passed. Skipping states is not permitted, and there is no transition from RUNNING to RUNNING. Changeover type determines the required cleaning program and verification checks, derived from the products being changed over.

Segregation of duties is crucial, with the verify_clearance.checked_by user differing from the record_cleaning.cleaned_by user, and both requiring a QA/supervisor role. The close_out process is a precondition, ensuring that any packaging or work in progress from the previous order has been returned, consumed, or explicitly scrapped before closing the order.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

V+ (Vit Plus): the “all-inclusive” environment that brings order to linting, formatting, testing and workflow

One CLI, one configuration file, consistent tools: less glue, less disconnected tools, more speed and shared standards. In recent years, we have normalized a certain "fragmentation" in the setup of…

  • V+ simplifies front-end project setup, configuration, and management
  • Single CLI with unified commands for project creation, linting, formatting, testing, and building
  • Utilizes Oxlint and Oxformat for superior performance and simplicity over ESLint and Prettier

How to Reply When You Can't Tell If Someone Is Upset in a Text

You get a short message: "fine." or "ok, whatever works." And now you're staring at your phone trying to work out whether the person is annoyed, tired, or just typing fast.

  • Separate message from personal interpretations to avoid negative assumptions
  • Use neutral responses that apply to all possible emotions
  • Keep replies concise, focused, and avoid escalating the situation

Pin the Fault Matrix Before You Refactor a Messy Module

Pin the Fault Matrix Before You Refactor a Messy Module Consider an illustrative composite scenario rather than one specific incident, because the shape repeats across review threads.

  • Error surface changes first in refactor, not happy path
  • Three patterns cause drift in error surface: type flattening, code loss, ordering drift
  • Fault matrix helps track raised exceptions during refactoring

More from Thursday, 15 October 2026 →