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.
@carbon/checks
Executable checks for the loop system's "core".
Conformance net
Forbids deprecated code patterns in migrations. Existing violations are
grandfathered in src/conformance/baseline.json; only new violations fail CI.
- Add a check: implement a
ConformanceCheckundersrc/conformance/, add it toCONFORMANCE_CHECKSinsrc/run.ts, then re-baseline. - Re-baseline (after intentionally accepting current state):
pnpm --filter @carbon/checks baseline - Run the gate:
pnpm --filter @carbon/checks test
Each check records provenance (the transition event that retired the old pattern).
Grandfathering granularity is per (checkId, file, snippet), not per occurrence:
adding a second occurrence of an already-baselined pattern to an already-baselined
file is not flagged. This is acceptable because shipped migrations are immutable /
append-only — new migration files, and new check types in old files, are always caught.
Clobber check
Detects when the same DB object (view or function) is redefined
on both the current branch and main since their merge-base — a "concurrent
redefinition" that will silently overwrite whichever side merges last.
- What counts as a clobber:
CREATE OR REPLACE VIEWorCREATE OR REPLACE FUNCTIONtargeting the same object name on both sides. Event triggers are not included: they live in the attachments manifest, not in migrations. - Run at PR time:
pnpm --filter @carbon/checks clobbers(needsorigin/mainfetched — rungit fetch origin mainfirst if needed). - Grow coverage: add a
{ kind, re }row toOBJECT_PATTERNSinsrc/clobber.ts— theobjectRefsandfindClobbersfunctions pick it up automatically. - Not in
testgate: the check requires git/branch context and is not appropriate for the staticvitest runjob. Run it as a separate CI step. - When a clobber is flagged: rebase onto the latest
main, then re-fork your redefinition frommain's version so you incorporate the concurrent change.
Invariant net
Runnable database assertions. Each invariant is a .sql file in src/invariants/
that SELECTs the rows which violate the rule (empty result = healthy).
- Add an invariant: drop a
.sqlfile insrc/invariants/— no code or registration. - Run against a database:
DATABASE_URL=<conn> pnpm --filter @carbon/checks invariants(exits non-zero if any invariant returns rows). - Invariants run against a live DB (a loop's worktree DB, or nightly against prod),
NOT the static CI
testjob. The runner is DB-agnostic (injected query), so the logic is unit-tested without a database.