FlexiRule Docs
Resolver
Resolvers are the "Data Glue" of FlexiRule. They solve a fundamental problem: **How do we get dynamic data into an action without writing Python?**
Resolver: Resolver Engine#
π― The Purpose of Resolvers#
Resolvers are the “Data Glue” of FlexiRule. They solve a fundamental problem: How do we get dynamic data into an action without writing Python?
Instead of hardcoding field paths, FlexiRule uses a Value Resolution Pipeline.
ποΈ Resolver Architecture#
The engine uses a Compiled Resolver Graph. When a rule is loaded, its dynamic values are “compiled” into optimized resolver objects.
The CompiledResolver Hierarchy#
StaticResolver: Returns a constant value.VariableResolver: Resolves a path likedoc.customer_nameorvars.total.MathFormulaResolver: Performs arithmetic (a + b,a * b) on context variables.DateFormulaResolver: Handles date math (Today + 7 days).NormalizationResolver: Cleans data (Trimming, Scrubbing).FormatResolver: Formats dates and currency.ExpressionResolver: The most powerfulβit chains multiple segments (Text + Token + Token) into a single result.
π The Resolution Lifecycle#
- Request: An action needs a value (e.g., “Assign to Field”).
- Dispatch: The
ValueResolver.compilemethod determines the resolver type from the configuration JSON. - Execution: The
resolve(context)method is called. It performs the logic (e.g., fetching from DB, calculating a sum). - Output: The raw value is returned to the action.
π Hidden Power: Chained Composition#
Because resolvers are objects, they can be nested.
- A
NormalizationResolvercan take the output of aVariableResolver. - An
ExpressionResolvercan combine aStaticResolver(“Order #”) with aVariableResolver(doc.name).
This enables Low-Code Logic Composition:
“Format the (Sum of (Child Table.Amount)) as Currency (USD)”
π Latent Capabilities#
The architecture is prepared for even more advanced patterns:
- Recursive Resolution: Resolvers that resolve other resolvers.
- Lazy Evaluation: Values that are only calculated when actually accessed.
- Caching: The
get_compiled_resolverhelper already uses request-local caching, making the system extremely fast even with hundreds of dynamic bindings.