Help us shape the future of Go! Take the 2026 Go Developer Survey

hive

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package hive is the hive engine both programs run on. Each application service lives in its own subpackage; Engine composes them over the drivers a program hands it and rebuilds the config-derived ones on Reload.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTerminalManager added in v0.58.0

func NewTerminalManager(logger zerolog.Logger, cfg *config.Config, source terminal.PaneSource) *terminal.Manager

NewTerminalManager builds the terminal integration manager from config. tmux is always enabled; availability is checked lazily by the manager.

func OpenDB added in v0.60.0

func OpenDB(ctx context.Context, dataDir string, opts config.DatabaseConfig) (*db.DB, error)

OpenDB opens hive.db in dataDir and imports the JSON stores that predate it.

func StatusOptionsFromConfig added in v0.60.0

func StatusOptionsFromConfig(cfg config.TerminalStatusConfig, pollInterval time.Duration) status.Options

StatusOptionsFromConfig maps the terminal.status config section onto the status tracker's debounce options.

Confirm.Missing is not part of status.Options: the tmux transport reads it as a retry count for failed list-panes calls, not as a tracker rule.

Types

type Engine added in v0.60.0

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

Engine is the hive engine. Accessors return the services built from the current config. Fetch a service per call (e.Sessions().X) and do not hold it across a Reload, or it keeps serving the old config.

The drive service is the exception: it holds the snapshot of the context root, so it is built once and follows a Reload through Reconfigure.

func New added in v0.60.0

func New(cfg *config.Config, p Ports) (*Engine, error)

func (*Engine) Bus added in v0.60.0

func (e *Engine) Bus() *events.EventBus

func (*Engine) Config added in v0.60.0

func (e *Engine) Config() *config.Config

Config returns the config the current services were built from.

func (*Engine) Doctor added in v0.60.0

func (e *Engine) Doctor(validator doctor.ConfigValidator, plugins []doctor.PluginInfo) *doctor.Service

Doctor returns the health checks for the current config. validator checks the program's whole config: a program whose config has sections the engine does not read passes its own, so those sections are checked too. plugins is what the program wants reported; the engine has none.

func (*Engine) Drive added in v0.64.0

func (e *Engine) Drive() *drivesvc.Service

Drive returns the Hive Drive service. Reload keeps it and re-roots it.

func (*Engine) DriveRemote added in v0.66.0

func (e *Engine) DriveRemote() *driveremote.Service

DriveRemote returns the drive server client service, or nil when the program gave the engine no credential store.

func (*Engine) Git added in v0.60.0

func (e *Engine) Git() git.Git

Git returns the git executor for the current GitPath.

func (*Engine) GitStatus added in v0.60.0

func (e *Engine) GitStatus() *gitstatus.Service

func (*Engine) HC added in v0.60.0

func (e *Engine) HC() *hcsvc.Service

HC returns the honeycomb service. It reads no config, so Reload keeps it.

func (*Engine) KV added in v0.63.0

func (e *Engine) KV() kv.KV

KV returns the persistent key-value store. Reload keeps it. The runtime runs SweepKV.

func (*Engine) Messages added in v0.60.0

func (e *Engine) Messages() *msgsvc.Service

func (*Engine) Notifications added in v0.63.0

func (e *Engine) Notifications() notify.Store

Notifications returns the notification history. Reload keeps it.

func (*Engine) Reload added in v0.60.0

func (e *Engine) Reload(cfg *config.Config) error

Reload swaps in services built from cfg and publishes config.reloaded. A config that fails validation changes nothing: the running services keep serving the config they were built from.

The database, the bus, and the services that read no config (honeycomb, KV, notifications, reviews) are kept, so a changed database section or data dir still needs a restart. The drive service is kept too and handed the new config and git executor; it re-roots itself when the context dir moved.

func (*Engine) Renderer added in v0.60.0

func (e *Engine) Renderer() *tmpl.Renderer

Renderer returns the template renderer for the current default agent.

func (*Engine) Reviews added in v0.63.0

func (e *Engine) Reviews() review.Store

Reviews returns the document review sessions and comments. Reload keeps it.

func (*Engine) Sessions added in v0.60.0

func (e *Engine) Sessions() *sessionsvc.Service

func (*Engine) Status added in v0.60.0

func (e *Engine) Status() *statussvc.Service

Status returns the terminal status service, or nil without a PaneSource.

func (*Engine) SweepKV added in v0.63.0

func (e *Engine) SweepKV(ctx context.Context, interval time.Duration)

SweepKV deletes expired KV entries every interval until ctx is done. Reads already treat an expired entry as missing; the sweep only reclaims the rows.

func (*Engine) Terminal added in v0.60.0

func (e *Engine) Terminal() *terminal.Manager

Terminal returns the terminal status manager, or nil without a PaneSource.

func (*Engine) Todos added in v0.60.0

func (e *Engine) Todos() *todosvc.Service

type NotificationRouter added in v0.60.0

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

NotificationRouter maps domain events to user-facing notifications.

func NewNotificationRouter added in v0.60.0

func NewNotificationRouter(bus *events.EventBus) *NotificationRouter

NewNotificationRouter constructs a router for event-to-notification mappings.

func (*NotificationRouter) Register added in v0.60.0

func (r *NotificationRouter) Register()

Register subscribes all supported event mappings.

type Ports added in v0.60.0

type Ports struct {
	// DB is hive.db and Bus the event bus. New requires both; StartRuntime
	// opens them itself and rejects ones the caller sets.
	DB       *db.DB
	Bus      *events.EventBus
	Executor executil.Executor
	Mux      sessionsvc.Multiplexer
	// PaneSource feeds terminal status. Nil disables status: Status and
	// Terminal return nil.
	PaneSource terminal.PaneSource
	// DataDir holds the bundled scripts the renderer points window commands at.
	DataDir string
	// Styler, Stdout and Stderr shape hook and file-copy output. Nil means
	// plain text to io.Discard.
	Styler sessionsvc.OutputStyler
	Stdout io.Writer
	Stderr io.Writer
	Logger zerolog.Logger
	// Credentials holds the drive server token. Nil disables DriveRemote.
	Credentials credentials.Store
}

