Graph identity and versioning
A graph’s identity answers “which process is this?” A graph’s revision answers “which definition of that process is this?” Your application needs both when a process changes while people still have sessions in progress.
The graph code gives the process a stable name. Publishing a new revision keeps that name and gives the changed definition a new version. A session remembers the code and the graph and DSL versions with which it is being interpreted. Your application must keep the corresponding definition retrievable or explicitly decide how that session can continue.
One process, two definitions
Section titled “One process, two definitions”Consider an application that reviews expense requests. Its graph is called expense-approval. Node 10 prepares a request, edge 101 submits it to the review at node 20, and edge 201 approves it at terminal 90. The graph describes the route; your application supplies the request data and presents each step.
The first definition is version 1.0.0. In version 1.1.0, the application makes the review title more specific: “Review the cost and cost centre.” The nodes, edges and route remain the same.
| Property | First definition | New definition |
|---|---|---|
graph_code |
expense-approval |
expense-approval |
graph_version |
1.0.0 |
1.1.0 |
dsl_version |
1.0 |
1.0 |
schema_version |
1.0 |
1.0 |
English title at node 20 |
Review the request | Review the cost and cost centre |
| Projection checksum | First value | Different value, because the title changed |
A new session can start on 1.1.0 while an earlier one still belongs to 1.0.0. Publishing the new definition does not rewrite the earlier session.
This is why replacing a file called “current graph” is not enough for an application with active sessions. Retain the old definition under a stable revision key, and decide separately which revision new sessions should receive.
What each identifier names
Section titled “What each identifier names”graph_code is the canonical identity used by the runtime. It is a non-empty string, such as expense-approval. A session for that code cannot be used with a graph called travel-review, even if their nodes, edges and numeric IDs are identical. The runtime rejects that substitution with EK-SESSION-002.
Some loaders also accept an integer graph_id as a lookup reference. That optional legacy field is distinct from the code. The session’s flow_id carries a numeric correlation value when one exists; it does not replace graph_code as the session’s identity.
For new definitions, provide the code explicitly. The array loader can derive a string code from a legacy numeric-only definition, but a persisted session must contain a valid graph_code to be restored. Do not recover a session’s identity by guessing from flow_id.
The other IDs have a smaller scope. Node and edge IDs identify positions and choices within a definition. Reusing an edge ID for a different connection in a later revision can change what an old history means. A new graph version is therefore a reason to check compatibility, not permission to reinterpret those IDs.
Graph versions and representation versions
Section titled “Graph versions and representation versions”A definition can carry several version fields because different things can change:
| Field or value | What it describes | Relationship to a session |
|---|---|---|
graph_version |
The revision of this process definition; use numeric triples such as 1.1.0. |
Stored as the session’s graph_version. |
dsl_version |
The declared DSL/model format understood by the compatibility checker. | Stored as the session’s dsl_version and compared when continuing. |
schema_version |
The declared graph representation schema, checked while loading. | It is a graph field, not a separate field in SessionState. |
| Installed package version | The release of the library, API or SDK that your application runs. | It is not the graph’s process revision. |
| Core state hash or API write generation | The saved session value or write that a concurrent request expects. | Used for conditional persistence. |
“Model version” describes the representation being checked; it does not introduce another model_version field into this graph. The DSL and schema contracts accept numeric major/minor forms such as 1.0, optionally with a numeric patch component. Session revision checks compare the stored strings exactly, so 1.0 and 1.0.0 are not interchangeable session values.
The loader’s compatibility configuration and the installed package release must also be considered separately. Version compatibility and session upgrades explains the loading checks and the explicit policy needed when a session’s revision differs from the available graph.
The session keeps its own revision
Section titled “The session keeps its own revision”The two definitions are available as versions-expense-1.0.json and versions-expense-1.1.json. Loading both gives your application two independent Graph objects:
use ExecKernel\Infrastructure\Engine\ExecKernelFactory;use ExecKernel\Infrastructure\Loader\JsonGraphLoader;
$loader = new JsonGraphLoader();$old = $loader->load(__DIR__ . '/versions-expense-1.0.json');$new = $loader->load(__DIR__ . '/versions-expense-1.1.json');$engine = (new ExecKernelFactory())->build();
$sessionA = $engine->start($old, 'en')->state;$sessionB = $engine->start($new, 'en')->state;$sessionA->graphCode and $sessionB->graphCode are both expense-approval. Their graphVersion values are 1.0.0 and 1.1.0. Keeping both objects in this example illustrates the same responsibility your application’s graph catalog has across requests.
When restoring A, retrieve its original definition or use an explicit revision-resolution policy. With no such policy, providing $new to resume(), getPayload() or choose() for A causes a version mismatch. Merely loading or publishing the new graph never updates A.
The engine compares the declared graph and DSL revisions; the session does not store the graph checksum. If your application silently changes a definition while keeping those version strings, that comparison cannot identify the replacement. Treat a published revision as immutable. Graph upgrade and publication pipeline shows how publication and readback can preserve a particular candidate.
What the checksum can tell you
Section titled “What the checksum can tell you”GraphChecksumCalculator::calculate($graph) returns a SHA-256 hash of a normalized projection. That projection includes the root node, node IDs and terminal flags, edge IDs and endpoints, labels, node metadata, terminal outputs and conditions.
use ExecKernel\Infrastructure\Loader\GraphChecksumCalculator;
$oldChecksum = GraphChecksumCalculator::calculate($old);$newChecksum = GraphChecksumCalculator::calculate($new);These two values differ because node 20 has different presentation text. Reordering the outer collections that the calculator sorts does not by itself change the corresponding projected content.
The projection does not include every graph property. It excludes the graph code, numeric graph ID, version declarations, default and allowed languages, and webhook declarations. Consequently, these comparisons have different results:
| Change to the first definition | Projection checksum |
|---|---|
| Change the review title | Changes. |
Change only graph_version |
Stays the same. |
Change only default_lang from en to es |
Stays the same, although the definition’s language policy changed. |
An equal checksum is useful when comparing that projection. It does not prove that two complete snapshots are exactly equal, or that a session can safely move between them. For immutable publication, compare the complete candidate according to the repository’s exact snapshot contract. For a session upgrade, check the session’s identity, revisions and history.
The complete identity example loads both downloadable definitions, starts one session on each and demonstrates these checksum comparisons. Place it and the two JSON files in your project’s root, alongside vendor/. It also attempts to resume a session with another graph code and receives EK-SESSION-002.
Changing a definition is covered in Graph migrations and rollback. Choosing whether an existing session may continue with that definition is the separate task developed in Version compatibility and session upgrades.