Muonroi.Core.Abstractions 1.0.0-alpha.16

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

Muonroi.Core.Abstractions

Core contracts, interfaces, and base types shared by every package in the Muonroi ecosystem.

NuGet License: Apache 2.0

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 contractsISystemExecutionContext / ISystemExecutionContextAccessor carry tenant ID, user ID, username, correlation ID, access token, API key, permissions, and source type across async call stacks via AsyncLocal<T>.
  • Context resolutionIContextResolver interface for plugging in custom tenant/user resolvers; NullContextResolver provided as a default no-op.
  • Tenant policyITenantContextPolicy enforces tenant context presence; DefaultTenantContextPolicy reads from IContextResolver and throws MissingTenantContextException / MissingUserContextException when required context is absent.
  • Structured responsesMResponse<T> wraps results and errors uniformly across all API boundaries; MVoidMethodResult for command endpoints; MErrorResult / MErrorResponse for consistent error payloads.
  • Domain entity baseMEntity provides Id, EntityId (Guid), soft-delete flags, audit timestamps, and a domain-event collection (AddDomainEvent / ClearDomainEvents).
  • Domain eventsIMDomainEvent / INotification marker interfaces for MediatR-style event dispatch.
  • Typed exceptionsMNotFoundException, MConflictException, MUnauthorizedException, MArgumentException, MInternalException (captures [CallerMemberName] / [CallerFilePath]) all derive from a common MException base.
  • Diagnostics contractsIMTraceContext / ITraceSession / ITraceSessionStore for structured, session-based distributed tracing; [MTraceable] / [MTraceSensitive] attributes for opt-in instrumentation.
  • Ecosystem registryIMEcosystemRegistry tracks which MCapability flags are active; each package self-registers during DI setup.
  • Auth helpersAuthOptions / AuthClaimMap for configurable JWT claim mapping; MAuthenticateTokenHelper<TPermission> for token generation.
  • Validation baseMValidationObject (base of MEntity) provides collected validation errors with a fluent pattern.
  • JSON serializationIMJsonSerializeService contract for pluggable JSON serialization; MDateTimeConverter for consistent DateTime handling.
  • UiEngine catalog contractsICatalogSnapshotStore, ICatalogScanService, and the MUiEngineCatalog* 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:

Compatibility

  • Target framework: net8.0
  • License: Apache-2.0 (OSS)
  • Muonroi.Core — runtime implementation: DI registration, AddMuonroiCore(), SystemExecutionContextAccessor wiring, JSON services
  • Muonroi.Logging.Abstractions — logging contracts depended on by this package

License

Licensed under the Apache License, Version 2.0.

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