Skip to content
Development preview · 2.0.0-SNAPSHOT

CompileFlow version routing

This page explains version selection and runtime installation. See the architecture overview for the basic concepts, Hot deployment for release steps, and the Deploy protocol for exact encoding and delivery rules.

Publish a flow to save an immutable version, then point an Alias at that version to send it traffic. These are separate operations: changing an Alias never changes published content. CompileFlow records each rollout and tracks which versions each runtime node has installed.

A published artifact is identified by (namespace, code, version):

  • namespace groups related resources. It does not grant or enforce access permissions.
  • code identifies the flow across versions.
  • version identifies one release. Its content cannot change, and its identifier cannot be reused.

Executing a definition directly uses the default namespace. Published-reference factories also use default when no namespace is supplied. APIs that take an explicit namespace reject null, blank, padded, or invalid identifiers; repositories, protocol adapters, and snapshots do not try to repair them.

The cf_process_version table stores each published version’s model type, exact source, SHA-256 digest, metadata, exact call bindings, actor, and database creation time. The row itself means the version is published; there is no separate preparation status. Model type is stored per version, so successive versions of a flow can use different formats. Calls to an exact published version may cross formats if they satisfy the shared input/output contract. Classpath calls use the caller’s format. Publishing saves the immutable definition and its version information without compiling it on runtime nodes or changing traffic.

The cf_process_alias table stores the current route for (namespace, code, alias): one stable version and, during a canary, one candidate. A retired Alias instead retains its identity and revision without a stable or candidate target. Both deployment commands and the runtime model express the candidate weight for percentage selection in basis points (1..9999); for example, 1_000 means 10%. There is no implicit unit conversion. A named policy can select the target first; see targeting policies and percentage selection for the order. The cf_rollout and cf_rollout_event tables record operations; execution reads the Alias route, not this history.

The local state in this section belongs to deployment nodes running ProcessEngine. Durable reads committed routes through DurableAliasStateSource when starting a Run; it does not use these local-ready snapshots. See Start by Version or Alias for that integration.

LocalRoutingState keeps two snapshots on each runtime node:

Snapshot Contents
LocalAliasRouteState The atomically published local-ready stable/candidate route and revision, or a deletion tombstone
InstalledVersionState Versions installed successfully and available for execution on this node

Each Alias update has a positive revision. The local-ready cache applies only a strictly newer revision. The projection subscriber ignores lower revisions and rejects conflicting content at the same revision. Identical repeated state reaches the local reconciler: pending work is reused, an already-ready route stays ready, and failed convergence can retry without a new revision. Retiring an Alias commits a tombstone with no target version and a higher revision. Each Core runtime applies the tombstone as a deletion; the tombstone retains the revision as a high-watermark so delayed updates cannot restore an older route. A retired Alias retains its identity; an all-at-once rollout using that revision can reactivate it. Do not delete authority rows or manually write projection tombstones: a missing row is not a revisioned route change.

These are derived node-local caches, not the authoritative route repository. The runtime tracks received desired routes separately while it installs their versions. Local state can be rebuilt from the route repository or delivery projection store. The default LocalReadyAliasRouteSource returns only routes that the node is ready to execute; deployment operations commit the persistent route in a database transaction.

ProcessEngine resolves requests as follows:

  1. ProcessRef.Version uses the explicitly requested immutable version.
  2. ProcessRef.Alias reads the configured ProcessAliasRouteSource and selects the stable or candidate version using the rules below.
  3. Each ProcessDefinition executes content from the source specified in that definition, without Alias routing.

In a deployment runtime, the selected exact version must be present in InstalledVersionState. Execution fails if that version is unavailable.

Both engines use AliasRoutingOptions for the optional routing key and policy attributes. With ProcessEngine, set them through ProcessExecutionOptions.Builder.aliasRouting(...). To start a Durable Run by Alias, pass them directly to DurableProcessEngine.start(runId, alias, input, options). These values do not become process variables.

