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.
Workflows: one switch — Publish / Unpublish
- Status: Approved (pending user sign-off)
- Date: 2026-08-24
- Author: aashu (with Claude)
- Research: .ai/research/2026-08-24-workflow-version-terminology.md
Problem
A workflow today has three user-facing words for what a customer experiences as two ideas, and one of them is a lie:
| Surface | Word | Backing data |
|---|---|---|
WorkflowsTable status column |
Published / Draft | workflow.activeVersionId != null |
| Version menu, in the builder | Live | version id == workflow.activeVersionId |
| List column + builder switch | Active | workflow.active (a separate boolean) |
"Published" and "Live" are the same fact seen from two levels. "Active" is a genuinely
separate kill switch, and it stole the word "active" from the pointer column
(activeVersionId) that means something else entirely. Our own documentation has a warning
callout about it — docs/content/docs/reference/workflows.mdx:113, "'Published' and
'Active' are different switches" — which is the tell that the model is too complicated to
explain. A workflow only runs when it is active and has a live version, and nothing on
screen says so.
Goals
- One concept, one word. Publishing is the on switch. Unpublishing is the off switch.
- The word for the running state is Published, everywhere: badge, version tag, docs, code.
- "Active" and "Live" disappear from every user-facing string and from the workflow schema.
- No customer's workflow silently starts or stops running because of this change.
Non-goals
- No change to how workflows are authored, validated, executed, scheduled, retried, or logged.
- No change to the version-locking model (publishing still freezes a version; editing still means creating a new one).
- No approval/review step before publishing. Not asked for.
- No rename of
eventSystemSubscription.active— a different table, a different concept, correctly named. Leave it alone.
Design
1. Data model
One migration, in this order:
-- A workflow that was published but switched OFF is deliberately paused. Collapsing the
-- two flags into one would silently resume it, so unpublish it first, before the column
-- that records the user's intent is gone.
UPDATE "workflow" SET "activeVersionId" = NULL WHERE "active" = FALSE;
-- ...and its trigger rows with it, to stay consistent with syncWorkflowTriggers, the only
-- other writer of that table. Must run BEFORE the column is dropped.
DELETE FROM "workflowTriggerEvent" te
USING "workflow" w
WHERE te."workflowId" = w."id" AND te."companyId" = w."companyId"
AND w."active" = FALSE;
-- Postgres SILENTLY DROPS any index whose predicate names a dropped column, so
-- "workflow_due_idx" (partial on "active" = TRUE) has to be rebuilt, not just left alone.
DROP INDEX IF EXISTS "workflow_due_idx";
ALTER TABLE "workflow" DROP COLUMN "active";
ALTER TABLE "workflow" RENAME COLUMN "activeVersionId" TO "publishedVersionId";
ALTER TABLE "workflow"
RENAME CONSTRAINT "workflow_activeVersionId_fkey" TO "workflow_publishedVersionId_fkey";
CREATE INDEX "workflow_due_idx" ON "workflow" ("nextRunAt")
WHERE "nextRunAt" IS NOT NULL AND "publishedVersionId" IS NOT NULL;
Three details that are easy to get wrong here:
workflow_due_idxis a partial index on"active" = TRUE— this is the scheduler's due-workflow index. Dropping the column takes the index with it without an error, so the scheduler would quietly fall back to a sequential scan. Rebuilding it is not optional. Its predicate loses theactivehalf and keeps the other two, which is exactly the collapse this change is about.- A column rename does not rename its constraint.
workflow_activeVersionId_fkeyhas to be renamed explicitly or the schema keeps the old word in the place people read it from. - The FK's
ON DELETE SET NULL ("activeVersionId")names its column explicitly on purpose (see.ai/lessons.md— a bareSET NULLwould nullcompanyIdtoo and make the parent row undeletable).RENAME COLUMNcarries that clause across intact; do not drop and re-add the constraint.
After this, workflow.publishedVersionId is the single source of truth:
NULL→ the workflow is a Draft. Nothing fires. NoworkflowTriggerEventrows exist.- set → the workflow is Published. That version is the one that runs.
In practice the trigger rows the DELETE targets should already be absent (turning a
workflow off syncs them away), so it is belt-and-braces against historical drift — but it is
exactly what the workflow-trigger-event-drift invariant checks, so a stale row would
otherwise fail CI right after the migration lands.
nextRunAt, canvasState, and every workflowVersion column are untouched.
Then pnpm run generate:types. Note that packages/database/src/types.ts,
swagger-docs-schema.ts and supabase/functions/lib/types.ts already carry uncommitted
regeneration drift on this branch — regenerating will absorb it, which is correct, but the
diff will be wider than this feature.
No new column to remember the last published version. Resuming means opening the
builder, picking a version and pressing Publish — the version menu is already the place
you choose a version, and every version now carries a Publish button when nothing is
published. Adding a lastPublishedVersionId would put a second version pointer on the same
row, which is the duplication this whole change exists to remove.
2. Runtime — three gates, all narrowing to one condition
Every place that reads workflow.active today is reading "is this workflow on". After the
change that question is publishedVersionId IS NOT NULL.
packages/workflows/src/sync.ts — syncWorkflowTriggers selects
["active", "activeVersionId"] and gates on workflow?.active && workflow.activeVersionId.
It becomes a select of ["publishedVersionId"] gated on workflow?.publishedVersionId.
Everything downstream (trigger-row rewrite, eventSystemSubscription reconciliation,
nextRunAt) is unchanged, including the required lockCompany first statement. This one
edit is what makes unpublish actually stop a workflow: no trigger rows, no dispatch.
packages/jobs/src/workflows/scheduler.ts — drop the two .where("w.active", "=", true)
predicates; the existing .where("w.publishedVersionId", "is not", null) beside each of them
already expresses the whole condition.
packages/jobs/src/workflows/engine/execute.ts — the last-moment guard
(if (!context.workflowActive) → Skipped) becomes if (!context.workflowPublished), fed by
log.ts selecting w."publishedVersionId" IS NOT NULL instead of w.active. This
deliberately tests "is the workflow published at all", not "is this run's version still
the published one" — a run already in flight keeps using the version it started with even
if a newer one is promoted mid-run, which is documented behaviour we are not changing. The
SWITCHED_OFF reason string becomes:
"This workflow was unpublished before the run started."
That string is written into workflowRun.statusReason and shown in run history, so it is
user-facing copy, not a comment.
3. Server + service layer
publishWorkflowVersion(workflows.server.ts) dropsactive: truefrom its update and setspublishedVersionId. Validation, thesyncAndWakecall, and the issue-return shape are unchanged.setWorkflowActivebecomesunpublishWorkflow(client, { workflowId, companyId, userId })— setspublishedVersionId: nulland calls the samesyncAndWake. It takes no boolean: there is only one direction, because publishing needs a version id and validation.getWorkflows/getWorkflow(workflows.service.ts) swap the column in theirselectlists, and thePublished/Draftstatic filter switches to.not("publishedVersionId", "is", null)/.is("publishedVersionId", null). The translation comment there stays accurate and gets the new column name.workflowToggleValidatoris deleted fromworkflows.models.ts— unpublish carries no fields.
4. Routes
| Before | After |
|---|---|
x+/workflow+/$id.toggle.tsx (reads active checkbox) |
x+/workflow+/$id.unpublish.tsx (no body) |
path.to.workflowToggle(id) |
path.to.workflowUnpublish(id) |
$id.publish.tsx keeps its path, validator and permission gate (update: "workflows").
The unpublish route gates on the same permission. Both remain the only authorization gate
in front of syncWorkflowTriggers, which bypasses RLS via Kysely.
5. UI
List page (WorkflowsTable.tsx)
- The
activecolumn andWorkflowActiveCheckboxare removed;WorkflowActiveCheckbox.tsxand the unusedWorkflowActiveSwitch.tsxare deleted. - The Status column keeps its
Published/Draftbadges and its static filter exactly as they read today — the copy customers already see does not change. - The row context menu gains Unpublish between Rename Workflow and Delete Workflow,
disabled unless
permissions.can("update", "workflows")and the row is published. It posts topath.to.workflowUnpublish(row.id)and shows a confirm modal ("Unpublish {name}? It will stop running until you publish a version again.") because it stops production automation. Publishing is not offered from the list: it needs a version choice and can fail validation with issues only the canvas can show.
Builder (BuilderHeader.tsx)
live/isLiveVersionbecomepublished/isPublishedVersion.- The primary button is Publish when the open version is not the published one, and Unpublish when it is — replacing today's dead disabled-Publish state on the published version. So: nothing published → every version offers Publish; something published → the published version offers Unpublish. Unpublish gets the same confirm modal as the list.
- The replace-confirm modal copy: "Version N is published now and will be replaced."
- The lock tooltip: "This version is published. Create a new version to edit."
Version menu (WorkflowVersionStatus.tsx) — prop isLive → isPublished, badge text
Live → Published. Still renders nothing for every other version, so exactly one version
in the menu ever carries a tag.
Also WorkflowLockModal.tsx ("…change and publish" — already correct, verify),
WorkflowsUpgradeOverlay.tsx (its fake sample rows carry an active field that must match
the real table's new shape), and IssuesPanel.tsx ("N problems — not published" — already
correct).
Unrelated active identifiers in TriggerForm.tsx (weekday toggles), catalog.ts /
recordPickers.tsx / NodePalette.tsx (custom-field active) are not touched.
New and changed strings are marked with Lingui macros as the surrounding code does, then
pnpm lingui:extract and the /translate skill fill the catalogs.
6. Demo datasets
packages/database/src/datasets/tiers/11-workflows.ts sets activeVersionId for every
seeded workflow and then skips trigger rows for the off ones. That two-step exists only
because the two flags were separate. It collapses:
SeedWorkflow.active→SeedWorkflow.published(type + the fourdata/{satellite,robotics,precision,motor}/workflows.tsfiles, oneactive: trueand sixactive: falseeach).- Set
publishedVersionIdonly whenpublished; keep thecontinuethat skips trigger rows for the rest. The log line becomes(draft)instead of(off). reconcileSubscriptions'sactive: trueis aneventSystemSubscriptioncolumn — untouched.
Row counts per table are unchanged (same workflows, same versions, same one published
workflow with trigger rows), so the .ai/runs/*-baseline.txt files stay valid.
pnpm db:check:datasets is the gate.
7. Conformance + docs
packages/checks/src/invariants/workflow-trigger-event-drift.sql— theactiveCTE drops itsWHERE w."active" = TRUEand filtersw."publishedVersionId" IS NOT NULLinstead; three violation strings mentioning "active" are reworded to "published". Rename the CTE topublishedso the SQL reads honestly.apps/erp/app/modules/workflows/AGENTS.md— the Vocabulary entry that explains why the boolean and the pointer are separate columns is now wrong and must be replaced with the single-pointer model; the Publish bullet loses its "setactive" step.packages/workflows/AGENTS.md(~line 302) — the if-and-only-if rule loses "is active"..claude/rules/workflow-matcher.md—syncWorkflowTriggersis called "on publish, on trigger edit, and on unpublish"; theactive/pointer wording in the sync section..claude/rules/workflow-engine.md— the skipped-run reason string.docs/content/docs/reference/workflows.mdx— delete the "'Published' and 'Active' are different switches" callout, rewrite the publish paragraph as one switch, change "This version is live" to "…is published", and drop "toggle active" from the Update-permission row.
Design decisions
| Decision | Choice | Why |
|---|---|---|
| Model | Publish/Unpublish is the only on-off switch; published version = the running version | n8n 2.0 removed its active/inactive toggle for exactly this reason; Zapier, Retool and HubSpot all ship a single publish switch |
| State word | Published everywhere (badge, version tag, docs) | Shares a root word with the Publish button, which is the easiest pairing to learn; also leaves today's list badge copy unchanged |
| "Live" | Removed from all copy | It was a second word for the same fact as the Published badge — the original confusion |
| Column | activeVersionId → publishedVersionId, in the same migration |
"Active" leaked from this column into the UI in the first place; leaving it keeps the trap set. Mechanical and typechecker-enforced |
| Re-arm after unpublish | Nothing stored; publish a version from the version menu | A second version pointer would reintroduce the duplication being removed |
| Paused workflows at migration time | UPDATE … SET activeVersionId = NULL WHERE active = FALSE before the drop |
A deliberately-paused workflow must not silently resume. This is the one irreversible-feeling step and it fails safe (stopped, not started) |
workflow_due_idx |
Dropped and recreated without the active half of its predicate |
Postgres drops a partial index whose predicate names a dropped column, silently — the scheduler would lose its index with no error anywhere |
| Engine guard | publishedVersionId IS NOT NULL, not "is this run's version still published" |
Faithful translation of the old active guard; in-flight runs keep their version, which is documented behaviour |
| List page | Status badge + Unpublish in the row context menu; no toggle column | Keeps a one-click stop reachable from the list. A toggle would lie: publishing can fail validation and needs a version choice |
| Unpublish confirmation | Confirm modal on both list and builder | It stops live automation; a misclick has production consequences |
eventSystemSubscription.active |
Untouched | Different table, different concept, correctly named |
Acceptance criteria
- Schema —
workflowhas noactivecolumn and haspublishedVersionId;pnpm exec turbo run typecheck --filter=erp --filter=@carbon/jobs --filter=@carbon/workflowspasses with no reference toworkflow.activeanywhere outside generated types. - Index survived — after
pnpm db:migrate,SELECT indexdef FROM pg_indexes WHERE indexname = 'workflow_due_idx'returns one row and its predicate namespublishedVersionIdandnextRunAtonly. - Migration safety — on a database seeded with the
satellitedataset plus a workflow manually set toactive = false, activeVersionId = <v>, afterpnpm db:migratethat workflow haspublishedVersionId IS NULL, has zeroworkflowTriggerEventrows, and shows Draft in the list. - Publish — in the builder on an unpublished workflow, every version's primary button
reads Publish; no version carries a tag. Pressing Publish on a valid version writes
publishedVersionId, tags that version Published, creates itsworkflowTriggerEventrows, and the list row flips to Published. - Unpublish from the builder — on the published version the button reads Unpublish;
confirming clears
publishedVersionId, removes everyworkflowTriggerEventrow for that workflow, drops the Published tag, and the list row reads Draft. Triggering the workflow's event afterwards creates noworkflowRun. - Unpublish from the list — the row menu's Unpublish is disabled on a Draft row and on a
user without
workflows_update; on a Published row it produces the same end state as (4). - Republish — after (4), publishing the same version again restores the trigger rows and
the Published tag. A schedule-triggered workflow gets a non-null
workflow.nextRunAt; an event-triggered one getsNULL. - In-flight run — a run queued for version 1 and then unpublished before it executes
settles
Skippedwith reason "This workflow was unpublished before the run started." - No "Active"/"Live" —
grep -rn "Live\|Active" apps/erp/app/modules/workflows/uireturns no user-facing workflow-state string, anddocs/content/docs/reference/workflows.mdxhas no "Active switch" callout. - Gates green —
pnpm exec biome check, the workflow unit tests (packages/jobs/src/workflows/*.test.ts,packages/workflows/src/seed-workflows.test.ts),pnpm db:check:datasets, andpnpm --filter @carbon/checks workflow-eventsall pass.
Open questions (resolved before writing)
- How do we remember which version to re-publish after an unpublish? — Answer: Don't. When nothing is published, every version in the menu offers Publish and no version carries a tag; when something is published, that version carries the tag and offers Unpublish. No new column. (User, 2026-08-24.)
- Which single word means "this is the version that runs"? — Answer: Published, everywhere — badge, version tag, code, docs. The button stays Publish/Unpublish, so the verb and the state share a root word. "Live" is removed. (User, 2026-08-24.)
- Rename
workflow.activeVersionId→publishedVersionId? — Answer: Yes, in the same migration. The word "active" leaked from that column into the UI, so leaving it keeps the trap set for the next engineer. (User, 2026-08-24.) - What replaces the Active checkbox column on the list page? — Answer: Nothing in the grid; the Published/Draft badge is the indicator, and Unpublish joins the row context menu so an emergency stop stays one click from the list. Publishing stays in the builder. (User, 2026-08-24.)
Changelog
- 2026-08-24 — Written after the four questions above were resolved with the user.
Grounded in
20260810100100_workflows-foundation.sql,packages/workflows/src/sync.ts,packages/jobs/src/workflows/{scheduler,matcher}.ts,packages/jobs/src/workflows/engine/{execute,log}.ts, the ERP workflows module, anddocs/content/docs/reference/workflows.mdx. Terminology grounded in the competitor scan at.ai/research/2026-08-24-workflow-version-terminology.md.