Skip to content

Support conditional nodes#16

Merged
johanflint merged 6 commits into
mainfrom
feature/conditional-node
Oct 31, 2025
Merged

Support conditional nodes#16
johanflint merged 6 commits into
mainfrom
feature/conditional-node

Conversation

@johanflint

Copy link
Copy Markdown
Owner
  • Add conditional node
  • Normalize Number types to floats for hashing and comparison
  • Validate that all link values are unique

The outgoing node of a flow node can now be an object that contains a node id and a value.
This allows the flow engine to determine which node to execute next based on the value of a condition.
Replaces the `Option` type in `FlowLink` with a `Value` enum.
This change allows `FlowLink` to carry more varied data,
which will be used for conditional node execution.

This change also updates all usages of `FlowLink` to use `Value::None`
instead of `None`.
Adds support for conditional flow nodes, allowing the flow engine
to execute different branches based on an expression.

Improves flow factory to handle multiple outgoing nodes and
ensures proper validation of node connections, preventing
cycles and orphaned nodes.

Adds a test case to validate multiple parent nodes.
Adds validation to ensure that outgoing links from a node
have unique values, preventing ambiguous flow execution paths.

Introduces `ordered-float` to allow `f64` values to be used
in hash maps.
Normalizes different `Number` types to floats before hashing and comparison.

This change ensures that numerical values are treated consistently regardless of their underlying representation (e.g., `Number::Float(1.0)` and `Number::PositiveInt(1)` are considered equal). It uses `OrderedFloat` to properly handle `NaN` values in comparisons.

This ensures that PartialOrd, PartialEq and Hash agree semantically, so that NaN, -0.0, etc. are treated consistently.
Adds support for conditional flow nodes, allowing flows to branch based on expression evaluation.

The engine now evaluates expressions within conditional nodes and navigates to the corresponding outgoing node based on the result.
Error handling is included for failed evaluations and missing flow links.
@johanflint johanflint force-pushed the feature/conditional-node branch from 062cf96 to 7016fdb Compare October 31, 2025 12:19
@johanflint johanflint merged commit 33b917b into main Oct 31, 2025
6 checks passed
@johanflint johanflint deleted the feature/conditional-node branch October 31, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant