Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
MES ability enforcement per process
Status: Approved Date: 2026-10-22 Research:
.ai/research/mes-ability-enforcement.md
TL;DR
- Each process that requires an ability now says what MES does when an operator lacks it: Warn (default) or Block.
- The choice sits on the process form, under "Requires Ability". It shows only while that toggle is on.
- The toggle's description now names the ability, which is the process's own name.
- Warn: MES shows a banner on the operation page. The operator can still start.
- Block: MES shows the banner and refuses all production work on the operation: Start, Log completed, Scrap, Rework, Mark as Done, step records and material issue. The message names the training that grants the ability.
- There is no company-wide setting. Today MES always blocks; after this change every process starts on Warn.
Overview diagram
flowchart LR
A["Operator opens operation"] --> B{"Process requires ability<br/>and operator lacks it?"}
B -- no --> S["Start works"]
B -- yes --> C{"process.abilityPolicy"}:::new
C -- warn --> W["Yellow banner, Start works"]:::new
C -- block --> X["Red banner, Start refused"]
classDef new stroke-dasharray:4 3
Problem
An operator gets an ability when they complete a training. The trigger grant_ability_on_training_completion writes the employeeAbility row.
MES checks the ability at Start with getOperationEligibility (apps/mes/app/services/operations.service.ts). That check always blocks. An admin cannot choose a softer mode, and some abilities need a block while others only need a warning. The operator also sees no warning before Start. The process form does not say which ability its toggle requires.
Goals
- Add a per-process mode:
WarnorBlock. The default isWarn. - In
Warnmode, show a warning and let the operator start. - In
Blockmode, refuse all production work on the operation. Tell the operator how to get the ability. - Show the warning before Start, on all three MES operation views.
- Name the ability in the "Requires Ability" description.
Non-goals
- No company-wide setting.
- No change to the ability data model, the training trigger, or expiry rules.
- No change to the scheduler's operator eligibility (
packages/planning). - No other UX changes to processes, abilities or trainings.
Design
Data model
Migration 20261022063357_process-ability-policy.sql:
CREATE TYPE "processAbilityPolicy" AS ENUM ('Warn', 'Block');
ALTER TABLE "process"
ADD COLUMN IF NOT EXISTS "abilityPolicy" "processAbilityPolicy" NOT NULL DEFAULT 'Warn';
ERP and MES read the values and the type from the generated processAbilityPolicy enum.
The same migration drops and re-creates the processes view, so p.* picks up the column. The column is read only while requiresAbility is on.
ERP process form
| Part | Change |
|---|---|
resources.models.ts |
Add processAbilityPolicies and abilityPolicy: z.enum(...).optional() to processValidator. |
ProcessForm.tsx |
The name field is controlled. The "Requires Ability" description reads "Only employees with the {name} ability can be scheduled for and run this process". |
ProcessForm.tsx |
AbilityPolicy renders a Select "If an operator isn't qualified": Warn / Block. It shows only while Requires Ability is on, like the batch type select. |
processes.$processId.tsx, processes.new.tsx |
Initial value abilityPolicy (stored value, else Warn). |
insertProcess / updateProcess spread the validated input, so they write the field with no change.
MES
getAbilityShortfallreturns what the operator lacks, or null. One embedded read gets the process and its ability. Then the qualification and the granting training are read in parallel. A shortfall carriespolicy,processName,expiredOnandtrainingName.abilityBlockRefusalis the only check the routes call. It builds the English flash text when the policy isBlock.abilityBlockRefusalreturns the refusal text when the policy isBlock. These routes call it before they write:event(Start),start.$operationId,end.$operationId(kanban complete scan),batch.$batchId.completeandbatch.$batchId.record(one member is checked, because every member runs the batch's process),complete,finish,scrap,rework,record,record.$id.delete,issue,issue-tracked-entity(single operation),unconsume,entity+/…scrap, and the inspectionsample,measurement,dispositionandcomplete-passedroutes.- The operation view disables the same actions when the policy is
Block. Pause, Maintenance, Quality Issue, Instructions and Chat stay enabled. Not guarded:steps.complete-all(a manager override),steps.inspection(an automatic sync) and a batch pick. x+/event.tsxredirects a full-page POST (Sec-Fetch-Mode: navigate, a press before the page hydrates) back to the referring page, keeping the flash.- The three loaders (
operation,assembly,inspection) pass the shortfall to the view asabilityWarning. The assembly and inspection views disable the same work, and skip their timer auto-start, when the policy isBlock. AbilityWarningrenders a warningAlert(Warn) or a destructiveAlert(Block). Its copy uses Lingui.
The server flash text stays English. MES routes have no server-side translation today.
Design decisions
| Decision | Choice | Why |
|---|---|---|
| Where the mode lives | On process |
Some abilities need a block and others a warning. User answer. |
| Company-wide setting | None | The per-process mode replaces it. User answer. |
| Column type | Enum processAbilityPolicy: Warn / Block |
One generated type for ERP and MES, with no casts. Same pattern as invoiceAutomation. |
| Default | Warn |
The original request. |
| Ability name on the form | In the toggle's description | Minimal. User answer. |
| Field visibility | Only while Requires Ability is on | Same pattern as the batch type select. |
| Warn UX | Banner on the page, no extra click | User answer. |
| Views with the banner | Operation, assembly and inspection | All three post Start to x+/event.tsx. |
| Which training to name | One Active training with grantsAbilityId = the ability |
The trigger grants the ability from that link. |
Acceptance criteria
- An existing process has
abilityPolicy = 'Warn'after the migration. - An admin opens a process and turns on Requires Ability. The description names the process. The "If an operator isn't qualified" select appears with Warn selected. Turning the toggle off hides the select.
- The admin picks Block and saves. The value is
Blockafter a reload. - Process "Welding" requires an ability, with policy
Warn. Operator A has noemployeeAbilityrow for it and opens a Welding operation. A yellow banner names the ability and its training. Operator A presses Start. The timer starts. - Same setup with policy
Block. Operator A sees a red banner. Start, Log completed, Scrap, Rework, Mark as Done, Record and Issue Material are disabled. A direct POST to any guarded route is refused, and nothing is written. - Same setup with policy
Block. Operator A scans the operation's start QR code. MES redirects to the operation page with the error toast. - Operator A's
employeeAbility.expiresAtis yesterday. The banner says the qualification expired, with the date. - Operator B has a valid
employeeAbilityrow. No banner shows. Start works in both modes. - The assembly and inspection views show the same banner as the operation view.
Open questions (resolved)
- Existing companies already get a hard block. What default do they get? — Answer:
Warn, as the request says. - How does an operator see the warning in Warn mode? — Answer: A banner on the operation page. Start needs no extra click.
- Company setting or per process? — Answer: Per process, on the process form. No company setting.
Changelog
- 2026-10-22: First draft with a company-wide setting in Production → Shop Floor.
- 2026-10-22: Implemented with the company setting.
- 2026-10-22: Thermo-nuclear review fixes: enum column, one shared check,
getAbilityShortfall, Block gating and no auto-start in the assembly and inspection views. - 2026-10-22: Block covers all production work, not only Start. The event route recovers from a full-page POST.
- 2026-10-22: Moved the mode onto the process and removed the company setting. Named the ability in the toggle's description.