CompileFlow execution flow
Suppose an application processes order A-42 through the production Alias. Once the engine selects v2 and binds its entire static call graph, the invocation keeps those runtimes until completion. An Alias change during business execution does not replace them. The engine then returns the result and invocation details.
To follow a ProcessEngine call, start at the public entry. For warm-up, loading, and unloading, see local administration. For persisted Runs, go directly to the Durable execution flow.
1. Public Entry
Section titled “1. Public Entry”The Map-based entry points take a ProcessRef or a ProcessDefinition, process variables, and ProcessExecutionOptions.
ProcessResult<Map<String, Object>> result = engine.execute(ref, variables, options);For DTO input, ProcessDataMapper converts the input to a Map before execution. After a successful execution, it converts
the output Map to the requested type. An input conversion failure returns CF_EXEC_010 before any process action runs.
An output conversion failure returns CF_EXEC_009 after the process has run; it does not undo action side effects.
ProcessExecutionOptions holds metadata for this invocation and its routing decision. Routing keys and attributes do not
become process variables.
2. Request Normalization
Section titled “2. Request Normalization”DefaultProcessEngine converts the public input into one internal ProcessRuntimeRequest:
| Public input | Internal request |
|---|---|
ProcessDefinition |
default namespace/code plus explicit source |
ProcessRef.Version |
namespace/code/exact version |
ProcessRef.Alias |
namespace/code/Alias pending route selection |
| local load of an exact Version | exact version reference plus explicit definition |
When a definition is loaded for a Version reference, their process codes must match. A direct definition specifies its model type and uses the documented default namespace; the engine does not assign it a Version or Alias.
3. Execution Scope
Section titled “3. Execution Scope”Before looking up runtimes, the engine opens an operation scope and creates an EngineExecutionContext containing:
- invocation ID;
- routing key and immutable routing attributes;
- requested process reference;
- effective route attribution as it becomes known;
- start and completion timestamps.
Internal components access this context through the scoped ThreadLocal in EngineExecutionContextHolder.
The EngineExecutionScope closes in finally and restores the previous context and captured logging context (MDC). It removes the thread-local binding if there was no previous context. Nested invocations therefore do not erase their caller’s context.
Each lifecycle event has a fixed ProcessEvent type. Completion and failure events include the caller’s
ProcessExecution and a separate ProcessEvent.ExecutionAttribution for operational details; failure events also include
a ProcessError. Start events contain the namespace, process code, and invocation ID. Trigger-start events add the
trigger. All events have a trace ID and event time. They cannot contain routing keys, variables, definition content,
free-form metadata, or raw exceptions.
ProcessExecution contains trace and invocation IDs, namespace, process code, an optional exact Version, start and
completion times, and the optional trigger entry at which execution stopped. Event attribution adds the parent invocation,
call depth, model type, source digest, and Alias routing details. Neither type exposes a generic metadata map.
4. Version Resolution
Section titled “4. Version Resolution”ProcessRuntimeResolver resolves the effective version:
ProcessRef.Versionis already exact and bypasses Alias selection.ProcessRef.Aliasreads a route from the configuredProcessAliasRouteSource. If the route has a candidate, it calls the configuredProcessAliasTargetingPolicy; if no policy is configured or it returns an empty result, the engine applies the protocol’s percentage selector. If the policy throws aRuntimeExceptionorLinkageError, or returnsnullinstead of anOptional, selection falls back to the stable target with reasonTARGETING_ERROR. Once a node has applied an Alias retirement, that Alias has no serving route and new admissions fail.- Every
ProcessDefinitionvariant is unversioned.
Alias resolution and runtime acquisition must agree on the selected route:
- The target must be the stable or candidate version of the Alias revision that was read.
- If acquisition of the root or its static call graph fails with
CF_EXEC_012, Core retries selection at most once, and only if the observed route has changed or disappeared. The retry may fail if the Alias has been retired. - Before execution, the engine binds and retains the selected root and every statically reachable child runtime.
- Root and child acquisition share the single handoff retry budget. Once binding succeeds, later Alias revisions do not change the call graph. Exact versions and already fixed Alias selections are not eligible for handoff retry.
A target outside the observed route, or an unavailable named targeting policy, makes the request fail. If the route is still available, the one allowed re-selection evaluates that route using its configured policy. It does not guess a latest version, return to a previous version, or choose a fallback at random.
On a deployment node, the exact version must already be present in InstalledVersionState. If its content is not ready
locally, a Version-only execution request does not fetch the definition remotely at that point.
5. Binding Key And Exact Identity
Section titled “5. Binding Key And Exact Identity”The cache has two related keys:
- an immutable Version binding key,
namespace#code#version(often shortened tocode#versionin diagnostics); - an exact
ProcessRuntimeIdentity.
The binding key finds the runtime associated with an exact Version. It does not contain enough information to identify a runtime for arbitrary source content. ProcessDefinition execution and warmUp use the cache keyed by ProcessRuntimeIdentity without creating a process-code or
Version binding.
ProcessRuntimeIdentity adds model type, process code, source digest, an opaque engine-local compilation fingerprint, and
class-loader identity. Fingerprints and class loaders are compared by object identity. Diagnostic strings show only a
digest prefix and descriptions of those identities.
6. Exact Source Resolution
Section titled “6. Exact Source Resolution”If a binding cache hit is available for a reference-only request, the runtime can be returned without loading source
again. Otherwise, the request must carry a ProcessDefinition with an explicit source.
DefaultProcessDefinitionLoader resolves one immutable source snapshot:
- inline content is encoded as UTF-8 and checked by byte size;
- classpath lookup enumerates matching resources, rejects non-local protocols and remote authorities, and checks each resource’s bytes;
- multiple locations with identical content are accepted; differing bytes fail with
CF_RESOURCE_003rather than selecting one by classpath order; - each input stream reads at most
maxBytes + 1bytes; - malformed UTF-8 fails before parser invocation.
The loader returns an immutable ProcessDefinitionSnapshot with the bytes, decoded content, a logical source description (inline content or classpath resource name),
and SHA-256 digest. The description does not contain a resolved physical URL; avoid sensitive resource names. Parsing, runtime identification, and compilation all use this snapshot. Two definitions do not become
the same definition merely because they use the same path or resource name.
7. Cache And Single-Flight
Section titled “7. Cache And Single-Flight”DefaultProcessRuntimeLoader first checks the exact ProcessRuntimeIdentity cache. A miss enters
InflightRuntimeLoadRegistry:
Registration uses putIfAbsent with the ProcessRuntimeIdentity, so only one caller submits preparation work:
- If a task already exists, the new caller waits on its Future.
- Otherwise, the caller registers a Future and submits one runtime-preparation task.
Callers share the result of one loading attempt, but each synchronous caller has its own waiting deadline and can be interrupted independently. Stopping one caller’s wait does not cancel the task or change its result. Other callers may still receive the prepared runtime. When the attempt finishes, its registry entry is removed; a later request can try again if no matching runtime is cached.
ProcessRuntimeLoader uses short critical sections rather than holding a lifecycle lock throughout a public call:
- An
AtomicBooleanrejects new calls after shutdown begins. InflightRuntimeLoadRegistrycoordinates task registration with shutdown and cancels incomplete futures during shutdown.- A separate critical section orders result publication against shutdown, preventing installation after the service closes.
8. Compilation
Section titled “8. Compilation”The runtime loader parses and validates the definition, then asks the selected factory to create its runtime:
| Stage | Output |
|---|---|
DefaultProcessDefinitionLoader.load reads the definition |
Immutable ProcessDefinitionSnapshot |
| Parsing and format-model conversion | TBBPM or BPMN model |
| Structural and semantic validation | ProcessSemanticCompilation for the backend |
The selected ProcessRuntimeFactory prepares execution |
A COMPILED or INTERPRETED ProcessRuntime |
Both factories receive the same semantic compilation result. Parsing and semantic compilation belong to the loader. The compiled factory generates and compiles Java process code; the interpreted factory prepares actions and expressions. The loader uses the requested ClassLoader for these steps and restores the worker’s previous context ClassLoader on success or failure. Preflight uses that ClassLoader for source resolution and linting too, including lint-only requests.
A shared preparation attempt does not retry internally. Parser, generator, javac, and configuration failures become its result with their original error types. After correcting the definition or environment, a later request can try again.
Optional debug export runs only when explicitly configured. Exported source/classes are diagnostic artifacts and use
package-relative paths under source/, metadata/, and optionally classes/ in an isolated compilation-<id>/ directory.
A complete marker identifies a fully exported compilation; concurrent compilations never share artifact paths.
They do not change Runtime identity; an export failure still fails preparation instead of silently dropping diagnostics.
9. Conditional Installation
Section titled “9. Conditional Installation”After preparation, runtimeCache.install updates the binding only if its conditions still hold:
- Binding an immutable Version to different content is a conflict.
- A newer binding installed concurrently is preserved.
- Other bindings and owners can continue to share the same runtime.
Cache capacity covers cached runtimes and runtimes retained by load or Deploy; resident ownership prevents eviction.
A running invocation may keep using a runtime after cache eviction until the invocation ends, so this limit does not bound
all live runtimes or JVM memory.
Before business code starts, the engine prepares and retains the entire static process-call graph. Published calls use the child versions declared at their call sites; direct calls use their specified Classpath or Version targets. A route update may release an old deployment’s ownership, but the current invocation keeps every runtime it needs until it ends.
The engine’s operation gate tracks direct execute, Alias requests, nested calls, and trigger from route selection
until execution ends, so shutdown can wait for them. Shutdown rejects new work, then waits within the configured budget for accepted calls, owned executor
tasks, and resource cleanup. If that wait times out or is interrupted, one cleanup task keeps waiting for active work to
exit before releasing resources. Repeated close() calls wait for the same cleanup, each with its own budget. See
Resource Management.
10. Runtime Execution
Section titled “10. Runtime Execution”DefaultProcessEngine invokes the acquired ProcessRuntime. Sequential nodes execute in graph order. Parallel branches use
the engine’s execution strategy. Their shared next step runs after the branches join. Timeout cancellation is cooperative; action code
must honor interruption when applicable.
The Engine converts known execution failures to ProcessError and returns
ProcessResult.failure(...). Uncaught Error instances propagate instead of being converted to ProcessResult. Success returns the
output variable map with the same execution details.
Nested process calls preserve the outer execution scope while returning their own result. Generated code identifies the
call site; the execution context performs one exact lookup in the resolved graph. It never derives a classpath from the
child code or selects a child through an Alias or a guessed latest version. A nested ProcessExecutionException is classified using its recognized engine error code; an unknown code becomes CF_EXEC_001. The public message is controlled by the engine, not copied from a nested exception.
11. Trigger Flow
Section titled “11. Trigger Flow”trigger(...) uses the same request normalization, routing, runtime resolution, execution context, error, and result
pipeline.
After obtaining the runtime, the engine requires a TriggerableProcess and executes the requested trigger-entry node,
passing the optional event. Every call creates a new in-memory instance from the supplied context. It does not provide durable
process-instance persistence, resume, external message correlation, or crash recovery.
12. Local Admin Flow
Section titled “12. Local Admin Flow”engine.runtime() returns a ProcessRuntimeManager for the engine’s local runtimes:
warmUp(ProcessDefinition...)prepares runtimes for the supplied root definitions and puts them in the local cache without creating process-code or Version bindings;load(ProcessRef.Version, ProcessDefinition)creates an immutable local Version binding and acquires runtime ownership;unload(ProcessRef.Version...)releases local ownership of exact-version bindings.
Warm-up shares the engine’s bounded runtime-load capacity; it has no separate parallelism setting. Loading or warming a local runtime neither writes a published version nor changes an Alias. Publish through ProcessDeploymentService.publish to save a published version.
ProcessTooling.preflight(...) validates the root definition. With runtimeCheckEnabled, it calls runtimeCheckSync and reports a RUNTIME_CHECK result for the selected COMPILED or INTERPRETED backend.
It may reuse a matching cached runtime. On a cache miss, it prepares the runtime for checking but does not cache the result, bind a Version, or retain ownership. It does not run actions, publish a version, or change a route.
13. Sensitive Data Boundary
Section titled “13. Sensitive Data Boundary”These limits apply to standard execution events and diagnostics. Explicit debug export, described in section 8, can contain generated source and classes. Caller-chosen identifiers and custom extensions are not automatically safe to disclose; use non-sensitive identifiers and do not log arbitrary extension input or diagnostic objects.
Allowed diagnostic fields:
- invocation ID;
- trace ID;
- namespace and process code;
- requested reference;
- effective version/Alias;
- Alias revision and stable/candidate target;
- model type and source digest;
- a stable error code and controlled default message; the call-depth error can also include a bounded process-code chain;
- timing.
Excluded from standard diagnostics:
- routing key;
- source content;
- full local path;
- credentials;
- raw variables;
- arbitrary application objects;
- raw exception context in public results.
14. Source Navigation
Section titled “14. Source Navigation”DefaultProcessEngineProcessRuntimeRequestProcessRuntimeResolverDefaultProcessDefinitionLoaderProcessDefinitionSnapshotProcessRuntimeIdentityDefaultProcessRuntimeLoaderInflightRuntimeLoadRegistryEngineExecutionContext
15. Durable Execution Flow
Section titled “15. Durable Execution Flow”For example, an order Run saves its position while waiting for payment, and the application restarts. After the payment result is saved, a Worker reads that Run’s definition and execution state and continues with shipment processing. Durable uses a separate API and transactional state machine for this sequence:
- Start with a Definition, Version, or Alias. Load the supplied definition or resolve the Version/Alias once, then store the immutable Process definition and its exact static-call bindings.
- Validate the input, prepare the root and statically referenced child runtimes, and create the initial saved state. Commit a
RUNNABLERun bound to the Process ID. - A Turn Worker claims the Run with an expiring lease and a fresh random token. It executes the next steps in saved branches and child calls. The Turn ends when it issues a new Wait, Timer, or Effect request, finishes the Run, or reaches its step limit.
- The Store saves the Run state, Wait/Timer/Effect records, Journal, and Integration Events to be sent in one transaction.
- A Wait completion, fired Timer, or recorded Effect result makes the stored result available to a later Turn. The Worker reads the result, continues execution, and saves both the result’s processed marker and the new execution state.
A new Wait, Timer, or Effect request ends the current Turn. If another path remains runnable, the Run stays runnable and a later Turn continues that work.
Recovery uses the stored Process ID. It does not resolve Version, Alias, or definition locations again, call
ProcessEngine.trigger(...), or restore a serialized Java stack. See Durable Architecture
for the state transitions, transaction contents, and recovery rules.