HoneyDrunk.Kernel.Abstractions
0.1.0
See the version list below for details.
dotnet add package HoneyDrunk.Kernel.Abstractions --version 0.1.0
NuGet\Install-Package HoneyDrunk.Kernel.Abstractions -Version 0.1.0
<PackageReference Include="HoneyDrunk.Kernel.Abstractions" Version="0.1.0" />
<PackageVersion Include="HoneyDrunk.Kernel.Abstractions" Version="0.1.0" />
<PackageReference Include="HoneyDrunk.Kernel.Abstractions" />
paket add HoneyDrunk.Kernel.Abstractions --version 0.1.0
#r "nuget: HoneyDrunk.Kernel.Abstractions, 0.1.0"
#:package HoneyDrunk.Kernel.Abstractions@0.1.0
#addin nuget:?package=HoneyDrunk.Kernel.Abstractions&version=0.1.0
#tool nuget:?package=HoneyDrunk.Kernel.Abstractions&version=0.1.0
HoneyDrunk.Kernel
Foundational primitives for HoneyDrunk.OS
๐งฌ Overview
HoneyDrunk.Kernel is the primordial layer of the Grid โ the bedrock that powers every Node, service, and agent across HoneyDrunk.OS. It defines the shared primitives that make the ecosystem coherent and interoperable: dependency injection, configuration, diagnostics, context propagation, and application lifecycles. Every architectural pattern within the Grid ultimately descends from the Kernel.
Signal Quote: "Where everything begins."
Target Framework: .NET 10.0
๐ Purpose
The Kernel exists to make architectural decisions once, not repeatedly across services. It's how small teams achieve large-scale stability โ one unified runtime grammar guiding the entire Hive.
๐งฉ Core Responsibilities
| Area | Description |
|---|---|
| Dependency Injection (DI) | Central composition layer for service registration and lifetime scoping. |
| Configuration | Unified configuration provider that reads from environment variables, manifests, and Vault. |
| Context Propagation | Lightweight context object for tracing, correlation, and cancellation across async boundaries. |
| Diagnostics | Shared contracts for logging, metrics, and health checks. |
| Time & ID Abstractions | Deterministic abstractions for time and unique identifiers to improve testability. |
| Hosting Lifecycle | Common startup, shutdown, and background worker orchestration primitives. |
๐ง Design Philosophy
- Predictability > Cleverness โ Simplicity scales.
- Replaceable without regret โ Kernel defines contracts, not frameworks.
- Observable by default โ Every operation should emit measurable signals.
- Secure by design โ Vault integration from the start, not bolted on later.
- Portable โ Works in APIs, background services, or agent runtimes.
๐ Framework Integration
HoneyDrunk.Kernel extends rather than replaces Microsoft.Extensions primitives:
| Microsoft.Extensions Feature | Kernel's Role |
|---|---|
ILogger<T> |
Used directly; no wrapper needed |
IConfiguration |
Used directly; Kernel adds ISecretsSource for Vault integration |
IHostedService |
Used directly for background services |
IServiceCollection |
Extended via AddKernelDefaults() |
What Kernel Adds:
IKernelContextfor correlation/causation propagation across async boundariesIClockandIIdGeneratorfor deterministic, testable time and ID generationISecretsSourcefor unified secrets management (environment, Vault, composite)IHealthCheckcomposition patterns for service health monitoringIMetricsCollectorabstraction (no-op by default; real backends provided by downstream services)
๐ซ Intentionally Out of Scope
The following belong in downstream Nodes, not Kernel:
| Feature | Recommended Location |
|---|---|
| Metrics backends (OpenTelemetry, Application Insights) | Service-level registration |
| Resilience (retry, circuit breaker, timeout) | HoneyDrunk.Transport |
Validation (IValidator<T>, FluentValidation) |
Service-level or HoneyDrunk.Data |
| Result<T> monads / Railway-oriented programming | Service-level or future HoneyDrunk.Common |
| HTTP clients (HttpClientFactory) | HoneyDrunk.Web.Rest |
| Database abstractions (repositories, EF Core) | HoneyDrunk.Data |
| Authentication/Authorization | HoneyDrunk.Auth |
Why? Kernel stays minimal and focused. Heavy behavior belongs at service boundaries where it can be composed and replaced independently.
๐งฑ Repository Layout
HoneyDrunk.Kernel/
โโโ HoneyDrunk.Kernel/ # Runtime library
โโโ HoneyDrunk.Kernel.Abstractions/ # Interfaces & shared contracts
โโโ HoneyDrunk.Kernel.Tests/ # Separate test project
โโโ HoneyDrunk.Kernel.sln
โโโ Directory.Build.props
โโโ Directory.Build.targets
โโโ .editorconfig
โโโ .gitattributes
โโโ .gitignore
โโโ CODEOWNERS
โโโ .github/
โโโ workflows/
โโโ build.yml
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.
๐ Relationships
Upstream:
- HoneyDrunk.Standards
- HoneyDrunk.Build
Downstream:
- HoneyDrunk.Data
- HoneyDrunk.Transport
- HoneyDrunk.Web.Rest
- HoneyDrunk.Auth
- HoneyDrunk.Vault
๐ Quick Start
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();
Use 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);
}
}
Use Deterministic Time
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, etc.) in your service's startup.
๐งช Local Development
git clone https://github.com/HoneyDrunkStudios/kernel
cd kernel
dotnet restore
dotnet build
dotnet test HoneyDrunk.Kernel.Tests/HoneyDrunk.Kernel.Tests.csproj
This Node consumes private packages from the HoneyDrunk Azure Artifacts feed. Configure the following secrets or NuGet.config sources:
HD_FEED_URLHD_FEED_USERHD_FEED_TOKEN
Writing Tests
Kernel abstractions enable deterministic testing:
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.UtcNoworDateTimeOffset.UtcNow - Use
IIdGeneratorfor correlation/causation IDs in tests - Mock
IMetricsCollectorto verify metrics are recorded correctly - Use
IKernelContextwith known correlation IDs for tracing validation
โ๏ธ Build & Release
- Workflow:
HoneyDrunk.Actionsโpublish-nuget.yml - Tag Convention:
vX.Y.Zโ triggers build, pack, and publish - Analyzers: Enforced automatically via
HoneyDrunk.Standards(buildTransitive) - Output: Internal Azure Artifacts feed
CI runs on:
pushโ build + testpull_requestโ validate formatting and analyzerstag v*โ publish package
๐ง Motto
"If the Kernel is stable, everything above it can change fearlessly."
| 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
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.