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
                    
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.4.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.4.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.4.0
                    
#r "nuget: HoneyDrunk.Kernel.Abstractions, 0.4.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.4.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.4.0
                    
Install as a Cake Addin
#tool nuget:?package=HoneyDrunk.Kernel.Abstractions&version=0.4.0
                    
Install as a Cake Tool

HoneyDrunk.Kernel.Abstractions

NuGet .NET 10

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 identifiers
  • SectorId - 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 boundaries
  • ProjectId - Project/workspace organization
  • RunId - 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() replaces WithBaggage() (mutates in-place, returns void)
    • v0.4.0: IsInitialized property for two-phase initialization checking
    • v0.4.0: BeginScope() removed (was a no-op)
    • CreateChildContext() for causality tracking

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-nullable GridContext property (no setter)
  • IOperationContextAccessor - Ambient operation context
  • IOperationContextFactory - Creates operation contexts from Grid context
  • v0.4.0: IGridContextFactory.CreateRoot() removed; only CreateChild() remains

βš™οΈ Configuration & Secrets

Hierarchical configuration abstractions:

  • IStudioConfiguration - Studio-level configuration access
  • ISecretsSource - 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, dependencies
  • INodeCapability - Advertised capabilities (protocols, endpoints, schemas)
  • INodeManifest - Deployment manifest metadata
  • IStudioConfiguration - Studio environment settings

πŸ€– Agents

AI agent execution framework abstractions:

  • IAgentDescriptor - Agent identity, capabilities, and constraints
  • IAgentExecutionContext - Scoped context for agent operations
  • IAgentCapability - 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 coordination
  • IStartupHook - Priority-ordered initialization logic
  • IShutdownHook - Priority-ordered cleanup logic

Health & Readiness:

  • IHealthCheck - Service health monitoring contract
  • HealthStatus - Standardized health status (Healthy, Degraded, Unhealthy)
  • IHealthContributor - Composite health aggregation
  • IReadinessContributor - 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 context
  • ITraceEnricher - Automatic trace enrichment hooks
  • ILogScopeFactory - Structured log scope creation
  • TelemetryTags - 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 envelopes
  • GridHeaderNames - 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 propagation
  • ErrorCode - Strongly-typed error codes with well-known taxonomy
  • IErrorClassifier - 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.

πŸ“š Documentation

See the main repository for comprehensive documentation:

Core Concepts:

Domain Guides:

πŸ“„ License

This project is licensed under the MIT License.


Built with 🍯 by HoneyDrunk Studios

GitHub β€’ Documentation β€’ Issues

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 (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.

Version Downloads Last Updated
0.4.0 300 1/19/2026
0.3.0 412 11/28/2025
0.2.1 267 11/22/2025
0.2.0 231 11/22/2025
0.1.2 408 11/13/2025
0.1.1 336 11/10/2025
0.1.0 152 11/7/2025

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.