modeldprobe

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package modeldprobe detects whether the modeld daemon (the separate CGO inference binary) is installed, running, or dead, so the runtime can fail honestly and the setup wizard can guide the user.

It is pure Go and self-contained: it locates the binary and inspects the owner lease via liblease. It deliberately does not import modeld — the only shared facts are the lease file name and the endpoint metadata key, mirrored here as constants (see cmd/modeld and modeld/owner.EndpointMetaKey).

Liveness via lease freshness is a proxy, not a health check: a wedged process can still hold a fresh lease. A real reachability ping rides on the IPC transport and is added when that exists. See docs/blueprints/modeld-provisioning-detection.md.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotInstalled = errors.New("modeld is not installed")
	ErrNotRunning   = errors.New("modeld is not running")
	ErrStale        = errors.New("modeld owner is stale (the daemon may have crashed)")
)

Typed, actionable errors. Status.Err returns one of these (or nil) so callers can branch with errors.Is.

Functions

func DefaultDataRoot

func DefaultDataRoot() string

DefaultDataRoot resolves the contenox data root: $CONTENOX_DATA_ROOT, else ~/.contenox.

Types

type Detector

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

Detector resolves the modeld state. Construct it with New; the now and lookPath fields are injectable for tests.

func New

func New(dataRoot string) *Detector

New returns a Detector for the given data root (where the owner lease lives). An empty dataRoot falls back to DefaultDataRoot.

func (*Detector) Detect

func (d *Detector) Detect() Status

Detect resolves the current modeld state. A live lease takes precedence (the daemon is running regardless of whether we can locate the binary locally, e.g. when an extension started it from its own directory); binary presence then distinguishes stale/not-running from not-installed.

type State

type State int

State is the detected condition of the modeld daemon.

const (
	// StateNotInstalled means no modeld binary could be located.
	StateNotInstalled State = iota
	// StateNotRunning means the binary exists but no owner lease is present.
	StateNotRunning
	// StateStale means an owner lease exists but has expired: the daemon
	// likely crashed or was killed.
	StateStale
	// StateRunning means a live owner holds a fresh lease.
	StateRunning
)

func (State) String

func (s State) String() string

type Status

type Status struct {
	State    State
	Binary   string // resolved binary path, when located
	Endpoint string // advertised IPC endpoint, when running
	Instance string // owner instance UUID, when a lease is present
}

Status is the result of a detection.

func (Status) Err

func (s Status) Err() error

Err maps the status to a typed error, or nil when the daemon is running. A nil error means install + liveness passed; it does NOT by itself mean inference works, because the wire transport is a separate concern.

Jump to

Keyboard shortcuts

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