Muonroi.RuleEngine.Abstractions 1.0.0-alpha.16

This is a prerelease version of Muonroi.RuleEngine.Abstractions.
dotnet add package Muonroi.RuleEngine.Abstractions --version 1.0.0-alpha.16
                    
NuGet\Install-Package Muonroi.RuleEngine.Abstractions -Version 1.0.0-alpha.16
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Muonroi.RuleEngine.Abstractions" Version="1.0.0-alpha.16" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muonroi.RuleEngine.Abstractions" Version="1.0.0-alpha.16" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.RuleEngine.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Muonroi.RuleEngine.Abstractions --version 1.0.0-alpha.16
                    
#r "nuget: Muonroi.RuleEngine.Abstractions, 1.0.0-alpha.16"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Muonroi.RuleEngine.Abstractions@1.0.0-alpha.16
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Muonroi.RuleEngine.Abstractions&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.RuleEngine.Abstractions&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Tool

Muonroi.RuleEngine.Abstractions

Contracts-only package that defines the rule engine interfaces, execution model, and shared value types used across the entire Muonroi Rule Engine ecosystem.

NuGet License: Apache 2.0

This package ships contracts only — interfaces, records, enums, and attributes. It contains no orchestration runtime, DI registrations, or rule-execution logic. Depend on it when authoring rules or writing code that consumes orchestration results without a direct dependency on a concrete engine.

For a working rule engine, add Muonroi.RuleEngine.Core (base orchestrator + DI wiring) or one of the specialised adapters such as Muonroi.AspNetCore.RuleEngine.

Installation

dotnet add package Muonroi.RuleEngine.Abstractions --prerelease

Quick Start

Implement IRule<TContext> to define a rule. The context type must implement IRuleContext.

using Muonroi.RuleEngine.Abstractions;

// 1. Define the context
public sealed class OrderContext : IRuleContext
{
    public decimal Amount { get; init; }
    public string CustomerType { get; init; } = "";

    private bool _halted;
    public void HaltGroup() => _halted = true;
}

// 2. Implement a rule
[RuleGroup("order-discount")]
public sealed class HighValueOrderRule : IRule<OrderContext>
{
    public string Code => "HIGH_VALUE_ORDER";
    public int Order => 0;

    public Task<RuleResult> EvaluateAsync(OrderContext ctx, FactBag facts, CancellationToken ct)
    {
        bool isHighValue = ctx.Amount >= 1000m;
        decimal discount = isHighValue ? 0.10m : 0m;
        facts.Set("discountRate", discount);
        facts.Set("isHighValueOrder", isHighValue);
        return Task.FromResult(RuleResult.Passed());
    }
}

Register and execute via Muonroi.RuleEngine.Core:

// Program.cs (requires Muonroi.RuleEngine.Core)
using Muonroi.RuleEngine.Core;

builder.Services.AddRuleEngine<OrderContext>();
builder.Services.AddRulesFromAssemblies(typeof(Program).Assembly);

See Quickstart.RuleEngine for a complete working example.

Features

  • IRule<TContext> — base rule contract with Code, Order, DependsOn, HookPoint, and EvaluateAsync / ExecuteAsync
  • ICompensatableRule<TContext> — extends IRule<TContext> with CompensateAsync for Saga-pattern rollback
  • IRuleContext — minimal context marker with HaltGroup() to short-circuit a rule group
  • FactBag — typed key/value store shared between rules during a single orchestration run; supports Set<T>, Get<T>, TryGet<T>, Remove, and JsonElement auto-conversion
  • IMRuleOrchestrator<TContext> — primary orchestration entry point; returns OrchestratorResult
  • OrchestratorResult — immutable execution summary with IsSuccess, ExecutionMode, per-rule RuleResults, aggregated Errors, and CompensationErrors
  • ExecutionMode — three strategies: AllOrNothing (default, stops on first failure), BestEffort (aggregates all failures), CompensateOnFailure (stops + compensates in reverse order)
  • RuleExecutionMode — routing enum for gradual migration: Traditional, Rules, Hybrid, Shadow
  • IRuleFactory<TContext> — DI-based rule instantiation contract
  • IRuleEventListener<TContext> — hook interface for observing rule lifecycle events
  • IHookHandler<TContext> — interface for pre/post rule execution hooks
  • Authoring attributes — [RuleGroup], [TenantRuleGroupAttribute], [ExtractAsRuleAttribute], [RuleModeAttribute], [MRuleCatalogEntryAttribute], [MRuleContextDescriptionAttribute], [MRuleFactDescriptionAttribute]
  • Authoring manifest models — MRuleAuthoringManifest, MRuleAuthoringEntry, MFactEntry, MFactSchemaNode, MFactSchemaField
  • Decision table models — RawDecisionTable, RawHitPolicy, FEEL expression types
  • Canary rollout contracts — ICanaryRolloutService, CanaryRolloutRecord, StartCanaryRequest
  • Rule set approval contracts — IRuleSetApprovalService, RuleSetRecord, RuleSetStatus

