Skip to content

Upgrades and workflow versions

RANGE ^1.0.0 · SAME CHANNELRunning instancecurrent: 1.0.01.0.0current1.0.1in range1.1.0newest in range2.0.0new majorcontinues on
RANGE ^1.0.0 · SAME CHANNELRunning instancecurrent: 1.0.01.0.0current1.0.1in range1.1.0newest in range2.0.0new majorcontinues on
Each time an instance of a deployed definition continues, it moves to the newest deployed version in the range ^ of its current version and the same release channel, never to a new major.
  • Immutable versions: a deployed name and version never changes; raise version when code or bundled dependencies change.
  • Forward-only migrations: PostgreSQL migrations run automatically on startup and cannot roll back — always back up the database before upgrading.
  • Reviewed access pins: compile and verify authorization.ts in staging, pin authorization.activate.digest, and review auditor grants on every upgrade.

Use this guide whenever you deploy updated Workflow Definitions, plan a version change while instances are running, or upgrade the IdentityFlow program on your servers. For initial VM installation, PostgreSQL provisioning, systemd, and TLS reverse-proxy setup, see Install and run IdentityFlow. For container builds and Kubernetes Recreate deployments, see Containers and Kubernetes.

The program deploys Workflow Definitions when it starts. To deploy a new or changed definition, update the workflow project on the server (using npm ci from the same lockfile verified in CI) and restart the program.

