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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
OEE: fixes from the strict self-review
Source: the nuclear self-review of PR #1909 on 2026-10-14. Each task names the finding it fixes.
Decisions
| # | Decision |
|---|---|
| 1 | The open workCenterLoad row is the load. The migration drops workCenter.loadedJobOperationId and loadedAt. Readers use the open row. |
| 2 | A load is refused when its start is earlier than the newest boundary in the work center's history (a loadedAt or an unloadedAt). (A starting event reopens a Done operation first, so status needs no rule.) |
| 3 | An unload ends the open row at GREATEST(NOW(), "loadedAt"). A CHECK refuses unloadedAt < loadedAt. A partial unique index allows one open row per work center. |
| 4 | A press records the earliest press since the last sync in workCenterDevice.unplannedPressAt. The sync clears it. |
| 5 | Time after a press, in the same run, goes to the queue. Time in a run with no press before it goes to the operation loaded at that moment. The engine applies one owner rule to every piece. |
| 6 | An open system slot follows its owner: it closes where the owner changes (a load change, a block start or end, an unassignable operation) and the next owner opens. This replaces the Canceled special case. |
| 7 | A late stop before a press trims the closed unattributed rows it overlaps. The engine never trims a Machine event. |
| 8 | A press takes its time under the lock, and it serializes on a transaction advisory lock for each work center. |
| 9 | The routes post every event a press ends, except batch events. |
| 10 | The migrations are not squashed: squashing needs a database rebuild, which the user must run. |
| 11 | Load rows stay 7 days after the unload (the user's decision). The purge keeps a row that a device has not planned past yet. |
Tasks
Database
-
- Migration: drop the pointer columns. Add the CHECK, the one-open index and the index for the sync's Machine-event reads. Add
unplannedPressAt. Change the retention guard.
- Migration: drop the pointer columns. Add the CHECK, the one-open index and the index for the sync's Machine-event reads. Add
-
- Interceptors: write only
workCenterLoad, with the boundary rule. (The status rule was dropped: see decision 2.)
- Interceptors: write only
-
- Event functions and
auditConfig.skipFields: remove the pointer columns.
- Event functions and
-
- The MES display view and service: read the open row.
-
packages/jobs/src/backups/id-refs.ts: addworkCenterLoad.jobOperationIdandmachineStateChange.workCenterDeviceId.
-
- SQL test: an older event after an unload, a reload, the CHECK, the index, the purge.
Engine and sync
-
- Engine: the owner rule, slots that follow their owner, the trim of late idle time,
firstUnplannedPressAt.
- Engine: the owner rule, slots that follow their owner, the trim of late idle time,
-
- Engine tests that run the same facts in different orders and compare the result.
-
- Sync: bounded reads,
recordedIntervalswith ids,unplannedPressAt, the trims,lastEventAtfrom stored changes, guarded close, no Canceled block.
- Sync: bounded reads,
-
- One pure
machineTimeRefusalin@carbon/ee/oee, used by the sync, the ee service and the ERP.
- One pure
-
- The
companyIdjoin inservice.server.ts.
- The
Press (MES)
-
recordManualMachinePress: advisory lock, press time taken under the lock,GREATESTonlastManualChangeAt,unplannedPressAt. Test that a press records itself.
-
startMachineProductionEventruns a Machine start (press, event, tracked activity) in one transaction. Remove the hook.
-
endMachineProductionEventin the service. The End route uses it and checksendedEventIds.
-
- Routes: check permission before any write (both routes), post the ended events, scope
endProductionEventbycompanyId, give a clear message for a refused End.
- Routes: check permission before any write (both routes), post the ended events, scope
ERP (subagent)
-
- Row link and close keep the list filters. Queue moves replace history.
-
- Drawer: log and show load errors. Suggestions span the interval's days.
-
- Search candidates include operations with no work center.
-
- Timezone: treat
''as missing.
- Timezone: treat
-
- Devices tab: store the matched device's fields. The picker hides work centers mapped to another device. A light module holds the cache key. The provider read runs in parallel.
-
- Lingui named placeholders, one casing. CSV duration and times.
-
- Tests: the queue keyset, more filter cases.
Deactivation
-
- Uninstalling or deactivating an OEE integration ends the sensor time of its devices.
Docs
-
- The OEE rule, the production
AGENTS.md, the database and jobsAGENTS.md,oee.mdx,work-centers.mdx, the spec, and one lesson.
- The OEE rule, the production
Verify
-
- Typecheck, tests, Biome, Lingui, dataset and backup checks. Commit and push.