Ports are the drivers and process-lived handles a program gives the engine. None of them is rebuilt on Reload.

type Runtime added in v0.66.0

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

Runtime owns the process-lifetime half of the engine: hive.db, the event bus and its goroutine, the engine, and the KV sweep. A config reload goes through Engine().Reload and keeps all of them.

func StartRuntime added in v0.66.0

func StartRuntime(ctx context.Context, cfg *config.Config, opts RuntimeOptions) (*Runtime, error)

StartRuntime opens hive.db, starts the bus, builds the engine from cfg, and starts the KV sweep. Background work stops when ctx is done or on Close. A failed step closes everything the earlier steps opened.

func (*Runtime) Bus added in v0.66.0

func (r *Runtime) Bus() *events.EventBus

Bus returns the event bus. Subscribing after StartRuntime is safe.

func (*Runtime) Close added in v0.66.0

func (r *Runtime) Close() error

Close stops the drive watcher and the background goroutines, then closes hive.db. It is idempotent and returns the first call's error. A drive watcher that fails to stop only warns: it must not fail the shutdown.

func (*Runtime) DB added in v0.66.0

func (r *Runtime) DB() *db.DB

DB returns hive.db. The runtime closes it.

func (*Runtime) Engine added in v0.66.0

func (r *Runtime) Engine() *Engine

type RuntimeOptions added in v0.66.0

type RuntimeOptions struct {
	// Ports are the program's drivers. DB and Bus must be nil: the runtime
	// opens them.
	Ports Ports
	// ScriptsVersion stamps the bundled scripts extracted into the data dir.
	ScriptsVersion string
}

RuntimeOptions is what a program hands StartRuntime.

type StartError added in v0.66.0

type StartError struct {
	Step StartStep
	Err  error
}

StartError is a StartRuntime failure. Error returns the cause's message unchanged; Step lets a caller add context per step.

func (*StartError) Error added in v0.66.0

func (e *StartError) Error() string

func (*StartError) Unwrap added in v0.66.0

func (e *StartError) Unwrap() error

type StartStep added in v0.66.0

type StartStep string

StartStep names the startup step a StartError came from.

const (
	StartStepDatabase StartStep = "database"
	StartStepEngine   StartStep = "engine"
)

Directories

Path Synopsis
Package daemon serves sessionapi.API for one hive data directory on a unix socket, so every client on the machine shares one writer and one status tracker.
Package daemon serves sessionapi.API for one hive data directory on a unix socket, so every client on the machine shares one writer and one status tracker.
daemonpath
Package daemonpath names the files of the hive daemon for a data directory, so a client finds them without importing the daemon.
Package daemonpath names the files of the hive daemon for a data directory, so a client finds them without importing the daemon.
wire
Package wire converts between the hive.daemon.v1 messages and the Go types sessionapi.API speaks, for both the daemon and its client.
Package wire converts between the hive.daemon.v1 messages and the Go types sessionapi.API speaks, for both the daemon and its client.
Package daemonclient implements sessionapi.API against a hive daemon.
Package daemonclient implements sessionapi.API against a hive daemon.
Package doctor runs health checks on a hive setup.
Package doctor runs health checks on a hive setup.
Package drive is the Hive Drive service: the document tree under the context root, served from one in-memory snapshot per space.
Package drive is the Hive Drive service: the document tree under the context root, served from one in-memory snapshot per space.
Package driveremote copies Hive Drive documents to and from a drive server.
Package driveremote copies Hive Drive documents to and from a drive server.
Code generated by gobusgen; DO NOT EDIT.
Code generated by gobusgen; DO NOT EDIT.
testbus
Package testbus provides test utilities for the event bus.
Package testbus provides test utilities for the event bus.
Package gitstatus reads the git state of session checkouts: branch, dirty tree, unpushed commits and the line delta against the default branch.
Package gitstatus reads the git state of session checkouts: branch, dirty tree, unpushed commits and the line delta against the default branch.
Package hc is the honeycomb task service.
Package hc is the honeycomb task service.
Package hivetest builds a hive.Engine over a temp database, a recording executor, and a tmux stand-in, for tests in any package that needs one.
Package hivetest builds a hive.Engine over a temp database, a recording executor, and a tmux stand-in, for tests in any package that needs one.
Package messaging publishes and reads inter-agent messages.
Package messaging publishes and reads inter-agent messages.
Package servers is the fleet of hive servers a client works with: the local daemon (or engine) and each server under servers: in config.yaml, reached over ssh.
Package servers is the fleet of hive servers a client works with: the local daemon (or engine) and each server under servers: in config.yaml, reached over ssh.
Package session is the session service: create, recycle, rename, delete and prune sessions, and spawn their terminals.
Package session is the session service: create, recycle, rename, delete and prune sessions, and spawn their terminals.
scripts
Package scripts embeds and extracts bundled helper scripts (hive-tmux, agent-send).
Package scripts embeds and extracts bundled helper scripts (hive-tmux, agent-send).
Package sessionapi is the session view the hive TUI, the CLI, and Hive Desktop share.
Package sessionapi is the session view the hive TUI, the CLI, and Hive Desktop share.
Package status reads agent terminal status for sessions and repositories.
Package status reads agent terminal status for sessions and repositories.
Package todo is the todo service and its creation limiter.
Package todo is the todo service and its creation limiter.

Jump to

Keyboard shortcuts

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