Overview
This technical reference documents the Rules step’s input/output format, data types, and behavior specifications. Use this as a reference when building integrations or debugging rule execution.Input Schema
The Rules step accepts two required inputs:facts and rules.
Facts Input
Type:Object<string, any>
A flat key-value object where keys are fact identifiers and values are either static data or variable mapping expressions.
- Keys must be valid JSON strings
- Keys are case-sensitive
- Duplicate keys will be overwritten (last one wins)
- Values can be any valid JSON type or variable mapping expression
Rules Input
Type:Object<string, Rule>
An object where each key is a rule name (the output key) and each value defines how to calculate that rule.
Simple Rule Format
Direct calculation without conditions:Conditional Rule Format
Array of condition/outcome pairs evaluated top-to-bottom:- At least one outcome object required
- Last outcome typically has no condition (default case)
- First matching condition determines the result
- Conditions evaluated strictly in order
Output Schema
The Rules step returns a flat object with outcomes for each rule. Type:Object<string, any>
Data Types
The Rules engine works with standard JSON data types and performs automatic type coercion where appropriate.Supported Types
Number
Number
Floating-point numbers following JSON number specification.Examples:Operations: All math operatorsCoercion: Strings containing numbers are auto-converted in math operations
String
String
UTF-8 text strings.Examples:Operations: String operators, comparison operatorsNote: Empty string
"" is truthy in boolean contextBoolean
Boolean
True or false values.Examples:Operations: Logic operators, comparison operatorsCoercion:
- Truthy:
true, non-zero numbers, non-empty strings, non-empty arrays, objects - Falsy:
false,0,null,undefined
Null
Null
Represents absence of value.Example:Behavior:
- Falsy in boolean context
- Treated as
0in numeric operations - Treated as empty string in string operations
Array
Array
Ordered collection of values.Examples:Operations: Array operators, aggregation functionsNote: Empty array
[] is truthyObject
Object
Key-value collections.Examples:Operations: Lookup operators, JSON operatorsNote: Empty object
{} is truthyFact Referencing
Reference facts in rules using the@fact: prefix followed by the exact fact key.
Syntax
Resolution Order
- Check facts object - Look for exact key match in facts
- Check prior rules - If not found in facts, check rule outcomes
- Error if not found - Undefined references cause rule evaluation to fail
Nested References
Rules can reference other rules, creating a dependency chain:subtotal → tax → total
Operator Input Types
Different operators expect different input formats.Single Value
Operators that work on one value:Two Values
Binary operators:Multiple Values
Operators accepting variable arguments:Array Input
Operators that process arrays:Nested Operations
Operators can be nested as input values:Evaluation Process
Understanding how the Rules engine processes your rules:1
1. Variable Mapping Resolution
All facts containing variable mapping expressions (starting with
$) are resolved by fetching data from previous steps in the flow2
2. Dependency Analysis
The engine analyzes which rules reference which facts and other rules, building a dependency graph
3
3. Topological Sort
Rules are ordered so dependencies are evaluated before dependents (rules that need them)
4
4. Rule Evaluation
Each rule is evaluated in dependency order:
- For simple rules: operator is applied to inputs
- For conditional rules: conditions checked top-to-bottom until match found
5
5. Output Generation
All rule outcomes are collected into a flat output object with keys matching rule names
Circular Dependencies
The engine detects circular dependencies and will fail with an error: ❌ Invalid (circular):Circular dependency detected: a.value → b.value → a.value
Performance Characteristics
Understanding performance implications of rule design:Time Complexity
| Operation Type | Complexity | Notes |
|---|---|---|
| Simple rule evaluation | O(1) | Direct calculation |
| Conditional rule | O(n) | n = number of conditions |
| Dependency resolution | O(n + m) | n = rules, m = dependencies |
| Array operations | O(k) | k = array length |
| JSONPath queries | O(k) | k = array length |
Best Practices
Minimize Conditions
Use
between operator instead of multiple >= conditions when possibleReuse Calculations
Calculate once and reference multiple times rather than recalculating
Limit Nesting
Deep nesting reduces readability and debuggability - break into multiple rules
Optimize Array Operations
Extract array values once with jPath, then reuse the extracted arrays
Memory Considerations
- Facts: Stored in memory during execution
- Intermediate results: Each rule outcome stored for potential reuse
- Arrays: Large arrays (>10,000 elements) may impact performance
Error Handling
Common error scenarios and their meanings:Undefined Reference
Error:Undefined fact reference: @fact:nonexistent.value
Cause: Referenced a fact or rule that doesn’t exist
Solution: Check spelling, ensure fact is defined, or that dependent rule is defined
Invalid Operator
Error:Unknown operator: invalidOp
Cause: Used an operator name that doesn’t exist
Solution: Check Operations Reference for valid operators
Type Mismatch
Error:Type error: cannot perform 'add' on string and number
Cause: Operator received incompatible types
Solution: Ensure operands are correct types or use type conversion operators
Circular Dependency
Error:Circular dependency detected: rule1 → rule2 → rule1
Cause: Rules reference each other in a loop
Solution: Restructure rules to eliminate circular references
Malformed Rule
Error:Invalid rule format for 'ruleName.value'
Cause: Rule doesn’t match simple or conditional format
Solution: Ensure rule has operator and input fields, or is an array of condition/outcome objects
Debugging Tips
Use Flow Debugger
Use Flow Debugger
The Flow Debugger shows:
- Input facts after variable mapping resolution
- Each rule’s outcome
- Evaluation order
- Errors with context
Simplify Complex Rules
Simplify Complex Rules
Break complex rules into smaller steps:❌ Hard to debug:✅ Easy to debug:
Check Variable Mapping
Check Variable Mapping
Ensure variable mapping expressions in facts are valid:
- Use correct
$.step_id.propertysyntax - Referenced step must execute before Rules step
- Property path must exist in step output
Verify Data Types
Verify Data Types
Common type issues:
- Strings that should be numbers:
"100"vs100 - Null/undefined values in calculations
- Empty arrays in aggregations
Test Edge Cases
Test Edge Cases
Test with boundary values:
- Empty arrays
[] - Zero values
0 - Null values
null - Empty strings
"" - Large numbers
- Negative numbers
Integration Patterns
Using Rules Step Output
Access rule outcomes in subsequent flow steps using variable mapping:Passing Arrays
When passing arrays to subsequent steps, the entire array is available: Rules output:Conditional Flow Routing
Use rule outcomes to determine flow paths:Limits & Constraints
Be aware of these limitations:| Constraint | Limit | Notes |
|---|---|---|
| Max rules per step | 1,000 | Performance degrades beyond this |
| Max fact size | 10 MB | Total size of all facts |
| Max rule depth (nesting) | 50 | Nested operator depth |
| Max array length | 100,000 | Individual array processing |
| Execution timeout | 30 seconds | Total rule evaluation time |
| Max conditions per rule | 100 | Conditional rule branches |
What’s Next?
Getting Started
Build your first rule with step-by-step guidance
Core Concepts
Understand how the Rules engine works
Operations Reference
Complete reference for all available operators
Examples Library
Real-world examples with complete code
Need Help? Visit our Help Center or join the Community for support.