Advanced demos
The advanced demos show how to add a decision or a way of presenting and communicating results around ExecKernel. Each lets you follow three parts: the extension point provided by the engine, the code your application registers or configures, and the interface that uses the result.
You can explore them in a browser. If a demo retains an earlier path, select Reset and accept any confirmation to start a new execution. In all four, Graph JSON shows the definition and Source code opens the extension or integration files. The experiments below identify what to compare and where to find its explanation.
Custom rules: observe a decision evaluated on choice
Section titled “Custom rules: observe a decision evaluated on choice”A custom rule can express a calculation that built-in comparisons do not cover. Through custom_rule, the graph identifies a handler, a PHP fragment registered by the application that returns the decision.
We return to Custom rules, developed in Custom rule evaluation. The demo prepares units for delivery. From node 10, base route 102 requires at least six units; the Full boxes route, edge 103, additionally requires no remainder when grouping units into boxes of six.
- Set
quantityto7. The base route becomes available and the full-box route appears Pending. - Select Test route #103. The trial is rejected: seven units cannot fill boxes of six without a remainder. Confirmed context and path stay unchanged.
- Set
quantityto12and test again. The trial is accepted and observes a temporary terminal92. - Select Choose on the full-box route. This navigation commits
quantity: 12and moves the saved execution to terminal92.
Pending does not mean the engine is running a background task. The preview checks the built-in minimum but defers the handler until navigation. That is why seven and twelve produce the same pending state even though their trials have different outcomes.
Test route #103 is an action added by this application: it attempts SDK navigation on a disposable copy of state. An accepted trial enables its Choose button for that candidate. The real choice evaluates the rule independently again; the trial does not grant the engine permission or update the saved session.
Open Source code and select full_boxes.rule. This is its content:
return $api->context->get('quantity') >= $args['box_size'] && $api->context->get('quantity') % $args['box_size'] === 0;The runtime provides $api for reading context and $args with the condition’s parameters. Here, quantity changes with the form and box_size is the fixed integer 6 declared in the graph. The first term requires at least one box; the division remainder must be zero for full boxes to be accepted.
In RuleRegistration.php, locate the other required pieces: the loader allows the full_boxes name, and the engine receives its code and execution driver. The browser’s box illustration helps explain the grouping; acceptance of a transition comes from the engine’s evaluation.
Custom rule evaluation develops this handler route. Creating custom rules teaches the other route: implementing a rule class and registering it through a plugin.
Chart Lab: keep the path and extend the payload
Section titled “Chart Lab: keep the path and extend the payload”A plugin groups code registered with the engine. In this demo it adds an output hook, a presentation function that receives the prepared payload and returns that array with additional data.
We revisit Chart Lab, presented as an example in Payload output hooks. Its graph collects quantities produced by four departments, A, B, C and D. Each confirmation saves that department’s quantity and advances to the next; the final step completes the report.
In With chart plugin mode, enter 120, 280, 190 and 260, confirming each quantity. While you edit a field, you have a draft; the chart incorporates its value after confirmation. At completion, it shows a total of 850, an average of 212.5 and a maximum of 280.