If no routing key is supplied, the engine uses the execution’s occurrence identity: synchronous execution uses its invocation ID, persisted Async execution uses its persisted invocation ID, and Durable uses the Process Run ID. Separate synchronous calls normally have different IDs. Provide a stable routing key when calls for the same customer or business identity should use the same bucket. For ProcessEngine, for example:

ProcessExecutionOptions options = ProcessExecutionOptions.builder()
.aliasRouting(new AliasRoutingOptions("customer-7", Map.of("region", "eu-west")))
.build();
engine.execute(
ProcessRef.alias("default", "order.process", "production"),
variables,
options).orElseThrow();

routingKey is opaque text: CompileFlow does not trim or parse it, expose it in results, or copy it into process variables. CompileFlow does not persist the raw routing key or attribute values as routing state. Treat both as untrusted request input. Do not log the options object: its string representation omits the routing key and attribute values but includes attribute names. Use non-sensitive names; custom policies must also avoid logging request data. Async invocation includes these routing inputs in the SHA-256 request fingerprint stored for idempotency checks. Custom attributes cannot duplicate reserved first-class fields or use the __cf_ namespace. The key is limited to 512 Unicode code points, the map to 32 entries, each name to 128 code points, and each value to 2,048 code points. The UTF-8 bytes of the key, attribute names and values together must fit within 32 KiB (32,768 bytes). See the API reference for validation rules.

Targeting policies and percentage selection

Section titled “Targeting policies and percentage selection”

An Alias route can name one ProcessAliasTargetingPolicy. The engine calls it only if the route has a candidate. The policy can read the Alias, stable and candidate versions, configured policy parameters, and the request’s routing key and routing attributes. It cannot read business process variables. It returns STABLE or CANDIDATE, or an empty result to use percentage routing. This excerpt shows the naming and selection methods; see the extension guide for implementation annotations and service-file declarations:

public interface ProcessAliasTargetingPolicy extends Extension<ExtensionContext> {
String name();
Optional<ProcessAliasTarget> target(ProcessAliasTargetingContext context);
}

The policy does not receive the candidate weight. It selects a target, and the engine maps that target to one of the route’s versions. A policy therefore cannot change the percentage algorithm or select an unrelated version. The protocol defines percentage routing; there is no public SPI for replacing it.

The percentage selector:

  1. Returns STABLE when there is no candidate. If a candidate exists, selection requires a routing key; when none is supplied, the engine uses the invocation ID or Run ID as described above.
  2. Writes the eight-byte ASCII prefix CFROUTE1, followed by namespace, process code, alias, candidate version, and the exact routing key, in that order. Each of these five fields is encoded as UTF-8 bytes preceded by its four-byte unsigned big-endian byte length.
  3. Computes SHA-256, interprets the first 64 bits as unsigned, and takes modulo 10,000.
  4. Selects CANDIDATE when the bucket is below candidateWeightBps; otherwise it selects STABLE.

The hash includes the candidate version. Changing that version can move requests to different buckets. Identical inputs produce the same target across threads, nodes, restarts, and conforming language implementations. Selection does not fall back to a random choice.

A request fails if its Alias has no serving route or the route source fails. A route that names an unavailable policy cannot become locally ready. If its target(...) method throws RuntimeException or LinkageError, or returns null, the engine selects STABLE and reports TARGETING_ERROR; it does not fall through to percentage routing. Other Error instances propagate to the caller. The one retry during a route change evaluates the complete newer route rather than guessing a version.

The selector produces one reason: STABLE_ONLY, TARGETING, SPLIT, or TARGETING_ERROR. ProcessEngine reports targeting failures in its error log, including the reason and policy name. Its execution result retains the selected version, and its terminal event also carries the Alias target. When starting a Durable Run, the engine persists the reason and optional policy name alongside the selected version. Diagnostics exclude request attributes and policy parameter values, and the raw policy context is not persisted for recovery.

The default route source reads LocalAliasRouteState; no custom source is required. In embedded deployments, it can load and prepare a previously unseen Alias on its first request.

To replace it, configure one ProcessAliasRouteSource through aliasRouteSource(...) or a Spring bean. It must supply immutable routes ready for local execution. An engine reads from this one explicitly configured source, whose lifecycle belongs to the application or Spring container. The engine does not discover route sources through the Extension service file, combine several sources, or fall back to local routing when a custom source is configured.

For each request, Core’s AliasAdmission reads the route once and calls AliasTargetSelector. Without a candidate, the selector returns STABLE without calling a targeting policy. With a candidate, it calls the named policy if configured. If no policy is configured or the policy returns an empty result, DeterministicAliasSelector applies percentage routing. The selected version, target, and revision stay in this invocation’s execution context. One engine can execute flows in the formats supported by its installed modules.

Before executing process code, the engine acquires the selected root runtime and binds its complete call graph. If either root or child acquisition reports CF_EXEC_012, the engine rereads the route to check whether it has changed. A confirmed change permits one retry of selection and complete graph acquisition, with a shared retry budget for the root and its children. An unchanged route, a different error, or a second acquisition failure does not permit another retry. Exact versions and previously fixed Alias selections never reroute. After binding succeeds, the call graph stays fixed even if the Alias changes again.

ProcessDeploymentService exposes these operations:

Operation Effect
publish(PublishProcessVersionCommand) Validate and save one immutable process version; does not install runtime state or route traffic
createRollout(CreateRolloutCommand) Atomically create rollout history and audit, mutate the route, and enqueue a routing Outbox event in EMBEDDED/DISTRIBUTED
updateCanaryWeight(UpdateCanaryWeightCommand) Change candidate weight in basis points using rollout and Alias revision checks
promoteRollout(PromoteRolloutCommand) Make the candidate the sole stable version and complete the rollout
abortRollout(AbortRolloutCommand) Restore the canary’s captured stable route and mark that rollout aborted
retireAlias(RetireAliasCommand) Retire a stable Alias while retaining its identity, revision, versions and audit history
rollbackRollout(RollbackRolloutCommand) Create a new all-at-once rollout to a completed source rollout’s captured baseline

ALL_AT_ONCE creates a completed rollout. CANARY creates an IN_PROGRESS rollout. During a canary in EMBEDDED or DISTRIBUTED, runtime nodes require both the stable and candidate runtimes.

To create a rollout, supply an actor, operation kind, idempotency key, and expected Alias revision. Revision zero means the Alias must not exist; use an all-at-once rollout to create that first route. A canary requires an existing stable version. The idempotency key is scoped to the namespace, process, Alias, and operation kind; the request fingerprint covers all fields that affect the operation. Canary updates check both the rollout revision and the target Alias. If either precondition is stale, the operation fails without overwriting a concurrent change.

To roll back, choose a completed source rollout that captured a baseline route and set expectedAliasRevision to the Alias’s current revision. Success creates a new ALL_AT_ONCE rollout to that baseline; it does not modify the source record. To stop an active canary, abort it instead: abort ends that rollout and restores the stable route saved at its start.

Suppose production points to stable version v1 and you are releasing v2. Each operation changes the following state:

Operation Alias route Rollout state
Publish v2 Still uses only v1 Saves the version without creating a canary
Create a 10% canary Stable v1, candidate v2, weight 1_000 IN_PROGRESS
Raise the weight to 50% Same versions, candidate weight 5_000 Still IN_PROGRESS
Promote after the metrics meet the release criteria Only v2; no candidate COMPLETED
Alternatively, abort before promotion Restores the stable v1 route captured at canary creation ABORTED

Promotion and abort are alternative outcomes, both requiring an IN_PROGRESS canary. Creation uses the current Alias revision. Later changes use the current rollout revision and also check the target Alias. See Hot deployment for the complete Java sequence and post-release checks.

AUTHORITY commits the route, rollout history, and audit without a routing Outbox. New Durable Runs read the committed route when they start. Core workers periodically read assigned Aliases in bounded exact-identity batches and pass the complete state into the same local-ready convergence mechanism. Failed reads retain the last ready route; absence is not a deletion. The interval does not bound total convergence time. EMBEDDED waits for local convergence to the committed Alias revision or a newer one before returning success and keeps the routing Outbox for recovery. A later concurrent change may already have superseded the requested route.

