HoneyDrunk.Kernel.Abstractions 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package HoneyDrunk.Kernel.Abstractions --version 0.2.0
                    
NuGet\Install-Package HoneyDrunk.Kernel.Abstractions -Version 0.2.0
                    
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="HoneyDrunk.Kernel.Abstractions" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HoneyDrunk.Kernel.Abstractions" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="HoneyDrunk.Kernel.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 HoneyDrunk.Kernel.Abstractions --version 0.2.0
                    
#r "nuget: HoneyDrunk.Kernel.Abstractions, 0.2.0"
                    
#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 HoneyDrunk.Kernel.Abstractions@0.2.0
                    
#: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=HoneyDrunk.Kernel.Abstractions&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=HoneyDrunk.Kernel.Abstractions&version=0.2.0
                    
Install as a Cake Tool

HoneyDrunk.Kernel

Validate PR License: MIT .NET 10

Foundational primitives for HoneyDrunk.OS - The bedrock that powers every Node, service, and agent across the Grid.

๐Ÿ“ฆ What Is This?

HoneyDrunk.Kernel is the primordial layer of HoneyDrunk.OS ("the Hive"). It defines shared primitives that make the ecosystem coherent and interoperable:

  • โœ… Dependency Injection - Service registration and lifetime scoping
  • โœ… Configuration - Unified secrets management (environment, Vault, composite)
  • โœ… Context Propagation - Correlation/causation tracking across async boundaries
  • โœ… Diagnostics - Health checks and metrics abstractions
  • โœ… Time & ID Abstractions - Deterministic, testable primitives
  • โœ… Framework Integration - Extends Microsoft.Extensions, doesn't replace it

Signal Quote: "Where everything begins."


๐Ÿš€ Quick Start

Installation

<ItemGroup>
  
  <PackageReference Include="HoneyDrunk.Kernel.Abstractions" Version="0.1.0" />
  
  
  <PackageReference Include="HoneyDrunk.Kernel" Version="0.1.0" />
</ItemGroup>

Register Kernel Services

using HoneyDrunk.Kernel.DI;

var builder = WebApplication.CreateBuilder(args);

// Register Kernel defaults (Clock, IdGenerator, Context, Metrics)
builder.Services.AddKernelDefaults();

var app = builder.Build();
app.Run();

๐ŸŽฏ Features

๐Ÿ” Core Primitives

Component Purpose Key Types
Context Propagation Correlation/causation tracking IKernelContext
Time Abstractions Deterministic time for tests IClock, SystemClock
ID Generation Unique identifiers (ULID) IIdGenerator, UlidGenerator
Secrets Management Vault + environment integration ISecretsSource, CompositeSecretsSource
Health Checks Composite health monitoring IHealthCheck, CompositeHealthCheck
Metrics Observability abstraction IMetricsCollector (no-op by default)

๐Ÿ”— Framework Integration

HoneyDrunk.Kernel extends rather than replaces Microsoft.Extensions:

Microsoft.Extensions Kernel's Role
ILogger<T> Used directly; no wrapper needed
IConfiguration Used directly; Kernel adds ISecretsSource
IHostedService Used directly for background services
IServiceCollection Extended via AddKernelDefaults()

๐Ÿšซ Intentionally Out of Scope

Kernel stays minimal. Heavy behavior belongs downstream:

Feature Recommended Location
Metrics backends (OpenTelemetry, App Insights) Service-level registration
Resilience (retry, circuit breaker) HoneyDrunk.Transport
Validation (FluentValidation) Service-level or HoneyDrunk.Data
Result<T> monads Service-level or HoneyDrunk.Common
HTTP clients HoneyDrunk.Web.Rest
Database abstractions HoneyDrunk.Data
Authentication/Authorization HoneyDrunk.Auth

Why? Predictability > Cleverness. Simplicity scales.


๐Ÿ“– Usage Examples

Context Propagation

using HoneyDrunk.Kernel.Abstractions.Context;
using Microsoft.Extensions.Logging;

public class OrderService(IKernelContext context, ILogger<OrderService> logger)
{
    public async Task ProcessOrderAsync(string orderId)
    {
        logger.LogInformation(
            "Processing order {OrderId} with CorrelationId: {CorrelationId}", 
            orderId, 
            context.CorrelationId);
        
        // Context flows through async boundaries automatically
        await SaveOrderAsync(orderId, context.Cancellation);
    }
}

Deterministic Time (Testable)

using HoneyDrunk.Kernel.Abstractions.Time;

public class EventStore(IClock clock)
{
    public Event CreateEvent(string data)
    {
        return new Event
        {
            Data = data,
            Timestamp = clock.UtcNow  // Mockable in tests!
        };
    }
}

Record Metrics

using HoneyDrunk.Kernel.Abstractions.Diagnostics;

