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
Run: NIST 1A.2 — Permission/role-change audit events (3.3.1/3.3.2)
Branch: feat/nist-1a2-permission-audit (base nist-800-110-audit)
Mode: fully autonomous — plan → execute → self-review (research/spec/grill skipped; design pre-resolved in plan §1A.2)
Goal
Emit structured audit events (actor, target user, before/after permission set, companyId) on permission/role mutations that today emit nothing.
Design (grounded)
- Extend
packages/auth/src/services/auth-events.server.tsAuthEventunion withpermission_changed+role_changed. Add two typed helperslogPermissionChange/logRoleChangeand a puregrantedPermissionKeys(permissions, companyId)summariser. - Thread acting
userId(actor) through the service-role write paths:deactivate{User,Employee,Customer,Supplier}inusers.server.tsgain optionalactorId; each concrete deactivation emitsrole_changed(role → null) with the before/after permission summary for the company.carbon/update-permissions+carbon/user-admin(deactivate) event payloads gain optionalactorId(packages/lib/src/events.ts); ERP routesbulk-edit-permissions.tsx,deactivate.tsx,revoke-invite.tsxpass the actinguserId.updatePermissionsjob snapshots the before-set and emitspermission_changed.
- Export
@carbon/auth/auth-events.serversubpath so the jobs package can import the emitter.
TDD
packages/auth/src/services/auth-events.server.test.ts— red→green:grantedPermissionKeyspurity +logPermissionChange/logRoleChangepayload shape (mock@carbon/logger).
Gates
pnpm exec turbo run typecheck --filter=@carbon/auth --filter=erp --filter=@carbon/jobspnpm run lintpnpm --filter @carbon/auth test
Additional path covered (analogous, not gold-plating)
- ERP single-user permission edit:
updateEmployee/updatePermissionsinapps/erp/app/modules/users/users.server.ts(routeemployees.$employeeId.tsx) — same class ofuserPermissionwrite as the bulk path; emitspermission_changedwith actor.
Deliberate scope boundaries (NOT emitting)
- Invite self-activation (
setUserPermissionsvia invite acceptance): actor == target, permissions pre-approved by an admin at invite-creation time; a lifecycle event, not an admin permission mutation. employeeTypePermissionrole-template writes (employee-types route): role DEFINITION config, different shape, not a per-user grant; would need separate modeling.
Status
- tests written + green (
packages/auth/src/services/auth-events.test.ts, 7 new) - implementation (emission wired into all named paths + analogous single-user path)
- gates pass — typecheck (@carbon/auth, @carbon/jobs, erp, @carbon/lib), lint (33/33), auth tests (30 passed)
- self-review + PR
UNVERIFIED (environment cannot prove)
- Runtime/DB/browser emission (no stack booted): the actual CloudWatch/JSONL lines are not observed. Proven only by unit tests + typecheck.