In DISTRIBUTED, the command returns after the database transaction commits. Runtime nodes receive the route afterward:

Process or architecture diagram

A successful distributed command does not mean every node has applied the route. Messages are delivered at least once. When automatic repair is enabled, reconciliation republishes the authoritative route only if its projection is missing or has the same identity and a lower revision. Conflicting content at the same or a newer revision is reported without being overwritten. Investigate the authority and projection first. A valid new authoritative route change can supersede a conflicting projection only if its revision is higher than the projection’s revision. A projection ahead of the authority can indicate inconsistent restoration; do not blindly issue rollouts to catch up.

Each node records a desired route before installing its versions. Until all required runtimes are installed and the desired revision has been rechecked, execution keeps using the previous local-ready route. With no previous route, requests fail. Installation failure also leaves the previous route in place and appears in runtime diagnostics; a node never serves a route with only some of its required versions installed. Use Outbox state, route-attributed execution logs, and installation errors to distinguish a committed change from one that is ready to serve.

Making a new route locally ready affects new requests; work already admitted continues on its selected version. Before running the first action, each versioned invocation acquires the runtime for its selected root version and prepares the complete static call graph. Published calls name an exact child version in the parent definition and inherit only its namespace. Alias routing applies to the root alone.

The prepared graph retains every runtime the invocation needs. Later Alias changes or cache eviction cannot replace runtimes used by that invocation. A missing or unavailable child version fails with CF_EXEC_012. A classpath child in a versioned process, a process code that differs from its declaration, or a cycle fails with CF_EXEC_014 before the first action.

Dependency installation uses the configured engine’s graph limits. The root has depth one, and installation stops before reading an artifact whose path would exceed maxCallDepth. It also counts declared call sites before collecting dependency targets or reserving runtimes. Two sites calling the same child count twice; a shared caller is counted once. The engine’s limit of 4,096 call sites applies, with no separate deployment limit.

Previously prepared runtimes can be reused, but the engine still checks the complete graph before making the route locally ready, including the longest path through shared descendants. If installation fails, it releases only resources acquired by that attempt that have no remaining owner. Other owners and the previous serving route remain intact. These graph budgets do not replace artifact-provider I/O deadlines.

Alias-selected executions record:

  • namespace and flow code;
  • requested and effective versions;
  • routing source;
  • route alias;
  • route revision.

The event becomes immutable before it is dispatched to asynchronous listeners. The server persists only the listed routing fields, not arbitrary application metadata.

Workbench canary health analysis reads the shared execution log and includes records for the same namespace, flow, and Alias, whose timestamps fall in the inclusive interval from the application clock minus the configured lookback duration to the current application clock, and whose revisions satisfy deployment.baseRouteRevision < log.routeRevision <= deployment.routeRevision. Route revisions identify the rollout; the time window limits sample age. This includes samples from earlier weight settings in the same rollout and excludes late completions from earlier rollouts. Executions without routing attribution are excluded.

The endpoint evaluates only an active canary. It reports insufficient_data below minCanarySamples, and otherwise checks the candidate’s absolute error-rate and p95 latency thresholds (maxCanaryP95Ms=0 disables the latency check). If the matching execution-log query exceeds compileflow.workbench.server.execution-log.max-query-rows, the endpoint returns HTTP 422 with EXECUTION_LOG_QUERY_LIMIT_EXCEEDED, not a health decision based on truncated data. It does not change traffic: an operator must promote or abort the rollout. Relative comparisons, external metrics, automatic decisions, and scheduled steps require a separate policy and a coordinator authorized to apply it.

  • Keep Alias names stable. Workbench suggests dev, staging, and production, but accepts any valid Process Alias.
  • Supply a stable routing key for repeatable percentage selection while the route parameters stay unchanged.
  • After a route revision conflict, read the current route before deciding whether to retry.
  • Monitor database commits and the time until each runtime node can serve the new route separately.
  • Inspect node-local demanded, in-flight, installed, and backed-off versions using the runtime diagnostics.
  • Investigate execution logs by route alias and revision when validating a canary step.
  • Never repair an incident by mutating a published version or bypassing rollout history.