public class PaymentProcessor(IMetricsCollector metrics)
{
    public async Task ProcessPaymentAsync(decimal amount)
    {
        metrics.RecordCounter("payments.processed", 1, 
            new KeyValuePair<string, object?>("currency", "USD"));
        
        metrics.RecordHistogram("payments.amount", (double)amount);
    }
}

Note: Kernel provides a no-op IMetricsCollector by default. Register a real backend (OpenTelemetry, Application Insights) in your service's startup.

Composite Health Checks

using HoneyDrunk.Kernel.Abstractions.Health;
using HoneyDrunk.Kernel.Health;

var healthChecks = new IHealthCheck[]
{
    new DatabaseHealthCheck(),
    new CacheHealthCheck(),
    new ExternalApiHealthCheck()
};

var composite = new CompositeHealthCheck(healthChecks);
var status = await composite.CheckAsync();
// Returns worst status: Unhealthy > Degraded > Healthy

๐Ÿงช Testing & Validation

Writing Deterministic Tests

Kernel abstractions enable repeatable tests:

using HoneyDrunk.Kernel.Abstractions.Time;
using Xunit;

public class EventStoreTests
{
    [Fact]
    public void CreateEvent_UsesFixedTimestamp()
    {
        // Arrange
        var fixedTime = new DateTimeOffset(2025, 1, 1, 0, 0, 0, TimeSpan.Zero);
        var clock = new FixedClock(fixedTime);
        var store = new EventStore(clock);
        
        // Act
        var evt = store.CreateEvent("test-data");
        
        // Assert
        Assert.Equal(fixedTime, evt.Timestamp);
    }
}

// Simple test double for IClock
public class FixedClock(DateTimeOffset fixedTime) : IClock
{
    public DateTimeOffset UtcNow => fixedTime;
    public long GetTimestamp() => fixedTime.Ticks;
}

Testing Best Practices:

  • โœ… Always inject IClock instead of using DateTime.UtcNow
  • โœ… Use IIdGenerator for correlation/causation IDs
  • โœ… Mock IMetricsCollector to verify metrics are recorded
  • โœ… Use IKernelContext with known correlation IDs for tracing validation

Local Development

git clone https://github.com/HoneyDrunkStudios/HoneyDrunk.Kernel
cd HoneyDrunk.Kernel/HoneyDrunk.Kernel

dotnet restore
dotnet build
dotnet test HoneyDrunk.Kernel.Tests/HoneyDrunk.Kernel.Tests.csproj

๐Ÿ› ๏ธ Configuration

Customization via DI

// Replace default implementations
builder.Services.AddSingleton<IClock, CustomClock>();
builder.Services.AddSingleton<IIdGenerator, GuidGenerator>();
builder.Services.AddSingleton<IMetricsCollector, OpenTelemetryMetricsCollector>();

Secrets Management

using HoneyDrunk.Kernel.Abstractions.Config;
using HoneyDrunk.Kernel.Config.Secrets;

// Composite source: try environment first, then Vault
var secrets = new CompositeSecretsSource(new ISecretsSource[]
{
    new EnvironmentSecretsSource(),
    new VaultSecretsSource(vaultClient)
});

if (secrets.TryGetSecret("DatabasePassword", out var password))
{
    // Use password
}

๐Ÿงฑ Architecture

Repository Layout

HoneyDrunk.Kernel/
 โ”œโ”€โ”€ HoneyDrunk.Kernel.Abstractions/    # Contracts & interfaces
 โ”œโ”€โ”€ HoneyDrunk.Kernel/                 # Runtime implementations
 โ”œโ”€โ”€ HoneyDrunk.Kernel.Tests/           # Test project
 โ”œโ”€โ”€ HoneyDrunk.Kernel.sln
 โ”œโ”€โ”€ .editorconfig
 โ””โ”€โ”€ .github/workflows/
     โ”œโ”€โ”€ validate-pr.yml
     โ””โ”€โ”€ publish.yml

Design Philosophy

  • Predictability > Cleverness โ€“ Simplicity scales
  • Replaceable without regret โ€“ Contracts, not frameworks
  • Observable by default โ€“ Every operation emits measurable signals
  • Secure by design โ€“ Vault integration from the start
  • Portable โ€“ Works in APIs, background services, agent runtimes

Relationships

Upstream Dependencies:

  • HoneyDrunk.Standards (analyzers, conventions)
  • HoneyDrunk.Build (CI/CD tooling)

Downstream Consumers:

  • HoneyDrunk.Data (database abstractions)
  • HoneyDrunk.Transport (messaging, resilience)
  • HoneyDrunk.Web.Rest (HTTP APIs)
  • HoneyDrunk.Auth (authentication/authorization)
  • HoneyDrunk.Vault (secrets management)

โš™๏ธ Build & Release

CI/CD Integration

The package is validated and published automatically:

# Validate on PR
- push โ†’ build + test
- pull_request โ†’ validate formatting and analyzers

# Publish on tag
- tag v* โ†’ build + test + pack + publish to NuGet

