Condition evaluation and edge availability
A condition is a test attached to an edge. It decides whether the session meets a requirement for following that choice: a context value may need to match, an earlier step may need to have been visited, or a time window may need to be open.
Your application uses these decisions in two moments. When it requests a payload, ExecKernel reports the availability of the outgoing edges so the application can present its options. When the application submits a choice, the engine evaluates that specific transition again. The first observation helps your application build a useful screen; the second decides whether the session can advance.
From a condition to an option
Section titled “From a condition to an option”An edge can have several conditions. All must allow the transition. During actual evaluation, a normal false result stops the remaining conditions on that edge. An edge without conditions has no rule requirement, although session, policy and navigation checks still apply.
To make this visible, we return to the learning-path graph introduced in Anatomy of a graph. At node 10, edge 101 leads to a guide at terminal 20, and edge 102 leads to browser practice at terminal 30. The guide has no condition. Practice requires the application to supply practiceEnabled: true.
This condition record belongs to the practice edge:
{ "edge_id": 102, "rule": "context_value", "params": { "key": "practiceEnabled", "operator": "==", "value": true }}The graph defines the requirement. Your application supplies the value being checked, for example from its own decision about whether practice is available. If that value is false, the engine keeps the practice edge in the payload and marks it as blocked. Your application can show the choice disabled and explain why.
The following extract contains only the relevant fields from the two outgoing edges:
{ "edges": [ { "id": 101, "enabled": true, "disabled_reason": null, "availability": "available" }, { "id": 102, "enabled": false, "disabled_reason": "context_value_failed", "availability": "blocked" } ]}The labels and other presentation fields remain available in the full payload. Your application combines them with availability to build its interface; context_value_failed is a technical reason that it can translate into a suitable message, such as “Practice is not available for this session.”
The three availability states
Section titled “The three availability states”An engine payload separates whether an option may be offered from how much its conditions have been evaluated:
availability |
enabled |
disabled_reason |
Meaning for your application |
|---|---|---|---|
available |
true |
null |
The preview checks passed. Offer the choice and handle the result of the actual request. |
blocked |
false |
A reason such as context_value_failed |
A known check prevents the transition. Disable the choice or otherwise explain its current restriction. |
pending |
true |
null |
A decision has been deferred. The application may offer an attempt, with wording that makes the remaining check clear. |
enabled is always a boolean. Both available and pending have enabled: true, so this field alone does not tell your application whether every condition has run. In a debug payload, debug.edges[*].allowed does distinguish them: it is true, false or null for available, blocked or pending, respectively.
Availability also includes restrictions beyond the condition itself. For example, an expired session, a navigation policy or the cycle protection can block an edge. A malformed condition can appear as blocked with disabled_reason: "condition_evaluation_error". Your application should distinguish a normal unmet requirement from an evaluation problem when explaining the result. Rejected transitions and error recovery develops that response.
A node with every outgoing edge blocked remains an ordinary node. It has not become a terminal, and the engine does not choose a fallback route automatically.
Why an option can be pending
Section titled “Why an option can be pending”The normal preview evaluates built-in conditions that inspect context, history or time. It checks rule registration and the parameters defined by the built-in contracts, including the custom_rule handler reference. It does not execute that handler or rules supplied as registered external types; those external rules own their parameter schemas.
If one of those conditions still needs to run and no known check blocks the edge, the result is pending. This is a deferred decision, not an asynchronous job: nothing has been scheduled to finish in the background. Repeatedly reading the payload does not run the deferred code.
The engine continues inspecting the built-in conditions even when a custom condition is pending. If a built-in condition fails, the whole edge is blocked. Likewise, a missing handler or an already open custom-rule circuit can produce a known block during preview. “Contains custom code” does not automatically mean “pending.”
Custom rule evaluation follows this distinction through a concrete rule and its real choice result.
Changing the view without advancing
Section titled “Changing the view without advancing”The same session can produce different option views when your application supplies different candidate context values. We continue with the learning-path graph above: $graph is loaded, $engine is configured, and $state is the current state at node 10, with practiceEnabled: false and no selected edge.
Your application can ask what the options would be with practice enabled:
use ExecKernel\Domain\Session\Context;
$updates = new Context(['practiceEnabled' => true]);
$view = $engine->getPayload( $graph, $state, 'en', contextUpdates: $updates,);
$practice = array_column($view['edges'], null, 'id')[102];Here, $updates supplies the candidate value used for this query. The returned practice option has availability: "available" and enabled: true. The original $state still contains practiceEnabled: false; its node and history have not changed. Context updates and candidate values explains how those candidate values are assembled.
This is an illustrative view your application could render. The changed button state reflects the query’s inputs, while the session remains at the same position.
Use an engine operation such as getPayload() to obtain this evaluated view. The lower-level PayloadBuilder can construct presentation data without an availability observation; in that case its options default to pending.
Choosing checks the transition again
Section titled “Choosing checks the transition again”When the person chooses practice, your application sends edge 102 and the values it intends to use for that choice:
$result = $engine->choose( $graph, $state, 102, 'en', contextUpdates: $updates,);The engine uses the state, candidate context and evaluation time for this operation. It verifies the edge belongs to the current node, checks the applicable conditions and navigation protections, and returns a new state only when the transition is accepted. With the example’s true value, that result reaches terminal 30 and includes the accepted context.
If your application instead supplies practiceEnabled: false for the choice, the condition rejects it even though the previous query showed an available option. A time window can also close between display and selection. Deferred custom code may return false when it finally runs.
For a normal condition rejection, direct PHP navigation throws ForbiddenEdgeException with code EK-SEC-NAV-002 and leaves the input state unchanged. Your application can keep the confirmed step, explain the rejection and refresh its options. A successful direct-engine result still needs to be saved by your integration, as explained in Execution lifecycle and confirmed state.
Availability is therefore an observation for presenting a choice, not a reservation of that transition. Use the actual choice result to decide what your application presents as completed.
To explore changing options interactively, open Context and conditions in the Showcase. For the rules behind those decisions, continue with Context and history-based rules or Temporal conditions and TimeDSL.