Muonroi.RuleEngine.Runtime
1.0.0-alpha.16
dotnet add package Muonroi.RuleEngine.Runtime --version 1.0.0-alpha.16
NuGet\Install-Package Muonroi.RuleEngine.Runtime -Version 1.0.0-alpha.16
<PackageReference Include="Muonroi.RuleEngine.Runtime" Version="1.0.0-alpha.16" />
<PackageVersion Include="Muonroi.RuleEngine.Runtime" Version="1.0.0-alpha.16" />
<PackageReference Include="Muonroi.RuleEngine.Runtime" />
paket add Muonroi.RuleEngine.Runtime --version 1.0.0-alpha.16
#r "nuget: Muonroi.RuleEngine.Runtime, 1.0.0-alpha.16"
#:package Muonroi.RuleEngine.Runtime@1.0.0-alpha.16
#addin nuget:?package=Muonroi.RuleEngine.Runtime&version=1.0.0-alpha.16&prerelease
#tool nuget:?package=Muonroi.RuleEngine.Runtime&version=1.0.0-alpha.16&prerelease
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.
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 byAllowedPathSegmentPattern - Postgres-backed store —
PostgresRuleSetStorevia EF Core + Npgsql for durable persistence (registered separately) - In-memory
IRuleSetRuntimeCache— hot-invalidated throughIRuleSetChangeNotifier; configurable absolute expiry viaRuntimeCacheMinutes - Redis hot-reload —
RedisRuleSetChangeNotifiersubscribes to a configurable pub/sub channel (muonroi:ruleset:changed) so all nodes pick up ruleset changes without restart - CloudEvents bridge —
CloudEventPublishingNotifierdecorates anyIRuleSetChangeNotifierto forward lifecycle events toIEventSink;RuleExecutionEventPublisherandIEventDrivenRuleEvaluatorintegrate with event-driven pipelines - Multi-dialect adapters —
FeelRuleAdapter,JavaScriptRuleAdapter(Jint),LiquidRuleAdapter,DecisionTableRuleAdapter,SubFlowRuleAdapter,ConnectorRuleAdapter,FeelRuleAdapter - Flow graph execution —
RuleGraphParserapplies Kahn's topological sort;ContextAdaptedRuleandReflectionContextFactory/ReflectionContextProjectorbridge typed contexts toFactBag - Ruleset signing —
HmacSha256RuleSetSignerandRsaRuleSetAuditSigner; optionalRequireSignatureenforcement in the store - Audit trail —
IRuleSetAuditStore/FileRuleSetAuditStorewithRuleSetAuditEntryrecords; RSA-signed entries viaRsaRuleSetAuditSigner - Rule toggles —
RuleOptions.RuleTogglesandTenantRuleTogglesfor per-rule and per-tenant feature flags evaluated byRuleEngine<T> - Execution tracing —
IRuleExecutionTracer+RuleExecutionTracerbacked byRedisRuleTraceStore; PII field redaction viaITraceRedactor; per-tenant TTL overrides - Debugger mode —
IRuleDebuggerModeServicewith Redis-backed on/off flag;RuleTracingEndpointsfor HTTP management - Maker-checker + canary —
RequireApprovalandEnableCanaryinRuleControlPlaneOptions;PercentageRuleActivationStrategyfor gradual rollout - OTel telemetry —
RuntimeTelemetryDescriptorexposes 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
AddMRuleEngineWithRedisHotReloadfor 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.Appframework reference - License: Apache-2.0 (OSS)
Related Packages
Muonroi.RuleEngine.Abstractions— contracts this package implements (IRuleSetStore,IRuleSetSigner, adapters)Muonroi.RuleEngine.Core— rule orchestrator, workflow runner, and audit hooksMuonroi.RuleEngine.DecisionTable— decision table executor consumed byDecisionTableRuleAdapterMuonroi.RuleEngine.Runtime.Web— REST + SignalR web surface built on top of this package
License
Apache-2.0. See LICENSE-APACHE for details.
| 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
- Jint (>= 4.6.3)
- MailKit (>= 4.17.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.3)
- Muonroi.Caching.Memory (>= 1.0.0-alpha.16)
- Muonroi.Core (>= 1.0.0-alpha.16)
- Muonroi.Core.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Governance.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Integration.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.RuleEngine.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.RuleEngine.Core (>= 1.0.0-alpha.16)
- Muonroi.RuleEngine.DecisionTable (>= 1.0.0-alpha.16)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.11)
- RulesEngine (>= 6.0.0)
- Scriban (>= 7.2.1)
- StackExchange.Redis (>= 2.8.37)
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 |