Execution lifecycle and confirmed state
A session starts at a graph’s root. Your application obtains the current step, requests a choice and receives the result of that choice. After the new state has been saved, it can present the confirmed progress and repeat the cycle until the session reaches a terminal.
This cycle lets a process continue across separate interactions. The person using your application can make one choice now and another later; the retained session state tells the engine where to continue.
From the first step to a terminal
Section titled “From the first step to a terminal”Starting a session creates its initial state at the graph’s root, with the supplied context and a history containing that starting node. The result also describes what the application can present at that position: for example, a title and choices.
Your application uses that result to show the current step or decide its next action. Reading the options does not move the session. A move happens when the application requests a specific edge, optionally supplying new data for that choice.
The engine then checks the request against the graph and session. If it accepts the choice, it returns the new state and a payload for the destination. The integration saves the new state so that the next interaction can continue from that position.
Your application can now present the accepted result. At an ordinary node, it may show the next choices and wait for another request. At a terminal, navigation is complete, and it can present any output associated with that terminal. A terminal without outputs still completes the route.
The same cycle applies whether the choices come from a person or from your application’s own logic. Each advance is requested explicitly.
When an advance is confirmed
Section titled “When an advance is confirmed”Evaluating a choice and retaining its result are two parts of the operation. A calculation that accepts an edge tells you what the next state should be. To rely on that progress in a later interaction, the state must also be recorded by the configured session store.
Who coordinates that work depends on the integration described in Architecture and components:
| Integration | Who retains the state? | What a successful result means |
|---|---|---|
| Direct PHP engine | Your application saves the state returned by the engine. | The engine has accepted the choice. Your application still needs to confirm its own storage operation. |
| Local PHP SDK | The SDK coordinates execution and the configured session store. | For session creation and navigation, storage has been confirmed before the SDK returns the result. |
| HTTP API with stored sessions | The API coordinates execution and session storage on the server. | For session creation and navigation, the API confirms storage before preparing the successful response. |
Your application should use that confirmed result when it presents a step as completed. If it embeds the engine directly, receiving the engine’s result is not yet confirmation that the state has been saved.
The choice of store determines how state is retained. Confirmation means that the configured store has accepted the operation; the storage and deployment choices are covered in Session stores.
Continuing from retained progress
Section titled “Continuing from retained progress”On a later interaction, the integration retrieves the retained state and the corresponding graph. The current node, context and history let it continue the same session instead of starting again at the root.
If an operation fails or your application does not receive a response, it should establish the current session state before presenting a guessed result. An error alone does not prove that nothing was saved. Client errors, transport and diagnostics covers those situations.
For the concrete calls that start, inspect and advance a session, continue with Starting and navigating sessions.