Select Base engine, then Start new run. Changing mode creates another execution: enter the same four quantities again to make the comparison.
| Observation at report completion | Base engine | With chart plugin |
|---|---|---|
| Path | Nodes 10, 20, 30, 40 and 90. |
The same path. |
| Confirmed context | The four entered quantities. | The same quantities. |
Data in extras.chart |
Not added. | Series, shares, statistics and an indication that all four departments are complete. |
| Report presentation | The application explains that base mode has no chart. | The application draws the data and offers a chart download. |
The plugin does not change which department comes next. ChartPayloadHook reads confirmed quantities, calculates the data in PHP and adds it to extras.chart. The frontend uses Chartist to draw the series and displays the received statistics. The graph’s terminal declares no output; the chart and its download belong to this application’s presentation.
In Source code, start with ChartPayloadHook.php to find the calculation. ChartPlugin.php registers the hook, chart-plugin.json declares the extension, and PluginRegistration.php shows how the chosen mode builds the engine with or without that registry. Plugin architecture and lifecycle explains when that connection is made.
Webhook Lab: compare the terminal with the HTTP receipt
Section titled “Webhook Lab: compare the terminal with the HTTP receipt”A webhook lets you notify an execution event over HTTP. The subscription identifies the event of interest; delivery configuration connects that event to a request to the receiver.
We return to Webhook Lab, linked from Configuring webhooks. The demo collects dispatch details in two steps and subscribes only terminal 90 to the event of reaching a terminal.
In the first step, select Keyboard and quantity 3, then Confirm product. Execution moves to node 20, and context incorporates those values. The receiver is still waiting: confirming the product has not yet reached the subscribed node.
Then select Valencia and Urgent, and choose Confirm dispatch. Execution reaches the terminal. If delivery is confirmed, the receiver card shows 200 OK, one observed attempt and the received body. This excerpt of its fields connects the form to the notification:
{ "node_id": 90, "context_scope": "result", "context": { "product": "keyboard", "quantity": 3, "warehouse": "valencia", "priority": "urgent" }, "outputs": []}The complete body adds the identities of the event, graph, session and delivery. context_scope: "result" indicates that the resulting context is being sent; the second step’s values are already included. outputs: [] shows another distinction: a terminal can emit the subscribed event even when it has no terminal outputs.
Compare the formatted and raw JSON views. The demo retains the bytes returned by its receiver and records Received only when it gets HTTP 200 and that body matches the one sent. The receiver is a real HTTP service that validates the request and returns the same bytes; it does not process a dispatch.
Open Source code to follow the connection. WebhookLabService.php saves terminal state before publishing the deferred event batch. Delivery.php configures sending and records the transport observation. receive.cjs contains the receiver’s validation and response.
Graph completion and delivery have distinct states. A rejected or unconfirmed delivery does not undo the transition. This demo makes one attempt and has no durable queue or automatic retry; reading state or copying JSON does not resend the request. To design your application’s policy, see Webhook delivery, retries and queues.
QR Pass: give meaning to a custom output type
Section titled “QR Pass: give meaning to a custom output type”A custom output type establishes a specific result contract between the code producing it and the application using it. The engine’s registry recognizes its name and validates its fields; the interface implements the corresponding presentation.
We revisit QR Pass, the demo used in Custom terminal output types. Enter the fictional name Luna and select Create pass. Edge 101 leads from node 10 to terminal 90, with that name in confirmed context.
The extension’s output has type: "qr-pass", the name in content, a localized label, open_behavior: "new_tab" and a URL whose path ends in /qr-pass/pass/Luna. The backend constructs that URL using the demo’s configured origin. The frontend uses the received URL both to generate the QR and to provide the link beneath it.
Open the link to see the welcome page. The engine’s path stays at the terminal: opening the page or scanning the QR uses the result without choosing another edge. The demonstration pass grants no access rights. The name appears in its URL; use a fictional name. To open it from another device, that device must be able to reach the configured origin.
In Graph JSON, observe that outputs is empty. The result is produced from the confirmed name through the code available in Source code:
| File | What it contributes |
|---|---|
QrPassType.php |
Produces the qr-pass fields and checks its name, URL and other values. |
QrPassPayloadHook.php |
Adds the output to outputs[] when presenting terminal 90. |
QrPassPlugin.php |
Registers both the terminal type and the hook producing the output. |
qr-pass-plugin.json and PluginRegistration.php |
Declare the extension and connect it to the engine and graph loading. |
The difference from Chart Lab is the contract used: Chart Lab adds a structure to extras.chart; QR Pass produces an entry of a registered terminal type. In both cases, the application must know how to use the data. Registering qr-pass allows that output to be validated and returned; frontend code draws the QR.