Skip to content

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.

Fix/workflow fixes (#1367)

Anshul sharma13f524c1d2f1
diff --git a/.claude/rules/workflow-matcher.md b/.claude/rules/workflow-matcher.md
index 44ca33f91a..c5f014b3ec 100644
--- a/.claude/rules/workflow-matcher.md
+++ b/.claude/rules/workflow-matcher.md
@@ -111,7 +111,8 @@ replay can never double-fire:
sends nothing.
- The Inngest event id is `` `${workflowId}:${workflowVersionId}:${sourceEventId}` ``.
- Both entry points also set Inngest `idempotency` (`event.data.msgId` /
- `event.data.momentId`) and a `limit: 5` per-`companyId` concurrency key.
+ `event.data.momentId`). Neither declares a `concurrency` block — no function-level
+ key means Inngest applies the account/plan concurrency instead of a hand-picked cap.
## Subscriptions are derived, never hand-managed
@@ -159,7 +160,7 @@ Kysely bypasses RLS. **The caller authorizes first** — phase 7's activation ro
- `events/workflow.ts` returns early on `TRUNCATE`; `record` is `new ?? old`, and
`before`/`after` are populated only for UPDATE.
- `workflows/run.ts` hands the payload to `src/workflows/engine/` and declares
- `idempotency: "event.data.runId"` plus per-`companyId` (5) and per-`workflowId` (5)
- concurrency keys. See `workflow-engine.md`.
+ `idempotency: "event.data.runId"` and no `concurrency` block — runs are limited by the
+ account's concurrency, not a per-`companyId`/per-`workflowId` cap. See `workflow-engine.md`.
- Deploy-time drift checks live with `packages/checks`: the `workflow-trigger-event-drift`
SQL invariant and `pnpm --filter @carbon/checks workflow-events`.
diff --git a/packages/jobs/src/inngest/functions/events/workflow.ts b/packages/jobs/src/inngest/functions/events/workflow.ts
index c4874860ab..71c24da757 100644
--- a/packages/jobs/src/inngest/functions/events/workflow.ts
+++ b/packages/jobs/src/inngest/functions/events/workflow.ts
@@ -23,11 +23,7 @@ export const workflowFunction = inngest.createFunction(
{
id: "event-handler-workflow",
retries: 3,
- idempotency: "event.data.msgId",
- concurrency: {
- limit: 5,
- key: "event.data.companyId"
- }
+ idempotency: "event.data.msgId"
},
{ event: "carbon/event-workflow" },
async ({ event, step }) => {
diff --git a/packages/jobs/src/inngest/functions/workflows/moment.ts b/packages/jobs/src/inngest/functions/workflows/moment.ts
index fd3a3c6355..bf3cd6464a 100644
--- a/packages/jobs/src/inngest/functions/workflows/moment.ts
+++ b/packages/jobs/src/inngest/functions/workflows/moment.ts
@@ -18,11 +18,7 @@ export const workflowMomentFunction = inngest.createFunction(
{
id: "workflow-moment",
retries: 3,
- idempotency: "event.data.momentId",
- concurrency: {
- limit: 5,
- key: "event.data.companyId"
- }
+ idempotency: "event.data.momentId"
},
{ event: "carbon/workflow-moment.raised" },
async ({ event, step, logger }) => {
diff --git a/packages/jobs/src/inngest/functions/workflows/run.ts b/packages/jobs/src/inngest/functions/workflows/run.ts
index 8a9cb2dbe2..9d5ba133cb 100644
--- a/packages/jobs/src/inngest/functions/workflows/run.ts
+++ b/packages/jobs/src/inngest/functions/workflows/run.ts
@@ -26,10 +26,6 @@ export const workflowRunFunction = inngest.createFunction(
id: "workflow-run",
retries: 3,
idempotency: "event.data.runId",
- concurrency: [
- { limit: 5, key: "event.data.companyId" },
- { limit: 5, key: "event.data.workflowId" }
- ],
onFailure: async ({ event, logger }) => {
const { runId, companyId } = event.data.event.data;
logger.error(`Workflow run ${runId} failed`, event.data.error);