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.
Phase 5 research — actions, entity operations, lookups
Condensed from four codebase sweeps (dispatcher/auth, notifications, webhooks, phase-4
engine seams). Every claim below was read out of the code on branch feat/automation.
1. The engine seams phase 5 must fill
| # | Seam | Where | What has to change |
|---|---|---|---|
| 1 | Executor registry | packages/workflows/src/runtime/executors.ts:8-13 |
Add lookup, entity, action. Nothing else in the engine switches on node.type. |
| 2 | NOT_AVAILABLE |
packages/jobs/src/workflows/engine/execute.ts:55,84 |
Becomes unreachable for those kinds; keep as the defence. |
| 3 | Permission action | execute.ts:89 |
Hardcoded "view". hasPermission already supports create/update/delete. A writing action needs a wider NodeExecutor.permission return. |
| 4 | RuntimeContext |
packages/workflows/src/runtime/types.ts:26-33 |
Only {catalog, loader, outputs, item?}. No owner-scoped client. Built at execute.ts:96-100. |
| 5 | ctx.item |
execute.ts:96 |
Declared but never set by the engine; only filter.ts:44 injects it locally. |
| 6 | itemKey |
execute.ts:115 |
Hardcoded "". Batch needs itemKeyFor(item). |
| 7 | Step id | execute.ts:274 |
`node:${nodeId}` needs a deterministic per-item suffix. |
| 8 | workflowStepRun.input |
engine/ledger.ts:53-84 |
Column exists (migration line 154), engine never writes it. |
| 9 | getAction/getOperation |
packages/workflows/src/catalog/catalog.ts |
Stubs: options.getAction?.(id). execute.ts:155 calls createEventCatalog() with no options, so both always return undefined. |
| 10 | CatalogAction/CatalogOperation |
packages/workflows/src/definition/catalog.ts:21-33 |
No permission field (unlike CatalogEvent). |
| 11 | write allowlist |
catalog/entities.ts + catalog/build.ts:29-38 |
RegistryEntry is `table |
| 12 | Loader table map | engine/loader.ts:29 |
REGISTRY_ENTRIES[entity]?.table is the only entity→table map, so Lookup can only reach registry entities. |
| 13 | Lost-claim replay | execute.ts:119-121 |
Always returns Skipped; the phase-4 spec wanted a terminal row's output reused. |
| 14 | Tests | runtime/executors.test.ts:17-20 |
Asserts the three kinds are undefined. |
Lookup already validates clean. NODE_KINDS.lookup.configured gates on getEntity,
which is real — so a lookup node passes activation today and fails only at run time with
"This kind of step is not available yet." Action and Entity gate on the two stubs, so they
genuinely cannot be activated.
Lookup cannot name the record it is searching. lookup.data.match is
clauseSchema[] (left: valueOrRef, operator, right: valueOrRef), and loopList is
undefined so {kind:"item"} is illegal there. There is no form that means "the candidate
record's status". This is the same shape of gap phase 4 found in Filter.
Reference executors: runtime/condition.ts and runtime/filter.ts. Both return
permission: () => undefined, so phase 5 writes the first non-undefined permission.
NodeResult.Failed already carries an optional handle, and execute.ts:144 honours it —
so failure-handle routing needs no engine change.
Batch machinery is built and unwired. runtime/batch.ts exports planBatch (caps at
MAX_LIST_ITEMS = 100) and itemKeyFor (entity id, else h:<fnv1a64>). Grep confirms no
caller outside the barrel and its test.
2. Acting as the owner, and calling business logic
getUserScopedClient(userId, { workflowRunId })(packages/auth/src/lib/supabase/client.server.ts:14) mints a 5-minute HS256 JWT with aworkflow_run_idclaim and returns an anon-key client — RLS fully applies.packages/jobs/src/workflows/engine/owner.ts—getOwnerClient,readOwnerPermissions(readsget_claimsas the owner, deliberately not the 1-hour-cached privileged path), andhasPermission(permissions, module, action, companyId)where"0"is the all-companies wildcard.
The dispatcher is not reachable from the engine
executeFunction(functionName, context, args)lives atapps/erp/app/routes/api+/mcp+/lib/direct-executor.ts:84. It imports~/modules/*, sopackages/jobscannot import it (packages/jobs/package.jsonhas no app dependency, and grep finds zero~/modulesimports underpackages/jobs/src).- It splits
<module>_<fn>, builds positional args fromserviceParams/injectAuthin the generatedapps/erp/app/routes/api+/mcp+/lib/tool-metadata.json(1397 tools, regenerated byscripts/generate-mcp.tsand by the husky pre-commit hook), stampscompanyId/companyGroupId/createdBy/updatedBy, and returns{success:true,data} | {success:false,error}. - It does no permission checking — only a one-entry blocklist
(
MCP_BLOCKED_TOOL_NAMES = ["settings_seedCompany"]). All authorization is RLS. tool-metadata.jsonhas no permission-module field, andExecutorContextneeds acompanyGroupIdthe workflowRunPayloaddoes not carry.
What the engine can reach today
- Owner-scoped Supabase reads/writes (
.from(table)), including the RPCget_next_sequence(apps/erp/app/modules/settings/settings.service.ts:395) for readable ids. - Supabase edge functions via
client.functions.invoke(...)— but thecreatefunction is narrow (nonConformanceTasks,purchaseOrderFrom*,receipt*,shipment*,journalEntry), not general document creation. - Shared Kysely business engines in
packages/database/src/*(e.g.quality.tsusesgetNextSequence) — but Kysely bypasses RLS, which conflicts with acting as the owner.
3. Notify
- One event,
carbon/notify(packages/lib/src/events.ts:16-35), handled bypackages/jobs/src/inngest/functions/notifications/notify.ts. It already does in-app + email + Slack, per-person opt-outs, plan gating and digesting. - Every message string is built by looking up the source document — one switch,
buildEventContentinnotifications/content.ts:137-1187, ~27 cases, each doing its ownclient.from(...)read. There is no path for caller-supplied text:EventContentOptions(content.ts:117-121) carries only{companyId, documentIds?, userId?}. - Adding a payload-text kind touches:
packages/lib/src/events.ts(carry the text),packages/notifications/src/index.ts(newNotificationEvent+ topic/heading/CTA cases),content.ts(EventContentOptions+ a case that reads no table),notify.ts(defaultDestinationsentry, forward the text, and thedocumentId ?? documentIds[0]guard at:200-205which currently throwsNonRetriableErrorwithout one),apps/erp/app/routes/api+/link.ts(else the CTA lands on the app root), andapps/erp/app/components/Layout/Topbar/Notifications.tsx:198-418(without a case the in-app row rendersnull— invisible). - No migration needed:
notification.event/.topicare plainTEXT. - Roles are groups. An
employeeTypeis mirrored 1:1 into agrouprow with the same id (20230123004632_groups.sql:68-78), and each user has an identity group whose id is the user id — so one mixed array of user ids and group ids resolves uniformly throughusers_for_groups(text[])(:310-324). That RPC isSECURITY DEFINERwith no tenant check, which is whynotify.ts:290-305re-filters againstuserToCompany. - Opt-outs:
notificationPreference(userId, companyId, channel ∈ {email,slack}, topic, enabled), absence of a row = enabled, in-app never filtered.
4. Call an outside URL
Two systems, neither signs anything.
- System A (the customer-facing one):
webhooktable → per-table Postgres triggers →pg_net→ edge functionpackages/database/supabase/functions/webhook/index.ts. Onefetch, no retries, no dedupe, no timeout, onlyContent-Type: application/json. CounterssuccessCount/errorCount. Plan-gated onWEBHOOKS. The docs state the at-most-once and no-signing behaviour explicitly (docs/content/docs/building/webhooks.mdx). - System B (live code, no producer):
eventSystemSubscriptionwithhandlerType = 'WEBHOOK'→ PGMQ →packages/jobs/src/inngest/functions/events/webhook.ts. 38 lines:axios.post(url, data, { headers: config.headers })withretries: 3,idempotency: "event.data.msgId", andconcurrency: { limit: 0, key: "<table>-<recordId>" }.limit: 0is not a documented Inngest value (already flagged in the phase-3 spec). Nothing in the repo ever inserts a WEBHOOK subscription row. - Zapier (
packages/ee/src/zapier/config.tsx) is an inactive registry stub, not a system. - No outbound signing exists anywhere. No
svix, nostandard-webhooks, nox-signature. Inbound verifiers to mirror: Slack (packages/ee/src/slack/lib/client.ts:117-150— versioned base stringv0:<ts>:<body>, hex HMAC-SHA256, 5-minute replay window) and Paperless Parts (apps/erp/app/routes/api+/webhook.paperless-parts.$companyId.ts:17-30— Stripe-stylet=<ts>,v1=<sig>header, per-company secret read fromcompanyIntegration.metadata). - Secret storage: there is no vault, no pgsodium, no application-level encryption.
Precedents are a plaintext JSON blob (
companyIntegration.metadata), a plaintext column (apiKey.key), an env-level single secret, or derive-don't-store (assemblerCallbackToken=HMAC(SESSION_SECRET, "<purpose>:<id>")). - No SSRF protection at all. Only
z.string().url(). No scheme/port restriction, no private-IP denylist, no DNS pinning, no redirect cap (axios follows up to 21), no timeout, no response-size cap. Retries spanning hours also mean a Slack-style 5-minute replay window would reject late attempts.
5. The entity registry as it stands
packages/workflows/src/catalog/entities.ts — 10 triggerable entities
(purchaseOrder, salesOrder, job, item, receipt, shipment, quote, supplier,
customer, nonConformance — labelled "Issue") and 5 reference-only
(user, jobOperation, salesInvoice, purchaseInvoice, location).
watch keys are bound to the table by ColumnOf<T>, so a renamed column fails to compile.
Known constraints from .claude/rules/workflow-event-catalog.md:
- Stored document totals (
purchaseOrder.orderTotal) live only on views, which carry no trigger and are not dot-readable — they were explicitly deferred to phase-5 Entity operations. packages/workflowsmust stay ES2019-safe and browser-safe (nonode:crypto, no BigInt literals) becauseapps/erpcompiles its source.- Runtime dependencies are only
zod,@carbon/utils,@lingui/core.