HoneyDrunk.Kernel.Abstractions
0.4.0
dotnet add package HoneyDrunk.Kernel.Abstractions --version 0.4.0
NuGet\Install-Package HoneyDrunk.Kernel.Abstractions -Version 0.4.0
<PackageReference Include="HoneyDrunk.Kernel.Abstractions" Version="0.4.0" />
<PackageVersion Include="HoneyDrunk.Kernel.Abstractions" Version="0.4.0" />
<PackageReference Include="HoneyDrunk.Kernel.Abstractions" />
paket add HoneyDrunk.Kernel.Abstractions --version 0.4.0
#r "nuget: HoneyDrunk.Kernel.Abstractions, 0.4.0"
#:package HoneyDrunk.Kernel.Abstractions@0.4.0
#addin nuget:?package=HoneyDrunk.Kernel.Abstractions&version=0.4.0
#tool nuget:?package=HoneyDrunk.Kernel.Abstractions&version=0.4.0
HoneyDrunk.Kernel.Abstractions
Pure Semantic Contracts for the HoneyDrunk Grid - Zero-dependency abstractions that define the OS layer for distributed systems.
π What Is This?
HoneyDrunk.Kernel.Abstractions defines the semantic OS contracts for the entire HoneyDrunk.OS Grid. This package contains only interfaces, value types, and strongly-typed primitivesβno concrete implementations, no middleware, no lifecycle hosts.
Key Characteristics:
- β Zero runtime dependencies (only .NET BCL + Microsoft.Extensions.* abstractions)
- β Safe for libraries - Reference from shared code without pulling in heavy runtimes
- β Stable contracts - Semantic versioning with additive-only minor changes
- β Grid-first design - Multi-tenant, observable, distributed by default
This is the package you reference when building libraries, SDKs, or custom implementations that need to understand Grid primitives without taking on implementation weight.
π¦ What's Inside
π Identity
Strongly-typed, validated identifiers for distributed systems:
Core IDs:
NodeId- Kebab-case validated Node identifiersSectorId- Logical grouping of Nodes (Core, Ops, AI, Market, etc.)EnvironmentId- Environment discrimination (Production, Staging, Development, etc.)
Correlation & Tracking:
CorrelationId- ULID-based request correlation (trace-id)CausationId- Parent-child operation tracking (parent-span-id)TenantId- Multi-tenant isolation boundariesProjectId- Project/workspace organizationRunId- Execution instance tracking
All IDs are validated at construction time and designed for safe serialization across transport boundaries.
π·οΈ Identity Registries
Static, discoverable registries of well-known Grid values:
Nodes.*- Real Nodes from the Grid catalog (Core.Kernel, Ops.Pulse, AI.AgentKit, Market.Arcadia, etc.)Sectors.*- Canonical sector taxonomy (Core, Ops, AI, Market, Data, Messaging, Storage, Web, Auth)Environments.*- Standard environment names (Production, Staging, Development, Testing, Performance, Integration, Local)ErrorCode.*- Well-known error codes for Grid exceptions
Benefits: IntelliSense discovery, compile-time validation, IDE refactoring support, consistent naming across Nodes.
π Context
Three-tier context model that flows through async boundaries:
Grid Context (Distributed):
IGridContext- Per-operation envelope that crosses Node boundaries- Carries
CorrelationId(trace-id),CausationId(parent-span-id),NodeId,StudioId,Environment - Baggage for metadata propagation
- v0.4.0:
AddBaggage()replacesWithBaggage()(mutates in-place, returns void) - v0.4.0:
IsInitializedproperty for two-phase initialization checking - v0.4.0:
BeginScope()removed (was a no-op) CreateChildContext()for causality tracking
- Carries
Node Context (Static):
INodeContext- Per-process Node identity- Static metadata (NodeId, Version, StudioId, Environment, LifecycleStage)
- Process info (MachineName, ProcessId, StartedAtUtc)
Operation Context (Scoped):
IOperationContext- Per-unit-of-work tracking- Timing (StartedAtUtc, CompletedAtUtc)
- Outcome (IsSuccess, ErrorMessage)
- Metadata tags
Accessors & Factories:
IGridContextAccessor- v0.4.0: Read-only, non-nullableGridContextproperty (no setter)IOperationContextAccessor- Ambient operation contextIOperationContextFactory- Creates operation contexts from Grid context- v0.4.0:
IGridContextFactory.CreateRoot()removed; onlyCreateChild()remains
βοΈ Configuration & Secrets
Hierarchical configuration abstractions:
IStudioConfiguration- Studio-level configuration accessISecretsSource- Secret retrieval abstraction (Vault, Key Vault, env vars)
Design Note: Full hierarchical scoping (Studio β Node β Tenant) is a design target. Current abstractions focus on Studio and Node levels, with Vault providing secure backing.
π’ Hosting
Node hosting and discovery contracts:
INodeDescriptor- Node identity, version, capabilities, dependenciesINodeCapability- Advertised capabilities (protocols, endpoints, schemas)INodeManifest- Deployment manifest metadataIStudioConfiguration- Studio environment settings
π€ Agents
AI agent execution framework abstractions:
IAgentDescriptor- Agent identity, capabilities, and constraintsIAgentExecutionContext- Scoped context for agent operationsIAgentCapability- Advertised agent skills and permissions
Design Note: Agent interop helpers (serialization, context projection) live in the runtime package (HoneyDrunk.Kernel), not here.
π Lifecycle & Health
Node lifecycle orchestration contracts:
Lifecycle Hooks:
INodeLifecycle- Node-level start/stop coordinationIStartupHook- Priority-ordered initialization logicIShutdownHook- Priority-ordered cleanup logic
Health & Readiness:
IHealthCheck- Service health monitoring contractHealthStatus- Standardized health status (Healthy, Degraded, Unhealthy)IHealthContributor- Composite health aggregationIReadinessContributor- Kubernetes-ready readiness probes
Lifecycle Stages:
NodeLifecycleStage- Enumeration of Node states (Initializing, Starting, Ready, Degraded, Stopping, Stopped, Failed)
π‘ Telemetry & Diagnostics
Observability abstractions for OpenTelemetry integration:
Telemetry:
ITelemetryContext- Correlation and trace contextITraceEnricher- Automatic trace enrichment hooksILogScopeFactory- Structured log scope creationTelemetryTags- Standard tag names for Grid telemetry
Diagnostics:
IMetricsCollector- Metrics abstraction (counters, histograms, gauges)
Design Note: Concrete telemetry helpers (GridActivitySource, OpenTelemetry wiring) live in the runtime package.
π Transport
Protocol-agnostic context propagation:
ITransportEnvelopeBinder- Bind GridContext to outgoing transport envelopesGridHeaderNames- Standard header names (X-Correlation-Id,X-Causation-Id,X-Node-Id, etc.)
Design Note: Concrete binders (HTTP, messaging, jobs) and context mappers live in the runtime package.
β οΈ Errors
Structured exception hierarchy:
HoneyDrunkException- Base exception with Grid identity propagationErrorCode- Strongly-typed error codes with well-known taxonomyIErrorClassifier- Maps exceptions to HTTP status codes and retry policies
Typed Exceptions:
ValidationException,NotFoundException,SecurityException,ConcurrencyException,DependencyFailureException
Design Note: All exceptions carry CorrelationId for distributed tracing.
π Dependency Injection
Modular service registration:
IModule- Composable DI registration units
π₯ Installation
dotnet add package HoneyDrunk.Kernel.Abstractions
<ItemGroup>
<PackageReference Include="HoneyDrunk.Kernel.Abstractions" Version="0.4.0" />
</ItemGroup>
Note: Version shown is an example. Check NuGet for latest version.
π― When to Use This Package
Use HoneyDrunk.Kernel.Abstractions when:
- β Building libraries or SDKs that integrate with the Grid
- β Creating shared code that multiple Nodes consume
- β Defining custom implementations of Kernel interfaces
- β You want minimal transitive dependencies (no runtime, no middleware, no lifecycle hosts)
- β Writing test doubles or alternative implementations
Use HoneyDrunk.Kernel (runtime) when:
- β Building executable Nodes/services
- β You need concrete implementations (GridContext, NodeContext, OperationContext)
- β You need middleware (UseGridContext, lifecycle orchestration)
- β You need transport binders (HTTP, messaging, jobs)
- β You need bootstrapping helpers (AddHoneyDrunkNode, ValidateHoneyDrunkServices)
π¨ Design Philosophy
Minimal Dependencies
This package depends only on:
- β .NET 10 BCL - Standard library only
- β Microsoft.Extensions.* - DI, Configuration, Hosting abstractions (contracts only)
- β Ulid - ULID generation for identity types
- β HoneyDrunk.Standards - Build-time analyzers (no runtime dependency)
Stable Contracts
Interfaces follow strict semantic versioning:
- π Breaking changes β Major versions only
- β Additive changes β Minor versions (new interfaces, optional members)
- π Bug fixes β Patch versions
Grid-First Design
All abstractions assume:
- π Distributed systems - Context propagates across Node boundaries
- π’ Multi-tenancy - TenantId and ProjectId are first-class
- π Observable by default - Correlation, causation, and baggage built-in
- π Strongly-typed identity - Compile-time validation, runtime safety
Explicit Over Implicit
- β No magic - Context is explicitly passed or accessed via accessor
- β No ambient state - AsyncLocal storage is opt-in via accessors
- β No reflection tricks - Interfaces define behavior, implementations execute
π‘ Example: Custom Implementations
Custom Secrets Source
using HoneyDrunk.Kernel.Abstractions.Configuration;
/// <summary>
/// Retrieves secrets from environment variables with a prefix.
/// </summary>
public class EnvironmentSecretsSource : ISecretsSource
{
private const string Prefix = "SECRET_";
public bool TryGetSecret(string key, out string? value)
{
var envKey = $"{Prefix}{key}";
value = Environment.GetEnvironmentVariable(envKey);
return value is not null;
}
}
// Usage (registration in runtime):
builder.Services.AddSingleton<ISecretsSource, EnvironmentSecretsSource>();
Custom Health Check
using HoneyDrunk.Kernel.Abstractions.Health;
/// <summary>
/// Checks database connectivity.
/// </summary>
public class DatabaseHealthCheck(IDbConnection db) : IHealthCheck
{
public async Task<HealthStatus> CheckHealthAsync(CancellationToken cancellationToken = default)
{
try
{
await db.ExecuteScalarAsync("SELECT 1", cancellationToken);
return HealthStatus.Healthy;
}
catch (Exception ex)
{
return HealthStatus.Unhealthy;
}
}
}
// Usage (registration in runtime):
builder.Services.AddSingleton<IHealthCheck, DatabaseHealthCheck>();
Custom Transport Binder
using HoneyDrunk.Kernel.Abstractions.Transport;
using HoneyDrunk.Kernel.Abstractions.Context;
/// <summary>
/// Binds GridContext to gRPC metadata.
/// </summary>
public class GrpcMetadataBinder : ITransportEnvelopeBinder
{
public void Bind(object envelope, IGridContext gridContext)
{
if (envelope is not Grpc.Core.Metadata metadata)
return;
metadata.Add(GridHeaderNames.CorrelationId, gridContext.CorrelationId);
metadata.Add(GridHeaderNames.CausationId, gridContext.CausationId ?? string.Empty);
metadata.Add(GridHeaderNames.NodeId, gridContext.NodeId);
metadata.Add(GridHeaderNames.StudioId, gridContext.StudioId);
metadata.Add(GridHeaderNames.Environment, gridContext.Environment);
foreach (var (key, value) in gridContext.Baggage)
{
metadata.Add($"{GridHeaderNames.BaggagePrefix}{key}", value);
}
}
}
// Usage (registration in runtime):
builder.Services.AddSingleton<ITransportEnvelopeBinder, GrpcMetadataBinder>();
Note: These examples show contract usage only. Actual registration, middleware wiring, and lifecycle orchestration happen in the HoneyDrunk.Kernel runtime package.
π Related Packages
- HoneyDrunk.Kernel - Runtime implementations (use this for executable Nodes)
- HoneyDrunk.Standards - Analyzers and coding conventions
π Documentation
See the main repository for comprehensive documentation:
Core Concepts:
- Complete File Guide - Architecture reference (START HERE)
- Identity Guide - Strongly-typed identifiers
- Identity Registries - Static well-known values (planned)
- Context Guide - Three-tier context propagation
Domain Guides:
- Lifecycle Guide - Lifecycle orchestration contracts
- Telemetry Guide - Observability primitives
- Transport Guide - Context propagation across boundaries
- Errors Guide - Exception hierarchy and error handling
- Agents Guide - Agent execution framework
- Health Guide - Health monitoring contracts
π License
This project is licensed under the MIT License.
Built with π― by HoneyDrunk Studios
GitHub β’ Documentation β’ Issues
| 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)
- Ulid (>= 1.4.1)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on HoneyDrunk.Kernel.Abstractions:
| Package | Downloads |
|---|---|
|
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. Integrated with HoneyDrunk.Kernel 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.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.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. |
|
|
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 for lifecycle management, health reporting, and distributed telemetry. |
GitHub repositories
This package is not used by any popular GitHub repositories.
v0.4.0: BREAKING CHANGES - IGridContext: AddBaggage() replaces WithBaggage() (void return), IsInitialized property added, BeginScope() removed. IGridContextAccessor: now read-only non-nullable GridContext property (no setter). IGridContextFactory: CreateRoot() removed, only CreateChild() remains. See CHANGELOG.md for migration guide.