HoneyDrunk.Kernel.Abstractions
0.2.0
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
<PackageReference Include="HoneyDrunk.Kernel.Abstractions" Version="0.2.0" />
<PackageVersion Include="HoneyDrunk.Kernel.Abstractions" Version="0.2.0" />
<PackageReference Include="HoneyDrunk.Kernel.Abstractions" />
paket add HoneyDrunk.Kernel.Abstractions --version 0.2.0
#r "nuget: HoneyDrunk.Kernel.Abstractions, 0.2.0"
#:package HoneyDrunk.Kernel.Abstractions@0.2.0
#addin nuget:?package=HoneyDrunk.Kernel.Abstractions&version=0.2.0
#tool nuget:?package=HoneyDrunk.Kernel.Abstractions&version=0.2.0
HoneyDrunk.Kernel
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
IClockinstead of usingDateTime.UtcNow - โ
Use
IIdGeneratorfor correlation/causation IDs - โ
Mock
IMetricsCollectorto verify metrics are recorded - โ
Use
IKernelContextwith 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
IClockandIIdGeneratorfor deterministic runs - CI gate: build fails if tests fail; coverage threshold optional
๐ค Contributing
Contributions are welcome! Please:
- Read .github/copilot-instructions.md for coding standards
- Open an issue for discussion before major changes
- Ensure all tests pass locally
- 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
enhancementlabel
๐ง 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 | 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
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
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.
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.