kernel

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package kernel provides typed command dispatch for core engine operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch[C any, R any](ctx context.Context, d *Dispatcher, cmd C) (R, error)

Dispatch routes cmd to its registered handler and returns the typed result.

func Register

func Register[C any, R any](d *Dispatcher, h Handler[C, R])

Register stores one handler for the command type C.

func ValidateDefaultRegistry

func ValidateDefaultRegistry(d *Dispatcher) error

ValidateDefaultRegistry ensures the default Phase A command set is registered.

Types

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

Dispatcher stores typed handlers keyed by command type.

func BuildDefault

func BuildDefault(deps KernelDeps) *Dispatcher

BuildDefault constructs a dispatcher with all six Phase A command handlers registered.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher constructs an empty typed dispatcher.

type Handler

type Handler[C any, R any] interface {
	Handle(ctx context.Context, cmd C) (R, error)
}

Handler executes one typed command and returns its typed result.

type HandlerTypeMismatchError

type HandlerTypeMismatchError struct {
	CommandType       reflect.Type
	ResultType        reflect.Type
	ActualHandlerType reflect.Type
}

HandlerTypeMismatchError reports a command dispatched with an incompatible result type for the registered handler.

func (*HandlerTypeMismatchError) Error

func (e *HandlerTypeMismatchError) Error() string

Error implements error.

type KernelDeps

type KernelDeps struct {
	Logger        *slog.Logger
	EventBus      *events.Bus[events.Event]
	Workspace     workspace.Context
	AgentRegistry agent.RuntimeRegistry
	// OpenRunScopeOptions controls whether executable extensions should be
	// initialized for run-aware commands handled by this dispatcher.
	OpenRunScopeOptions model.OpenRunScopeOptions
	// contains filtered or unexported fields
}

KernelDeps groups shared infrastructure used by kernel handlers.

type UnregisteredHandlerError

type UnregisteredHandlerError struct {
	CommandType reflect.Type
}

UnregisteredHandlerError reports a command type with no registered handler.

func (*UnregisteredHandlerError) Error

func (e *UnregisteredHandlerError) Error() string

Error implements error.

Directories

Path Synopsis
Package commands defines typed kernel command and result contracts.
Package commands defines typed kernel command and result contracts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL