Migration plan format
A migration plan is an ordered list of changes to a graph snapshot. The parser recognizes the document and its action names; the validator checks the actions against a specific source; the applier produces a new snapshot. The publication pipeline adds further requirements before treating that snapshot as an executable graph revision.
Use this reference to look up an action or identify which surface can apply it. Migrations and rollback and the upgrade publication pipeline explain the complete procedures.
Plan document
Section titled “Plan document”The parser accepts JSON or YAML. File extensions .json, .yaml and .yml select the format; without an explicit format, content beginning with { or [ is attempted as JSON and other content as YAML. YAML requires an available supported parser.
| Field | Type and presence | Contract |
|---|---|---|
version |
Required string | Migration identity in X.Y.Z-mig.N form. It must advance the source snapshot’s migration ledger. |
author |
Optional string or null |
Attribution, with no execution effect. |
description |
Optional string or null |
Description, with no execution effect. |
actions |
Required nonempty list of objects | Applied in list order. Each object has a recognized type. |
source_snapshot_hash |
Optional string or null |
Exactly 64 lowercase hexadecimal characters. When present, it must equal MigrationSnapshot::hash($sourceSnapshot). |
JSON duplicate keys, an object used in place of the actions list, unknown action names and an empty action list are rejected. Parsing does not establish that an action’s referenced node or edge exists; that is checked against the snapshot during validation.
The numeric components of version must fit the supported integer range. The ledger applied_migrations is a list of migration versions in strictly increasing numeric order. Counters with different zero padding, such as mig.1 and mig.001, identify the same numeric position and cannot be applied twice.
Migration version, source hash and graph version
Section titled “Migration version, source hash and graph version”| Value | Meaning |
|---|---|
Plan version |
Records which migration was applied. |
Plan source_snapshot_hash |
Binds the plan to the exact source snapshot, including its ledger, collection order and value types. Use MigrationSnapshot::hash() rather than hashing a pretty-printed JSON file. |
Snapshot graph_version |
Identifies the graph revision represented by the snapshot. |
UpgradeExportRequest::targetGraphVersion |
Explicit destination revision supplied to the publication pipeline. It must be valid SemVer and strictly later than the source graph revision. |
MigrationApplier::apply() does not derive a target graph version from the migration name and does not change graph_version automatically. The pipeline materializes the actions, then assigns the separately requested target version.
Minimal bound plan
Section titled “Minimal bound plan”This plan changes the English title of node 10 from Review to Review request. It leaves the node ID and graph topology unchanged. Its hash binds it to the source snapshot supplied with the example.
{ "version": "1.0.0-mig.1", "source_snapshot_hash": "a23cb1f12e8ca983df20e75779e9f63ac810e0139bdf9dd12e65cf8d9d64343a", "actions": [ { "type": "RENAME_NODE", "nodeId": 10, "lang": "en", "title": "Review request" } ]}Download migration-plan-example.json, which also includes optional author and description fields. Applied to that source in CompatibilityMode::LOOSE, it changes the title, appends 1.0.0-mig.1 to the ledger and retains graph version 1.0.0. A pipeline request can separately choose a later graph revision.
Node and presentation actions
Section titled “Node and presentation actions”IDs below are actual integers. Strings such as "10" are not coerced. “Pipeline” means the action is admitted by the publication action check; graph validation, source binding and the remaining stages must still succeed.
| Action | Required fields after type |
Optional fields and effect | Pipeline |
|---|---|---|---|
ADD_NODE |
nodeId: int, metadata: array |
is_terminal: bool or alias isTerminal. Adds the node and its metadata. Empty metadata is allowed at this action boundary, subject to resulting graph validation. |
Yes |
REMOVE_NODE |
nodeId: int |
Node must exist and have no incident edges at this point in the plan. Removes its metadata and outputs as well. Strict mode rejects an active node. | Yes |
UPDATE_NODE_METADATA |
nodeId: int, metadata: array |
Replaces all metadata rows for that node. | Yes |
RENAME_NODE |
nodeId: int, title: string |
Title aliases: name, value, text. lang may be omitted if the snapshot has default_lang. Changes a localized title, never the ID. |
Yes |
MARK_AS_TERMINAL |
nodeId: int |
Sets terminal state to true. Strict mode rejects changing an active node. |
Yes |
SET_NODE_TERMINAL |
nodeId: int, is_terminal: bool |
isTerminal is an alias. Sets either terminal state; strict mode rejects a change on an active node. |
Yes |
SET_TITLE |
nodeId: int, lang: string, value: string |
Value aliases: title or text. Updates this field in the language row. |
Yes |
SET_SUBTITLE |
nodeId: int, lang: string, value: string |
Value aliases: subtitle or text. |
Yes |
SET_DESCRIPTION |
nodeId: int, lang: string, value: string |
Value aliases: description or text. |
Yes |
ADD_TRANSLATION |
nodeId: int, lang: string, at least one non-null title/subtitle/description string |
Upserts the language row. Unspecified presentation fields become null. |
Yes |
REMOVE_TRANSLATION |
nodeId: int, lang: string |
Removes the matching metadata language row if present. | Yes |
Except for ADD_NODE, these actions require an existing node. A title/value required by a field-setting action must be a nonempty string. If several aliases are present, their values must be strictly equal.
metadata accepts either a list of language rows or maps of language to value under title, subtitle and description. For example, these two payloads express the same title:
[ {"lang": "en", "title": "Review request"}]{"title": {"en": "Review request"}}Rows use nonempty language strings; title, subtitle and description values are strings or null. Omitted presentation fields normalize to null. A replacement action replaces the node’s complete metadata collection, so include every language you intend to retain.
Edge and rule actions
Section titled “Edge and rule actions”| Action | Required fields after type |
Effect and restrictions | Pipeline |
|---|---|---|---|
ADD_EDGE |
edgeId: int, from: int, to: int |
Both nodes must exist. Optional labels: array and rules: array add declarations for the edge. |
Yes |
REMOVE_EDGE |
edgeId: int |
Removes the edge, its labels and its conditions. Strict mode rejects an active edge. | Yes |
UPDATE_EDGE_RULES |
edgeId: int, rules: array |
Replaces all conditions on the edge. Strict mode rejects an active edge. | Yes |
UPDATE_EDGE_LABELS |
edgeId: int, labels: array |
Replaces all labels on the edge. | Yes |
REMAP_EDGE_TARGET |
edgeId: int, newTo: int |
Destination node must exist. Strict mode rejects an active edge. | Yes |
ADD_RULE |
edgeId: int, rule: array |
Adds one condition. Strict mode rejects a duplicate or an active edge. | Yes |
REMOVE_RULE |
edgeId: int, rule: array |
Requires exactly one match by rule family, exact parameters and, if supplied, version. Strict mode rejects an active edge. | Yes |
PATCH_RULE |
edgeId: int, rule: array |
Requires exactly one existing condition of that rule family. Replaces its parameters in place; an optional version updates that field. Strict mode rejects an active edge. | Yes |
DISABLE_EDGE |
edgeId: int |
Adds the existing edge ID to the snapshot’s disabled_edges bookkeeping. Strict mode rejects an active edge. |
No |
ENABLE_EDGE |
edgeId: int |
Removes the existing edge ID from disabled_edges. |
No |
Every edge action except ADD_EDGE requires an existing edge. An edge added earlier in the plan can be referenced by a later action.
labels accepts a language/text map such as {"en":"Continue"} or a list such as [{"lang":"en","text":"Continue"}]. Both language and text must be nonempty strings. UPDATE_EDGE_LABELS with an empty list removes all labels for that edge.
A nested rule payload identifies its family with rule or its alias type. Parameters can be under params or directly beside the family name. Combining a params wrapper with extra parameter fields is ambiguous and rejected. Optional edge_id must agree with the outer edgeId; optional version is retained.
This action fragment replaces the parameters of the unique context_value condition on edge 101:
{ "type": "PATCH_RULE", "edgeId": 101, "rule": { "rule": "context_value", "params": {"key": "reviewed", "operator": "==", "value": true} }}If that edge has two context_value conditions, the action is rejected; it has no occurrence-index selector. PATCH_RULE does not merge individual parameter keys. Rule parameters defines the resulting condition’s own requirements.
In loose mode, adding an existing node, edge or identical rule can be a no-op only when the requested declaration agrees with what already exists. Loose mode does not turn contradictory duplicate declarations into updates. A rule with the same family and parameters but a conflicting version is rejected.
Version-catalogue actions
Section titled “Version-catalogue actions”| Action | Fields | Snapshot effect | Pipeline |
|---|---|---|---|
CREATE_FLOW_VERSION |
value: string, alias version |
Adds a SemVer entry to flow_versions. |
No |
DEPRECATE_FLOW_VERSION |
value: string, alias version |
Requires an existing entry and removes it. Clears default_flow_version if it selected that entry. |
No |
SET_DEFAULT_FLOW_VERSION |
value: string, alias version |
Requires an existing entry and selects it as default_flow_version. |
No |
These actions and DISABLE_EDGE/ENABLE_EDGE are recognized by the format and the snapshot applier. The publication pipeline rejects all five through UpgradeGraphExport::assertRuntimeActions() because they do not have a verifiable runtime effect through this path. It also rejects a candidate with nonempty disabled_edges. That field does not disable navigation at runtime.
The version-catalogue actions do not substitute for targetGraphVersion and do not publish graph revisions themselves. No action in this format migrates running sessions.
Source snapshot and validation
Section titled “Source snapshot and validation”MigrationValidator::validate(MigrationPlan $plan, array $graphSnapshot, CompatibilityMode $mode): void validates source shape, source binding, migration ordering and the action sequence, then validates the resulting graph.
| Snapshot data | Requirement |
|---|---|
engine_version, graph_code, graph_version, dsl_version, schema_version |
Nonempty strings required for graph validation. Graph versions and model versions are interpreted by their respective contracts. |
nodes / edges |
Lists of declarations with unique integer IDs. Structural references must remain valid. |
metadata, labels, outputs, conditions |
When present, lists of declaration rows. Their resulting values undergo graph validation. |
active_nodes / active_edges |
Explicit lists required in strict mode. IDs must exist and cannot repeat. Your application supplies these facts; the validator does not inspect a live session store. |
disabled_edges |
Optional list of distinct existing edge IDs for snapshot bookkeeping; not a runtime restriction. |
flow_versions |
Optional list of distinct valid SemVer strings. |
default_flow_version |
Optional null or an entry present in flow_versions. |
applied_migrations |
Optional list, default [], following the ordering rules above. |
Actions are validated in order. Remove an edge before removing a node it references, and add a node before an edge targeting it. The final graph still needs valid root, terminal, language and rule contracts; an action being syntactically valid is insufficient.
MigrationApplier::apply(MigrationPlan $plan, array $graphSnapshot, CompatibilityMode $mode): array returns a detached new snapshot and appends the migration version. It validates before and after applying. It does not write a repository or mutate the caller’s source array.
Compensation contract
Section titled “Compensation contract”RollbackPlanBuilder::build(MigrationPlan $plan, array $graphSnapshot, string $rollbackVersion, ?string $author = null, ?string $description = null, CompatibilityMode $mode = CompatibilityMode::LOOSE): MigrationPlan needs the original snapshot, not only the forward plan. It applies the forward change, builds compensating actions in reverse order, binds the compensation to the changed snapshot’s hash, applies it, and compares restored content with the source.
The comparison deliberately excludes applied_migrations and normalizes selected absent/empty metadata fields. The ledger continues forward: compensation is another migration, not erasure of history. Collection order and meaningful value types still matter.
Download the example’s compensation plan. It restores Review and leaves the ledger containing 1.0.0-mig.1 followed by 1.0.0-mig.2. A changed forward snapshot fails the compensation’s source-hash check.
A syntactically reversible action may lack a faithful automatic compensation. Removing a node can remove outputs that the generated ADD_NODE cannot restore; replacing a missing former default cannot recover an unknown value. The builder rejects a compensation that fails its content comparison. Retain the original immutable revision and the forward candidate as evidence.
Within the publication pipeline, the compensation is rebound to the materialized target candidate and checked again. It compensates content while retaining the candidate’s graph-version identity; producing the plan does not automatically republish the old revision or restore live sessions.