Cirreum.Core
1.0.40
dotnet add package Cirreum.Core --version 1.0.40
NuGet\Install-Package Cirreum.Core -Version 1.0.40
<PackageReference Include="Cirreum.Core" Version="1.0.40" />
<PackageVersion Include="Cirreum.Core" Version="1.0.40" />
<PackageReference Include="Cirreum.Core" />
paket add Cirreum.Core --version 1.0.40
#r "nuget: Cirreum.Core, 1.0.40"
#:package Cirreum.Core@1.0.40
#addin nuget:?package=Cirreum.Core&version=1.0.40
#tool nuget:?package=Cirreum.Core&version=1.0.40
Cirreum Core
Foundational primitives and abstractions for the Cirreum Framework
Overview
Cirreum.Core is the foundational library of the Cirreum ecosystem. It provides the core abstractions, primitives, and shared patterns used across all Cirreum libraries and runtime components.
This is not the application's domain core. Instead, it acts as the framework coreβthe layer that defines the structural backbone of the entire stack.
All other Cirreum libraries (Conductor, Messaging, Authorization, Runtime, Components, and more) build directly on this project.
Purpose
Cirreum.Core exists to deliver a stable, consistent, and expressive foundation that:
- Defines contracts and interfaces shared across the framework
- Supplies lightweight primitives for contexts, identifiers, and pipelines
- Hosts cross-cutting patterns such as CQRS contracts and authorization resources
- Provides utilities supporting consistent behavior across the ecosystem
Its mission is to centralize building blocks that must be universally accessible and long-lived across all Cirreum packages.
Key Features
π― Context Architecture
A composable context system that provides single-source-of-truth operational context throughout your application:
- OperationContext - Canonical WHO/WHEN/WHERE/TIMING information
- RequestContext - Pipeline-aware request context with delegation
- AuthorizationContext - Authorization decisions with effective roles
// Created once in the dispatcher
var operation = OperationContext.Create(
userState, operationId, correlationId, startTimestamp);
// Composed into request context
var requestContext = new RequestContext<TRequest>(
operation, request, requestType);
// Composed into authorization context
var authContext = new AuthorizationContext<TResource>(
operation, effectiveRoles, resource);
See detailed context documentation
π Authorization Abstractions
Flexible, policy-based authorization with support for both RBAC and ABAC patterns:
IAuthorizationEvaluator- Pluggable authorization evaluationIAuthorizableResource- Resources that can be authorizedIAuthorizationValidator- Custom authorization logic- Role resolution with inheritance support
- Built-in Authorization visualizers and documenters
- Flexible AuthN/AuthZ with support for OIDC/MSAL
π Messaging & CQRS (Cirreum Conductor)
A high-performance mediator implementation with comprehensive pipeline support for command/query separation:
Core Features
- Type-safe request/response contracts with
Result<T>pattern - Automatic handler discovery and registration
- Configurable intercept pipeline (validation, authorization, caching, telemetry)
- Pub/sub notification system with multiple publishing strategies
- OpenTelemetry integration with zero overhead when disabled
Request Abstractions
IRequest/IRequest<TResponse>- Base request contractsIDomainCommand/IDomainCommand<TResponse>- Commands with auditing and authorizationIDomainQuery<TResponse>- Queries with auditing and authorizationIDomainCacheableQuery<TResponse>- Cacheable queries with automatic cache management
Built-in Intercepts
- Validation - FluentValidation integration
- Authorization - Resource and policy-based authorization
- Performance Monitoring - Request timing and metrics
- Query Caching - Automatic result caching with configurable providers
Extension Interfaces
IAuditableRequest/IAuditableRequest<T>- Automatic audit trail generationIAuthorizableRequest/IAuthorizableRequest<T>- Authorization evaluationICacheableQuery<T>- Query result caching with sliding/absolute expiration
ποΈ Primitives & Utilities
Battle-tested building blocks:
- High-precision timing with
StartTimestamp - Environment and runtime context
- Identity and user state abstractions
- Correlation and operation tracking
Responsibilities
1. Cross-Framework Abstractions
Base interfaces and extensibility points for:
- Messaging and dispatch behaviors (implemented by Cirreum.Conductor)
- Authorization and evaluator pipelines
- Environment and identity access
- Plugin and integration boundaries
2. Core Primitives
Foundational building blocks including:
- Context structures (
OperationContext,RequestContext,AuthorizationContext) - Identifiers, markers, and metadata carriers
- Base implementations for validators, handlers, and authorizable resources
- High-precision timing infrastructure
3. Shared Patterns
Definitions that support Cirreum's architectural patterns:
- CQRS-style request and response contracts
- ABAC/RBAC authorization with role inheritance
- Interceptors, pipelines, and execution flows
- Metadata propagation and scoped request details
| Interface | Auth | Audit | Cache | Use Case |
|---|---|---|---|---|
IRequest<T> |
β | β | β | Internal/anonymous |
IAuthorizableRequest<T> |
β | β | β | Protected, no logging |
IAuditableRequest<T> |
β | β | β | Logged, open access |
ICacheableQuery<T> |
β | β | β | Public cached lookups |
IAuthorizableCacheableQuery<T> |
β | β | β | Protected high-freq reads |
IDomainQuery<T> |
β | β | β | Sensitive reads |
IDomainCommand<T> |
β | β | β | State mutations |
IDomainCacheableQuery<T> |
β | β | β | Full coverage + cache |
4. Utilities & Helpers
Common functionality implemented using a curated set of stable dependencies:
- SmartFormat for formatting and templating
- FluentValidation for rule-based validation
- Humanizer for readable string and value transformations
- CsvHelper for import/export workflows
Dependencies
Cirreum.Core is intentionally lightweight, but not dependency-free. It includes a small, stable set of critical foundational libraries:
Cirreum.Result- Railway-oriented programming with Result<T>- 'OpenTelemetry.Api' - OpenTelemetry support
- 'OpenTelemetry.Extensions.Hosting' - OpenTelemetry support
Microsoft.Extensions.Telemetry.Abstractions- OpenTelemetry supportMicrosoft.Extensions.Configuration.Json- Configuration managementMicrosoft.Extensions.Configuration.Binder- Configuration bindingFluentValidation- Validation and Authorization rulesHumanizer.Core- Human-readable transformationsSmartFormat- String formattingCsvHelper- CSV processing
These are framework-level dependencies chosen for stability, longevity, and ecosystem alignment.
Design Principles
π¨ Lightweight, Not Minimalist
Dependencies are curatedβnot avoided for their own sake. Each dependency provides significant value and is widely adopted in the .NET ecosystem.
π Stable and Forward-Compatible
The API surface here is foundational and should evolve slowly. Breaking changes are avoided whenever possible.
π Extensible by Design
Every contract is intended to be implemented differently across runtimes or applications. Extensibility is a first-class concern.
β Testability First
All primitives and abstractions are unit-test-friendly with minimal dependencies and clear interfaces.
β‘ Performance Conscious
Zero-allocation patterns where possible, computed properties over mutable state, and careful use of immutable records.
π Observable by Default
Built-in support for OpenTelemetry, structured logging, and distributed tracing through context propagation.
Architecture
Context Composition
OperationContext (Single Source of Truth)
ββ> WHO: UserState, UserId, UserName, TenantId, Roles
ββ> WHEN: Timestamp, StartTimestamp, Elapsed
ββ> WHERE: Environment, RuntimeType
ββ> TIMING: High-precision duration calculation
RequestContext (Pipeline Context)
ββ> Composes: OperationContext
ββ> Adds: Request, RequestType
ββ> Delegates: All user/timing properties to Operation
AuthorizationContext (Authorization Decisions)
ββ> Composes: OperationContext
ββ> Adds: EffectiveRoles, Resource
ββ> Delegates: All user properties to Operation
Zero-Allocation Timing
// Captured once at operation start
long startTimestamp = Stopwatch.GetTimestamp();
// Computed on demand, zero allocation
TimeSpan elapsed = operation.Elapsed;
double milliseconds = operation.ElapsedMilliseconds;
// Available throughout pipeline via delegation
TimeSpan requestElapsed = requestContext.ElapsedDuration;
Authorization Flow
// Ad-hoc authorization (creates context)
var result = await evaluator.Evaluate(resource);
// Pipeline authorization (reuses context)
var result = await evaluator.Evaluate(resource, operationContext);
// Validators receive canonical AuthorizationContext
public class MyValidator : IAuthorizationValidator<MyResource>
{
public Task<Result> Validate(
AuthorizationContext<MyResource> context,
CancellationToken ct)
{
// Access user, roles, resource, timing all in one place
if (context.IsAuthenticated &&
context.EffectiveRoles.Contains(requiredRole))
{
return Result.Success();
}
return Result.Failure("Unauthorized");
}
}
Logical Structure
Cirreum.Core/
βββ Abstractions/
β βββ Authorization/ # IAuthorizationEvaluator, IAuthorizableResource
β βββ Identity/ # IUserState, IUserStateAccessor
β βββ Messaging/ # Request/response contracts
β βββ Environment/ # Runtime and environment abstractions
βββ Contexts/
β βββ OperationContext.cs # Canonical operational context
β βββ RequestContext.cs # Pipeline request context
β βββ AuthorizationContext.cs # Authorization decision context
βββ Primitives/
β βββ Identifiers/ # Operation IDs, correlation IDs
β βββ Markers/ # Interface markers and tags
β βββ Metadata/ # Context metadata carriers
βββ Patterns/
β βββ Validators/ # Base validator implementations
β βββ Interceptors/ # Pipeline interceptor patterns
β βββ Resources/ # Authorizable resource models
βββ Utilities/
βββ Formatting/ # SmartFormat helpers
βββ Validation/ # FluentValidation extensions
βββ Csv/ # CSV import/export utilities
Usage
Installation
dotnet add package Cirreum.Core
Basic Context Usage
// 1. Create operation context (done once in dispatcher)
var operation = OperationContext.Create(
userState: currentUserState,
operationId: Guid.NewGuid().ToString(),
correlationId: Activity.Current?.TraceId.ToString() ?? Guid.NewGuid().ToString(),
startTimestamp: Stopwatch.GetTimestamp()
);
// 2. Use in request pipeline
var requestContext = RequestContext<MyRequest>.Create(
userState: currentUserState,
request: myRequest,
requestType: nameof(MyRequest),
requestId: operation.OperationId,
correlationId: operation.CorrelationId,
startTimestamp: operation.StartTimestamp
);
// 3. Access context throughout pipeline
logger.LogInformation(
"Processing {RequestType} for user {UserId} - {Elapsed}ms",
requestContext.RequestType,
requestContext.UserId,
requestContext.ElapsedDuration.TotalMilliseconds
);
Authorization
// Define authorizable resource
public record DocumentResource : IAuthorizableResource
{
public required string DocumentId { get; init; }
public required string OwnerId { get; init; }
}
// Create validator
public class DocumentAccessValidator
: IAuthorizationValidator<DocumentResource>
{
public Task<Result> Validate(
AuthorizationContext<DocumentResource> context,
CancellationToken ct)
{
// Owner can always access
if (context.Resource.OwnerId == context.UserId)
return Task.FromResult(Result.Success());
// Admins can access
if (context.EffectiveRoles.Any(r => r.Name == "Admin"))
return Task.FromResult(Result.Success());
return Task.FromResult(
Result.Failure("You don't have permission to access this document"));
}
}
// Evaluate authorization
var resource = new DocumentResource
{
DocumentId = "doc-123",
OwnerId = "user-456"
};
var result = await authEvaluator.Evaluate(resource, operationContext);
if (result.IsFailure)
{
return Forbid(result.Error);
}
Integration with Cirreum Ecosystem
Every other Cirreum library depends on Cirreum.Core:
- Cirreum.Conductor - Implements messaging abstractions with CQRS patterns
- Cirreum.Authorization - Provides default authorization evaluators
- Cirreum.Runtime - Supplies runtime-specific implementations
- Cirreum.Components - Builds on primitives for UI components
- Cirreum.Messaging - Extends messaging contracts for events/notifications
This library:
- Defines the shared vocabulary of the framework
- Establishes conventions for request handling, authorization, and behaviors
- Acts as the foundational contract layer between domain-agnostic logic and implementation-specific libraries
Documentation
- Context Architecture - Detailed context composition guide
- Authorization Flow - Authorization best practices
- Authorization Sequence - Authorization best practices
Contribution Guidelines
Be conservative with new abstractions
The API surface must remain stable and meaningful.Limit dependency expansion
Only add foundational, version-stable dependencies.Favor additive, non-breaking changes
Breaking changes ripple through the entire ecosystem.Include thorough unit tests
All primitives and patterns should be independently testable.Document architectural decisions
Context and reasoning should be clear for future maintainers.Follow .NET conventions
Use established patterns from Microsoft.Extensions.* libraries.
Versioning
Cirreum.Core follows Semantic Versioning:
- Major - Breaking API changes
- Minor - New features, backward compatible
- Patch - Bug fixes, backward compatible
Given its foundational role, major version bumps are rare and carefully considered.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- π Documentation
- π Issue Tracker
- π¬ Discussions
Cirreum Foundation Framework
Layered simplicity for modern .NET
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Cirreum.Exceptions (>= 1.0.1)
- Cirreum.Result (>= 1.0.11)
- CsvHelper (>= 33.1.0)
- FluentValidation (>= 12.1.1)
- Humanizer.Core (>= 3.0.1)
- Microsoft.Extensions.Telemetry.Abstractions (>= 10.2.0)
- OpenTelemetry.Api (>= 1.15.0)
- OpenTelemetry.Extensions.Hosting (>= 1.15.0)
- SmartFormat (>= 3.6.1)
NuGet packages (14)
Showing the top 5 NuGet packages that depend on Cirreum.Core:
| Package | Downloads |
|---|---|
|
Cirreum.Services.Client
The Services Infrastructure Library for WebAssembly Client applications. |
|
|
Cirreum.Persistence.Azure
Persistence Library using Azure Cosmos DB for NoSQL. |
|
|
Cirreum.Services.Server
The Service Library for Servers (Web Api or Web App). |
|
|
Cirreum.Runtime.Authorization
The Runtime Authorization configuration. |
|
|
Cirreum.Graph.Provider
The MsGraph provider for the Cirreum foundation |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.40 | 309 | 2/4/2026 |
| 1.0.39 | 410 | 1/23/2026 |
| 1.0.38 | 188 | 1/22/2026 |
| 1.0.37 | 300 | 1/21/2026 |
| 1.0.36 | 285 | 1/12/2026 |
| 1.0.35 | 343 | 1/10/2026 |
| 1.0.34 | 267 | 1/5/2026 |
| 1.0.33 | 255 | 1/5/2026 |
| 1.0.32 | 97 | 1/3/2026 |
| 1.0.31 | 98 | 1/3/2026 |
| 1.0.30 | 306 | 1/2/2026 |
| 1.0.29 | 250 | 12/31/2025 |
| 1.0.28 | 256 | 12/30/2025 |
| 1.0.27 | 244 | 12/29/2025 |
| 1.0.26 | 232 | 12/29/2025 |
| 1.0.25 | 190 | 12/29/2025 |
| 1.0.24 | 183 | 12/29/2025 |
| 1.0.23 | 367 | 12/22/2025 |
| 1.0.22 | 260 | 12/20/2025 |
| 1.0.21 | 558 | 12/16/2025 |