The program searches workflows.path below workflows.cwd (by default, the directory of the configuration file) for files matching **/*.{request,approval,flow,workflow,wf}.?(m)[jt]s or **/workflows/*.?(m)[jt]s. Test files, hooks files, node_modules, and the other excluded paths in the configuration reference are skipped.

The program deploys only the default export of each file, so one file holds one workflow. A file without a valid default export is skipped with the log line workflow bundle invalid. Each name belongs to one file: when two files declare the same name, the program logs workflow bundle name conflict, and which of the two it deploys is not defined.

A Workflow Definition is a draft unless it sets draft: false. The program skips drafts and logs Skipping deployment of draft workflow:. Set draft: false when a definition is ready to run.

Each deployed definition is identified by its name and version. A deployed version is immutable:

  • Changed bundle stops startup: if a workflow file or its bundled dependencies change while its name and version stay the same, startup stops with WF_DEFINITION_BUNDLE_CHANGED: Workflow Definition "<name>" version "<version>" has a different bundle. … Raise the version before starting.
  • Explicit versions: if a definition omits version, the program assigns 0.0.0+<hash>, which changes with every bundle change. Set an explicit semantic version so logs, UI screens, and audit trails show which release ran.
  • Permanent storage: deployed versions stay in PostgreSQL permanently. IdentityFlow has no way to remove a deployed version.

Versions follow semantic versioning, and running instances follow it too. Each time a running instance of a project-deployed Workflow Definition continues — for example after a dialog answer or timer wake — IdentityFlow runs it with the newest deployed version in the same release channel that satisfies ^<its current version>:

  • From 1.0.0 onward, 1.0.1 and 1.1.0 are compatible with 1.0.0; 2.0.0 is a new major version and is not compatible.
  • Below 1.0.0, the caret range is narrower: 0.2.0 is not compatible with 0.1.0, and 0.0.4 is not compatible with 0.0.3.
  • Definitions registered directly inside a Workflow Test do not move between versions; they stay on the exact version passed to workflowTest(...).

A minor or patch version must therefore remain safe for every instance that started on an earlier version of the same major:

  1. Parameters and decoded results: its params schema must accept every value older versions accepted, because IdentityFlow validates recorded start parameters again on every continuation. Schemas that decode already-recorded step or dialog results must still accept those recorded values.
  2. Recorded steps: steps that already ran must keep their names, kinds (do, sleep, dialog, request, start), and order. Add new steps only after existing steps or inside branches older instances never reached.
  3. Breaking changes need a new major version: renaming, removing, or reordering steps, changing a step’s kind, or tightening a params or dialog schema requires a new major version (or a new minor version below 1.0.0). Instances on the old major keep running on their stored version from PostgreSQL.

Change a definition in place: edit its file and raise version. Do not keep the old version in a second file or second export. IdentityFlow loads older versions from PostgreSQL whenever existing instances continue, even after the old code is no longer in your project.

See Deploy a new version of a workflow for a complete tested example (including adding optional parameters across paused dialogs) and Replay rules for deterministic authoring rules. In the web application, the line under an instance’s title shows <name>@v<version> · <release channel>, and the Operations list shows v<version>.

The program migrates the PostgreSQL database itself on every start. All pending migrations run in one transaction under an exclusive lock on the migrations table, using the NOSUPERUSER database-owner role provisioned during setup.

Migrations only go forward. A program refuses a database that a newer program has migrated and stops with WF_DATABASE_MIGRATION_MISMATCH: Database was migrated by a newer or incompatible IdentityFlow program, or its migration history has a gap. The message names the recorded migration key and the newest key the program knows.

To recover from a mismatch, start the program version that migrated the database or restore a backup taken before the upgrade. Always back up PostgreSQL before starting a new IdentityFlow program version.

The canonical-identity contract changes every newly compiled identity once, including unchanged Workflows and Access Configurations. Prepare this transition before deploying the new IdentityFlow program:

  1. Raise each affected Workflow Definition version. Use a compatible minor or patch only when running instances can safely replay against it under the versioning rules.
  2. Compile the Access Configuration in a preparation deployment with authorization.activate absent, or in your deployment build. Review the inert Candidate and its source. Omitting activation leaves the existing active revision intact; do not remove a production pin to activate unseen code.
  3. Replace authorization.activate.digest with the newly reviewed digest while retaining the reason and Account attribution. Deploy that pin, the new Workflow versions, and the new IdentityFlow program together.
  4. Check startup and the deployed versions. A stale pin still refuses before the already-active shortcut. An equal active Candidate does not need another Access Configuration Revision.

Existing Events, Workflow Definitions, stored bundles, and audit history stay unchanged. Retained bundles remain executable, and running instances continue under the existing compatibility rules. Hook provenance changes once: relation projections may refresh, and stale required-version evidence may temporarily deny access until reconciliation. Keep that fencing in place.

Follow this sequence whenever you upgrade the IdentityFlow program or deploy a new project release to production:

  1. Back up PostgreSQL first. Database migrations are forward-only; a pre-upgrade backup is your rollback path.
  2. Read the release notes. Check Release overview and Version history for breaking changes, migration requirements, and schema updates.
  3. Test against the target release in CI. Pin @identity-flow/api, @identity-flow/sdk, @identity-flow/binding-graphql, and @identity-flow/testing to the target release version, install with npm ci, and pass type checks, *.test.ts, and *.case.ts against the matching Workflow Test distribution (CI for workflow projects).
  4. Bump changed Workflow Definition versions. Equal source, compiler settings, and executable module graphs produce equal bundles across package managers, but dependency upgrades or peer changes can alter a compiled bundle and trigger WF_DEFINITION_BUNDLE_CHANGED. Raise the version of every affected definition before rollout.
  5. Review authorization.ts, digest pins, and auditor grants. Verify the compiled Access Configuration digest in staging before pinning authorization.activate.digest in production (Access control). Confirm that auditor grants stay restricted to people authorized to read recorded event data payloads as well as metadata (Read an audit trail).
  6. Stop old instances before starting the new release. Never mix different program builds against one database. On VMs, wait for clean shutdown (Stop the program); on Kubernetes, rely on strategy.type: Recreate (Containers and Kubernetes).
  7. Verify readiness and record deployed versions. Confirm /-/ready returns ready 200, check startup logs for activated definitions and access revisions, and record which workflow versions were deployed and when so audit reviews can correlate steps with deployed code.

Only for an installation that runs 0.2.0 today. The upgrade changes the database in one direction; back up first.

Upgrade steps from 0.2.0 and how to go back

The upgrade changes the database in one direction.

  1. Back up the database.
  2. Stop the 0.2.0 program.
  3. Update the npm packages in your project to 0.3.1 and run npm ci.
  4. Be ready for WF_DEFINITION_BUNDLE_CHANGED. 0.2.0 silently kept the stored bundle when a file changed under an existing name and version; newer releases stop the start instead. New package versions can change the bundle of a definition whose source you did not touch. Raise the version of each definition the message names: a patch version when its behavior is unchanged, because running instances move to it. If the named definition is an older version of a line that already has a newer one, stop exporting it instead: its instances move to the newest version of the line, and its stored bundle stays in the database.
  5. Check the configuration against the configuration reference. If no Access Configuration is active in the database yet, add an authorization block with activate, or nobody reaches the workflow catalog; see Access control.
  6. Start the 0.3.1 program. It migrates the database.

After step 6, the 0.2.0 program cannot use the database; it fails with 42723: function "uuid_generate_v7" already exists with same argument types. To go back, restore the backup from step 1. The complete list of changes is on the release overview page.