Muonroi.RuleEngine.Runtime 1.0.0-alpha.16

This is a prerelease version of Muonroi.RuleEngine.Runtime.
dotnet add package Muonroi.RuleEngine.Runtime --version 1.0.0-alpha.16
                    
NuGet\Install-Package Muonroi.RuleEngine.Runtime -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.Runtime" 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.Runtime" Version="1.0.0-alpha.16" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.RuleEngine.Runtime" />
                    
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.Runtime --version 1.0.0-alpha.16
                    
#r "nuget: Muonroi.RuleEngine.Runtime, 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.Runtime@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.Runtime&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.RuleEngine.Runtime&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Tool

Muonroi.RuleEngine.Runtime

Runtime orchestration layer for the Muonroi Rule Engine — provides file-backed ruleset storage, in-memory caching with hot-reload, Redis pub/sub invalidation, CloudEvents bridging, execution tracing, and pluggable signing/audit for rule evaluation pipelines.

NuGet License: Apache 2.0

Muonroi.RuleEngine.Runtime is the infrastructure layer that connects the abstract rule engine contracts (Muonroi.RuleEngine.Abstractions) and core orchestrator (Muonroi.RuleEngine.Core) to real-world storage, caching, and observability. It ships a file-backed IRuleSetStore, an optional Postgres store, in-memory runtime caching invalidated through IRuleSetChangeNotifier (in-process or Redis pub/sub), HMAC-SHA-256 and RSA audit signing, and a CloudEvents bridge that publishes ruleset lifecycle changes to any IEventSink. It also provides multi-dialect rule adapters (FEEL, JavaScript via Jint, Liquid, Scriban, decision tables, sub-flow graphs) so externally-authored rules can be executed without code recompilation.

Installation

dotnet add package Muonroi.RuleEngine.Runtime --prerelease

Quick Start

Register the file-backed store and execution services, then optionally enable Redis hot-reload for multi-node deployments:

// Program.cs
using Muonroi.RuleEngine.Runtime.Rules;
using Muonroi.RuleEngine.Runtime.Tracing;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

// Core store + RulesEngineService + IRuleSetRuntimeCache
builder.Services.AddRuleEngineStore(builder.Configuration);

// Optional: replace in-process notifier with Redis pub/sub hot-reload
string? redisConnection = builder.Configuration.GetConnectionString("RuleEngineRedis");
if (!string.IsNullOrWhiteSpace(redisConnection))
{
    builder.Services.AddMRuleEngineWithRedisHotReload(redisConnection);
}

// Optional: CloudEvents bridge — every ruleset lifecycle change emits a CloudEvent
builder.Services.AddRuleEventBridge();

// Optional: execution tracing backed by Redis
builder.Services.AddRuleEngineTracing(options =>
{
    options.DefaultTtl = TimeSpan.FromHours(48);
    options.RedactedFieldNames.Add("accountNumber");
});

WebApplication app = builder.Build();
app.Run();

Ruleset files are resolved from the path configured under RuleStore:RootPath (defaults to a rules/ folder next to the application binary).