Release Workflow

# Tag a release
git tag v0.1.0
git push origin v0.1.0

# GitHub Actions automatically:
# 1. Builds solution
# 2. Runs tests
# 3. Packs both packages
# 4. Publishes to NuGet.org
# 5. Creates GitHub Release

๐Ÿ“‹ Testing Policy

  • All tests live in HoneyDrunk.Kernel.Tests โ€” none in runtime projects
  • Shared fixtures will later come from HoneyDrunk.Testing
  • Tests must use IClock and IIdGenerator for deterministic runs
  • CI gate: build fails if tests fail; coverage threshold optional

๐Ÿค Contributing

Contributions are welcome! Please:

  1. Read .github/copilot-instructions.md for coding standards
  2. Open an issue for discussion before major changes
  3. Ensure all tests pass locally
  4. Update documentation for new features

Development Workflow

# Restore dependencies
dotnet restore HoneyDrunk.Kernel/HoneyDrunk.Kernel.sln

# Build with warnings as errors
dotnet build HoneyDrunk.Kernel/HoneyDrunk.Kernel.sln -c Release /p:TreatWarningsAsErrors=true

# Run tests
dotnet test HoneyDrunk.Kernel/HoneyDrunk.Kernel.Tests/HoneyDrunk.Kernel.Tests.csproj

# Pack for local testing
dotnet pack HoneyDrunk.Kernel/HoneyDrunk.Kernel.Abstractions/HoneyDrunk.Kernel.Abstractions.csproj -c Release -o ./artifacts
dotnet pack HoneyDrunk.Kernel/HoneyDrunk.Kernel/HoneyDrunk.Kernel.csproj -c Release -o ./artifacts

๐Ÿ“„ License

This project is licensed under the MIT License.


๐Ÿ About HoneyDrunk Studios

HoneyDrunk.Kernel is part of the Hive ecosystem - a collection of tools, libraries, and standards for building high-quality .NET applications.

Other Projects:

  • ๐Ÿš€ HoneyDrunk.Standards - Build-transitive analyzers and conventions
  • ๐Ÿšง HoneyDrunk.Data (coming soon) - Database abstractions
  • ๐Ÿšง HoneyDrunk.Transport (coming soon) - Messaging and resilience

๐Ÿ“ž Support

  • Questions: Open a discussion
  • Bugs: File an issue
  • Feature Requests: Open an issue with the enhancement label

๐Ÿงƒ Motto

"If the Kernel is stable, everything above it can change fearlessly."


<div align="center">

Built with ๐Ÿฏ by HoneyDrunk Studios

GitHub โ€ข NuGet: Abstractions โ€ข NuGet: Kernel โ€ข Issues

</div>

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (16)

Showing the top 5 NuGet packages that depend on HoneyDrunk.Kernel.Abstractions:

Package Downloads
HoneyDrunk.Kernel

Production-ready runtime implementations for HoneyDrunk.OS Grid. Provides GridContext, NodeContext, OperationContext implementations, transport binders (HTTP/messaging/jobs), context mappers, GridContextMiddleware, lifecycle orchestration, AgentsInterop, telemetry (GridActivitySource), and unified bootstrapping (AddHoneyDrunkGrid).

HoneyDrunk.Vault

Secrets and configuration management library for .NET. Provides a unified abstraction for accessing secrets from multiple providers (File, Azure Key Vault, AWS Secrets Manager, Configuration, In-Memory). Integrated with HoneyDrunk.Kernel v0.8.0 for lifecycle management, health reporting, and distributed telemetry.

HoneyDrunk.Transport

Transport-agnostic messaging library for .NET. Provides a unified abstraction layer over different message brokers with middleware pipeline pattern, retry strategies, and transactional outbox support. Uses HoneyDrunk.Kernel.Abstractions for Grid-aware context propagation.

HoneyDrunk.Transport.InMemory

In-memory transport implementation for HoneyDrunk.Transport. Provides observable queues and pub/sub subscriptions for testing without external dependencies.

HoneyDrunk.Data

Provider-neutral persistence orchestration layer for HoneyDrunk.OS Grid. Complete architecture overhaul with Kernel integration for tenant resolution, correlation tracking, and telemetry enrichment. Does not depend on any specific database provider.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.8.0 1,528 5/26/2026
0.7.0 2,231 5/18/2026
0.6.0 107 5/17/2026
0.5.0 593 5/4/2026
0.4.0 1,888 1/19/2026
0.3.0 431 11/28/2025
0.2.1 284 11/22/2025
0.2.0 248 11/22/2025
0.1.2 427 11/13/2025
0.1.1 352 11/10/2025
0.1.0 174 11/7/2025

v0.1.2: Updated Microsoft.Extensions.* packages to 10.0.0. Updated Microsoft.CodeAnalysis.NetAnalyzers to 10.0.100. Updated HoneyDrunk.Standards to 0.2.3.