Repository: https://github.com/muonroi/muonroi-building-block
Status: public repo, open-core (Apache-2.0 OSS packages + commercial-licensed packages).
Target audience: unknown (repo docs suggest teams building .NET services that need rule orchestration, decision tables, multi-tenancy, and governance primitives).
Version:1.0.0-alpha.9(repo-wide versioning is configured viaDirectory.Build.props).
Executive summary
Muonroi Building Block is the .NET foundation of the Muonroi ecosystem. It bundles a rule engine stack (strongly typed rules + orchestration + tracing), decision tables (with common hit policies), and supporting infrastructure like governance/licensing concepts and multi-tenancy helpers. The repository is open-core: OSS packages are Apache 2.0, while commercial packages are distributed under a separate commercial license and are expected to be gated at runtime.
A key differentiator is its developer experience around rule authoring: write rule logic in normal C#, mark it with an attribute, then let source generators and CLI tools generate rule classes and DI registration glue. This reduces handmade boilerplate and allows verification steps (e.g., dependency checks) before runtime.
Key features and use cases
Key features (as described by repo README + deep map)
-
Strongly typed rule abstraction (
IRule<TContext>) and shared state via a FactBag. - Rule orchestration with execution hooks, ordering, and dependency constraints.
- Decision table engine with widely used hit policies (Unique, Any, First, All, Collect, RuleOrder).
- Source generators + analyzers to extract rules from code and generate DI registration.
- CLI toolchain (RuleGen) for extract/verify/register/watch flows.
- Multi-tenancy packages for resolving tenant context and linking per-tenant resources.
- Explicit OSS/commercial boundary enforcement via scripts (modular boundary checks).
Practical use cases
- Policy/risk/fraud scoring where rules evolve faster than deployments.
- Decision tables for business-friendly rule maintenance with deterministic evaluation.
- Multi-tenant SaaS foundations: consistent tenant resolution + quota enforcement primitives.
- Preproduction verification: catch rule dependency errors (and other analyzer-driven issues) before runtime.
Architecture and main components
Big-picture: rule execution pipeline
flowchart TD
Input[Input context + facts] --> Orchestrator[IMRuleOrchestrator.ExecuteAsync]
Orchestrator --> FactBag[FactBag shared state]
FactBag --> Rules[Compiled rules / FEEL / decision tables / flow graph]
Rules --> Result[OrchestratorResult + updated facts]
Big-picture: code-first rule authoring + generation
flowchart LR
Dev[Developer writes C# method] --> Attr[[MExtractAsRule]]
Attr --> CLI[muonroi-rule extract/register/verify]
CLI --> Gen[Generated rule classes + DI registration]
Gen --> DI[services.AddRuleEngine<T>() + AddGeneratedRules()]
DI --> Runtime[Runtime executes rules via orchestrator]
Monorepo layout (high level)
muonroi-building-block/
src/
Muonroi.RuleEngine.Abstractions/
Muonroi.RuleEngine.Core/
Muonroi.RuleEngine.DecisionTable/
Muonroi.RuleEngine.SourceGenerators/
Muonroi.Tenancy.*
Muonroi.Governance.*
Muonroi.Observability
(...more packages...)
tools/
Muonroi.RuleGen/ # CLI for rule extraction/registration/verification
Muonroi.DecisionTableGen/ # decision table tooling (per deep map)
Muonroi.RuleGen.VisualStudio/ # VS extension (per deep map)
Muonroi.RuleGen/vscode-extension/ # VS Code extension (per deep map)
samples/
Quickstart.RuleEngine/
Quickstart.DecisionTable/
FraudDetection/
LoanApproval/
MultiTenantSaaS/
RuleSourceGen/
REPO_DEEP_MAP.md
OSS-BOUNDARY.md
LICENSE-APACHE / LICENSE-COMMERCIAL
If you want the “map of everything,” the repo provides it:
Installation and quickstart
Install the core rule engine packages
dotnet add package Muonroi.RuleEngine.Core
dotnet add package Muonroi.RuleEngine.SourceGenerators
Exact versions are unknown here; prefer pinning versions explicitly for production.
Quick example: write a rule in plain C
[MExtractAsRule("HIGH_VALUE_ORDER", DependsOn = new[] { "CREDIT_SCORE" })]
public RuleResult HighValue(OrderContext context, FactBag facts)
{
if (context.Amount <= 1000m) return RuleResult.Failure("Below threshold.");
facts["requiresReview"] = true;
return RuleResult.Success();
}
Generate the glue code and wire up DI
muonroi-rule extract --source src/Rules --output Generated/Rules
muonroi-rule register --rules Generated/Rules --output Generated/RuleEngineRegistrationExtensions.g.cs
using Muonroi.RuleEngine.Generated;
builder.Services.AddRuleEngine<OrderContext>();
builder.Services.AddGeneratedRules();
Run a sample (Rule Engine quickstart)
cd <workspace-root>\muonroi-building-block\samples\Quickstart.RuleEngine\src\Quickstart.RuleEngine.Api
dotnet restore
dotnet run
Test request:
curl -X POST http://localhost:5000/api/orders/evaluate `
-H "Content-Type: application/json" `
-d "{\"amount\":1200,\"customerType\":\"premium\",\"countryCode\":\"US\"}"
Run a sample (Decision Table quickstart)
Start Postgres locally:
docker run --name muonroi-sample-postgres `
-e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=muonroi_decision_tables `
-p 5432:5432 -d postgres:16
Run the API sample:
cd <workspace-root>\muonroi-building-block\samples\Quickstart.DecisionTable\src\Quickstart.DecisionTable.Api
dotnet restore
dotnet run
Create and execute a table via REST APIs:
Invoke-RestMethod -Method Post -Uri "http://localhost:5000/api/v1/decision-tables" `
-ContentType "application/json" -InFile ".\assets\discount-table.json"
$body = '{"inputs":{"amount":1200,"customerType":"premium","country":"US"}}'
Invoke-RestMethod -Method Post -Uri "http://localhost:5000/api/v1/decision-tables/discount-rules/execute" `
-ContentType "application/json" -Body $body
Contribution guide and license
Contributing
The contribution guide emphasizes “boundary-safe” work:
- Default working branch:
develop - Prereqs: .NET SDK 8+, PowerShell 7+; Postgres/Redis only if your change needs them
- Run tests + the modular boundary check before opening a PR:
pwsh ./scripts/check-modular-boundaries.ps1 -RepoRoot .
dotnet test Muonroi.BuildingBlock.sln -c Debug
Contributing guide:
https://github.com/muonroi/muonroi-building-block/blob/main/CONTRIBUTING.md
License (open-core)
- OSS packages: Apache 2.0 (
LICENSE-APACHE) - Commercial packages: Muonroi commercial license (
LICENSE-COMMERCIAL) - The repo documents an OSS/commercial boundary rule and checks it via a script:
- OSS packages MUST NOT depend on commercial packages.
- Commercial packages MAY depend on OSS packages.
Key boundary doc:
https://github.com/muonroi/muonroi-building-block/blob/main/OSS-BOUNDARY.md
License files:
- https://github.com/muonroi/muonroi-building-block/blob/main/LICENSE-APACHE
- https://github.com/muonroi/muonroi-building-block/blob/main/LICENSE-COMMERCIAL
Comparison to similar projects (brief)
-
Microsoft RulesEngine: JSON-defined workflows and dynamic expression evaluation; Muonroi Building Block offers a more “code-first + source-generated” workflow (plus decision tables, tenancy/governance packages).
References: NRules: Rete-based .NET rules engine with an internal DSL in C#. Muonroi’s approach leans more toward orchestration + multiple rule types (compiled rules, decision tables, FEEL, flow graphs) and a CLI/source-generator pipeline.
Reference: https://github.com/NRules/NRulesDrools / DMN decision tables: DMN decision tables and FEEL are widely used in decision modeling; Muonroi explicitly implements decision tables and FEEL-related pieces in its runtime/tooling.
Reference: https://docs.drools.org/7.73.0.Final/drools-docs/html_single/index.html
Suggested tags and social blurb
Suggested dev.to tags
dotnet, csharp, rulesengine, decisiontable, opensource, multitenant, architecture, sourcegenerators, cli, observability
Social blurb (3–5 lines)
Muonroi Building Block is an open-core .NET foundation for rule engines, decision tables, and multi-tenant services.
It supports code-first rules + source-generated registration, decision table evaluation, and runtime orchestration with shared FactBag state.
If you’re building policy-heavy systems (risk/fraud/pricing) and want strong DX around rule authoring, it’s worth a deep look.
Repo: https://github.com/muonroi/muonroi-building-block
References
- Repo deep map: https://github.com/muonroi/muonroi-building-block/blob/main/REPO_DEEP_MAP.md
- OSS boundary doc: https://github.com/muonroi/muonroi-building-block/blob/main/OSS-BOUNDARY.md
- Microsoft RulesEngine: https://github.com/microsoft/RulesEngine
- NRules: https://github.com/NRules/NRules
- Drools DMN + decision tables: https://docs.drools.org/7.73.0.Final/drools-docs/html_single/index.html
Top comments (0)