Features

  • File-backed IRuleSetStore — reads/writes ruleset JSON artifacts from disk; path traversal is blocked by AllowedPathSegmentPattern
  • Postgres-backed storePostgresRuleSetStore via EF Core + Npgsql for durable persistence (registered separately)
  • In-memory IRuleSetRuntimeCache — hot-invalidated through IRuleSetChangeNotifier; configurable absolute expiry via RuntimeCacheMinutes
  • Redis hot-reloadRedisRuleSetChangeNotifier subscribes to a configurable pub/sub channel (muonroi:ruleset:changed) so all nodes pick up ruleset changes without restart
  • CloudEvents bridgeCloudEventPublishingNotifier decorates any IRuleSetChangeNotifier to forward lifecycle events to IEventSink; RuleExecutionEventPublisher and IEventDrivenRuleEvaluator integrate with event-driven pipelines
  • Multi-dialect adaptersFeelRuleAdapter, JavaScriptRuleAdapter (Jint), LiquidRuleAdapter, DecisionTableRuleAdapter, SubFlowRuleAdapter, ConnectorRuleAdapter, FeelRuleAdapter
  • Flow graph executionRuleGraphParser applies Kahn's topological sort; ContextAdaptedRule and ReflectionContextFactory/ReflectionContextProjector bridge typed contexts to FactBag
  • Ruleset signingHmacSha256RuleSetSigner and RsaRuleSetAuditSigner; optional RequireSignature enforcement in the store
  • Audit trailIRuleSetAuditStore / FileRuleSetAuditStore with RuleSetAuditEntry records; RSA-signed entries via RsaRuleSetAuditSigner
  • Rule togglesRuleOptions.RuleToggles and TenantRuleToggles for per-rule and per-tenant feature flags evaluated by RuleEngine<T>
  • Execution tracingIRuleExecutionTracer + RuleExecutionTracer backed by RedisRuleTraceStore; PII field redaction via ITraceRedactor; per-tenant TTL overrides
  • Debugger modeIRuleDebuggerModeService with Redis-backed on/off flag; RuleTracingEndpoints for HTTP management
  • Maker-checker + canaryRequireApproval and EnableCanary in RuleControlPlaneOptions; PercentageRuleActivationStrategy for gradual rollout
  • OTel telemetryRuntimeTelemetryDescriptor exposes cache hit/miss counters, eviction counter, and hot-reload lag histogram

Configuration

RuleStore section (RuleStoreConfigs)

{
  "RuleStore": {
    "RootPath": "rules",
    "UseContentRoot": true,
    "MaxRuleSetSizeBytes": 1048576,
    "RequireSignature": false,
    "AllowedPathSegmentPattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$",
    "EnableRuntimeCache": true,
    "RuntimeCacheMinutes": 10,
    "RuleChangeChannel": "muonroi:ruleset:changed",
    "RequireApproval": false,
    "NotifyOnStateChange": true
  }
}

RuleControlPlane section (RuleControlPlaneOptions)

{
  "RuleControlPlane": {
    "RequireApproval": false,
    "NotifyOnStateChange": true,
    "EnableCanary": true,
    "AuditSignerKeyId": "ruleset-control-plane",
    "AuditPrivateKeyPemPath": "/run/secrets/ruleset-signing.pem"
  }
}

RuleTracing section (RuleTracingOptions)

{
  "RuleTracing": {
    "DefaultTtl": "24:00:00",
    "ScanPageSize": 200,
    "MaxQueryResults": 1000,
    "Database": 0,
    "TraceKeyPrefix": "rule-trace",
    "DebuggerKeyPrefix": "rule-debugger:enabled",
    "ModeCacheDuration": "00:00:10",
    "RedactedFieldNames": ["password", "token", "ssn", "creditCard"]
  }
}

RuleOptions (per-rule toggles)

builder.Services.Configure<RuleOptions>(options =>
{
    options.RuleToggles["FRAUD_CHECK"] = false;         // disable globally
    options.TenantRuleToggles["tenant-42"] = new Dictionary<string, bool>
    {
        ["HIGH_VALUE_ORDER"] = false                    // disable for one tenant
    };
});

API Reference

