API design principles
execute needs a process and input. A rollout also needs a revision and actor. A list query needs filters and a cursor.
CompileFlow uses arguments, Options, Commands, and Queries to make those different requirements visible.
This page explains their uses and the identities and resources callers must keep separate.
Execution, control, and queries
Section titled “Execution, control, and queries”| Task | API form | Examples |
|---|---|---|
| Invoke a process, start a Run, or complete a wait | Required arguments, with optional Options |
ProcessEngine.execute, DurableProcessEngine.start, completeWait |
| Change state with auditing or concurrency checks | verb(Command) |
Publish, rollback, pause, resume, and operator Effect resolution |
| Read with several filters or pagination | verb(Query) |
Run, timeline, outbox, version, and rollout queries |
Execution methods take required information as arguments. Options controls optional behavior for that call and does
not collect unrelated business data. Calls such as execute, start, completeWait, and cancel do not need a
Command wrapper merely to give every API the same shape.
A control command groups fields that must be checked together, such as the expected revision, actor, reason, and audit context. A query holds immutable filters, ordering, limits, and a cursor. Each form lets the caller see what is required before making the request.
Use types to show valid inputs
Section titled “Use types to show valid inputs”When an operation accepts only one reference type, its parameter uses that type. For example, Durable start with
routing options takes ProcessRef.Alias. The overload without routing options takes ProcessRef and accepts a
Version or Alias. Pass these objects intact rather than unpacking and rebuilding them as strings.
Definitions and references are also distinct:
ProcessDefinitionsupplies source throughInlineorClasspath. Model type, process code, and the exact loaded content determine the definition to execute.ProcessRef.Versionidentifies immutable content supplied by a local binding or Deploy.ProcessRef.Aliasidentifies a published route that selects a version when the invocation is accepted.
ProcessDefinition does not carry a namespace or version. Direct definition execution by ProcessEngine uses the default
namespace without a version binding. Exact version loading takes the namespace and version from ProcessRef.Version,
whose process code must match the definition.
The reference forms ProcessEngine can use depend on the routing capabilities configured by the application.
After execution, ProcessExecution identifies the process that ran and includes the exact ProcessRef.Version
when one was used.
When contributing a public API, add a type only if it provides a needed operation or rules out a concrete invalid request.
Use Instant for a point in time and Duration for an interval, or state the unit in the field name.
Use a builder or another suitable construction API for complex objects instead of asking callers to remember a long
sequence of similarly typed constructor arguments.
Java types, JSON representations, and database columns serve calling, transport, and storage respectively.
They need not map one-to-one: an SQL bigint does not require a Java API to expose a raw long.
Starting a process and recovering a Run
Section titled “Starting a process and recovering a Run”Suppose the production Alias points to v1. Starting a Durable Run by that Alias saves the selected exact definition
and its Process ID. Moving production to v2 affects new starts. The existing Run still recovers from its saved definition.
Several similar-looking identifiers therefore have different uses:
| Information | Purpose | What cannot replace it |
|---|---|---|
| Model type, process code, and exact source | Identify the definition | Engine configuration or a mutable file path |
| Version or Alias | Choose the target of a new invocation | The state used to recover an existing Run |
| Local runtime identity | Identify a prepared object using content, compilation pipeline, and ClassLoader | A portable database key |
| The Run’s saved Process, position, and call targets | Continue that existing execution | Current Alias routes, version sources, or an object that happens to be cached |
| Control state, revisions, and leases | Check whether a particular change is still permitted | Process code, execution diagnostics, or a Worker name |
For new definitions, all sources accepted under the same policy pass the same limits before semantic compilation. Recovery reads the saved definition without returning to its original source or applying a new incoming-definition size limit to an existing Run.
The starting Version can be retained for queries, but does not alter recovery.
Deploy artifacts live in deploy.api.artifact; transport values, parsers, and keys live in deploy.protocol,
keeping executable data separate from its wire representation.
Pass tokens and cursors unchanged
Section titled “Pass tokens and cursors unchanged”Pass capability tokens unchanged, without decoding or rewriting them. Java queries return typed keyset cursors; pass the returned cursor to request the next page. Transport adapters can encode and sign cursors as opaque page tokens. Do not infer database keys, internal Run or element IDs, or ordering rules from those transport tokens. See Query visibility and pagination for cursor and pagination behavior.
Database records, artifact copies, and diagnostics may contain the same information. The implementation must specify which copy is used to make decisions, how the others are checked, and when they become invalid. Similar fields are not automatically interchangeable sources for a decision.
Let the engine manage its resources
Section titled “Let the engine manage its resources”The engine manages its configuration and runtime resources. Internal components receive only the dependencies and settings they need. Framework adapters bind properties and coordinate startup and shutdown without taking over resources already managed by the engine.
runtime(), tooling(), and operator() return objects for runtime management, tooling, and operator actions.
These objects share the engine’s lifecycle. Keeping a reference does not extend resource lifetime or allow new operations after the engine closes.
Configuration, factories, Providers, and persistence components follow the same division of responsibility rather than keeping independent settings for the same fact. When concurrency, recovery, or cleanup needs coordination, name the component that performs it.
Which public types applications may use
Section titled “Which public types applications may use”Java public means accessible, not supported for integration. Internal metrics, repository records, adapters, and
bootstrap code become application APIs only when listed in Supported surfaces.
For the execution details, see Version routing and Durable architecture.