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
Capacity planning: fix the 8 high findings
Source: the browser test of 2026-10-24 (findings F1, F5, F6, F10, F12, F16, F26, F27). Decisions from the user on 2026-10-26:
- Scope is the 8 high findings only.
- F10: save the work center that the scheduler picks.
- F26: change the
users_for_groupsguard. - F27: stop the data loss and correct the help text. No scheduler work for contractors.
Each fix gets a test at its seam (see .claude/rules/testing.md), then a browser check.
Tasks
- F6 — a batch is placed against bookings that the run will replace.
- In
packages/planning/src/scheduling/batch-scheduler.ts, add a pure functionbatchBlockingReservations. It keeps the bookings that block a released batch. It drops this location's own batch rows and every non-batch row of a job that the run re-plans. - Call it from
placeReleasedBatcheswithorderedJobIds. - Test:
batch-scheduler.test.ts.
- In
- F10 — the chosen work center is not saved.
- Add
isOperationStarted(op)toapply-work-center-selections.ts. The selector uses it too. applyWorkCenterSelectionswrites the selected work center when the op is placed and not started. A started op and a placeholder keep the stored work center.buildWriteswrites the applied work center.- Test:
apply-work-center-selections.test.ts.
- Add
- F12 — an operator is booked after the qualification expires.
- In
operator-eligibility.ts, addclipToQualification(windows, expiresAt, timeZone). The qualification ends at the start of theexpiresAtday in the plant timezone. buildEligibleMembersclips each member's windows. A member with no window left is dropped.- The People board treats the expiry day as expired (
<=), like the engine and MES. - Test:
operator-eligibility.test.ts.
- In
- F16 — holidays are ignored.
- Add
closeHolidaystomachine-availability.tsandwithHolidaystopeople-utils.ts. Both usesubtractDates, which cuts whole days in the plant timezone. - The provider reads the company's holidays once (
getHolidayDates). - The provider removes holidays from every work center that is not lights-out, and from the location default calendar.
buildFiniteContextadds each holiday as an absence for every person.- The Forecast shades holidays. The Capacity view shows 0 Available on a holiday.
- The holiday operations notify the scheduler. The 3 holiday routes call those operations.
- Tests:
machine-availability.test.ts,people-utils.test.ts,forecast.test.ts,capacity-buckets.test.ts.
- Add
- F5 — a shift change does not re-plan ungated work.
createShift,updateShiftanddeleteShiftnotify kindshiftwith the shift id. The delete route callsdeleteShift.- Add a pure function
workCentersOnShiftto the jobs package. It returns the work centers whose hours come from the shift: explicit links, plus unlinked, not lights-out stations at the shift's location. - The mark step stamps the jobs with open ops on those work centers, plus the gated jobs as before.
- Test: a unit test for
workCentersOnShift.
- F1 — the Capacity view puts hours on nights and weekends.
buildPeopleCapacityBucketstakes each work center's working windows.- It divides a booking's
workHoursby the working time inside each day. If the booking has no working time, it uses the clock time as before. - The People loader builds the windows with
resolveWorkCenterWindowsand the holidays. - Test:
productionunit test with the Potting Station example (8h booking Mon 12:00 → Tue 11:30 = 2.5h + 5.5h).
- F26 — a training assigned to one person is invisible.
- Main fixed this first (
699d31dc28, migration20261026114317_users-for-groups-identity-groups.sql). This branch drops its own migration and keeps that fix. - The browser check of F26 runs against main's fix.
- Main fixed this first (
- F27 — a contractor save deletes the abilities.
upsertContractorreplaces the abilities only when the caller sendsabilities.- The edit route stops sending an empty list.
- Correct the glossary text for
contractor-hours-per-week.
- Docs: update
.claude/rules/scheduling-data-structures.mdand the production and resourcesAGENTS.mdfor F6, F10, F12, F16. - Verify: typecheck (planning, jobs, erp), Biome, unit tests, the SQL test, and a browser check of each finding.
Result (2026-10-26)
| Check | Result |
|---|---|
Typecheck: @carbon/planning, @carbon/jobs, erp |
Pass |
| Unit tests: planning (358), jobs scheduled (70), ERP (8) | Pass |
@carbon/checks conformance (403) and clobbers |
Pass |
| Biome on the 32 changed files | No errors |
rpc-privileges.test.sql (main's version) |
Pass |
| Browser check of each finding | Pass. Details below. |
- F6: 4 regenerates in a row give the same order and work center per station.
- F10: 0 of 81 bookings name a station other than the op's work center (42 before).
- F1: Capacity for 26 Oct to 1 Nov shows 0 overloaded (8 before), and no weekend hours.
- F5: adding a shift stamped 5 jobs. Editing Swing Shift stamped 11 jobs, and no booking runs past the new end.
- F12: an operator whose qualification ends on 28 Oct is not booked on 29 Oct.
- F16: the holiday stamped 13 jobs. Capacity shows 0 Available on that day, and the Forecast shades it.
- F26: the Assignments list and drawer show the training assigned to one person.
- F27: two contractor saves wrote the hours, and the ability stayed.
The test data is restored: 85 reservations, 0 placeholders, 0 stale jobs.
Self-review follow-ups (2026-10-26)
- The
placeReleasedBatchesdoc comment is back on its function. placementWrites(run-overlay.ts) now builds the placement writes, andbuildWritescalls it. A new test applies a selection and checks the write. With the old rule put back, that test fails.- The ERP uses the engine's
closeHolidaysandsubtractDates(now exported from@carbon/planning). It has no copy of its own. - The Forecast loader reads holidays in parallel with its other reads.
- The abilities table takes today from the browser's calendar, not the UTC day.
people.mdxandscheduling.mdxdescribe holidays. Two lessons are in.ai/lessons.md.