Type Purpose
RuleEngineServiceCollectionExtensions DI entry point: AddRuleEngineStore, AddMRuleEngineWithRedisHotReload, AddRuleEventBridge / AddRuleEngineEventBridge
RuleTracerServiceCollectionExtensions AddRuleEngineTracing — wires IRuleExecutionTracer, ITraceRedactor, IRuleTraceStore, IRuleDebuggerModeService
IRuleSetStore Load, save, activate, archive rulesets
IRuleSetAuditStore Persist and page through RuleSetAuditEntry records
IRuleSetRuntimeCache In-memory cache with hot-invalidation
IRuleSetChangeNotifier Publishes and subscribes to ruleset change signals
RulesEngineService Main scoped service facade for rule set operations
RuleEngine<T> AddRule, RemoveRule, ExecuteAsync, GetCatalog — runtime rule management
RuleStoreConfigs Options for disk storage (section RuleStore)
RuleControlPlaneOptions Control plane options: approval, canary, signing (section RuleControlPlane)
RuleOptions Per-rule and per-tenant toggle maps (RuleToggles, TenantRuleToggles)
RuleTracingOptions Tracing TTL, Redis database, PII redaction, per-tenant retention (section RuleTracing)
FileRuleSetStore File-system IRuleSetStore implementation
FileRuleSetAuditStore File-system IRuleSetAuditStore implementation
RedisRuleSetChangeNotifier Redis pub/sub IRuleSetChangeNotifier
InMemoryRuleSetChangeNotifier In-process IRuleSetChangeNotifier (default when no Redis)
RuleSetRuntimeCache IRuleSetRuntimeCache backed by IMemoryCache
HmacSha256RuleSetSigner HMAC-SHA-256 IRuleSetSigner
RsaRuleSetAuditSigner RSA IRuleSetAuditSigner
CloudEventPublishingNotifier Decorator that forwards change events to IEventSink
RuleExecutionEventPublisher Publishes rule execution outcomes as events
IEventDrivenRuleEvaluator Evaluates rules in an event-driven pipeline; result via EventEvaluationStatus
FeelRuleAdapter<TContext> Evaluates FEEL expressions; writes facts with __node.{code}.{path} scoping
JavaScriptRuleAdapter<TContext> Evaluates JS rules via Jint
LiquidRuleAdapter<TContext> Evaluates Liquid template rules via Scriban
DecisionTableRuleAdapter<TContext> Delegates to IDecisionTableExecutor
SubFlowRuleAdapter<TContext> Executes nested rule sub-flows with cycle detection
ConnectorRuleAdapter<TContext> Bridges to external connector rules
RuleGraphParser Parses flow graph JSON and produces topologically sorted RuleGraphEntry lists
ContextAdaptedRule<TChild> Adapts a typed IRule<TChild> for execution against a FactBagRuleContext
ReflectionContextFactory<TContext> IContextFactory<TContext> via reflection
ReflectionContextProjector<TContext> IContextProjector<TContext> via reflection
PercentageRuleActivationStrategy<T> IRuleActivationStrategy<T> for canary/percentage-based activation
MRuleAuthoringManifestRegistry Discovers IRuleAuthoringManifestProvider implementations for rule schema publishing
MRuleContextJsonRegistry Type-safe deserialization registry for rule context types
RuntimeTelemetryDescriptor ITelemetryDescriptor exposing OTel cache and hot-reload metrics

Samples

  • MultiTenantSaaS — multi-tenant pricing API demonstrating AddMRuleEngineWithRedisHotReload for cross-node hot-reload
  • Quickstart.RuleEngine.Runtime.Web — full runtime governance web surface with REST endpoints and SignalR hub via Muonroi.RuleEngine.Runtime.Web

Compatibility

  • Target framework: net8.0
  • Requires Microsoft.AspNetCore.App framework reference
  • License: Apache-2.0 (OSS)

License

Apache-2.0. See LICENSE-APACHE for details.

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 (7)

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

Package Downloads
Muonroi.Messaging.MassTransit

Package Description

Muonroi.RuleEngine.Runtime.Web

Runtime ruleset governance Web API and UI-engine manifest integration for Muonroi RuleEngine.

Muonroi.AuthZ

Package Description

Muonroi.AspNetCore.RuleEngine

ASP.NET Core rule engine integration: Auto CRUD with RuleOrchestrator, generic controllers, and rule change management.

Muonroi.UiEngine.Catalog

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.16 71 6/22/2026
1.0.0-alpha.15 125 5/31/2026
1.0.0-alpha.14 127 5/15/2026
1.0.0-alpha.13 100 5/2/2026
1.0.0-alpha.12 94 4/2/2026
1.0.0-alpha.11 126 4/2/2026
1.0.0-alpha.9 67 3/31/2026
1.0.0-alpha.8 166 3/28/2026
1.0.0-alpha.1 89 3/8/2026