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.

Workflow improvements (#1410)

Anshul sharma953fb47a091d
diff --git a/.ai/plans/2026-08-17-workflows-compute-node-rename.md b/.ai/plans/2026-08-17-workflows-compute-node-rename.md
new file mode 100644
index 0000000000..2535bc7435
--- /dev/null
+++ b/.ai/plans/2026-08-17-workflows-compute-node-rename.md
@@ -0,0 +1,125 @@
+# Rename the workflow `entity` node ("Record") → `compute` ("Compute")
+
+Date: 2026-08-17 · Branch: `fix/workflow-improvements`
+
+## What and why
+
+The workflow node type stored as `type: "entity"` is shown in the builder palette as
+**"Record"**, described as *"Writes to a record in Carbon"*. Both are wrong: the node is
+read-only — it runs one catalog **operation** and returns a computed value (an order
+total, a job's scrap percentage, an item's quantity on hand). Everything that *writes*
+is an Action step. The docs already carry a warning callout apologising for the name
+(`docs/content/docs/reference/workflows.mdx:64`).
+
+So this is a full internal rename, not just a label swap:
+
+- node type discriminant `entity` → `compute`
+- palette label `Record` → `Compute`, with an accurate description
+- the stale "Despite the name…" docs callout goes away
+
+## Scope boundary — `entity` is overloaded
+
+Rename **only** the node type. Leave every other `entity` alone:
+
+| Not renamed | Where |
+|---|---|
+| the value-type kind `{ kind: "entity", of }` | `definition/types.ts`, `runtime/values.ts`, `entityValue()` |
+| catalog entities (record-type registry) | `catalog/entities.ts`, `CatalogEntity`, `getEntity`, `entity.<name>` label keys |
+| the **lookup** node's `data.entity` field | `lookupNode` schema, `NODE_KINDS.lookup` |
+| `EntityLoader` (record-reading port) | `runtime/types.ts`, `engine/loader.ts` |
+| `MomentEntityRef`, `entityRefs.ts`, `EntityRecordLink.tsx` | catalog / runs UI |
+| the trigger output named `"record"` | `run-trigger.ts`, `OUTPUT_LABELS.record` |
+| the runs-table "Record" column | `WorkflowRunsTable.tsx`, `workflow-runs.mdx` |
+
+## Stored-data facts (verified)
+
+- `workflowVersion.nodes` is **JSONB** (`20260810100100_workflows-foundation.sql:61`) —
+ live definitions hold `{"type":"entity"}`.
+- `workflowStepRun.nodeType` is a plain **TEXT** column (same migration, line 155) with
+ **no enum and no CHECK**. Historical run rows keep the string `"entity"` forever.
+- No migration, view, RPC or constraint references `'entity'` in a workflow context.
+
+→ **No SQL migration.** Stored definitions are upgraded on read by `migrateDefinition`;
+historical step rows are handled by a display alias.
+
+## Steps
+
+### 1. `packages/workflows` — the contract
+
+- [ ] `definition/schema.ts`: `entityNode` → `computeNode`, `z.literal("entity")` →
+ `z.literal("compute")`, union member, `EntityNode` → `ComputeNode`.
+- [ ] `definition/schema.ts`: `CURRENT_DEFINITION_FORMAT_VERSION` **3 → 4**.
+- [ ] `definition/normalize.ts`: add the v3 → v4 block **after** the v2 → v3 name
+ backfill (so a v2 document still gets the `entity_0` names it already carries),
+ rewriting only `type === "entity"` nodes to `type: "compute"`.
+- [ ] `definition/nodes.ts`: `NODE_KINDS.entity` → `.compute`, `entityBatchInput` →
+ `computeBatchInput`, import + doc comment.
+- [ ] `runtime/entity.ts` → `runtime/compute.ts`; `entityExecutor` → `computeExecutor`.
+- [ ] `runtime/executors.ts`, `runtime/index.ts`, `src/index.ts`: keys/imports/exports.
+- [ ] `definition/validate.ts:480` comment wording.
+
+### 2. `packages/workflows` tests
+
+- [ ] `runtime/entity.test.ts` → `compute.test.ts`; `runtime/executors.test.ts`;
+ `definition/validate.test.ts:673`; `seed-workflows.test.ts:29` (sort order).
+- [ ] `definition/normalize.test.ts`: every `formatVersion` 3 → 4 and 4 → 5
+ (future-format rejection), plus a new "v3 → v4 renames entity to compute" case
+ that also pins that the node's `name` is left untouched.
+
+### 3. `packages/database` seeds
+
+- [ ] `seed-dev/tiers/workflow-definitions.ts`: `FORMAT_VERSION` 3 → 4; node
+ `entity_total` → `compute_total` (type, id, the `ref(...)` and both `edge(...)`).
+
+### 4. `packages/jobs`
+
+- [ ] `engine/end-to-end.test.ts:161,596` — the two `type: "entity"` nodes.
+- [ ] Nothing else: dispatch is `executorFor(node)`, and `nodeType: node.type` follows.
+
+### 5. `apps/erp` builder
+
+- [ ] `nodes/meta.ts`: key `entity` → `compute`; `name: "Compute"`; icon
+ `LuPencilRuler` → `LuCalculator`; description → *"Works out a value from a
+ record"*; `defaultTitle` → *"Compute a value"*; both `node.type` narrowings;
+ `NODE_KIND_ORDER`.
+- [ ] `nodes/kinds.ts` (3 maps), `nodes/index.ts` (`nodeTypes`).
+- [ ] `graph.ts:178` `case "entity"` (leave line 194 — that's lookup's `data.entity`).
+- [ ] `config/forms/EntityForm.tsx` → `ComputeForm.tsx` (`git mv`), component name,
+ `NodeFormProps<"compute">`; `config/forms/index.ts` import + `NODE_FORMS` key.
+- [ ] `useDefinition.ts`: `useEntityBatchInput` → `useComputeBatchInput`.
+- [ ] `Runs/WorkflowRunSteps.tsx:110` narrowing + comment; `Runs/useNodeLabel.ts:11`.
+
+### 6. Back-compat (the two places it actually bites)
+
+- [ ] `labelKeys.ts` `DEFAULT_NODE_NAME`: add `compute`, **keep `entity`**. Saved
+ workflows carry node names like `entity_0`; drop it and every existing card,
+ step row and outcome sentence starts rendering the literal "Entity 0". Test
+ pins both.
+- [ ] Historical `workflowStepRun.nodeType === "entity"` rows: add one resolver
+ (`metaForNodeType`) in `nodes/meta.ts` mapping the legacy string to the compute
+ meta, and use it at `WorkflowRunSteps.tsx:286` and `runOutcome.ts:26`. Without
+ it an old run's step renders the raw word "entity" as its title.
+
+### 7. Docs and rules
+
+- [ ] `docs/content/docs/reference/workflows.mdx:60` table row → **Compute**;
+ delete the now-moot line-64 callout and rewrite line 65 as a plain sentence.
+ Leave `workflow-runs.mdx` alone (its "Record" is the trigger-record column).
+- [ ] `.claude/rules/workflow-engine.md:24` and `packages/workflows/AGENTS.md:110`
+ (`entity.ts` → `compute.ts`); `AGENTS.md:29` version 3 → **4** and the
+ "one upgrade today" line (already stale — there are two, becoming three).
+- [ ] `apps/erp/app/modules/workflows/AGENTS.md:3` node-kind list.
+
+### 8. Verify
+
+- [ ] `pnpm exec turbo run typecheck --filter=@carbon/workflows --filter=@carbon/jobs --filter=@carbon/database --filter=erp`
+- [ ] `pnpm run test` (workflows, jobs, erp workflow tests)
+- [ ] `pnpm exec biome check` on touched files
+
+## Deliberately not doing
+
+- No SQL migration and no JSONB backfill of `workflowVersion.nodes` — `readWorkflowVersion`
+ migrates on read, which is the package's stated seam for exactly this.
+- No `.po` changes. `NODE_KIND_META` strings are plain JS literals that Lingui never
+ extracted; the existing `msgid "Record"` comes from unrelated `t\`Record\`` call sites.
+ Wrapping these in `msg` descriptors is a separate, larger change.
diff --git a/.ai/runs/2026-08-14-workflows-context.md b/.ai/runs/2026-08-14-workflows-context.md
new file mode 100644
index 0000000000..9b60ffa716
--- /dev/null
+++ b/.ai/runs/2026-08-14-workflows-context.md
@@ -0,0 +1,493 @@
+# Workflows feature — context map (2026-08-14)
+
+Branch `fix/workflow-improvements`. Gathered before starting improvement/UX work.
+Sources: 3 parallel explore passes over code, rules, specs, migrations, git history.
+
+---
+
+## 0. Orientation
+
+Two unrelated things are called "workflow" in this repo. This doc is about the
+**customer-facing automation feature** (`workflow*` tables, `packages/workflows`,
+`apps/erp/app/modules/workflows`). Not `issue-workflow+` (quality/NCR) and not
+`approvals-workflow` (document approvals).
+
+Ships as **"Workflows"**, not "Automations" — PRD wording is stale.
+Currently gated to the **Partner plan** for internal testing (`4716b694a`,
+superseding the earlier Business-plan gate).
+
+**Branch state:** `HEAD == origin/main == 87a19b325`. No commits of our own yet.
+`git diff main...HEAD` is misleading (local `main` is stale at `e51dfa383`) —
+use `origin/main...HEAD`. Working tree has 5 uncommitted files, none
+workflow-related (seed-dev tiers + generated DB types).
+
+---
+
+## 1. Architecture in one pass
+
+```
+ERP event / moment / schedule / test-run
+ ↓
+matcher (packages/jobs/src/workflows/matcher.ts)
+ ↓ inserts workflowRun rows (Queued), emits carbon/workflow-run.queued
+Inngest workflow-run fn (packages/jobs/src/inngest/functions/workflows/run.ts)
+ ↓
+engine (packages/jobs/src/workflows/engine/execute.ts) walks the graph
+ ↓ per node → EXECUTORS (packages/workflows/src/runtime/)
+ledger writes workflowStepRun rows → Runs UI
+```
+
+`packages/workflows` = **pure contract package**. Zero I/O, zero DB client.
+`@carbon/database` is types-only. Compiled for browser at **ES2019** — no
+`node:*`, **no BigInt literals**.
+
+---
+
+## 2. Definition format
+
+`CURRENT_DEFINITION_FORMAT_VERSION = 3` — `packages/workflows/src/definition/schema.ts:11`
+
+```ts
+{ formatVersion: number, nodes: WorkflowNode[], edges: WorkflowEdge[] }
+```
+
+**6 node types** (discriminated union on `type`, `schema.ts:106`):
+
+| Type | data | handles |
+|---|---|---|
+| `trigger` | `{ events: string[], origin, schedule? }` | `["out"]` |
+| `condition` | `{ paths: ConditionPath[] }` (if/elseIf/else) | one per `path.id` |
+| `entity` | `{ operation, inputs }` | `["out"]` |
+| `lookup` | `{ entity, returns: "one"\|"list", match }` | `["success","failure"]` |
+| `filter` | `{ source?, combinator, clauses }` | `["out"]` |
+| `action` | `{ action, inputs }` — no stored batch flag | `["success","failure"]` |
+
+Node base: `id`, `name` (`/^[a-z0-9_]+$/`, unique, refs bind to **id** not name),
+`position`, `expanded?`. Note `node.data.title` no longer exists (dropped in v3).
+
+**Value union** (`valueOrRefSchema`, `definition/types.ts`): `literal` | `ref`
+(nodeId+output+path) | `item` | `template` (interleaved text/var parts) |
+`pairs` (webhook headers only).
+
+**Migration**: only `migrateDefinition` in `definition/normalize.ts`, applied to
+raw JSON *before* the current-schema parse. One upgrade today (v1→v2 resets
+lookup `match` to `[]`). Missing `formatVersion` ⇒ 1. `from > 3` ⇒ `future-format`.
+**Rule:** always parse a row against the row's own `formatVersion`.
+
+**Constants**: `DEFAULT_OUTPUT="result"`, `DEFAULT_HANDLE="out"`,
+`MAX_LIST_ITEMS=100`, `MAX_CHAIN_DEPTH=10`, `MAX_NODE_EXECUTIONS=500`
+(`engine/walk.ts:7`), `BATCH_CONCURRENCY=5`, `MAX_RUN_STEPS=200` (service).
+
+---
+
+## 3. Package layout — `packages/workflows/src`
+
+| Path | Owns |
+|---|---|
+| `definition/schema.ts` | node/edge/definition zod, format version, handle constants |
+| `definition/types.ts` | `ValueType`, `OPERATORS_BY_TYPE`, value union, clauses, schedule |
+| `definition/nodes.ts` (769L) | `NODE_KINDS` registry — 7 mandatory members per node type; mapped type makes a missing entry a compile error |
+| `definition/validate.ts` (528L) | `validateDefinition` → `WorkflowIssue[]`, 7 layers. Never switches on node type |
+| `definition/normalize.ts` | `readWorkflowVersion` — the one raw-JSON boundary |
+| `definition/batch.ts` | `batchCandidates`/`batchPlan` — the rule for "does this action step repeat" (actions only) |
+| `definition/catalog.ts` | `WorkflowCatalog` interface, `walkPath`, `createFixtureCatalog` |
+| `definition/variables.ts` | builder-side available-variable computation |
+| `definition/schedule.ts` | `nextOccurrenceAfter`/`nextRunAfter` — tz-aware, only copy |
+| `catalog/` | 4 hand-written inputs (`entities/moments/actions/operations.ts`) → **4 committed generated files** (`events`, `actions`, `labels`, `help` `.generated.ts`) |
+| `runtime/` | 5 executors + `EXECUTORS`, `values`/`resolve`/`compare`, `batch.ts`, `fixtures.ts` |
+| `run-trigger.ts` | `runTriggerSchema` — 3-variant wire contract shared with `@carbon/lib` + `@carbon/jobs` |
+| `sync.ts` | trigger-event + `eventSystemSubscription` reconciler (4 exports) |
+
+**Catalog counts (verified):** 106 events, 16 entities, 16 actions, 15 operations,
+plus `WORKFLOW_ENTITY_ENUMS`. Actions = `notify`, `webhook`, 4 creates
+(`job/nonConformance/purchaseOrder/salesOrder.create`), 10 generated
+`<entity>.update`.
+
+Generated files are drift-checked by `scripts/check-workflow-catalog.ts`
+(produced by `scripts/generate-workflow-catalog.ts`). Never verify by importing
+the generator — re-run it.
+
+---
+
+## 4. Runtime
+
+`EXECUTORS` — `runtime/executors.ts:11`. **5 entries**; `trigger` has none
+(recorded, never executed).
+
+| Kind | File | Permission | Outcome |
+|---|---|---|---|
+| `action` | `runtime/action.ts` | `catalog.getAction(id).permission` | `services.runAction` → success/failure |
+| `condition` | `runtime/condition.ts` | — | first passing path id as handle; no match ⇒ `handle: null`, `branchTaken:"none"` |
+| `entity` | `runtime/entity.ts` | `catalog.getOperation(id).permission` | `services.runOperation` |
+| `filter` | `runtime/filter.ts` | — | pure clause loop |
+| `lookup` | `runtime/lookup.ts` | `catalog.getEntity(id).permission` | `services.search` |
+
+**Run walk** — `packages/jobs/src/workflows/engine/execute.ts`:
+1. `step.run("load")` — inactive ⇒ `Skipped`; unreadable version ⇒ `Failed`;
+ `claimRun` (`UPDATE … WHERE status='Queued'`) ⇒ `Duplicate` if lost.
+2. `step.run("permissions")` — owner client, `hasPermission(module,"view")` from
+ `catalog.getEvent(eventId).permission`.
+3. Trigger step row written at `sequence: 0` with `triggerOutputs`.
+4. Loop `nextNode(state)` → `step.run("node:<id>")` or `runBatchedNode`.
+5. `step.run("finish")` — `failInterruptedSteps()`, then `Failed` if
+ failed/capped/interrupted.
+
+**Graph state** (`engine/walk.ts`, pure): per **edge**, `live`/`dead`/pending.
+`promoteReady` queues a node when all incoming edges settled and ≥1 is live;
+all-dead ⇒ skipped, and a skip settles its outgoing edges dead (cascades).
+Only one trigger fires; other triggers' edges dead at `createWalkState`.
+
+**Condition eval** — `runtime/compare.ts` `evaluateClauses`.
+`contains`/`startsWith`/`endsWith` case-insensitive; `eq`/`neq` not.
+Unresolvable operand ⇒ **Skipped with a reason, never falls through to else**.
+
+**Batching**: action batching derived from wiring, never stored; items in groups
+of 5, step ids `node:<id>:<itemKeyFor(item)>`, then one aggregate row with
+`itemKey: ""`. `itemKeyFor` = record id, else `h:${fnv1a64(...)}` — never a
+list position. Entity batching is a **separate, weaker inline mechanism**
+(`runtime/entity.ts:30-67`) — one step, no per-item rows, silently drops failures.
+
+**Ledger** — `engine/ledger.ts`: `claimStep` = INSERT `Running`
+`ON CONFLICT DO NOTHING` (at-most-once). `redactForLog` redacts by key regex
+and by `pairs` shape, truncates >4096.
+Deliberately NOT redacted: `itemKey`, `authorizedBy`, `keyword`, `sessionId`.
+
+---
+
+## 5. Matcher
+
+`packages/jobs/src/workflows/matcher.ts` — 4 pure planning fns + 1 DB orchestrator.
+
+| Source | Function | `sourceEventId` |
+|---|---|---|
+| Record change (pgmq → `carbon/event-workflow`) | `inngest/functions/events/workflow.ts` | `pgmq:<msgId>` |
+| Moment (`raiseMoment`) | `inngest/functions/workflows/moment.ts` | `moment:<momentId>` |
+| Schedule wake | `workflows/scheduler.ts` `dispatchDue` | `schedule:<workflowId>:<dueAtIso>` |
+| Builder test run | `engine/manual.ts` (bypasses matcher) | `manual:<nanoid>` |
+
+`matchAndQueue`: indexed read on `(companyId, eventId IN …)` → `filterByOrigin`
+(`workflowRunId` present ⇒ Automation, absent ⇒ Person, Both always survives) →
+`planRuns` + loop guard (cycle via `path.includes`, then depth ≥ 10; blocked ⇒
+`Blocked` row, no event) → single INSERT `ON CONFLICT ON CONSTRAINT
+workflowRun_dedupe_key DO NOTHING`; only genuinely-inserted rows emit
+`carbon/workflow-run.queued`.
+
+`computeEventIds` (`workflows/event-ids.ts`): INSERT/DELETE → direct id;
+UPDATE → one `.changed` id per genuinely-moved watched column.
+
+---
+
+## 6. Inngest wiring
+
+| Function | id | Trigger | retries | Notes |
+|---|---|---|---|---|
+| `workflowRunFunction` | `workflow-run` | `carbon/workflow-run.queued` | 3 | idempotency `runId`; `onFailure` → `failCrashedRun`; **no concurrency block** |
+| `workflowMomentFunction` | `workflow-moment` | `carbon/workflow-moment.raised` | 3 | idempotency `momentId` |
+| `workflowSchedulerFunction` | `workflows-scheduler` | `carbon/workflow-scheduler.wake` | 3 | `singleton` skip; Redis chain token; wake ceiling 10min, `MAX_DUE_PER_WAKE=200` |
+| `workflowSchedulerBackstopFunction` | `workflows-scheduler-backstop` | cron `0 * * * *` | 2 | revives stale chain (>15 min) |
+| `workflowFunction` | `event-handler-workflow` | `carbon/event-workflow` | 3 | idempotency `msgId` |
+| `workflowRunRetentionFunction` | `workflow-run-retention` | cron `0 4 * * *` | 2 | 4 passes (below) |
+
+Registered `packages/jobs/src/inngest/index.ts:84-138`.
+
+**Retention, nightly 04:00** — every pass filters TERMINAL status; age is always
+`COALESCE("completedAt","createdAt")`:
+1. `reap-stale-runs` — close Queued/Running > 24h (`STALE_RUN_HOURS=24`)
+2. `purge-run-headers` — delete terminal runs > 90d (`RUN_HEADER_DAYS=90`)
+3. `compact-step-payloads` — `compactForLog`, set `compactedAt` (`FULL_DETAIL_DAYS=7`, 200/night)
+4. `drop-step-detail` — delete step rows, header survives (`COMPACT_DETAIL_DAYS=30`, 500/night)
+
+Pass 3 before pass 4 so `compactedAt` is always set first — the UI reads it to
+tell "steps purged" from "run has no steps yet".
+
+---
+
+## 7. Database
+
+**Three migrations, all landed together 2026-08-10** (squashed; timestamps synthetic):
+
+1. `20260810100000_workflows-run-tag.sql` — `dispatch_event_batch()` stamps
+ `workflowRunId` from the `workflow_run_id` JWT claim
+2. `20260810100100_workflows-foundation.sql` (311L) — the whole data model
+3. `20260810100200_workflow-run-history.sql` — `workflowStepRun.detail`,
+ retention indexes, `workflowLastRun` view
+
+⚠️ `.ai/lessons.md:573` and `.ai/plans/automation/pending-changes.md` cite
+migration filenames that **no longer exist** (renamed on squash).
+
+**Tables** (all composite PK `("id","companyId")`):
+
+- **`workflow`** (`wf`) — `name` (unique/company), `ownerId`, `active` (default
+ FALSE), `activeVersionId` (nullable), `nextRunAt`, `canvasState` JSONB
+ (per-workflow, **not** per-user). `activeVersionId` FK uses column-scoped
+ `ON DELETE SET NULL ("activeVersionId")` — a bare SET NULL on a composite FK
+ nulls `companyId` and makes the parent undeletable.
+- **`workflowVersion`** (`wfv`) — immutable snapshot: `versionNumber`,
+ `formatVersion`, `nodes`/`edges` JSONB
+- **`workflowTriggerEvent`** (`wfe`) — derived dispatch index, rewritten on
+ promote/toggle. `origin` CHECK `Person|Automation|Both`. No UPDATE RLS by
+ design (delete-then-insert)
+- **`workflowRun`** (`wfr`) — status CHECK `Queued|Running|Succeeded|Failed|Blocked|Skipped`,
+ `isTest`, lineage `rootRunId`/`causedByRunId`/`depth`/`path TEXT[]`
+ (**deliberately not FKs** so retention purges don't cascade), `compactedAt`.
+ UNIQUE `(workflowId, companyId, workflowVersionId, sourceEventId)`
+- **`workflowStepRun`** (`wfs`) — `sequence`, `nodeId`, `nodeType`, `itemKey`
+ (default `''`), `input`/`output`/`detail` JSONB, `branchTaken`.
+ UNIQUE `(runId, companyId, nodeId, itemKey)`.
+ `detail` = diagnostics only, never node data; shape `NodeDetail`
+
+No new PG enums (TEXT + CHECK). One enum change: `ALTER TYPE "module" ADD VALUE
+'Workflows'` + `COMMIT;` + `modules` view recreate.
+
+**View `workflowLastRun`** — `DISTINCT ON (companyId, workflowId)`, exists
+because PostgREST can't express latest-per-group. Filters `isTest = false`.
+
+**RLS**: `workflows_view|create|update|delete`, seeded to Admin + Management
+employee types and copied from `settings_*` in existing `userPermission` blobs.
+`workflowRun`/`workflowStepRun` are **SELECT-only** — no user can forge a run log.
+Both are in the `supabase_realtime` publication.
+
+---
+
+## 8. ERP UI surface
+
+**Two route trees** — the builder is in the SINGULAR one, easy to miss:
+
+`apps/erp/app/routes/x+/workflows+/` (sidebar shell)
+- `_layout.tsx`, `_index.tsx` (list), `runs.tsx`, `runs.$runId.tsx` (xl Drawer),
+ `new.tsx` (POST, seeds v1 with a lone trigger node), `$id.rename.tsx`,
+ `delete.$id.tsx`
+
+`apps/erp/app/routes/x+/workflow+/` (full-screen builder, no sidebar)
+- `$id.tsx:148` — the builder. `ReactFlowProvider` → `WorkflowBuilderProvider` →
+ `BuilderHeader` + `WorkflowBuilder` + `IssuesPanel` + `Autosave` +
+ `LiveValidation` + `TestRunDialog`. `isReadOnly = isLiveVersion || !can("update")`
+- `$id.save.tsx` (autosave, 409 on lock), `$id.canvas.tsx` (viewport),
+ `$id.publish.tsx`, `$id.toggle.tsx`, `$id.version.new.tsx`, `$id.test-run.tsx`
+
+**No settings route.** No owner transfer, no version delete, no per-workflow
+run-history page.
+
+**Builder** — `@xyflow/react` (React Flow v12), CSS via route-level `links`.
+- `ui/Builder/WorkflowBuilder.tsx` — `ResizablePanelGroup` palette 14 / canvas 62
+ / test-results 24. `deleteKeyCode={["Delete"]}` only (no Backspace, no undo)
+- `ui/Builder/BuilderHeader.tsx` — inline title, `SaveMarker`, `VersionMenu`,
+ "Live" badge, Publish + replace-live confirm
+- `ui/Builder/BuilderControls.tsx` — zoom, fit, auto-arrange, collapse-all,
+ pan/select toggle, MiniMap. Good a11y here
+- `ui/Builder/NodePalette.tsx` — 6 draggable buttons, drag *or* click-to-add
+- `ui/Builder/nodes/WorkflowNodeCard.tsx` → generic `NodeCard.tsx`; per-kind data
+ only in `nodes/meta.ts` + `nodes/kinds.ts`
+- **Config panels are inline in the card body**, not a side drawer.
+ `config/forms/`: `TriggerForm` (EventPicker, origin toggle, ScheduleEditor),
+ `ActionForm` (553L — the biggest), `ConditionForm` + `ClauseRow` +
+ `CombinatorToggle`, `FilterForm`, `LookupForm`, `EntityForm`, `InlineNodeName`
+- `ui/Builder/fields/*` (25 files) — `control.ts pickControl` is the single
+ dispatch; `VariableTreeMenu` via `InlineVariableMenu` (ProseMirror) and
+ `VariableMenuPopover` (Radix); `menuNav.ts` the one keyboard impl
+- State: `store.ts` (vanilla zustand behind `context.tsx`), `selectors.ts`,
+ `graph.ts` (`toReactFlow`/`fromReactFlow`/`createNode`/`canConnect`/`wouldCreateCycle`)
+- Validation: `LiveValidation.tsx` (250ms debounce) → `liveIssues`; publish →
+ `issues`; `selectAllIssues` merges (live wins); `IssuesPanel` + `IssueList`
+
+**Module files** — `workflows.models.ts` (69L), `workflows.service.ts` (422L),
+`workflows.server.ts` (not in barrel: `checkWorkflowVersionLock`,
+`publishWorkflowVersion`, `setWorkflowActive`, `syncAfterWorkflowDelete`;
+`syncWorkflowTriggers` under `pg_advisory_xact_lock(hashtext(companyId))`),
+`types.ts` (11L).
+
+**Runs UI** — `ui/Runs/`: `WorkflowRunsTable`, `WorkflowRunDetail`,
+`WorkflowRunSteps` (420L — topological order via `topologicalNodeOrder`,
+"Not reached" ghost rows, compacted banners), `ConditionDetail`,
+`RuntimeValueView`, `RunStatus`, `EntityRecordLink`, `runOutcome.ts`,
+`useNodeLabel.ts` (single naming authority), `RunLiveUpdates.tsx`
+(`useDebouncedRealtime`, 1.5s quiet, mounts only while non-terminal rows exist).
+
+**Test run**: play icon on trigger card → `TestRun/TestRunDialog.tsx` (page-level)
+→ `TestRun/TestRunPanel.tsx`. **No dry-run** — it runs for real and writes a real
+`workflowRun` row with `isTest = true`.
+
+**Autosave**: 1s debounce, baseline snapshot compare, toast on failure. **No undo**
+(deliberate, documented).
+
+---
+
+## 9. Known rough edges — candidate improvement backlog
+
+### Stale UI copy (highest-confidence bug)
+Test runs DO write real rows visible on the Runs page (`isTest=true` +
+`TestRunBadge`), but four strings say the opposite:
+- `ui/TestRun/TestRunPanel.tsx:108` — "Test runs are not saved. Close this panel and the result is gone."
+- `ui/TestRun/TestRunPanel.tsx:19` (comment) — "Nothing was written…"
+- `ui/TestRun/TestRunDialog.tsx:195` — "The result will not appear on the Runs page."
+- `ui/Builder/nodes/WorkflowNodeCard.tsx:169` — tooltip "results are not saved to the Runs page"
+
+### UX
+- **Native `window.confirm`** at `config/forms/ConditionForm.tsx:167` — the only
+ browser-native dialog in the feature; unstyled, untranslatable
+- **Trigger form is single-event, the data model is multi-event.**
+ `TriggerForm.tsx:413` writes `{ events: [id] }` and reads `events[0]`, but
+ `meta.ts:61` renders "N events" and `TestRunDialog.tsx:198` shows an event
+ chooser when `events.length > 1`. Opening the picker silently truncates
+- **No empty states.** Neither `WorkflowsTable` nor `WorkflowRunsTable` passes
+ the `emptyState` prop `Table` supports — new tenants see "No results found"
+- **Dead-end navigation.** No link from builder → that workflow's runs;
+ `path.to.workflowRuns` takes no workflow filter (you hand-build
+ `?filter=workflowId:eq:<id>`). No "see all runs" from the list either
+- **No on/off switch in the builder.** `WorkflowActiveSwitch` is only in
+ `WorkflowsTable.tsx:93` (its own docstring claims otherwise) — you must go back
+ to the list to arm a workflow you just published
+- `workflows+/_index.tsx` runs all three loader queries then throws them away
+ behind a client-side `usePlanGate`; every other route gates server-side
+- `WorkflowsTable` "Last Run" is `id:"lastRun"` with no accessor → can't sort or
+ filter despite `filterHeader` being set
+- Pagination inconsistency: runs table passes `withPagination`, workflows table
+ relies on the default
+
+### i18n
+- `runOutcome.ts` builds English sentences by concatenation, no `t`/`Trans` —
+ the most-read sentence on the run page is untranslatable
+- `WorkflowRunSteps.tsx:324` "Skipped — the check above didn't match" — same
+- `IssuesPanel.tsx:24` bare English `aria-label="Dismiss"`
+
+### a11y
+- `WorkflowRunSteps.tsx:169` disclosure button has no `aria-expanded`/`aria-controls`
+ (same for both Show-raw toggles)
+- `NodeCard.tsx:172` — collapsed cards drop port labels, handles stack on the
+ midline; **no keyboard path to create an edge at all** (React Flow drag only)
+- `NodePalette.tsx` draggable buttons, no keyboard drag (click-to-add mitigates)
+- `ConditionForm.tsx:300` — dnd-kit sortable ids are array indices
+ (`sortId={String(i)}`, `key={i}`), so reordering re-keys every row
+
+### Duplication
+- Inline rename implemented twice with the same `settled`-ref pattern:
+ `BuilderHeader.tsx:56` (`WorkflowTitle`) and `config/InlineNodeName.tsx:14`
+- Step-title rule exists twice: `Runs/useNodeLabel.ts:20` (hook) and
+ `Runs/runOutcome.ts:18` `stepTitle` (pure) — kept in sync by comment only
+- `ActionForm.tsx:454` hard-codes `<Trans>Notify</Trans>` as the label for
+ *every* `requireOneOf` group, keyed by index
+
+### Engine / correctness
+- **Entity-node batching silently drops failures** (`runtime/entity.ts:44-67`) —
+ one step, no per-item rows, no failed count, never marks the run Failed.
+ Actions do this properly; entity is a second weaker mechanism
+- **Scheduled runs skip the trigger-level permission check** —
+ `SCHEDULE_EVENT_ID = "schedule"` isn't a catalog event, so the gate at
+ `execute.ts:472` is a no-op. Per-node checks still apply
+- **A lost step claim always returns `Skipped`**, even when the existing row is
+ terminal — self-declared known divergence from the phase-4 spec
+- **Depth guard is best-effort across the 90-day retention boundary** — a chain
+ outliving its purged root restarts at depth 0
+- **No `concurrency` block on any workflow function** (removed deliberately in
+ `13f524c1d` because `limit: 0` means *zero capacity*, not unlimited —
+ `.ai/lessons.md:901`). Bounded only by account/plan concurrency
+- `packages/jobs/src/workflows/retention.ts:1` shadows the name `MAX_LIST_ITEMS`
+ with a local `5`, unrelated to the workflow cap of 100
+
+### Doc drift (rules/AGENTS files lying about the code)
+- `syncWorkflowSubscriptions` **does not exist** — named in
+ `packages/workflows/AGENTS.md:135,149` and `.claude/rules/workflow-matcher.md:132`
+- `src/runtime/template.ts` **does not exist** — listed in `AGENTS.md:115`;
+ `renderTemplate`/`renderValue` come from `resolve.ts`
+- "Three generated files" is now **four** (`help.generated.ts` undocumented, as is
+ `WORKFLOW_ENTITY_ENUMS`)
+- `AGENTS.md:146` omits the required 4th arg `lockCompany` on `syncWorkflowTriggers`
+- `packages/jobs/AGENTS.md:96` understates the real `SECRET_KEY` redaction regex
+- The workflows module `AGENTS.md` documents `updateWorkflowOwner`,
+ `deleteWorkflowVersion`, `$id.owner.tsx`, `ui/WorkflowLockAlert.tsx` — **none exist**
+- `.claude/rules/workflow-event-catalog.md:175` notes
+ `packages/jobs/.../tasks/post-transaction.ts` is dead code
+
+---
+
+## 10. Explicitly deferred (from the specs — don't "fix" these by accident)
+
+- **Replay / retry of a run** — blocked on what `sourceEventId` a replay carries
+ (everything keys on it). Zapier/Make precedent already analyzed
+- **Canvas overlay of a past run** — planned as a later addition on the same loader
+- **Per-company retention settings** — tiers are hardcoded constants
+- **Run quotas / plan gates** — out of scope per `technical-decisions.md`
+- **Nested condition groups** — the stored shape is permanently one combinator
+ per path over a flat clause list
+- **An expression language** — structured references only, by decision
+- **Undo** — a recorded phase-7 decision
+- **All-or-nothing action groups** — PRD defers to v2
+- **A general action surface over all ~1,400 service functions** — the catalog is
+ hand-curated and editorial, by decision
+- **Fixing the two pre-existing webhook systems** (no signing, no URL
+ restriction) — recorded as debt
+- No new node kinds; no "Duplicate node" action (considered, cut)
+
+---
+
+## 11. Specs, plans, history
+
+**11 specs, all in `.ai/specs/implemented/`** — 9 phases + 2 UX rounds:
+foundation, event-catalog, matcher, engine, catalogs, scheduling,
+builder-canvas, node-configuration, run-history, builder-ux-overhaul,
+workflow-variable-ux. Matching plans 1:1 in `.ai/plans/`, plus
+`2026-08-03-workflow-builder-round-6.md`, `2026-08-04-workflow-field-help.md`,
+`2026-08-07-variable-picker-descriptions.md`.
+
+⚠️ **The original PRD and technical-decisions doc live OUTSIDE this repo** at
+`/Users/aashu/work/carbon/plans/automations-engine/`.
+
+⚠️ `.ai/plans/automation/pending-changes.md` is a 7-item list that reads like a
+TODO but **every item appears already shipped**. Historical, not a backlog.
+
+**Git**: built on `feat/automation` over ~10 days (2026-08-02 → 08-10), squashed
+into **`58e2de238` "feat: automation workflows (#1294)"** — 424 files,
++95,805/−2,638. Followed same-day by **`13f524c1d` "Fix/workflow fixes (#1367)"**
+(drops the broken concurrency caps). **Nothing workflow-related has landed since.**
+
+One stray commit off this line: `faba64b6c` (test: validate every dataset's seed
+workflows) lives only on `feat/onboarding-templates` — will conflict if we touch
+`packages/workflows/src/seed-workflows.test.ts`.
+
+**`.ai/lessons.md` lines ~573-790 and ~901** are the densest lesson cluster in
+the file — 12+ workflow-derived lessons. Read before non-trivial changes.
+
+---
+
+## 12. Tests — 60 files (one of the best-tested subsystems here)
+
+- `packages/workflows/` (28) — `definition/` (10), `runtime/` (12),
+ `catalog/` (2), `seed-workflows.test.ts`, `sync.test.ts`
+- `packages/jobs/src/workflows/` (23) — `matcher`, `event-ids`, `scheduler`,
+ `retention`; `engine/` (7, incl. `end-to-end.test.ts`); `actions/` (9, incl.
+ `url-guard.test.ts` for SSRF/DNS-rebinding); + the retention cron test
+- `apps/erp/app/modules/workflows/ui/` (14) — deliberately tests **pure extracted
+ logic**, not components: `Builder/{store,graph,layout,ports,labelKeys}`,
+ `nodes/meta`, `fields/{variableMenu,menuNav,menuBridge,tokenId,valueParts,pairsRows}`,
+ `Runs/{runOutcome,entityRefs}`
+
+**Gap: no Playwright/e2e.** The matcher spec still reads "pending e2e sign-off";
+the variable-UX spec says "browser pass still outstanding".
+
+---
+
+## 13. Where things live — quick index
+
+```
+packages/workflows/src/ pure contract: definition, catalog, runtime
+packages/jobs/src/workflows/ matcher, scheduler, retention, engine/, actions/
+packages/jobs/src/inngest/functions/workflows/ run, moment, scheduler
+packages/jobs/src/inngest/functions/events/workflow.ts
+packages/jobs/src/inngest/functions/scheduled/workflow-run-retention.ts
+apps/erp/app/modules/workflows/ models, service, server, ui/{Builder,Runs,TestRun}
+apps/erp/app/routes/x+/workflows+/ list + runs (sidebar)
+apps/erp/app/routes/x+/workflow+/ builder (full screen)
+packages/database/supabase/migrations/20260810100*.sql
+scripts/generate-workflow-catalog.ts, scripts/check-workflow-catalog.ts
+docs/content/docs/reference/{workflows,workflow-runs}.mdx
+.claude/rules/workflow-{engine,matcher,actions,event-catalog,run-history,event-system}.md
+.ai/specs/implemented/2026-07-30..2026-08-03-workflow*.md
+```
+
+**Validation for this area:**
+```bash
+pnpm exec turbo run typecheck --filter=@carbon/workflows --filter=@carbon/jobs --filter=erp
+pnpm exec biome check
+npx vitest run # from the relevant package
+npx tsx scripts/check-workflow-catalog.ts # after touching catalog inputs
+```
diff --git a/.claude/rules/workflow-engine.md b/.claude/rules/workflow-engine.md
index e5ddba0903..4402b722d2 100644
--- a/.claude/rules/workflow-engine.md
+++ b/.claude/rules/workflow-engine.md
@@ -21,7 +21,7 @@ packages/workflows/src/runtime/ pure. no I/O, no client, no database.
values.ts RuntimeValue + fromColumn coercion
resolve.ts {kind:"ref"|"item"|"literal"|"template"} -> a value, or a reason
compare.ts operator semantics + evaluateClauses
- condition.ts filter.ts entity.ts lookup.ts action.ts the five executors
+ condition.ts filter.ts compute.ts lookup.ts action.ts the five executors
executors.ts the node-kind -> executor registry
batch.ts planBatch + itemKeyFor
diff --git a/apps/erp/app/modules/agent/kb/docs/reference/workflows.md b/apps/erp/app/modules/agent/kb/docs/reference/workflows.md
index 4b698ec6c0..5428a9334a 100644
--- a/apps/erp/app/modules/agent/kb/docs/reference/workflows.md
+++ b/apps/erp/app/modules/agent/kb/docs/reference/workflows.md
@@ -51,11 +51,13 @@ Six kinds, in palette order.
| **Trigger** | Starts the workflow. One per workflow, and nothing can connect into it. |
| **Condition** | Sends the run down one path. Each path is a set of clauses, with an optional **"Otherwise"**. |
| **Action** | Does the work — notifies, creates, updates, or calls out. Has separate **Success** and **Failure** handles. |
-| **Record** | Works out a number from a record, such as an order total or a scrap percentage. |
+| **Compute** | Works out a number from a record, such as an order total or a scrap percentage. |
| **Find** | Looks a record up so later steps can use it. |
| **Filter** | Keeps only the items in a list that match your rules. |
-Despite the name, a **Record** step is read-only: its picker is titled **"Operation"** and it computes a value, such as a purchase order's total, a sales order's line count, a job's scrap percentage or earliest operation start, or an item's quantity on hand. Everything that *writes* is an **Action** step.
+A **Compute** step is read-only. Its picker is titled **"Operation"**, and it works out a value such as a purchase order's total, a sales order's line count, a job's scrap percentage or earliest operation start, or an item's quantity on hand. Everything that *writes* is an **Action** step.
+
+Workflows you built before the rename are unaffected — they open as **Compute** steps and keep whatever step names you gave them.
**Actions** come in three families. Four create records — a job, an issue, a purchase order, or a sales order — and each runs through the same service Carbon's own screens use, so sequences, defaults, and required fields behave identically. Ten update an existing record, one per watched record type. The last two are **"Notify someone"** and **"Call an outside URL"**.
diff --git a/apps/erp/app/modules/workflows/AGENTS.md b/apps/erp/app/modules/workflows/AGENTS.md
index 1991e82c1d..235e2a31f2 100644
--- a/apps/erp/app/modules/workflows/AGENTS.md
+++ b/apps/erp/app/modules/workflows/AGENTS.md
@@ -1,6 +1,6 @@
# Workflows Module
-Customer-authored automation. A workflow is a graph of nodes (trigger, condition, entity, lookup, filter, action) stored as a versioned definition; the engine in `packages/jobs` walks it. This module is the ERP front end: the list page, the full-screen builder canvas, versioning and publishing.
+Customer-authored automation. A workflow is a graph of nodes (trigger, condition, compute, lookup, filter, action) stored as a versioned definition; the engine in `packages/jobs` walks it. This module is the ERP front end: the list page, the full-screen builder canvas, versioning and publishing.
The definition schema, validator, catalogs, matcher and engine all live outside this module in `packages/workflows` and `packages/jobs`. Read `packages/workflows/AGENTS.md` before touching anything that imports `@carbon/workflows`.
diff --git a/apps/erp/app/modules/workflows/ui/Builder/NodeCard.tsx b/apps/erp/app/modules/workflows/ui/Builder/NodeCard.tsx
index f7f173aa71..e895c2d7c8 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/NodeCard.tsx
+++ b/apps/erp/app/modules/workflows/ui/Builder/NodeCard.tsx
@@ -1,6 +1,6 @@
import { cn } from "@carbon/react";
import { Handle, Position, useUpdateNodeInternals } from "@xyflow/react";
-import type { ReactNode } from "react";
+import type { KeyboardEvent, ReactNode } from "react";
import { useEffect, useRef } from "react";
import { LuTriangleAlert } from "react-icons/lu";
import { HANDLE_CLASS } from "./handles";
@@ -21,6 +21,26 @@ const BODY_TYPE = [
const INTERACTIVE =
"input,textarea,select,button,a,[role=button],[role=combobox],[contenteditable=true]";
+// The keys React Flow acts on itself: Delete removes the node, the arrows nudge it,
+// Enter and Space select it.
+const CANVAS_KEYS = new Set([
+ "Delete",
+ "Backspace",
+ "ArrowUp",
+ "ArrowDown",
+ "ArrowLeft",
+ "ArrowRight",
+ "Enter",
+ " "
+]);
+
+/** Bubble phase, so the field or dropdown that owns the key has already had it —
+ * stopping in capture swallowed every dropdown's arrow keys. Escape passes through:
+ * Radix closes an overlay from a listener on the document. */
+export function stopCanvasKeys(event: KeyboardEvent) {
+ if (CANVAS_KEYS.has(event.key)) event.stopPropagation();
+}
+
// Body drags, controls don't. Toggles `nodrag` in the capture phase, which beats
// React Flow's listener; stopPropagation here would wedge every Radix dropdown open.
function useBodyDragFilter() {
@@ -148,7 +168,11 @@ export function NodeCard({
{/* Never clip: the condition form draws its own handles, and they straddle the
card's right border. Every control inside is `min-w-0` instead. */}
{isExpanded && children && (
- <div ref={bodyRef} className={cn("border-t px-2.5 py-2", BODY_TYPE)}>
+ <div
+ ref={bodyRef}
+ className={cn("border-t px-2.5 py-2", BODY_TYPE)}
+ onKeyDown={stopCanvasKeys}
+ >
{children}
</div>
)}
diff --git a/apps/erp/app/modules/workflows/ui/Builder/WorkflowBuilder.tsx b/apps/erp/app/modules/workflows/ui/Builder/WorkflowBuilder.tsx
index 6ea8ace5f6..53843fd6d6 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/WorkflowBuilder.tsx
+++ b/apps/erp/app/modules/workflows/ui/Builder/WorkflowBuilder.tsx
@@ -20,6 +20,7 @@ import { NODE_DRAG_TYPE } from "./constants";
import { useBuilderStore, useBuilderStoreApi } from "./context";
import { edgeTypes } from "./edges/WorkflowEdge";
import { canConnect } from "./graph";
+import { stopCanvasKeys } from "./NodeCard";
import { NodePalette } from "./NodePalette";
import { nodeTypes } from "./nodes";
import { TestRunPanel } from "./TestRun/TestRunPanel";
@@ -93,15 +94,16 @@ export function WorkflowBuilder({
);
// A field with focus owns its keys; the canvas must not steal Delete/arrows.
- const onKeyDownCapture = useCallback((event: KeyboardEvent) => {
+ // Node cards stop these at their own body — this is the backstop for anything
+ // else in the canvas, and it leaves a bare pane's Delete alone.
+ const onKeyDown = useCallback((event: KeyboardEvent) => {
const target = event.target as HTMLElement | null;
if (!target) return;
- if (target.closest(OVERLAY_SELECTOR)) {
- event.stopPropagation();
- return;
- }
- if (target.closest("input,textarea,select,[contenteditable=true]")) {
- event.stopPropagation();
+ if (
+ target.closest(OVERLAY_SELECTOR) ||
+ target.closest("input,textarea,select,[contenteditable=true]")
+ ) {
+ stopCanvasKeys(event);
}
}, []);
@@ -126,7 +128,7 @@ export function WorkflowBuilder({
<ResizablePanel id="canvas" order={2} defaultSize={62} minSize={30}>
<div
className="relative h-full"
- onKeyDownCapture={onKeyDownCapture}
+ onKeyDown={onKeyDown}
onDrop={onDrop}
onDragOver={(event) => {
event.preventDefault();
diff --git a/apps/erp/app/modules/workflows/ui/Builder/config/forms/EntityForm.tsx b/apps/erp/app/modules/workflows/ui/Builder/config/forms/ComputeForm.tsx
similarity index 95%
rename from apps/erp/app/modules/workflows/ui/Builder/config/forms/EntityForm.tsx
rename to apps/erp/app/modules/workflows/ui/Builder/config/forms/ComputeForm.tsx
index cabb2aa0ac..163cc27d22 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/config/forms/EntityForm.tsx
+++ b/apps/erp/app/modules/workflows/ui/Builder/config/forms/ComputeForm.tsx
@@ -26,7 +26,7 @@ import {
import { useBuilderStore } from "../../context";
import { ValueField } from "../../fields/ValueField";
import { issueForField, partIssuesForField } from "../../issues";
-import { useEntityBatchInput } from "../../useDefinition";
+import { useComputeBatchInput } from "../../useDefinition";
import { FormStack, Section } from "../layout";
import type { NodeFormProps } from "./index";
@@ -115,16 +115,16 @@ function OperationPicker({ selected, onSelect, label }: OperationPickerProps) {
);
}
-// ── EntityForm ────────────────────────────────────────────────────────────────
+// ── ComputeForm ───────────────────────────────────────────────────────────────
-export function EntityForm({ node, issues }: NodeFormProps<"entity">) {
+export function ComputeForm({ node, issues }: NodeFormProps<"compute">) {
const updateNodeData = useBuilderStore((s) => s.updateNodeData);
const label = useWorkflowLabel();
const { operation: operationId, inputs } = node.data;
const opDef = operationId ? catalog.getOperation(operationId) : undefined;
- const batchInput = useEntityBatchInput(node.id, operationId, inputs);
+ const batchInput = useComputeBatchInput(node.id, operationId, inputs);
// Inputs ordered required-first, then optional (preserving catalog order within each)
const orderedInputNames = useMemo(() => {
diff --git a/apps/erp/app/modules/workflows/ui/Builder/config/forms/TriggerForm.tsx b/apps/erp/app/modules/workflows/ui/Builder/config/forms/TriggerForm.tsx
index de82673b8d..026d1a5ae1 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/config/forms/TriggerForm.tsx
+++ b/apps/erp/app/modules/workflows/ui/Builder/config/forms/TriggerForm.tsx
@@ -136,7 +136,9 @@ function EventPicker({
{ids.map((id) => (
<CommandItem
key={id}
- value={id}
+ // Search runs on `value`, so the visible label has to be in it —
+ // the id alone is never what someone types, and never translated.
+ value={`${id} ${label(id)}`}
onSelect={() => {
onSelect(id);
setOpen(false);
@@ -158,7 +160,7 @@ function EventPicker({
{momentIds.map((id) => (
<CommandItem
key={id}
- value={id}
+ value={`${id} ${label(id)}`}
onSelect={() => {
onSelect(id);
setOpen(false);
@@ -473,7 +475,14 @@ export function TriggerForm({ node }: NodeFormProps<"trigger">) {
{/* Origin selector */}
<div className="space-y-2">
- <Section>
+ <Section
+ hint={
+ <Trans>
+ Everything else covers people, imports, integrations and the
+ API — anything that is not one of your workflows.
+ </Trans>
+ }
+ >
<Trans>Triggered by</Trans>
</Section>
<ToggleGroup
@@ -503,12 +512,6 @@ export function TriggerForm({ node }: NodeFormProps<"trigger">) {
<Trans>Both</Trans>
</ToggleGroupItem>
</ToggleGroup>
- <p className="text-xs text-muted-foreground">
- <Trans>
- Everything else covers people, imports, integrations and the API
- — anything that is not one of your workflows.
- </Trans>
- </p>
</div>
</>
) : (
diff --git a/apps/erp/app/modules/workflows/ui/Builder/config/forms/index.ts b/apps/erp/app/modules/workflows/ui/Builder/config/forms/index.ts
index 0ef9732867..b849eb4ccf 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/config/forms/index.ts
+++ b/apps/erp/app/modules/workflows/ui/Builder/config/forms/index.ts
@@ -6,8 +6,8 @@ import type {
import type { ComponentType } from "react";
import type { BuilderNode } from "../../../../types";
import { ActionForm } from "./ActionForm";
+import { ComputeForm } from "./ComputeForm";
import { ConditionForm } from "./ConditionForm";
-import { EntityForm } from "./EntityForm";
import { FilterForm } from "./FilterForm";
import { LookupForm } from "./LookupForm";
import { TriggerForm } from "./TriggerForm";
@@ -29,7 +29,7 @@ export const NODE_FORMS: {
} = {
trigger: TriggerForm,
condition: ConditionForm,
- entity: EntityForm,
+ compute: ComputeForm,
lookup: LookupForm,
filter: FilterForm,
action: ActionForm
diff --git a/apps/erp/app/modules/workflows/ui/Builder/config/layout.tsx b/apps/erp/app/modules/workflows/ui/Builder/config/layout.tsx
index 520b1dadc8..c18b09c5be 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/config/layout.tsx
+++ b/apps/erp/app/modules/workflows/ui/Builder/config/layout.tsx
@@ -1,5 +1,12 @@
-import { cn } from "@carbon/react";
+import {
+ cn,
+ HoverCard,
+ HoverCardContent,
+ HoverCardTrigger
+} from "@carbon/react";
+import { useLingui } from "@lingui/react/macro";
import type { ReactNode } from "react";
+import { LuInfo } from "react-icons/lu";
const GAP: Record<number, string> = {
3: "gap-3",
@@ -20,10 +27,43 @@ export function FormStack({
);
}
-export function Section({ children }: { children: ReactNode }) {
+export function Section({
+ children,
+ hint
+}: {
+ children: ReactNode;
+ /** Explains the setting on hover, so the form stays a column of controls. */
+ hint?: ReactNode;
+}) {
+ const { t } = useLingui();
return (
- <div className="text-[11px] font-semibold text-muted-foreground">
- {children}
+ <div className="flex items-center gap-1 text-[11px] font-semibold text-muted-foreground">
+ <span>{children}</span>
+ {hint && (
+ <>
+ <HoverCard openDelay={200} closeDelay={100}>
+ <HoverCardTrigger asChild>
+ <button
+ type="button"
+ tabIndex={-1}
+ aria-label={t`More information`}
+ className="inline-flex size-4 items-center justify-center rounded-full transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ <LuInfo className="size-3" aria-hidden />
+ </button>
+ </HoverCardTrigger>
+ <HoverCardContent
+ side="top"
+ align="start"
+ className="w-auto max-w-xs p-3 text-xs font-normal leading-relaxed text-pretty text-muted-foreground"
+ >
+ {hint}
+ </HoverCardContent>
+ </HoverCard>
+ {/* The popup is pointer-only; a reader gets the same sentence inline. */}
+ <span className="sr-only">{hint}</span>
+ </>
+ )}
</div>
);
}
diff --git a/apps/erp/app/modules/workflows/ui/Builder/edges/WorkflowEdge.tsx b/apps/erp/app/modules/workflows/ui/Builder/edges/WorkflowEdge.tsx
index 9723abb297..45a6743694 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/edges/WorkflowEdge.tsx
+++ b/apps/erp/app/modules/workflows/ui/Builder/edges/WorkflowEdge.tsx
@@ -62,9 +62,11 @@ function WorkflowEdgeImpl({
/>
{!isReadOnly && (
<EdgeLabelRenderer>
- {/* The renderer's container is pointer-events:none, so the button opts back in. */}
+ {/* The renderer's container is pointer-events:none, so the button opts back in.
+ z above 1000, the z-index React Flow gives a selected node — otherwise a
+ node's port label paints over this button. */}
<div
- className="nodrag nopan pointer-events-auto absolute"
+ className="nodrag nopan pointer-events-auto absolute z-[1001]"
style={{
transform: `translate(-50%, -60%) translate(${labelX}px, ${labelY}px)`
}}
@@ -79,8 +81,10 @@ function WorkflowEdgeImpl({
// Opaque, because the edge runs underneath. `after:` widens the hit
// box without growing the dot on the canvas.
className={cn(
- "!bg-card after:absolute after:-inset-2 after:content-['']",
- armed && "border-destructive text-destructive"
+ "!bg-card hover:!bg-card after:absolute after:-inset-2 after:content-['']",
+ // The cursor is still on the button after the first click, so the
+ // hover color has to go red too or the armed state never shows.
+ armed && "text-destructive hover:text-destructive"
)}
onClick={(e) => {
e.stopPropagation();
diff --git a/apps/erp/app/modules/workflows/ui/Builder/fields/recordPickers.tsx b/apps/erp/app/modules/workflows/ui/Builder/fields/recordPickers.tsx
index 7fd4281103..f320d557f9 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/fields/recordPickers.tsx
+++ b/apps/erp/app/modules/workflows/ui/Builder/fields/recordPickers.tsx
@@ -1,4 +1,4 @@
-import { CreatableCombobox } from "@carbon/react";
+import { Combobox } from "@carbon/react";
import type { ComponentType } from "react";
import { useMemo } from "react";
import { Enumerable } from "~/components/Enumerable";
@@ -8,6 +8,8 @@ import { UserSelect } from "~/components/Selectors";
import type { IndividualOrGroup } from "~/components/Selectors/UserSelect/types";
import { useCustomers, useItems, useSuppliers } from "~/stores";
+// Plain Combobox, never CreatableCombobox: a workflow picks an existing record,
+// so a "Create <whatever you typed>" row would be an offer we cannot honor.
export type RecordPickerProps = {
value: string | undefined;
onChange: (id: string | undefined) => void;
@@ -23,7 +25,7 @@ const CustomerPicker = ({ value, onChange, isDisabled }: RecordPickerProps) => {
[customers]
);
return (
- <CreatableCombobox
+ <Combobox
options={options}
value={value}
isClearable
@@ -43,7 +45,7 @@ const SupplierPicker = ({ value, onChange, isDisabled }: RecordPickerProps) => {
[suppliers]
);
return (
- <CreatableCombobox
+ <Combobox
options={options}
value={value}
isClearable
@@ -70,7 +72,7 @@ const ItemPicker = ({ value, onChange, isDisabled }: RecordPickerProps) => {
[items]
);
return (
- <CreatableCombobox
+ <Combobox
options={options}
value={value}
isClearable
@@ -86,7 +88,7 @@ const ItemPicker = ({ value, onChange, isDisabled }: RecordPickerProps) => {
const LocationPicker = ({ value, onChange, isDisabled }: RecordPickerProps) => {
const locations = useLocations();
return (
- <CreatableCombobox
+ <Combobox
options={locations}
value={value}
isClearable
@@ -106,7 +108,7 @@ const IssueTypePicker = ({
}: RecordPickerProps) => {
const options = useIssueTypes();
return (
- <CreatableCombobox
+ <Combobox
options={options.map((o) => ({
value: o.value,
label: <Enumerable value={o.label} />
diff --git a/apps/erp/app/modules/workflows/ui/Builder/graph.ts b/apps/erp/app/modules/workflows/ui/Builder/graph.ts
index c1f78c65cd..aa57454ccb 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/graph.ts
+++ b/apps/erp/app/modules/workflows/ui/Builder/graph.ts
@@ -175,7 +175,7 @@ export function createNode(
]
}
};
- case "entity":
+ case "compute":
return {
id,
name,
diff --git a/apps/erp/app/modules/workflows/ui/Builder/labelKeys.test.ts b/apps/erp/app/modules/workflows/ui/Builder/labelKeys.test.ts
index c70b7ec1ea..d02e6f589d 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/labelKeys.test.ts
+++ b/apps/erp/app/modules/workflows/ui/Builder/labelKeys.test.ts
@@ -88,6 +88,8 @@ describe("isDefaultNodeName", () => {
"trigger",
"action",
"condition",
+ "compute",
+ // The old spelling of `compute`. Saved workflows still carry these names.
"entity",
"lookup",
"filter"
diff --git a/apps/erp/app/modules/workflows/ui/Builder/labelKeys.ts b/apps/erp/app/modules/workflows/ui/Builder/labelKeys.ts
index fea4f781ae..f1ef064f2a 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/labelKeys.ts
+++ b/apps/erp/app/modules/workflows/ui/Builder/labelKeys.ts
@@ -99,9 +99,12 @@ export function describeValueType(
}
/** Matches the auto-generated names `nextNodeName` hands out (`action_0`, `trigger_1`).
- * A name the user never changed carries no meaning, so callers fall back instead. */
+ * A name the user never changed carries no meaning, so callers fall back instead.
+ * `entity` is the old spelling of `compute` and stays here forever: a node's name is an
+ * identifier other nodes reference, so the rename left already-saved `entity_0` names
+ * alone. Drop it and every one of them starts rendering as "Entity 0". */
const DEFAULT_NODE_NAME =
- /^(trigger|action|condition|entity|lookup|filter)_\d+$/;
+ /^(trigger|action|condition|compute|entity|lookup|filter)_\d+$/;
export function isDefaultNodeName(name: string): boolean {
return DEFAULT_NODE_NAME.test(name);
diff --git a/apps/erp/app/modules/workflows/ui/Builder/nodes/index.ts b/apps/erp/app/modules/workflows/ui/Builder/nodes/index.ts
index 17fc322b58..d495b48068 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/nodes/index.ts
+++ b/apps/erp/app/modules/workflows/ui/Builder/nodes/index.ts
@@ -8,7 +8,7 @@ import { WorkflowNodeCard } from "./WorkflowNodeCard";
export const nodeTypes: Record<WorkflowNodeType, ComponentType<NodeProps>> = {
trigger: WorkflowNodeCard,
condition: WorkflowNodeCard,
- entity: WorkflowNodeCard,
+ compute: WorkflowNodeCard,
lookup: WorkflowNodeCard,
filter: WorkflowNodeCard,
action: WorkflowNodeCard
diff --git a/apps/erp/app/modules/workflows/ui/Builder/nodes/kinds.ts b/apps/erp/app/modules/workflows/ui/Builder/nodes/kinds.ts
index 5ffb7c094c..968ec44e18 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/nodes/kinds.ts
+++ b/apps/erp/app/modules/workflows/ui/Builder/nodes/kinds.ts
@@ -9,7 +9,7 @@ export const NODE_CARD_WIDTH: Record<WorkflowNodeType, number> = {
trigger: 360,
condition: 612,
action: 420,
- entity: 420,
+ compute: 420,
lookup: 500,
filter: 500
};
@@ -23,7 +23,7 @@ export const NODE_CARD_HEIGHT: Record<WorkflowNodeType, number> = {
trigger: 180,
condition: 320,
action: 260,
- entity: 260,
+ compute: 260,
lookup: 280,
filter: 280
};
@@ -38,7 +38,7 @@ export const NODE_ACCEPTS_INCOMING: Record<WorkflowNodeType, boolean> = {
trigger: false,
condition: true,
action: true,
- entity: true,
+ compute: true,
lookup: true,
filter: true
};
diff --git a/apps/erp/app/modules/workflows/ui/Builder/nodes/meta.ts b/apps/erp/app/modules/workflows/ui/Builder/nodes/meta.ts
index a025df4b44..a22bc62005 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/nodes/meta.ts
+++ b/apps/erp/app/modules/workflows/ui/Builder/nodes/meta.ts
@@ -3,8 +3,8 @@ import type { WorkflowNode, WorkflowNodeType } from "@carbon/workflows";
import { WORKFLOW_LABELS } from "@carbon/workflows/labels";
import type { IconType } from "react-icons";
import {
+ LuCalculator,
LuFilter,
- LuPencilRuler,
LuPlay,
LuSearch,
LuSplit,
@@ -101,16 +101,16 @@ export const NODE_KIND_META: Record<WorkflowNodeType, NodeKindMeta> = {
return labelText(node.data.action) ?? node.data.action;
}
},
- entity: {
- name: "Record",
- Icon: LuPencilRuler,
- description: "Writes to a record in Carbon",
- defaultTitle: "Create or update a record",
- hasTarget: NODE_ACCEPTS_INCOMING.entity,
+ compute: {
+ name: "Compute",
+ Icon: LuCalculator,
+ description: "Works out a value from a record",
+ defaultTitle: "Compute a value",
+ hasTarget: NODE_ACCEPTS_INCOMING.compute,
catalogId: (node) =>
- node.type === "entity" ? node.data.operation || undefined : undefined,
+ node.type === "compute" ? node.data.operation || undefined : undefined,
summary: (node) => {
- if (node.type !== "entity" || !node.data.operation) return undefined;
+ if (node.type !== "compute" || !node.data.operation) return undefined;
return labelText(node.data.operation) ?? node.data.operation;
}
},
@@ -155,7 +155,21 @@ export const NODE_KIND_ORDER: WorkflowNodeType[] = [
"trigger",
"condition",
"action",
- "entity",
+ "compute",
"lookup",
"filter"
];
+
+/** What a node type saved before a rename used to be called. A stored definition is
+ * migrated on read, but `workflowStepRun.nodeType` is a plain column: a run from before
+ * the rename keeps the old string forever, and without this its step row would show the
+ * raw word "entity" where every other row shows a kind. */
+const LEGACY_NODE_TYPES: Record<string, WorkflowNodeType> = {
+ entity: "compute"
+};
+
+/** The presentation for a node type read back from the database, old spellings included. */
+export function metaForNodeType(type: string): NodeKindMeta | undefined {
+ const current = LEGACY_NODE_TYPES[type] ?? (type as WorkflowNodeType);
+ return NODE_KIND_META[current];
+}
diff --git a/apps/erp/app/modules/workflows/ui/Builder/useDefinition.ts b/apps/erp/app/modules/workflows/ui/Builder/useDefinition.ts
index d37440286a..9370a96179 100644
--- a/apps/erp/app/modules/workflows/ui/Builder/useDefinition.ts
+++ b/apps/erp/app/modules/workflows/ui/Builder/useDefinition.ts
@@ -100,9 +100,9 @@ export function useActionBatchPlan(
}, [actionId, inputs, typeOf]);
}
-/** The name of the entity operation input that is wired to a list, or undefined when
+/** The name of the compute operation input that is wired to a list, or undefined when
* the node runs once. The form uses this to show the batch note. */
-export function useEntityBatchInput(
+export function useComputeBatchInput(
nodeId: string,
operationId: string,
inputs: Record<string, ValueOrRef>
diff --git a/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunSteps.tsx b/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunSteps.tsx
index 829eb29035..9cfa63f5cf 100644
--- a/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunSteps.tsx
+++ b/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunSteps.tsx
@@ -10,7 +10,11 @@ import {
operationInputLabelKey,
outputLabel
} from "../Builder/labelKeys";
-import { humanizeField, NODE_KIND_META } from "../Builder/nodes/meta";
+import {
+ humanizeField,
+ metaForNodeType,
+ NODE_KIND_META
+} from "../Builder/nodes/meta";
import { ConditionDetail } from "./ConditionDetail";
import { StepStatus } from "./RunStatus";
import { ValueMap } from "./RuntimeValueView";
@@ -94,7 +98,7 @@ function stepInputView(input: unknown): { value: unknown; resolved: boolean } {
return { value: input, resolved: false };
}
-/** An action or record step names its inputs in the catalog ("Title", "Assignee");
+/** An action or compute step names its inputs in the catalog ("Title", "Assignee");
* every other kind has no catalog entry, so its keys keep the humanised form. */
function inputLabelResolver(
node: WorkflowNode | undefined,
@@ -107,7 +111,7 @@ function inputLabelResolver(
return (key) =>
label(actionInputLabelKey(catalogId, key), humanizeField(key));
}
- if (node.type === "entity") {
+ if (node.type === "compute") {
return (key) =>
label(operationInputLabelKey(catalogId, key), humanizeField(key));
}
@@ -283,7 +287,7 @@ function stepRowFromType(
step: RunStepView,
recordNames: Record<string, string>
) {
- const meta = NODE_KIND_META[step.nodeType as keyof typeof NODE_KIND_META];
+ const meta = metaForNodeType(step.nodeType);
const Icon = meta?.Icon;
return (
<StepRow
diff --git a/apps/erp/app/modules/workflows/ui/Runs/runOutcome.ts b/apps/erp/app/modules/workflows/ui/Runs/runOutcome.ts
index 77a4537898..bb8b9654d1 100644
--- a/apps/erp/app/modules/workflows/ui/Runs/runOutcome.ts
+++ b/apps/erp/app/modules/workflows/ui/Runs/runOutcome.ts
@@ -2,7 +2,7 @@ import type { WorkflowDefinition } from "@carbon/workflows";
import type { WorkflowRunDetail } from "../../workflows.service";
import type { LabelFor } from "../Builder/labelKeys";
import { nodeTitle } from "../Builder/labelKeys";
-import { NODE_KIND_META } from "../Builder/nodes/meta";
+import { metaForNodeType, NODE_KIND_META } from "../Builder/nodes/meta";
import type { RunStepView } from "./WorkflowRunSteps";
export type RunOutcome = {
@@ -22,10 +22,7 @@ function stepTitle(
): string {
const node = definition?.nodes.find((n) => n.id === step.nodeId);
if (!node) {
- return (
- NODE_KIND_META[step.nodeType as keyof typeof NODE_KIND_META]
- ?.defaultTitle ?? step.nodeType
- );
+ return metaForNodeType(step.nodeType)?.defaultTitle ?? step.nodeType;
}
const meta = NODE_KIND_META[node.type];
const catalogId = meta.catalogId?.(node);
diff --git a/apps/erp/app/modules/workflows/ui/Runs/useNodeLabel.ts b/apps/erp/app/modules/workflows/ui/Runs/useNodeLabel.ts
index d61def19f6..1cb36e3208 100644
--- a/apps/erp/app/modules/workflows/ui/Runs/useNodeLabel.ts
+++ b/apps/erp/app/modules/workflows/ui/Runs/useNodeLabel.ts
@@ -8,7 +8,7 @@ export type NodeLabel = {
title: string;
/** What the step does, shown under the title. Empty when it repeats the title. */
subtitle: string;
- /** The kind chip: Trigger / Record / Condition / Action / Find / Filter. */
+ /** The kind chip: Trigger / Compute / Condition / Action / Find / Filter. */
kind: string;
};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
index b31bc43a57..126ed94225 100644
--- a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
@@ -1,5 +1,5 @@
{
- "generated": "2026-08-18T03:22:37.309Z",
+ "generated": "2026-08-18T07:59:22.902Z",
"totalTools": 1443,
"modules": 15,
"tools": [
diff --git a/docs/content/docs/reference/workflows.mdx b/docs/content/docs/reference/workflows.mdx
index d2d1753ece..5481388a02 100644
--- a/docs/content/docs/reference/workflows.mdx
+++ b/docs/content/docs/reference/workflows.mdx
@@ -57,12 +57,14 @@ Six kinds, in palette order.
| **Trigger** | Starts the workflow. One per workflow, and nothing can connect into it. |
| **Condition** | Sends the run down one path. Each path is a set of clauses, with an optional **"Otherwise"**. |
| **Action** | Does the work — notifies, creates, updates, or calls out. Has separate **Success** and **Failure** handles. |
-| **Record** | Works out a number from a record, such as an order total or a scrap percentage. |
+| **Compute** | Works out a number from a record, such as an order total or a scrap percentage. |
| **Find** | Looks a record up so later steps can use it. |
| **Filter** | Keeps only the items in a list that match your rules. |
-<Callout type="warn" title="The Record step doesn’t write anything">
-Despite the name, a **Record** step is read-only: its picker is titled **"Operation"** and it computes a value, such as a purchase order's total, a sales order's line count, a job's scrap percentage or earliest operation start, or an item's quantity on hand. Everything that *writes* is an **Action** step.
+A **Compute** step is read-only. Its picker is titled **"Operation"**, and it works out a value such as a purchase order's total, a sales order's line count, a job's scrap percentage or earliest operation start, or an item's quantity on hand. Everything that *writes* is an **Action** step.
+
+<Callout type="note" title="Compute was called “Record”">
+Workflows you built before the rename are unaffected — they open as **Compute** steps and keep whatever step names you gave them.
</Callout>
**Actions** come in three families. Four create records — a job, an issue, a purchase order, or a sales order — and each runs through the same service Carbon's own screens use, so sequences, defaults, and required fields behave identically. Ten update an existing record, one per watched record type. The last two are **"Notify someone"** and **"Call an outside URL"**.
diff --git a/packages/database/src/seed-dev/tiers/04-sales.ts b/packages/database/src/seed-dev/tiers/04-sales.ts
index bf23c2b0a0..1def934c46 100644
--- a/packages/database/src/seed-dev/tiers/04-sales.ts
+++ b/packages/database/src/seed-dev/tiers/04-sales.ts
@@ -351,6 +351,11 @@ export async function runTier4(ctx: Ctx): Promise<void> {
// The external link is what /share/quote/:id resolves against. It has to be
// created after the quote (it stores the quote's id) and pointed back at it,
// which is the same two-step upsertExternalLink does when a quote is created.
+ // externalLink's PK is ("id") alone, so the company-scoped wipe can't reach a
+ // row a previous run left under another company — clear the fixed id first.
+ await ctx.client.query(`DELETE FROM "externalLink" WHERE id = $1`, [
+ NOVASAT_QUOTE_LINK_ID
+ ]);
const quote2Link = await insertId(ctx, "externalLink", {
id: NOVASAT_QUOTE_LINK_ID,
documentType: "Quote",
diff --git a/packages/database/src/seed-dev/tiers/05-purchasing.ts b/packages/database/src/seed-dev/tiers/05-purchasing.ts
index a81d4123a6..b7c157ff36 100644
--- a/packages/database/src/seed-dev/tiers/05-purchasing.ts
+++ b/packages/database/src/seed-dev/tiers/05-purchasing.ts
@@ -376,6 +376,11 @@ export async function runTier5(ctx: Ctx): Promise<void> {
// Same two steps as supplier-quote finalize: create the external link, then
// point the quote at it — that id is what /share/supplier-quote/:id reads.
+ // Fixed id + a PK of ("id") alone: the company-scoped wipe can leave a row
+ // from a run under another company, so clear it before re-creating.
+ await ctx.client.query(`DELETE FROM "externalLink" WHERE id = $1`, [
+ spec.externalLinkId
+ ]);
await insertRow(ctx, "externalLink", {
id: spec.externalLinkId,
documentType: "SupplierQuote",
diff --git a/packages/database/src/seed-dev/tiers/workflow-definitions.ts b/packages/database/src/seed-dev/tiers/workflow-definitions.ts
index 2bc042d9ca..1aeee8bfc0 100644
--- a/packages/database/src/seed-dev/tiers/workflow-definitions.ts
+++ b/packages/database/src/seed-dev/tiers/workflow-definitions.ts
@@ -2,7 +2,7 @@
// them so `@carbon/workflows` can import it and assert every definition still passes
// `validateDefinition` — the cycle blocks that check from running on this side.
-export const FORMAT_VERSION = 3;
+export const FORMAT_VERSION = 4;
/** Mirrors each event's `match` block in the workflow catalog, spelled out here for the
* same package-cycle reason. `null` is a business moment: it has no table to subscribe to. */
@@ -222,9 +222,9 @@ export function buildSeedWorkflows(refs: {
data: { events: ["purchaseOrder.status.changed"], origin: "Both" }
},
{
- id: "entity_total",
+ id: "compute_total",
name: "order_total",
- type: "entity",
+ type: "compute",
position: { x: 480, y: 0 },
expanded: true,
data: {
@@ -246,7 +246,7 @@ export function buildSeedWorkflows(refs: {
combinator: "and",
clauses: [
{
- left: ref("entity_total", "result"),
+ left: ref("compute_total", "result"),
operator: "gt",
right: literal(num, 10000)
}
@@ -283,8 +283,8 @@ export function buildSeedWorkflows(refs: {
}
],
edges: [
- edge("edge_total", "trigger_po_status", "entity_total", "out"),
- edge("edge_size", "entity_total", "condition_large", "out"),
+ edge("edge_total", "trigger_po_status", "compute_total", "out"),
+ edge("edge_size", "compute_total", "condition_large", "out"),
edge("edge_flag", "condition_large", "action_flag", "path_large")
]
},
diff --git a/packages/ee/src/plan.ts b/packages/ee/src/plan.ts
index 69c3c1c3a9..b4b71539a1 100644
--- a/packages/ee/src/plan.ts
+++ b/packages/ee/src/plan.ts
@@ -15,7 +15,7 @@ export const FEATURE_PLANS = {
STORAGE_RULES: [Plan.Business, Plan.Partner],
CUSTOMER_PORTALS: [Plan.Business, Plan.Partner],
AI_AGENT: [Plan.Business, Plan.Partner],
- WORKFLOWS: [Plan.Partner]
+ WORKFLOWS: [Plan.Business, Plan.Partner]
} as const satisfies Record<string, Plan[]>;
export type Feature = keyof typeof FEATURE_PLANS;
diff --git a/packages/jobs/src/workflows/engine/end-to-end.test.ts b/packages/jobs/src/workflows/engine/end-to-end.test.ts
index b87e803602..d42f129834 100644
--- a/packages/jobs/src/workflows/engine/end-to-end.test.ts
+++ b/packages/jobs/src/workflows/engine/end-to-end.test.ts
@@ -158,7 +158,7 @@ describe("a workflow end to end", () => {
},
{
id: "total",
- type: "entity",
+ type: "compute",
position: { x: 0, y: 1 },
data: {
operation: "purchaseOrder.total",
@@ -593,7 +593,7 @@ describe("a workflow end to end", () => {
},
{
id: "scrap",
- type: "entity",
+ type: "compute",
position: { x: 0, y: 1 },
data: {
operation: "job.totalScrapQuantity",
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index e4c4483cec..bba92a28eb 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -9129,6 +9129,9 @@ msgstr "Mehr"
msgid "More actions"
msgstr "Weitere Aktionen"
+msgid "More information"
+msgstr "Weitere Informationen"
+
msgid "More options"
msgstr "Weitere Optionen"
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index dbd11ef477..eb2871b54e 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -9129,6 +9129,9 @@ msgstr "More"
msgid "More actions"
msgstr "More actions"
+msgid "More information"
+msgstr "More information"
+
msgid "More options"
msgstr "More options"
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index 280238b934..df85cb9372 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -9129,6 +9129,9 @@ msgstr "Más"
msgid "More actions"
msgstr "Más acciones"
+msgid "More information"
+msgstr "Más información"
+
msgid "More options"
msgstr "Más opciones"
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index 064a0701b7..444c9c12c9 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -9129,6 +9129,9 @@ msgstr "Plus"
msgid "More actions"
msgstr "Plus d'actions"
+msgid "More information"
+msgstr "Plus d'informations"
+
msgid "More options"
msgstr "Plus d'options"
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index df80a18843..beedbc359b 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -9129,6 +9129,9 @@ msgstr "अधिक"
msgid "More actions"
msgstr "अधिक क्रियाएं"
+msgid "More information"
+msgstr "अधिक जानकारी"
+
msgid "More options"
msgstr "अधिक विकल्प"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index 9ae580a216..f530bff3e1 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -9129,6 +9129,9 @@ msgstr "Altro"
msgid "More actions"
msgstr "Altre azioni"
+msgid "More information"
+msgstr "Più informazioni"
+
msgid "More options"
msgstr "Altre opzioni"
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index ab0434d644..40bb5c38e5 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -9129,6 +9129,9 @@ msgstr "もっと"
msgid "More actions"
msgstr "その他のアクション"
+msgid "More information"
+msgstr "詳細情報"
+
msgid "More options"
msgstr "その他のオプション"
diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.po
index 2ed19d32f8..d6688303af 100644
--- a/packages/locale/locales/ko/erp.po
+++ b/packages/locale/locales/ko/erp.po
@@ -9129,6 +9129,9 @@ msgstr "더 보기"
msgid "More actions"
msgstr "추가 작업"
+msgid "More information"
+msgstr "자세한 정보"
+
msgid "More options"
msgstr "추가 옵션"
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index ce1bd7b6bd..b9ffc11768 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -9129,6 +9129,9 @@ msgstr "Więcej"
msgid "More actions"
msgstr "Więcej akcji"
+msgid "More information"
+msgstr "Więcej informacji"
+
msgid "More options"
msgstr "Więcej opcji"
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index b2b0821e3f..d87a54d2ef 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -9129,6 +9129,9 @@ msgstr "Mais"
msgid "More actions"
msgstr "Mais ações"
+msgid "More information"
+msgstr "Mais informações"
+
msgid "More options"
msgstr "Mais opções"
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index e5004a2e4f..80c0d4b875 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -9129,6 +9129,9 @@ msgstr "Ещё"
msgid "More actions"
msgstr "Ещё действия"
+msgid "More information"
+msgstr "Дополнительная информация"
+
msgid "More options"
msgstr "Ещё опции"
diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.po
index cf91578d94..cb23ac09af 100644
--- a/packages/locale/locales/tr/erp.po
+++ b/packages/locale/locales/tr/erp.po
@@ -9129,6 +9129,9 @@ msgstr "Daha fazla"
msgid "More actions"
msgstr "Daha fazla işlem"
+msgid "More information"
+msgstr "Daha fazla bilgi"
+
msgid "More options"
msgstr "Daha fazla seçenek"
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index c931a33852..8dcdc216a4 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -9129,6 +9129,9 @@ msgstr "更多"
msgid "More actions"
msgstr "更多操作"
+msgid "More information"
+msgstr "更多信息"
+
msgid "More options"
msgstr "更多选项"
diff --git a/packages/workflows/AGENTS.md b/packages/workflows/AGENTS.md
index a601da650f..6799f393e4 100644
--- a/packages/workflows/AGENTS.md
+++ b/packages/workflows/AGENTS.md
@@ -24,9 +24,11 @@ Specs: `.ai/specs/2026-07-30-workflows-foundation.md` (schema, validator, runtim
- Upgrade an older stored shape only inside `migrateDefinition` in `src/definition/normalize.ts`.
It is private and runs on the **raw JSON before** the current-schema parse — a document old
enough to need upgrading cannot satisfy the current schema, so migrating after that parse could
- never run. It carries one upgrade today: v1 → v2 resets a lookup node's `match` to `[]` because
- its shape changed, which discards nothing (no v1 lookup could be activated).
-- Bump `CURRENT_DEFINITION_FORMAT_VERSION` (now **3**, in `src/definition/schema.ts`) when the
+ never run. It carries three upgrades today: v1 → v2 resets a lookup node's `match` to `[]` because
+ its shape changed (no v1 lookup could be activated); v2 → v3 backfills node `name`s from
+ the old `title`; v3 → v4 renames the `entity` node type to `compute`, leaving stored node
+ names alone — a name is an identifier other nodes reference.
+- Bump `CURRENT_DEFINITION_FORMAT_VERSION` (now **4**, in `src/definition/schema.ts`) when the
stored shape changes, and add the upgrade to `migrateDefinition` in the same change.
- Pass a `WorkflowCatalog` into `validateDefinition`. `createWorkflowCatalog()` in
`src/catalog/catalog.ts` is the real one — events, entities, actions and operations behind one
@@ -107,7 +109,7 @@ src/runtime/
├── compare.ts # operator semantics + clause evaluation
├── condition.ts # the Condition executor
├── filter.ts # the Filter executor
-├── entity.ts # the Entity executor — one catalog operation
+├── compute.ts # the Compute executor — one catalog operation
├── lookup.ts # the Lookup executor — one search
├── action.ts # the Action executor — one item, never a loop
├── executors.ts # EXECUTORS: node kind -> executor. A kind with no entry refuses to run
diff --git a/packages/workflows/src/definition/nodes.ts b/packages/workflows/src/definition/nodes.ts
index a7f4603531..dffe3302bd 100644
--- a/packages/workflows/src/definition/nodes.ts
+++ b/packages/workflows/src/definition/nodes.ts
@@ -3,9 +3,9 @@ import type { CatalogInput, WorkflowCatalog } from "./catalog";
import type { WorkflowIssue } from "./issues";
import {
type ActionNode,
+ type ComputeNode,
DEFAULT_HANDLE,
DEFAULT_OUTPUT,
- type EntityNode,
FAILURE_HANDLE,
type FilterNode,
SUCCESS_HANDLE,
@@ -127,9 +127,9 @@ function filterLoopList(node: FilterNode, ctx: NodeContext): LoopList {
}
/** The first operation input wired to a list where the operation expects a single value.
- * When set, the entity node runs the operation once per list item and returns a list. */
-function entityBatchInput(
- node: EntityNode,
+ * When set, the compute node runs the operation once per list item and returns a list. */
+function computeBatchInput(
+ node: ComputeNode,
ctx: NodeContext
): string | undefined {
const operation = ctx.catalog.getOperation(node.data.operation);
@@ -458,13 +458,13 @@ export const NODE_KINDS: {
}
},
- entity: {
+ compute: {
handles: () => [DEFAULT_HANDLE],
values: (node) => inputValues(node.data.inputs),
outputs: (node, ctx) => {
const operation = ctx.catalog.getOperation(node.data.operation);
if (operation === undefined) return undefined;
- const batchInput = entityBatchInput(node, ctx);
+ const batchInput = computeBatchInput(node, ctx);
if (batchInput !== undefined && operation.output.kind !== "list") {
return {
[DEFAULT_OUTPUT]: { kind: "list", of: operation.output as ScalarType }
@@ -475,7 +475,7 @@ export const NODE_KINDS: {
loopList: (node, ctx) => {
const operation = ctx.catalog.getOperation(node.data.operation);
if (operation === undefined) return { failure: "unconfigured" };
- const batchInput = entityBatchInput(node, ctx);
+ const batchInput = computeBatchInput(node, ctx);
if (batchInput === undefined || operation.output.kind === "list")
return undefined;
return { type: { kind: "list", of: operation.output as ScalarType } };
@@ -485,7 +485,7 @@ export const NODE_KINDS: {
checkTypes: (node, ctx) => {
const operation = ctx.catalog.getOperation(node.data.operation);
if (operation === undefined) return [];
- const batchInput = entityBatchInput(node, ctx);
+ const batchInput = computeBatchInput(node, ctx);
return checkInputs(
node,
node.data.inputs,
diff --git a/packages/workflows/src/definition/normalize.test.ts b/packages/workflows/src/definition/normalize.test.ts
index 130f046483..8acb828d63 100644
--- a/packages/workflows/src/definition/normalize.test.ts
+++ b/packages/workflows/src/definition/normalize.test.ts
@@ -43,7 +43,7 @@ describe("readWorkflowVersion", () => {
if (!result.ok) return;
expect(result.definition.nodes).toHaveLength(1);
expect(result.definition.nodes[0]?.id).toBe("n1");
- expect(result.definition.formatVersion).toBe(3);
+ expect(result.definition.formatVersion).toBe(4);
});
it("keeps nodes and edges apart", () => {
@@ -121,7 +121,7 @@ describe("readWorkflowVersion", () => {
});
expect(result.ok).toBe(true);
if (!result.ok) return;
- expect(result.definition.formatVersion).toBe(3);
+ expect(result.definition.formatVersion).toBe(4);
});
it("opens a v1 lookup as v2 with its old two-sided rules dropped", () => {
@@ -166,6 +166,54 @@ describe("readWorkflowVersion", () => {
expect(lookup.data.returns).toBe("list");
});
+ it("opens a v3 entity node as a compute node, keeping its stored name", () => {
+ const result = readWorkflowVersion({
+ formatVersion: 3,
+ nodes: [
+ { ...triggerNode, name: "trigger_0" },
+ {
+ id: "n2",
+ name: "entity_0",
+ type: "entity",
+ position: { x: 1, y: 1 },
+ data: { operation: "purchaseOrder.total", inputs: {} }
+ }
+ ],
+ edges: []
+ });
+ expect(result.ok).toBe(true);
+ if (!result.ok) return;
+ const compute = result.definition.nodes[1];
+ expect(compute?.type).toBe("compute");
+ if (compute?.type !== "compute") return;
+ expect(compute.data.operation).toBe("purchaseOrder.total");
+ // The name is an identifier other nodes reference — renaming it would break them.
+ expect(compute.name).toBe("entity_0");
+ });
+
+ it("leaves a lookup node's `entity` field alone when renaming the node type", () => {
+ const result = readWorkflowVersion({
+ formatVersion: 3,
+ nodes: [
+ { ...triggerNode, name: "trigger_0" },
+ {
+ id: "n2",
+ name: "lookup_0",
+ type: "lookup",
+ position: { x: 1, y: 1 },
+ data: { entity: "purchaseOrder", returns: "one", match: [] }
+ }
+ ],
+ edges: []
+ });
+ expect(result.ok).toBe(true);
+ if (!result.ok) return;
+ const lookup = result.definition.nodes[1];
+ expect(lookup?.type).toBe("lookup");
+ if (lookup?.type !== "lookup") return;
+ expect(lookup.data.entity).toBe("purchaseOrder");
+ });
+
it("round-trips a definition already at the current version", () => {
const row = { formatVersion: 2, nodes: [triggerNode], edges: [] };
const once = readWorkflowVersion(row);
@@ -196,7 +244,7 @@ describe("readWorkflowVersion", () => {
it("rejects a document written by a newer release rather than emptying it", () => {
const result = readWorkflowVersion({
- formatVersion: 4,
+ formatVersion: 5,
nodes: [{ id: "n1", type: "brandNewKind", position: { x: 0, y: 0 } }],
edges: []
});
@@ -334,7 +382,7 @@ describe("readWorkflowVersion", () => {
expect(first).toEqual(second);
});
- it("runs both migrations on a v1 document and ends at formatVersion 3", () => {
+ it("runs every migration on a v1 document and ends at formatVersion 4", () => {
const result = readWorkflowVersion({
formatVersion: 1,
nodes: [triggerNode],
@@ -342,13 +390,13 @@ describe("readWorkflowVersion", () => {
});
expect(result.ok).toBe(true);
if (!result.ok) return;
- expect(result.definition.formatVersion).toBe(3);
+ expect(result.definition.formatVersion).toBe(4);
expect(result.definition.nodes[0]?.name).toBe("trigger_0");
});
- it("rejects a document at formatVersion 4 as future-format", () => {
+ it("rejects a document at formatVersion 5 as future-format", () => {
const result = readWorkflowVersion({
- formatVersion: 4,
+ formatVersion: 5,
nodes: [],
edges: []
});
diff --git a/packages/workflows/src/definition/normalize.ts b/packages/workflows/src/definition/normalize.ts
index 29b6b3931f..1e5f40f44d 100644
--- a/packages/workflows/src/definition/normalize.ts
+++ b/packages/workflows/src/definition/normalize.ts
@@ -90,6 +90,26 @@ function migrateDefinition(raw: RawDefinition, from: number): RawDefinition {
})
};
}
+ // v3 → v4: the `entity` node became `compute`. It never wrote a record — it runs
+ // one catalog operation and returns the value. Only the discriminant moves; the
+ // node's `name` is left as stored (`entity_0` and friends stay), which is why this
+ // block sits after the v2 → v3 backfill that derives names from the type.
+ if (from < 4 && Array.isArray(current.nodes)) {
+ current = {
+ ...current,
+ formatVersion: 4,
+ nodes: current.nodes.map((node) => {
+ if (
+ typeof node !== "object" ||
+ node === null ||
+ (node as { type?: unknown }).type !== "entity"
+ ) {
+ return node;
+ }
+ return { ...(node as Record<string, unknown>), type: "compute" };
+ })
+ };
+ }
return current;
}
diff --git a/packages/workflows/src/definition/schema.ts b/packages/workflows/src/definition/schema.ts
index 9c6e8af320..fcddd44cfd 100644
--- a/packages/workflows/src/definition/schema.ts
+++ b/packages/workflows/src/definition/schema.ts
@@ -8,7 +8,7 @@ import {
variableRefSchema
} from "./types";
-export const CURRENT_DEFINITION_FORMAT_VERSION = 3;
+export const CURRENT_DEFINITION_FORMAT_VERSION = 4;
/** Cap on the items one repeating step works through. */
export const MAX_LIST_ITEMS = 100;
@@ -64,9 +64,9 @@ const conditionNode = z.object({
})
});
-const entityNode = z.object({
+const computeNode = z.object({
...nodeBase,
- type: z.literal("entity"),
+ type: z.literal("compute"),
data: z.object({
operation: z.string(),
inputs: z.record(valueOrRefSchema).default({})
@@ -106,7 +106,7 @@ const actionNode = z.object({
export const nodeSchema = z.discriminatedUnion("type", [
triggerNode,
conditionNode,
- entityNode,
+ computeNode,
lookupNode,
filterNode,
actionNode
@@ -116,7 +116,7 @@ export type WorkflowNodeType = WorkflowNode["type"];
export type TriggerNode = Extract<WorkflowNode, { type: "trigger" }>;
export type ConditionNode = Extract<WorkflowNode, { type: "condition" }>;
-export type EntityNode = Extract<WorkflowNode, { type: "entity" }>;
+export type ComputeNode = Extract<WorkflowNode, { type: "compute" }>;
export type LookupNode = Extract<WorkflowNode, { type: "lookup" }>;
export type FilterNode = Extract<WorkflowNode, { type: "filter" }>;
export type ActionNode = Extract<WorkflowNode, { type: "action" }>;
diff --git a/packages/workflows/src/definition/validate.test.ts b/packages/workflows/src/definition/validate.test.ts
index f2eaf21499..39a4b9f0cd 100644
--- a/packages/workflows/src/definition/validate.test.ts
+++ b/packages/workflows/src/definition/validate.test.ts
@@ -670,7 +670,7 @@ describe("configuration", () => {
{
id: "e1",
name: "e1",
- type: "entity",
+ type: "compute",
position: { x: 0, y: 0 },
data: { operation: "job.vibes", inputs: {} }
}
diff --git a/packages/workflows/src/definition/validate.ts b/packages/workflows/src/definition/validate.ts
index b704ac21f3..4c90eb17d7 100644
--- a/packages/workflows/src/definition/validate.ts
+++ b/packages/workflows/src/definition/validate.ts
@@ -477,7 +477,7 @@ function checkTypes(
/**
* Layer 6, second half — a record dropped into a sentence has no reading, so it is
* rejected here rather than silently flattened to an id at run time. This lives in
- * one place for every template: an action's message, an entity's field, a clause.
+ * one place for every template: an action's message, a compute step's input, a clause.
*/
function checkTemplateParts(
node: WorkflowNode,
diff --git a/packages/workflows/src/index.ts b/packages/workflows/src/index.ts
index e8ab002b96..9cb6c36f73 100644
--- a/packages/workflows/src/index.ts
+++ b/packages/workflows/src/index.ts
@@ -58,9 +58,9 @@ export {
} from "./definition/schedule";
export type {
ActionNode,
+ ComputeNode,
ConditionNode,
ConditionPath,
- EntityNode,
FilterNode,
LookupNode,
Origin,
@@ -161,8 +161,8 @@ export type {
export {
actionExecutor,
compare,
+ computeExecutor,
conditionExecutor,
- entityExecutor,
entityValue,
evaluateClauses,
executorFor,
diff --git a/packages/workflows/src/runtime/entity.test.ts b/packages/workflows/src/runtime/compute.test.ts
similarity index 81%
rename from packages/workflows/src/runtime/entity.test.ts
rename to packages/workflows/src/runtime/compute.test.ts
index 7128b31971..2f0029d886 100644
--- a/packages/workflows/src/runtime/entity.test.ts
+++ b/packages/workflows/src/runtime/compute.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import { createFixtureCatalog } from "../definition/catalog";
-import type { EntityNode } from "../definition/schema";
-import { entityExecutor } from "./entity";
+import type { ComputeNode } from "../definition/schema";
+import { computeExecutor } from "./compute";
import { createRuntimeContext } from "./fixtures";
import type { RuntimeValue, WorkflowServices } from "./types";
import { entityValue, primitiveValue } from "./values";
@@ -17,11 +17,11 @@ const jobRef = {
const node = (
operation = "job.totalScrap",
- inputs: EntityNode["data"]["inputs"] = { job: jobRef }
-): EntityNode => ({
+ inputs: ComputeNode["data"]["inputs"] = { job: jobRef }
+): ComputeNode => ({
id: "scrap",
name: "scrap",
- type: "entity",
+ type: "compute",
position: { x: 0, y: 0 },
data: { operation, inputs }
});
@@ -36,7 +36,7 @@ const unreachable: WorkflowServices["runOperation"] = async () => {
throw new Error("the service should not have been called");
};
-describe("entityExecutor", () => {
+describe("computeExecutor", () => {
it("puts the operation's value on `result` and follows the out handle", async () => {
const calls: Array<[string, Record<string, RuntimeValue>]> = [];
const ctx = contextWith(async (operationId, inputs) => {
@@ -44,7 +44,7 @@ describe("entityExecutor", () => {
return { ok: true, value: primitiveValue("number", 12) };
});
- expect(await entityExecutor.execute(node(), ctx)).toEqual({
+ expect(await computeExecutor.execute(node(), ctx)).toEqual({
status: "Succeeded",
outputs: { result: primitiveValue("number", 12) },
handle: "out"
@@ -55,7 +55,7 @@ describe("entityExecutor", () => {
});
it("skips with the resolver's own reason when an input cannot be resolved", async () => {
- const result = await entityExecutor.execute(
+ const result = await computeExecutor.execute(
node("job.totalScrap", {
job: { kind: "ref", nodeId: "gone", output: "result", path: [] }
}),
@@ -68,7 +68,7 @@ describe("entityExecutor", () => {
});
it("fails with the service's error", async () => {
- const result = await entityExecutor.execute(
+ const result = await computeExecutor.execute(
node(),
contextWith(async () => ({
ok: false,
@@ -82,17 +82,17 @@ describe("entityExecutor", () => {
});
it("reports the operation's declared permission", () => {
- expect(entityExecutor.permission(node(), catalog)).toEqual({
+ expect(computeExecutor.permission(node(), catalog)).toEqual({
module: "production",
action: "view"
});
expect(
- entityExecutor.permission(node("job.gone"), catalog)
+ computeExecutor.permission(node("job.gone"), catalog)
).toBeUndefined();
});
it("skips when the operation is no longer in the catalog", async () => {
- const result = await entityExecutor.execute(
+ const result = await computeExecutor.execute(
node("job.gone"),
contextWith(unreachable)
);
diff --git a/packages/workflows/src/runtime/entity.ts b/packages/workflows/src/runtime/compute.ts
similarity index 96%
rename from packages/workflows/src/runtime/entity.ts
rename to packages/workflows/src/runtime/compute.ts
index 3408776272..a9e4c7a544 100644
--- a/packages/workflows/src/runtime/entity.ts
+++ b/packages/workflows/src/runtime/compute.ts
@@ -1,7 +1,7 @@
import {
+ type ComputeNode,
DEFAULT_HANDLE,
- DEFAULT_OUTPUT,
- type EntityNode
+ DEFAULT_OUTPUT
} from "../definition/schema";
import type { ScalarType } from "../definition/types";
import { resolveValue } from "./resolve";
@@ -10,7 +10,7 @@ import { listValue } from "./values";
const GONE = "This calculation is no longer available.";
-export const entityExecutor: NodeExecutor<EntityNode> = {
+export const computeExecutor: NodeExecutor<ComputeNode> = {
permission: (node, catalog) =>
catalog.getOperation(node.data.operation)?.permission,
diff --git a/packages/workflows/src/runtime/executors.test.ts b/packages/workflows/src/runtime/executors.test.ts
index fc9b096d91..e3acbdfa83 100644
--- a/packages/workflows/src/runtime/executors.test.ts
+++ b/packages/workflows/src/runtime/executors.test.ts
@@ -1,8 +1,8 @@
import { describe, expect, it } from "vitest";
import type { WorkflowNode, WorkflowNodeType } from "../definition/schema";
import { actionExecutor } from "./action";
+import { computeExecutor } from "./compute";
import { conditionExecutor } from "./condition";
-import { entityExecutor } from "./entity";
import { executorFor } from "./executors";
import { filterExecutor } from "./filter";
import { lookupExecutor } from "./lookup";
@@ -14,7 +14,7 @@ const RUNNABLE: WorkflowNodeType[] = [
"condition",
"filter",
"lookup",
- "entity",
+ "compute",
"action"
];
@@ -23,7 +23,7 @@ describe("executorFor", () => {
expect(executorFor(nodeOf("condition"))).toBe(conditionExecutor);
expect(executorFor(nodeOf("filter"))).toBe(filterExecutor);
expect(executorFor(nodeOf("lookup"))).toBe(lookupExecutor);
- expect(executorFor(nodeOf("entity"))).toBe(entityExecutor);
+ expect(executorFor(nodeOf("compute"))).toBe(computeExecutor);
expect(executorFor(nodeOf("action"))).toBe(actionExecutor);
});
diff --git a/packages/workflows/src/runtime/executors.ts b/packages/workflows/src/runtime/executors.ts
index a92883812d..1ac1d07574 100644
--- a/packages/workflows/src/runtime/executors.ts
+++ b/packages/workflows/src/runtime/executors.ts
@@ -1,7 +1,7 @@
import type { WorkflowNode, WorkflowNodeType } from "../definition/schema";
import { actionExecutor } from "./action";
+import { computeExecutor } from "./compute";
import { conditionExecutor } from "./condition";
-import { entityExecutor } from "./entity";
import { filterExecutor } from "./filter";
import { lookupExecutor } from "./lookup";
import type { NodeExecutor } from "./types";
@@ -12,8 +12,8 @@ const EXECUTORS: {
[K in WorkflowNodeType]?: NodeExecutor<Extract<WorkflowNode, { type: K }>>;
} = {
action: actionExecutor,
+ compute: computeExecutor,
condition: conditionExecutor,
- entity: entityExecutor,
filter: filterExecutor,
lookup: lookupExecutor
};
diff --git a/packages/workflows/src/runtime/index.ts b/packages/workflows/src/runtime/index.ts
index ae7081b62b..c987930e75 100644
--- a/packages/workflows/src/runtime/index.ts
+++ b/packages/workflows/src/runtime/index.ts
@@ -1,8 +1,8 @@
export { actionExecutor } from "./action";
export { itemKeyFor, planBatch } from "./batch";
export { compare, evaluateClauses } from "./compare";
+export { computeExecutor } from "./compute";
export { conditionExecutor, NO_BRANCH } from "./condition";
-export { entityExecutor } from "./entity";
export { executorFor } from "./executors";
export { filterExecutor, filterSummary } from "./filter";
export { lookupExecutor } from "./lookup";
diff --git a/packages/workflows/src/seed-workflows.test.ts b/packages/workflows/src/seed-workflows.test.ts
index c7ab465919..b7d4e6f878 100644
--- a/packages/workflows/src/seed-workflows.test.ts
+++ b/packages/workflows/src/seed-workflows.test.ts
@@ -25,8 +25,8 @@ describe("dev seed workflows", () => {
const types = new Set(workflows.flatMap((w) => w.nodes.map((n) => n.type)));
expect([...types].sort()).toEqual([
"action",
+ "compute",
"condition",
- "entity",
"filter",
"lookup",
"trigger"
@@ -37,7 +37,7 @@ describe("dev seed workflows", () => {
workflows.map((w) => [w.name, w] as const)
)("%s is a valid definition", (_name, workflow) => {
const read = readWorkflowVersion({
- formatVersion: 3,
+ formatVersion: 4,
nodes: workflow.nodes,
edges: workflow.edges
});