Code Effects vs. RETE-Based Rules Engines:
Imperative Chaining vs. Forward-Chaining

Short answer: Code Effects does not implement the RETE algorithm, and that's a deliberate design decision, not a missing feature. RETE-based engines like Drools (with its Phreak algorithm) and NRules use forward-chaining to automatically infer which rule should fire next based on prior evaluation results or data changes. Code Effects instead uses imperative chaining: the business explicitly defines which rule runs next, rules are pre-compiled to IL, and circular references between rules are prevented by validation when a rule is saved - in the editor and, in the Rule Repository, on every save and every Go Live - so a cycle never reaches production. The trade-off is real in both directions - RETE gives you automatic dependency inference across large, loosely-coupled rule networks; Code Effects gives you speed, predictability, and acyclic rule chains in exchange for the business declaring the chain instead of the engine inferring it. In Code Effects 7, that explicit chain also becomes part of the rule language itself, through inline rules, and part of a governed rule lifecycle with versions, tests and approvals.

Comparison at a Glance

Code Effects RETE-Based Engines (Drools, NRules, etc.)
Core algorithm Custom evaluation engine, rules compiled to IL RETE algorithm or a RETE derivative such as Drools' Phreak (pattern-matching network)
Rule chaining model Imperative chaining - the business declares the next rule explicitly, through reusable rules in conditions, inline rules in THEN/ELSE actions, or a developer-defined action that runs a rule by ID Forward-chaining - engine infers next rule from data/state changes
Circular reference protection Validation at save time: the editor's server-side validation follows every rule a rule references, at any depth, through a GetRuleDelegate rule resolver, and refuses a rule whose references lead back to itself; the Rule Repository repeats the check on every save and every Go Live, and also prevents changes that would break a calling rule Not automatic - relies on human discipline, engine features that limit re-firing, or manual salience/agenda-group design
Infinite-loop prevention tools Not needed for referenced rules - cycles are rejected before a rule is saved Drools: property reactivity by default, plus salience, agenda-group / ruleflow-group, activation-group, no-loop, lock-on-active; NRules: rule priority and a repeatability setting
Rule authoring UI Built-in visual, sentence-based Rule Editor; with the Rule Repository, also an AI Rule Editor that writes rules from instructions in any language Typically none, or a separate/limited add-on (e.g., Drools has no built-in visual DRL authoring UI since Business Central was retired, and NRules rules are C# code)
Rule management Rule Repository: immutable versions, drafts, tests, and a decision workflow of approval, Go Live and Take Offline Left to the team's own source control and deployment pipeline in the open-source engines
Execution model Stateless rule evaluation; rule-to-rule invocation via a compiled delegate lookup Working-memory pattern matching and agenda-based conflict resolution
Best fit Business logic where the rule chain is knowable in advance Large, data-driven rule networks where dependencies aren't fully known upfront
Platform .NET Standard 2.0 (.NET Framework 4.6.2+, .NET Core 2.0+, .NET 8+); the entire platform is planned for Java in 2027 Java (Drools), .NET (NRules); RETE variants exist across languages, such as CLIPS and Jess

What Forward-Chaining Is, and Why RETE Exists

Forward-chaining is a data-driven inference strategy: instead of a developer hard-coding "if rule A fires, then run rule B," the engine watches the facts in working memory and automatically re-evaluates and fires whichever rules now match, based on what just changed. The RETE algorithm, designed by Charles Forgy at Carnegie Mellon University and published in 1982, exists to make this efficient - it builds a network of the rule conditions and stores partial matches, so that when a fact changes, only the affected pattern matches are recomputed rather than re-running every rule from scratch. It deliberately trades memory for speed. When several rules match at once, a separate conflict resolution step - an agenda ordered by salience, rule order or similar criteria - decides which fires first. This is genuinely valuable when you have a large number of rules with data dependencies that aren't fully known in advance, or that change as the ruleset grows - the engine, not the developer, is responsible for figuring out what needs to re-fire.

The family is still active: Drools replaced classic RETE with Phreak, a lazy, goal-oriented variant, and ships as part of Apache KIE (latest release 10.2.0, April 2026); NRules brings RETE to .NET with rules written in C# (latest release 1.0.4, February 2026); CLIPS, Jess and newer Java engines such as Evrete implement it as well. One naming note: Rete.js is a TypeScript framework for building visual node editors, not a RETE rules engine, despite the name.

The Circular Reference Problem

Most RETE-based engines either have no visual rule-authoring UI at all, or one that isn't sophisticated enough to detect circular references across rules automatically. That detection is left to a human reviewing the rule logic, or to engine features that limit re-firing at run time - and any manual process like that carries real risk of error, especially as a ruleset grows past the size a person can hold in their head.

Code Effects takes a different approach: circular references are prevented by validation, before a rule can be saved, not detected by the engine while it runs. Whenever a rule is validated or saved, the editor's server-side validation follows every rule it references - reusable rules in its conditions and, in version 7, inline rules in its actions - at any depth, through the rule resolver (a GetRuleDelegate), and refuses a rule whose references lead back to itself. There's no manual review step to get this guarantee - a rule with a cycle simply can't be saved. In the Rule Repository the check runs on every save and again before a version goes live, and the repository also prevents changes that would break a rule that calls the one being changed. The engine itself runs what it is given; the protection belongs to the validation that every saved rule passes, whether a person, a script or an AI agent wrote it.

Why Code Effects Didn't Implement Forward-Chaining

Forward-chaining's core promise is that developers don't need to track logic dependencies by hand - the engine and RETE handle it. But the risk of rule A triggering rule B which triggers rule A again is real enough that Drools and other RETE engines had to build dedicated features to contain it: salience (priority ordering), agenda groups and rule-flow groups (partitioning which rules are even eligible to fire), activation groups (letting only one rule in a group fire), and no-loop / lock-on-active (suppressing re-activation caused by a rule's own side effects). Drools now also applies property reactivity by default, re-evaluating only the patterns that constrain a changed property, which its documentation says removes the need for no-loop in many cases; NRules offers a repeatability setting that keeps a rule from firing again on the same facts. These features reduce the risk; they don't remove the need to reason about it.

Handled carelessly, that machinery can undermine the premise of forward-chaining it was built to protect - you're back to manually reasoning about firing order, just with more attributes to manage.

Code Effects' team decided from the outset not to implement forward-chaining. Instead, the engine is built around the idea that the business, not the developer, should decide and set which rule fires next based on the result of a prior evaluation. In practice, that decision is made explicitly in the rule logic itself rather than inferred by the engine at runtime.

How Imperative Chaining Works

In Code Effects 7, the most direct way to chain rules is in the rule language itself. An evaluation rule can be used as a condition in any other rule as a reusable rule, and an execution rule can run another execution rule from its THEN or ELSE section as an inline rule. The business author picks the next rule from a menu, the chain is visible when anyone reads the rule, and these references are exactly what the circular-reference validation follows. In the Rule Repository, a rule calls the live version of the rule it references, and the live rules are loaded together with the rules they depend on as a complete ruleset (Context.GetRules).

Developers can also build their own chaining actions. Because Code Effects allows any public method that returns void to be used as a rule action, a developer can declare an action - for example, ExecuteRule - that takes a rule ID as its parameter. The Evaluator is instantiated as a singleton and reused inside that action, calling the Evaluate overload that takes a rule ID. That overload pulls the target rule from the already-compiled ruleset and evaluates it against the same dataset.

using CodeEffects.Rule.Engine;

public static class EvaluatorSingleton
{
    // Compiled once, on first use, from the ruleset your application stores
    private static readonly Lazy<Evaluator<SourceObject>> instance =
        new Lazy<Evaluator<SourceObject>>(() => new Evaluator<SourceObject>(RuleStorage.GetRulesetXml()));

    public static Evaluator<SourceObject> Instance => instance.Value;
}

public class SourceObject
{
    public void ExecuteRule(string ruleID)
    {
        EvaluatorSingleton.Instance.Evaluate(this, ruleID);
    }
}

Obviously, depending on the use case, the action can be declared to accept the rule name, rule type enum, or any combination of parameters that makes it easier for business users to determine which rule should be evaluated next.

A custom action like this is your own code, and the rule ID it receives is an ordinary parameter value, so the chain it builds is yours to keep acyclic. When you want Code Effects to validate the whole chain for you, use reusable and inline rules.

Because every rule is already compiled into IL objects ahead of time, chaining one rule to another this way costs little more than one method invoking another - there's no re-matching against a working-memory network, no agenda to resolve. That's why imperative chaining is often faster, sometimes significantly so, than RETE-style forward-chaining: the runtime cost of "what fires next" is decided by the business at design time instead of computed by the engine at evaluation time. The engine is stateless and thread-safe, and in Code Effects' benchmark it evaluates ONE MILLION object instances against a simple rule in under 10 milliseconds.

Code Effects has found through customer focus groups and support conversations that users actually prefer this model over true forward-chaining, specifically because of the complete control it gives them over nested rule evaluation and logic flow.

Explicit Chains Are Easier to Test, Govern and Explain

An explicit chain has a practical benefit beyond speed: anyone - a business user, an auditor or an AI agent - can read a rule and see what it calls. Code Effects 7 builds on that. In the Rule Repository, a test of a rule or a proposed version runs on your real classes and shows the decision path, the conditions that held or failed, and the resulting values; tests can be saved and run in batches of up to 350 whenever a rule in the chain changes. Each version goes live only through a decision workflow of approval, Go Live and Take Offline. With Audit, each production evaluation is recorded - the rule and source versions, the values read, the branch taken - and can be replayed step by step and turned into a test. In a forward-chaining engine, the path through the rules is decided at run time by the facts in working memory; with imperative chaining, the path is part of the rules themselves, which makes "why did this decision come out this way?" a question you can answer from the rule, the test and the recorded evaluation.

The same is true for AI. When the Rule Repository's AI Rule Editor or an AI agent connected through the MCP server writes a rule that calls other rules, the rule is validated against its source object and checked for circular references like any other, every AI save requests approval, and AI can never approve, put a rule into production or take it offline.

The Honest Framing of the Trade-off

It would be inaccurate to describe Code Effects as simply "a faster RETE." A more accurate framing: Code Effects trades automatic dependency inference and cross-rule state sharing for speed and simplicity, in cases where the business already knows the chain - which, in Code Effects' experience, covers the majority of real-world business-rule use cases. That's a reasonable trade-off for a large share of business-rule scenarios, but it isn't a strictly faster version of what RETE does.

It's opting out of the problem RETE exists to solve - undeclared, data-driven rule interdependency at scale - in exchange for lower per-call overhead and full control over the evaluation process.

Where RETE Genuinely Wins

If your rule network is large, the dependencies between rules aren't fully known ahead of time, and you need the engine itself to infer which rules should re-fire as facts change over time, RETE's forward-chaining is doing real work that imperative chaining doesn't attempt to replace. Complex expert-system-style reasoning, rule sets that evolve dynamically without a developer re-declaring the chain, scenarios with genuinely emergent (not pre-known) rule interactions, and reasoning over streams of events - such as Drools Fusion's temporal operators and sliding windows - are territory where Drools, NRules and other RETE engines have a real architectural advantage. Code Effects' bet is that most commercial business-rule automation doesn't actually live in that territory - but for the cases that do, RETE's automatic inference isn't something imperative chaining is designed to replicate.

FAQ

Is Code Effects a RETE-based rules engine? No. Code Effects intentionally does not implement the RETE algorithm or forward-chaining. It uses a custom evaluation engine with pre-compiled IL rules and an explicit, business-declared chaining model called imperative chaining.

What is forward-chaining in a rules engine? Forward-chaining is a data-driven execution strategy where the engine automatically determines which rules to re-evaluate and fire based on changes to the underlying facts, rather than a developer explicitly specifying the next rule to run. RETE is the algorithm most commonly used to implement forward-chaining efficiently.

Which rules engines use RETE? Drools (through Phreak, its RETE derivative) on Java, NRules on .NET, and long-established engines such as CLIPS and Jess, among others. Rete.js, despite its name, is a framework for building visual node editors, not a RETE rules engine.

How does Drools prevent infinite loops between rules? Drools applies property reactivity by default, re-evaluating only patterns that constrain a changed property, and offers attributes like salience (priority), agenda-group and ruleflow-group (partitioning rule eligibility), activation-group, and no-loop / lock-on-active (suppressing re-activation from a rule's own effects). Where property reactivity isn't enough, these require deliberate configuration by the rule author.

How does Code Effects prevent circular references between rules? By validation, not at run time. Whenever a rule is validated or saved, the editor's server-side validation follows every rule it references through the rule resolver (a GetRuleDelegate), and a rule whose references lead back to itself cannot be saved. In the Rule Repository, the check runs on every save and every Go Live, so no manual review is needed.

What is imperative chaining in Code Effects? Imperative chaining is Code Effects' explicit alternative to forward-chaining. A rule calls other rules directly - as reusable rules in its conditions, as inline rules in its THEN or ELSE actions, or through a developer-declared action such as ExecuteRule that invokes another already-compiled rule by ID via the Evaluator - rather than relying on the engine to infer which rule should fire next from data changes.

Is imperative chaining faster than RETE forward-chaining? Often, yes, sometimes significantly. Because all rules are pre-compiled to IL, chaining from one rule to another is effectively one method invoking another, without the overhead of re-matching against a working-memory pattern network.

Does Code Effects support forward-chaining at all? No. This is a deliberate architectural decision, not a current limitation. Code Effects is built around explicit, business-defined rule chaining rather than engine-inferred chaining.

When should I use a RETE-based engine like Drools instead of Code Effects? When your rule network is large and its dependencies aren't fully known in advance, or when you need the engine itself to infer which rules should re-fire as underlying facts change dynamically, RETE's forward-chaining provides genuine value that imperative chaining doesn't attempt to replicate.

Does removing forward-chaining make Code Effects less capable than RETE engines? It makes a different trade-off, not a strictly worse one. Code Effects gives up automatic dependency inference and cross-rule state sharing in exchange for speed, predictability, and acyclic rule chains - a good fit when the business already knows the rule chain, which covers most business-rule use cases but not all of them.

Do most RETE-based engines have a visual rule-authoring UI? Generally no, or a limited one. Drools has had no web-based DRL authoring tool since Business Central was retired in Drools 8, and NRules rules are written in C#. Most RETE-based engines either lack a built-in visual authoring interface or don't offer one that automatically detects circular references, leaving that check to manual human review.

What does GetRuleDelegate have to do with circular reference detection? A GetRuleDelegate is the rule resolver the editor uses to find the rules a rule references when they are not in the same document. With it, the validation follows every reference to its end, so a saved rule can never contain a circular reference. The check belongs to validation, not to the engine: the engine runs what it is given.

Is Code Effects available for Java, like Drools? Not yet. Code Effects runs on .NET today, and the entire Code Effects platform is planned for the Java platform in 2027.

Is Code Effects' approach a replacement for RETE in general? No - it's an alternative optimized for a different set of use cases. Code Effects opts out of the specific problem RETE is built to solve (undeclared, data-driven rule interdependency at scale) in favor of lower overhead and full control when the rule chain is already known.

l102

p101

×