Drafts, versioning & company scoping
Workflow definitions are drafted, versioned and company-scoped — there is no XML to author
for any of it. The same machinery serves wizards: both share one draft table and
one version history table. The implementation lives in Features/Flow/ (FlowDraftService,
FlowVersionService).
Draft and published
Section titled “Draft and published”The designers work like the report designer: editing a live flow does not change it until you publish.
- Save draft stores the canvas in
Workflow.FlowDrafts— one draft per definition. Nothing live changes: new workflow instances keep starting on the published version, the wizard runner keeps serving it, no version is minted, and (for a wizard) no response storage is provisioned. A draft is not parsed, so you can save a half-finished flow. - Publish promotes the draft through the flow’s normal save — the steps below — and clears the
draft in the same commit. It asks for an optional version note (prefilled with the draft’s).
Publishing a draft identical to the live flow just clears it (
Unchanged). - Discard draft throws it away and reloads the published flow.
- Opening the designer loads the draft when there is one, otherwise the published flow.
The toolbar and the definitions grids (Workflow Definitions, Wizard Definitions) show one of
four states: Never published, Draft, Published, Published + Draft. The published marker
is the definition’s VersionHash — a new definition has none until its first publish.
Stale drafts. A draft remembers the version it started from (BaseVersionHash). If something else
publishes meanwhile — an XML import, GenieClient, another author — the designer shows a banner, and
Publish asks before replacing that newer version.
New wizards. A wizard opened at /wizard-designer with no Id gets its row on the first
Save draft, from the document’s Name/Slug/Label/Schema (so that first draft must be
well-formed XML, and the Name must be free). It reads Draft until published; the runner refuses it.
VersionHash + unified history
Section titled “VersionHash + unified history”Every publish runs through WorkflowDesignerService.SaveAsync (wizards: WizardFormService.SaveAsync),
which:
- Parses and validates the XML (a
Startnode is required). A document that fails here is a400carrying the reason, and the draft is kept so you can fix it. - For a workflow, checks the
WorkflowScriptsgrant when a Script node changed. - Calls
IFlowVersionService.SnapshotAsync, which mints a fresh 6-characterVersionHashand appends a snapshot row to the unifiedWorkflow.FlowVersionstable only when the XML changed. Publishing with no change keeps the current hash — no duplicate snapshot. - Stores the new XML and hash on the
Workflow.Definitionsrow (wizards:Wizard.Forms, then queues response-table provisioning).
A FlowVersion snapshot row records:
| Column | Meaning |
|---|---|
FlowType |
Workflow or Wizard — the discriminator that unifies both flow kinds in one table. |
DefinitionId |
Id of the owning definition (Workflow.Definitions or Wizard.Forms). |
Name |
Definition name captured at snapshot time. |
VersionHash |
The 6-char id, also stamped on the definition and on instances/responses. |
FlowXml |
The complete XML for this version (immutable). |
Notes |
Optional author note — a “commit message” describing the change. |
CompanyId + audit traits |
Tenant + CreatedAt/CreatedById. |
The hash is generated to be unique among a definition’s existing versions (bounded retry).
The History dialog
Section titled “The History dialog”Each designer’s History dialog lists every version, newest first (saved time · hash · notes · IsCurrent), backed by GET /api/v1/genie/workflow/definitions/{id}/versions. Selecting a version
loads its XML read-only onto the canvas (GET …/versions/{versionHash}).
- Publish prompts for an optional note (“what changed”), stored on the new snapshot.
- Restore into draft copies a past version into the draft (noted
Restored from version …) and returns you to editing it. Nothing goes live until you publish, and older versions are never mutated.
Permissions
Section titled “Permissions”The authoring endpoints — definitions, save, draft, publish, discard, history, and wizard delete — need
the definitions grid’s resource: Wf_DefinitionsView for workflows, WizardDefinitions for wizards
(View to read, Update to write, Delete to delete a wizard). A missing grant is a 403. Running a
flow (starting or transitioning an instance, filling and submitting a wizard) is not gated by these.
Instance pinning (backward-compatible runs)
Section titled “Instance pinning (backward-compatible runs)”Each running instance records the VersionHash it started on. At every runtime step the engine
resolves that pinned XML from Workflow.FlowVersions (ParsePinnedModelAsync → ResolveXmlAsync), so
editing a definition never changes how already-running instances behave.
- Instances started before versioning existed fall back to the definition’s current XML; the engine
also lazily mints a first version (
Initial version) on start when a definition has no hash yet. - The designer’s instance preview renders the pinned XML (falling back to the current XML), so the overlay shows the graph the instance actually runs.
The same guarantee extends to wizards: a submitted wizard response (in the wizard’s own
Wizard.Resp{Name} table) stamps the wizard’s VersionHash, recording exactly which version produced
it — plus a SchemaHash recording the storage shape that captured it. See
Storage and lifecycle for why those are two separate hashes.
Company scoping
Section titled “Company scoping”Workflow (and wizard) definitions carry a CompanyId:
- Designer-created definitions are stamped with the active session company
(
sessionCompany.GetSessionCompanyId()), so they are only visible there. - Definition list views are filtered to the session company, so different companies see and edit their own flows.
- History snapshots inherit the definition’s company.
See Multi-tenant company scoping for how company scoping is enforced.
Per-company unique names (deferred)
Section titled “Per-company unique names (deferred)”Copyright © 2026 Orbyn Technologies. All rights reserved.