Namespace RuleWright.Core
Classes
- CallExpression
A value expression that invokes a registered value function. In JSON,
{ "call": "RoundTo", "operands": [ { "field": "Order.Total" }, 2 ] }. The function itself is C# registered on the engine builder (RuleWrightBuilder.RegisterValueFunction), so the rule document stays pure data: it names the function, it never embeds code. An unregistered name fails atLoadRuleSet, exactly as an unregisteredcustomcondition function does.
- ConditionGroup
A logical grouping of child conditions combined with LogicalOperator. Not groups must contain exactly one child.
- ConditionLeaf
A leaf condition comparing a left-hand side against a constant value, or delegating to a registered custom function. The left-hand side is usually a fact field (a dotted path such as
Customer.Age), but can also be a computed Left value expression (such asOrder.Total * 0.9).
- ConditionNode
A node in a rule's condition tree: either a ConditionGroup (logical combinator) or a ConditionLeaf (field comparison). Immutable after construction.
- ConditionTraceNode
The traced outcome of one condition node. Mirrors the shape of the rule's condition tree; nodes that were never reached because of short-circuiting report a null Passed.
- EvaluationOptions
Per-evaluation options. Immutable once constructed, so the shared Default instance cannot be reconfigured out from under other callers — set values with an object initializer (
new EvaluationOptions { EnableTrace = true }).
- EvaluationTrace
A full execution trace: one entry per rule in the set, in evaluation order. Produced only when EnableTrace is true.
- FieldExpression
A value expression that reads a fact field via a dotted path (
Order.Total), using the same resolution and null semantics as a ConditionLeaf field: a null anywhere along the path yields null. In JSON,{ "field": "Order.Total" }.
- FiredRule
A rule that contributed outputs during an evaluation — either because its condition passed (Then) or because it did not and the rule has an
elsebranch (Else) — with the outputs that branch produced.
- LiteralExpression
A value expression that evaluates to a constant. In JSON, a bare scalar (
10,"gold",true,null) or an explicit{ "literal": <scalar> }node.
- OperatorExpression
A value expression that applies an ExpressionOperator to one or more operand expressions. In JSON,
{ "op": "multiply", "operands": [ { "field": "Order.Total" }, 0.1 ] }. Operand order is significant for non-commutative operators (Subtract, Divide, Modulo).
- Rule
A single business rule: a condition tree plus the actions applied when it passes. Immutable after construction; parsed once from JSON and compiled once per fact type.
- RuleAction
An action applied when a rule fires — from its
actionswhen the condition passes, or itselseactions when it does not. Most actions write a ValueExpression into the evaluation result's outputs under Target: a constant is simply a LiteralExpression, and a value derived from the fact is a FieldExpression or OperatorExpression. The Type decides how the value combines with what fired rules have already written:setOutputreplaces,addToOutputaccumulates numerically,appendToOutputcollects into a list, andremoveOutputdeletes the key (ignoring any value).
- RuleEvaluationResult
The result of evaluating a rule set against one fact: which rules fired, the merged outputs, how execution ran, and (when enabled) a full execution trace.
- RuleFacts
Several named facts evaluated as one — the multi-input shape. Each fact is addressed by its name as the first segment of a field path: with
RuleFacts.With("customer", c).And("order", o), a rule readscustomer.Ageandorder.Total.A RuleFacts is a dictionary fact, so it runs the interpreter (
CompilationMode.Interpreted) — the set of member types isn't a single CLR shape to compile against. Facts inside it are still read through the interpreter's cached reflection. When evaluation is hot enough that the compiled path matters, wrap the same inputs in a composite POCO (class Checkout { Customer Customer; Order Order; }) instead; the two spell the same field paths.
- RuleFailure
One rule's authored explanation for not matching: produced when a rule that declares a
failureMessageis evaluated and its condition does not pass. Skipped rules (disabled, or unreached after a stop-on-first-match) produce none — a message means the rule was actually asked and said no.
- RuleFunctionDescriptor
Discovery metadata for a single custom function registered on an engine — its name plus whatever IRuleFunctionMetadata it opted to expose, or the "unknown" defaults when it didn't. See
RuleWrightEngine.FunctionCatalog.
- RuleSet
An ordered collection of rules parsed from a single JSON document. Immutable after construction.
- RuleTrace
The trace of a single rule within an evaluation: whether it fired, whether it was skipped, and the per-node condition results.
- RuleValueFunctionDescriptor
Discovery metadata for a single value function registered on an engine — its name plus whatever IRuleValueFunctionMetadata it opted to expose, or the "unknown" defaults when it didn't. See
RuleWrightEngine.ValueFunctionCatalog.
- RuleWrightException
Base type for all exceptions thrown by RuleWright libraries.
- ValueExpression
A node in a computed action's value expression tree: a LiteralExpression (a constant), a FieldExpression (a dotted fact path read), or an OperatorExpression (an operator over sub-expressions). Immutable after construction. Value expressions are pure data — a closed operator vocabulary, never embedded code — mirroring the condition tree.
Interfaces
- IRuleFunction
A custom condition function referenced from JSON as
{ "operator": "custom", "name": "..." }. Implementations are registered with the engine builder and bound into compiled rules at compile time — no name lookup or reflection happens per evaluation.
- IRuleFunctionMetadata
Optional metadata an IRuleFunction implementation can expose about itself — a human-readable description and the expected shape of its
valueoperand. Purely descriptive, consumed via RuleFunctionDescriptor; the engine never validates against it. Intended for rule-authoring UIs (e.g. acustom-operator function picker) that need more than just a function's name to build a sensible value editor.
- IRuleValueFunction
A custom value-returning function referenced from a value expression as
{ "call": "...", "operands": [...] }. Where an IRuleFunction answers a condition (true/false), a value function computes a value usable anywhere an expression is: an action'svalue, the left-hand side of a condition, or a decision-table cell. Implementations are registered with the engine builder and bound into compiled rules at compile time — no name lookup or reflection happens per evaluation.
- IRuleValueFunctionMetadata
Optional metadata an IRuleValueFunction implementation can expose about itself. The description is purely informational (surfaced via RuleValueFunctionDescriptor for rule-authoring UIs); a declared RequiredOperandCount is additionally enforced at
LoadRuleSet, so a call with the wrong number of operands fails at load rather than computing null mid-evaluation.
Enums
- CompilationMode
How a rule set was executed for a given fact shape. Exposed on CompilationMode so interpreted (slower) execution is visible rather than a silent degradation.
- ConditionOperator
Comparison operator applied by a ConditionLeaf. JSON documents use the schema spellings (
"Equals","NotEquals", …); the domain enum uses Equal/NotEqual to avoid colliding with Equals(object).
- ExpressionOperator
The closed vocabulary of operators available inside a computed action OperatorExpression. Deliberately small and pure-data — RuleWright never embeds arbitrary code strings, so a UI can safely generate these and a reviewer can safely diff them.
- LogicalOperator
Logical combinator applied by a ConditionGroup to its children.
- RuleBranch
Which side of a rule produced a FiredRule: the
actionsthat run when the condition passes, or theelseactions that run when it does not.
- RuleFunctionValueKind
A coarse hint about the shape of the
valueoperand a custom IRuleFunction expects, when it opts into IRuleFunctionMetadata. Purely descriptive — the engine never validates against it; it exists so a rule-authoring UI can choose an appropriate value editor for thecustomoperator.
- RuleSkipReason
Why a rule contributed nothing to an evaluation. A skipped rule is never evaluated at all, so its Condition is null — this says which of the two very different reasons applies, so a trace reader can tell "the author turned this off" from "evaluation had already finished".