Muonroi.RuleEngine.Abstractions
1.0.0-alpha.16
dotnet add package Muonroi.RuleEngine.Abstractions --version 1.0.0-alpha.16
NuGet\Install-Package Muonroi.RuleEngine.Abstractions -Version 1.0.0-alpha.16
<PackageReference Include="Muonroi.RuleEngine.Abstractions" Version="1.0.0-alpha.16" />
<PackageVersion Include="Muonroi.RuleEngine.Abstractions" Version="1.0.0-alpha.16" />
<PackageReference Include="Muonroi.RuleEngine.Abstractions" />
paket add Muonroi.RuleEngine.Abstractions --version 1.0.0-alpha.16
#r "nuget: Muonroi.RuleEngine.Abstractions, 1.0.0-alpha.16"
#:package Muonroi.RuleEngine.Abstractions@1.0.0-alpha.16
#addin nuget:?package=Muonroi.RuleEngine.Abstractions&version=1.0.0-alpha.16&prerelease
#tool nuget:?package=Muonroi.RuleEngine.Abstractions&version=1.0.0-alpha.16&prerelease
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.
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 withCode,Order,DependsOn,HookPoint, andEvaluateAsync/ExecuteAsyncICompensatableRule<TContext>— extendsIRule<TContext>withCompensateAsyncfor Saga-pattern rollbackIRuleContext— minimal context marker withHaltGroup()to short-circuit a rule groupFactBag— typed key/value store shared between rules during a single orchestration run; supportsSet<T>,Get<T>,TryGet<T>,Remove, andJsonElementauto-conversionIMRuleOrchestrator<TContext>— primary orchestration entry point; returnsOrchestratorResultOrchestratorResult— immutable execution summary withIsSuccess,ExecutionMode, per-ruleRuleResults, aggregatedErrors, andCompensationErrorsExecutionMode— 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,ShadowIRuleFactory<TContext>— DI-based rule instantiation contractIRuleEventListener<TContext>— hook interface for observing rule lifecycle eventsIHookHandler<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
- Quickstart.RuleEngine — minimal rule with
IRule<TContext>,FactBag, andRuleResult - Quickstart.AspNetCore.RuleEngine — ASP.NET Core integration with middleware pipeline
- Quickstart.RuleEngine.EntityFrameworkCore — persisted rule sets via EF Core
- Quickstart.RuleEngine.NRules — NRules backend adapter
- Quickstart.RuleEngine.Proliferation — rule proliferation and catalog management
- Quickstart.RuleEngine.Runtime.Web — runtime web API for rule management
Compatibility
- Target framework:
net8.0 - License: Apache-2.0 (OSS)
Related Packages
Muonroi.RuleEngine.Core— concrete orchestrator, DI extensions (AddRuleEngine<T>,AddRulesFromAssemblies), andMRuleEngineOptionsMuonroi.AspNetCore.RuleEngine— ASP.NET Core middleware integrationMuonroi.RuleEngine.Runtime— full runtime with rule set persistence, FEEL expressions, and workflow cacheMuonroi.RuleEngine.Runtime.Web— REST API layer for runtime rule managementMuonroi.RuleEngine.EntityFrameworkCore— EF Core rule set storeMuonroi.RuleEngine.DecisionTable— decision table evaluation engineMuonroi.RuleEngine.NRules— NRules backend adapterMuonroi.RuleEngine.SourceGenerators— source generator that scaffolds rule registrations from[ExtractAsRuleAttribute]Muonroi.RuleEngine.Testing— fluent test helpers andMFactBagAssertions
License
Apache-2.0. See LICENSE-APACHE for the full text.
| Product | Versions 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Muonroi.Core.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Quota.Abstractions (>= 1.0.0-alpha.16)
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 |
v1.7.0: Added Saga Pattern support (ICompensatableRule), ExecutionMode enum (AllOrNothing/BestEffort/CompensateOnFailure), and OrchestratorResult for detailed execution feedback. Added 84 comprehensive unit tests.