Compiling and versioning
How a project compiles to a bundle, how content hashes version each workflow, what happens to users already in a journey when you deploy a change, and how a deploy that would break them is refused.
Journeys run for days or weeks, and you will deploy many times while they do. Sendwend's answer is to version each workflow by a hash of its compiled IR and pin every running journey to the version it entered on, while templates, segments and actions resolve to what is deployed now. Before a deploy writes anything, the engine checks the new bundle against every version journeys are still running on and refuses one that would break them. This page covers the compiler, the hashes, what a pinned journey still picks up, and how to deploy.
Compiling
compileConfig(config) turns workflow.config.ts into the BundleIR the host deploys:
compileConfig is compileBundle plus a template manifest generated from the registries. It checks the registries first (every template is one of its channel with an id, an id is registered once per channel, email metadata is valid, every topic is declared by the contract) and then every message node. An unregistered or cross-channel template, a missing or undeclared prop, a literal the schema refuses, or a u.xxx the contract's profile does not declare fails with a ConfigCompileError naming the workflow and node:
It also checks that every field a workflow reads from its triggering event is declared for that event, and that every emitted event matches the contract.
compileBundle({ workflows, segments?, templates?, actions? }) is the lower level, without a config. It compiles each workflow and rejects duplicate ids, segments referenced but missing from the bundle, segments that reference each other in a cycle, payload conditions outside a where, misplaced trigger payload references, and actions that are not passed in.
Both are pure functions: no database, no network. That makes the compiled bundle snapshot-testable and lets CI compile a project without a host. See Testing.
Content hashes
Every workflow in the bundle carries a contentHash over its own IR, with metadata excluded. The hash is SHA-256 over canonical JSON, truncated.
| Change | Hash | plan() status |
|---|---|---|
| A changed delay, condition, template, prop or step | changes | changed |
A new or changed trigger, goal, exitWhen or re-entry policy | changes | changed |
| A renamed cohort arm (it is part of node ids) | changes | changed |
name, description, a branch label, an exit or filter reason, the recorded source location | unchanged | metadata_only |
So a reworded description is not a new version, and a changed delay is. The hash is the address the IR is stored under in Postgres, and a journey is pinned to the hash it entered on. A deploy recomputes every declared hash and refuses a bundle whose hashes do not describe its contents.
Node ids are structural paths (0, 1, 2.c0.1), so inserting a step shifts the ids of the steps after it. plan() then reports a run of changed nodes. The verdict is still correct, only noisier than ideal; that is the trade-off for ids nobody has to author.
Planning a deploy
plan(local, deployed?) diffs workflows, segments, templates and actions between two bundles. Each change is added, removed, changed, metadata_only or unchanged. A workflow change lists the workflow-level fields that moved (trigger, goal, exitWhen) and the nodes that changed, with their type. hasChanges ignores metadata-only edits. Omitting deployed plans a first deploy.
plan is a pure function, so a CLI, Studio and CI all reach the same verdict. It answers "what changed"; the in-flight check below answers "what would break".
What happens to users in flight
An in-flight journey finishes on the version it started, however many times you deploy underneath it. The pin covers the workflow's structure: its steps, waits, branches, goal and exit condition. A user halfway through a three-email series keeps getting that series even if you shorten it to two.
What a pinned journey still picks up
The pin covers the structure and nothing else, on purpose. The IR names a template by channel and key, a segment or an action by id, and each is resolved when the journey reaches it, against the deployed bundle and the code serving it:
- Templates: the latest content goes out. A typo fixed in an email reaches everyone, including journeys that entered before the fix. So does what the template says about itself: a send checks the opt-out of the topic the template declares now, and follows its
redeliveryas it is now, so the topic a copy is checked against is the one its unsubscribe link names. - Segments: a segment is a live audience. A
branchorwaitUntilon a segment asks whether the user is in it now, under the deployed condition. A changed condition starts no journey by itself: the people it newly covers are recorded as members of a segment atrigger.enterswaits on, not entered (see Entering a segment is not being in it). - Actions: the current handler runs. Their code ships with the host, never in the IR.
That is how marketing automation behaves, and the engine does not try to improve on it. Customer.io lets people already in a campaign continue their journey when its trigger changes, re-evaluates them when a segment filter changes, and sends the saved version of a message to those who have not reached it yet. Braze's Canvas creates a new version on every update and moves the people already in it onto the new version. Iterable switches people in a published journey to the new version as they finish their current step, and exits those sitting in a deleted tile. Durable-execution engines sit at the other end, for another reason: Temporal's pinned mode and AWS Lambda durable functions keep an execution on the code version it started on so that replay stays deterministic, a property of code rather than content.
A deploy never takes away what a pinned journey names
What a deploy must never do is remove something a pinned IR still uses:
- a template removed, or moved to another channel;
- a new required prop the pinned props do not supply;
- a segment or an action no longer in the bundle;
- a field of the triggering event's payload a journey reads, gone from the contract;
- an event a journey emits or still waits for (a
waitUntil,exitWhen, the goal), gone from the contract.
A running journey would reach that node and fail, or wait for something that can no longer arrive. So before any write, a deploy holds the bundle, and the templates of the code deploying it, against the IRs journeys are still running on, and refuses with an InFlightError: a 409 on POST /deploy and POST /bundle/deploy, listing each pinned version, how many journeys it carries and what breaks. A compatible change passes: a reworded template, a new optional prop, a segment whose condition changed. ?force=1 deploys anyway and reports what it broke in inFlight.
This is the engine's counterpart to Temporal's replay test in CI and to the publish-time rules of the UI products (Braze refuses some edits on a live Canvas; Iterable settles what happens to people in a deleted tile). It is cheap here because the IR is declarative: the message node is checked against the template's schema, and no history has to be replayed. One thing it does not check is a profile field whose type changed under a prop that reads it: the field's name is checked, its value is parsed by the template at each send.
To remove a template or a required event safely, deploy the workflow change first, let the journeys on the old version finish (or exit them), then remove what they used.
Deploying a bundle
Deploying is replacing the routing table with the new bundle's, after the in-flight check and a schema check of the live database (a deploy answers 503 listing every missing table or column). How it is triggered depends on the host:
- Cloudflare. The journeys are compiled into the Worker, so each version carries its own bundle. With the
CF_VERSION_METADATAbinding, a new version makes its bundle live on its first request or cron run, and only over an older version, so isolates of the previous version that keep serving for a few seconds can never put their routes back. Afterwrangler rollback, callPOST /bundle/deployto apply the running version's bundle. On Cloudflare a published version's code serves at once, so run the in-flight check before publishing too:sendwend plan --database-url …compiles the project, reads the pinned IRs from the database and exits non-zero on a problem. Put it in CI ahead ofwrangler deploy. See Cloudflare. - AWS Lambda. Each published version carries its compiled bundle and makes it live by itself, only over an older one. The platform pins each execution to the function version that started it, so template changes cannot reach a running journey there; the segment and action checks still matter, since those come from the database. See AWS Lambda.
- Node. Passing
versiontojourneyNodemakes the bundle compiled into the process go live by itself, only over an older one; without it, deploy withPOST /bundle/deploy. See Self-hosting.
POST /deploy takes an arbitrary compiled bundle, which is how a development host is fed one. A production host that carries its own bundle refuses it with a 409: there, deploying is publishing a version, and a bundle posted by hand could only be a leaked token at work.
One database per host: the routing tables are global, so two hosts on one Postgres schema would swap each other's routes on every deploy. Give staging and production their own schema (database: { schema }) or database.
Sources
Customer.io, Edit triggers, filters, or frequencies in live automations and Workflow changes; Braze, Canvas version history and Edit Canvases after launch; Iterable, Editing journeys; Temporal, Worker versioning; AWS, Invoking Lambda durable functions.