Rule Engine Core¶
Parse YAML rule DSL into an AST, evaluate conditions/actions, and provide rule, constant, batch, and audit services.
Use the AST parser/evaluation engine for the embedded rule path; use RulesEvaluationService for the request/audit service path. Validate YAML and input variable names before production evaluation and inspect action/function behavior in the focused DSL tests.
| Maven artifact | Packaging | Source project |
|---|---|---|
org.fireflyframework:fireflyframework-rule-engine-core |
jar |
modules/rule-engine/fireflyframework-rule-engine-core |
Part of Business operations.
In the onboarding service¶
Evaluate a validated onboarding rule against application input through the parser/engine or the audited service path. Custom functions and external calls must be registered/configured by the application.
Add the component¶
Installation and version availability explains source builds and published releases.
<dependency>
<groupId>org.fireflyframework</groupId>
<artifactId>fireflyframework-rule-engine-core</artifactId>
<version>26.10.20-SNAPSHOT</version>
</dependency>
Quick start¶
The Java examples in this section are API fragments for application code. Use the stated imports and supply the application-owned collaborators described alongside them.
Choose the entry path to match your runtime:
- For embedded DSL evaluation, use
ASTRulesDSLParserandASTRulesEvaluationEngine; the platform quick start demonstrates the YAML and evaluation flow. - For service evaluation with an audit context, inject
RulesEvaluationServiceand callevaluateRulesPlainWithAudit(request, exchange),evaluateRulesDirectWithAudit(...), orevaluateRuleByCodeWithAudit(...). - Use
YamlDslValidatorand the structured validation DTOs to report authoring problems before evaluating a stored rule.
RulesEvaluationService accepts the matching interfaces DTO and a ServerWebExchange for audit context. A base64-encoded rule and plain YAML use different request DTOs. Custom functions are registered through the source CustomFunctionRegistry; the DSL tests are the reference for supported expressions and actions.
Configuration and wiring¶
This module declares no @ConfigurationProperties class of its own. Use the constructor/port contracts above and the configuration of the host or related core module.
Property-based wiring conditions found in this module:
prefix = "firefly.observability.metrics", name = "enabled", havingValue = "true", matchIfMissing = true. RuleEngineObservabilityAutoConfiguration.java.
Public API and extension points¶
| Type | Contract and responsibility |
|---|---|
ASTRulesDSLParser |
Pure AST-based rules DSL parser that converts YAML directly to AST nodes. |
ASTRulesEvaluationEngine |
Pure AST-based rules evaluation engine with no legacy dependencies. |
RulesEvaluationService |
Service interface for rules evaluation operations. |
YamlDslValidator |
Comprehensive YAML DSL validator that orchestrates all validation components. |
CustomFunctionRegistry |
Registry of user-defined RuleFunction implementations available to the rule DSL. |
Related components¶
| Related component | Why it belongs nearby |
|---|---|
| Rule Engine Library | Group the YAML rule evaluator, public DTOs, persistence models, HTTP service, and generated SDK. |
| Rule Engine Interfaces | Share request/response DTOs, rule definitions, validation results, and value/result enums for the rule engine. |
| Rule Engine Models | Persist rule definitions, constants, and audit trails with reactive repositories. |
| Kernel | Share a consistent exception vocabulary across application, domain, and infrastructure boundaries. |
| Starter Core | Assemble core infrastructure conventions for WebClient, actuator, logging, configuration, and service discovery. |
| Common Cache Library | Use a common cache API with a local Caffeine default and pluggable distributed providers. |
Build and test¶
Use Java 25. From the repository root, build this component with its required dependencies:
git clone https://github.com/fireflyframework/fireflyframework-jafly.git
cd fireflyframework-jafly
./mvnw -pl :fireflyframework-rule-engine-core -am verify
./mvnw -pl :fireflyframework-rule-engine-core -am install
verify runs the selected projects' tests. install makes the current build available in your local Maven repository.
Representative test sources:
- AuditHelperTest.java.
- CacheIntegrationTest.java.
- ASTParserIntegrationTest.java.
- AdvancedDSLFeaturesTest.java.
- ArithmeticActionSymmetryTest.java.
- B2BCreditScoringEngineTest.java.
Test fixture¶
The percentile test demonstrates one concrete behavior. Excerpt from DroolsDmnParityFeaturesTest.java. The test class supplies its fixtures and imports.
@Test
@DisplayName("percentile() interpolates between sorted samples")
void percentile() {
String yaml = """
name: pct
then:
- run p50 as percentile([1,2,3,4,5,6,7,8,9,10], 50)
- run p90 as percentile([1,2,3,4,5,6,7,8,9,10], 90)
output:
p50: p50
p90: p90
""";
ASTRulesEvaluationResult r = engine.evaluateRules(yaml, Map.of());
assertThat(r.isSuccess()).isTrue();
// p50 of 1..10 -> 5.5 ; p90 -> 9.1
assertThat(((BigDecimal) r.getOutputData().get("p50")).doubleValue()).isEqualTo(5.5);
assertThat(((BigDecimal) r.getOutputData().get("p90")).doubleValue()).isEqualTo(9.1);
}
Continue the application¶
Use the Rule Engine Interfaces guide for the next part of this integration. The runnable submission/query service is in Getting started.