Muonroi.Core.Abstractions
1.0.0-alpha.16
dotnet add package Muonroi.Core.Abstractions --version 1.0.0-alpha.16
NuGet\Install-Package Muonroi.Core.Abstractions -Version 1.0.0-alpha.16
<PackageReference Include="Muonroi.Core.Abstractions" Version="1.0.0-alpha.16" />
<PackageVersion Include="Muonroi.Core.Abstractions" Version="1.0.0-alpha.16" />
<PackageReference Include="Muonroi.Core.Abstractions" />
paket add Muonroi.Core.Abstractions --version 1.0.0-alpha.16
#r "nuget: Muonroi.Core.Abstractions, 1.0.0-alpha.16"
#:package Muonroi.Core.Abstractions@1.0.0-alpha.16
#addin nuget:?package=Muonroi.Core.Abstractions&version=1.0.0-alpha.16&prerelease
#tool nuget:?package=Muonroi.Core.Abstractions&version=1.0.0-alpha.16&prerelease
Muonroi.Core.Abstractions
Core contracts, interfaces, and base types shared by every package in the Muonroi ecosystem.
This package ships contracts only — interfaces, base classes, options, and exception types. It contains no runtime service registrations. All Muonroi packages depend on it as their shared vocabulary; the runtime implementations live in Muonroi.Core.
Installation
dotnet add package Muonroi.Core.Abstractions --prerelease
Quick Start
Add this package when you are building a library or adapter that needs to depend on Muonroi contracts without pulling in full runtime implementations. Implement or consume the key interfaces directly:
using Muonroi.Core.Abstractions.Context;
// Implement IContextResolver to feed tenant/user identity into the execution context.
public sealed class HttpContextResolver(IHttpContextAccessor accessor) : IContextResolver
{
public string? ResolveTenantId() =>
accessor.HttpContext?.Request.Headers["X-Tenant-Id"].FirstOrDefault();
public string? ResolveUserId() =>
accessor.HttpContext?.User.FindFirst("sub")?.Value;
public string? ResolveUsername() =>
accessor.HttpContext?.User.Identity?.Name;
}
// Consume ISystemExecutionContext wherever you need the current tenant/user/correlation context.
public class OrderService(ISystemExecutionContextAccessor ctx)
{
public void PlaceOrder()
{
ISystemExecutionContext context = ctx.Get();
string tenantId = context.TenantId ?? throw new InvalidOperationException("No tenant");
string correlationId = context.CorrelationId;
// ...
}
}
For the full runtime wiring (DI registration, middleware, AsyncLocal accessor), see Muonroi.Core.
Features
- Execution context contracts —
ISystemExecutionContext/ISystemExecutionContextAccessorcarry tenant ID, user ID, username, correlation ID, access token, API key, permissions, and source type across async call stacks viaAsyncLocal<T>. - Context resolution —
IContextResolverinterface for plugging in custom tenant/user resolvers;NullContextResolverprovided as a default no-op. - Tenant policy —
ITenantContextPolicyenforces tenant context presence;DefaultTenantContextPolicyreads fromIContextResolverand throwsMissingTenantContextException/MissingUserContextExceptionwhen required context is absent. - Structured responses —
MResponse<T>wraps results and errors uniformly across all API boundaries;MVoidMethodResultfor command endpoints;MErrorResult/MErrorResponsefor consistent error payloads. - Domain entity base —
MEntityprovidesId,EntityId(Guid), soft-delete flags, audit timestamps, and a domain-event collection (AddDomainEvent/ClearDomainEvents). - Domain events —
IMDomainEvent/INotificationmarker interfaces for MediatR-style event dispatch. - Typed exceptions —
MNotFoundException,MConflictException,MUnauthorizedException,MArgumentException,MInternalException(captures[CallerMemberName]/[CallerFilePath]) all derive from a commonMExceptionbase. - Diagnostics contracts —
IMTraceContext/ITraceSession/ITraceSessionStorefor structured, session-based distributed tracing;[MTraceable]/[MTraceSensitive]attributes for opt-in instrumentation. - Ecosystem registry —
IMEcosystemRegistrytracks whichMCapabilityflags are active; each package self-registers during DI setup. - Auth helpers —
AuthOptions/AuthClaimMapfor configurable JWT claim mapping;MAuthenticateTokenHelper<TPermission>for token generation. - Validation base —
MValidationObject(base ofMEntity) provides collected validation errors with a fluent pattern. - JSON serialization —
IMJsonSerializeServicecontract for pluggable JSON serialization;MDateTimeConverterfor consistent DateTime handling. - UiEngine catalog contracts —
ICatalogSnapshotStore,ICatalogScanService, and theMUiEngineCatalog*model graph for the UI engine integration layer.
Configuration
This package declares no DI registration extension. Configure it through the implementation package:
// In your host, register Muonroi.Core (the implementation):
builder.Services.AddMuonroiCore(); // defined in Muonroi.Core
AuthOptions can be bound from appsettings.json:
{
"Auth": {
"ClaimMap": {
"UserIdentifier": "sub",
"TenantId": "tid",
"Permission": "permissions"
}
}
}
builder.Services.Configure<AuthOptions>(builder.Configuration.GetSection("Auth"));
API Reference
| Type | Purpose |
|---|---|
ISystemExecutionContext |
Read-only view of tenant, user, correlation, permissions, and source type for the current request |
ISystemExecutionContextAccessor |
Get/set/clear the AsyncLocal-backed execution context |
SystemExecutionContext |
Default implementation with a .With(...) copy-and-update method and a static .Empty sentinel |
IContextResolver |
Plug in custom tenant/user resolution logic (HTTP headers, gRPC metadata, etc.) |
NullContextResolver |
No-op resolver; returns null for all methods |
ITenantContextPolicy |
Enforce tenant/user context presence; throws typed exceptions on violation |
DefaultTenantContextPolicy |
Default policy backed by IContextResolver and optional IConfiguration |
MissingTenantContextException |
Thrown when tenant context is required but absent |
MissingUserContextException |
Thrown when user context is required but absent |
MResponse<T> |
Unified response envelope: Result, Error, StatusCode, AddErrors |
MVoidMethodResult |
Base response for void/command operations |
MErrorResult |
Single structured error with ErrorCode and ErrorValues |
MEntity |
Base entity: Id, EntityId (Guid), soft-delete, audit timestamps, domain events |
IMDomainEvent |
Marker interface for domain events collected on MEntity |
MNotFoundException |
404-mapped domain exception; records EntityName and EntityId in Details |
MConflictException |
409-mapped domain exception |
MUnauthorizedException |
401-mapped security exception |
MInternalException |
500-mapped internal exception; auto-captures caller member/file/line |
MArgumentException |
Argument validation exception |
IMEcosystemRegistry |
Query or register MCapability flags activated at startup |
IMTraceContext |
Begin/access distributed trace sessions scoped to async flow |
ITraceSession |
Active trace session with node recording |
ITraceSessionStore |
Persist and retrieve MTraceSessionRecord data |
AuthOptions / AuthClaimMap |
JWT claim key mapping for tenant, user, permissions |
MAuthenticateTokenHelper<TPermission> |
Generate signed JWT tokens from a MTokenPayload |
IMJsonSerializeService |
Pluggable JSON serialize/deserialize contract |
MValidationObject |
Base class for validation-aware objects |
ICatalogSnapshotStore |
Store/retrieve UiEngine catalog snapshots |
ICatalogScanService |
Scan and register UiEngine API/rule descriptors |
Samples
No dedicated sample targets this package directly. The contracts are consumed by all runtime samples in this repository:
- Muonroi.Experience.Sample — demonstrates context and response patterns via the full runtime stack
Compatibility
- Target framework:
net8.0 - License: Apache-2.0 (OSS)
Related Packages
Muonroi.Core— runtime implementation: DI registration,AddMuonroiCore(),SystemExecutionContextAccessorwiring, JSON servicesMuonroi.Logging.Abstractions— logging contracts depended on by this package
License
Licensed under the Apache License, Version 2.0.
| 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.Logging.Abstractions (>= 10.0.3)
- Microsoft.IdentityModel.Tokens (>= 8.0.1)
- Muonroi.Logging.Abstractions (>= 1.0.0-alpha.16)
- System.IdentityModel.Tokens.Jwt (>= 8.0.1)
NuGet packages (52)
Showing the top 5 NuGet packages that depend on Muonroi.Core.Abstractions:
| Package | Downloads |
|---|---|
|
Muonroi.RuleEngine.Abstractions
Rule Engine Abstractions for Muonroi.BuildingBlock |
|
|
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.Tenancy.Abstractions
Multi-tenancy contracts: ITenantContext, ITenantIdResolver, and shared tenant models for Muonroi applications. |
|
|
Muonroi.Quota.Abstractions
Quota tracking contracts and in-memory implementations for Muonroi multi-tenant applications. Contains ITenantQuotaTracker, ITenantQuotaStore, QuotaType, TenantQuota models and presets. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.16 | 198 | 6/22/2026 |
| 1.0.0-alpha.15 | 348 | 5/31/2026 |
| 1.0.0-alpha.14 | 332 | 5/15/2026 |
| 1.0.0-alpha.13 | 267 | 5/2/2026 |
| 1.0.0-alpha.12 | 130 | 4/2/2026 |
| 1.0.0-alpha.11 | 173 | 4/2/2026 |
| 1.0.0-alpha.9 | 130 | 3/30/2026 |
| 1.0.0-alpha.8 | 370 | 3/28/2026 |
| 1.0.0-alpha.7 | 85 | 3/27/2026 |
| 1.0.0-alpha.5 | 88 | 3/27/2026 |
| 1.0.0-alpha.4 | 83 | 3/27/2026 |
| 1.0.0-alpha.3 | 91 | 3/27/2026 |
| 1.0.0-alpha.2 | 95 | 3/26/2026 |
| 1.0.0-alpha.1 | 139 | 3/8/2026 |