Configuration

This package contains no DI registrations or runtime configuration. Configuration (options, assembly scanning, quota hooks) lives in Muonroi.RuleEngine.Core. See that package's README for AddRuleEngine<TContext> and MRuleEngineOptions.

API Reference

Type Purpose
IRule<TContext> Base rule contract; implement to define a rule
ICompensatableRule<TContext> Rule with Saga compensation support
IRuleContext Context marker; must be implemented by every context type
FactBag Typed shared-state bag passed between rules
RuleResult Per-rule outcome; factory methods Passed(), Success(), Failure(errors)
IMRuleOrchestrator<TContext> Run all registered rules and return an OrchestratorResult
OrchestratorResult Immutable run summary; factory methods Success(...), Failure(...)
ExecutionMode AllOrNothing / BestEffort / CompensateOnFailure
RuleExecutionMode Traditional / Rules / Hybrid / Shadow
HookPoint Enum for hook placement relative to rule execution
IRuleFactory<TContext> DI-based rule factory contract
IRuleEventListener<TContext> Lifecycle event observer contract
IHookHandler<TContext> Pre/post execution hook contract
[RuleGroup(key)] Groups rules into a named execution group
[TenantRuleGroupAttribute(workflow, tenant)] Tenant-scoped rule group
[ExtractAsRuleAttribute(code)] Marks a method for rule source-generator extraction
[RuleModeAttribute(mode)] Declares the RuleExecutionMode for a rule
MRuleAuthoringManifest Describes an entire rule catalog for tooling/authoring UIs
ICanaryRolloutService Contract for canary rollout management
IRuleSetApprovalService Contract for rule set approval workflows
RawDecisionTable Raw model for decision table rules

Samples

Compatibility

  • Target framework: net8.0
  • License: Apache-2.0 (OSS)

License

Apache-2.0. See LICENSE-APACHE for the full text.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (15)

Showing the top 5 NuGet packages that depend on Muonroi.RuleEngine.Abstractions:

Package Downloads
Muonroi.RuleEngine.Core

Rule Engine Core implementation for Muonroi.BuildingBlock

Muonroi.RuleEngine.NRules

[FROZEN] Use Muonroi.RuleEngine.Runtime instead. NRules integration — no active development.

Muonroi.Mediator

Mediator pattern implementation for Muonroi: command/query dispatching, pipeline behaviors, and validation integration.

Muonroi.Data.EntityFrameworkCore

Entity Framework Core infrastructure for Muonroi: MDbContext with audit, soft-delete, multi-tenant filters, and repository base.

Muonroi.RuleEngine.DecisionTable

Decision table models, converters, validators, and serializers for Muonroi Rule Engine.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.16 118 6/22/2026
1.0.0-alpha.15 205 5/31/2026
1.0.0-alpha.14 189 5/15/2026
1.0.0-alpha.13 158 5/2/2026
1.0.0-alpha.12 94 4/2/2026
1.0.0-alpha.11 155 4/2/2026
1.0.0-alpha.9 91 3/30/2026
1.0.0-alpha.8 345 3/28/2026
1.0.0-alpha.7 82 3/27/2026
1.0.0-alpha.5 78 3/27/2026
1.0.0-alpha.4 72 3/27/2026
1.0.0-alpha.3 72 3/27/2026
1.0.0-alpha.2 87 3/26/2026
1.0.0-alpha.1 121 3/8/2026
Loading failed

v1.7.0: Added Saga Pattern support (ICompensatableRule), ExecutionMode enum (AllOrNothing/BestEffort/CompensateOnFailure), and OrchestratorResult for detailed execution feedback. Added 84 comprehensive unit tests.