modeldprobe

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package modeldprobe detects whether the modeld daemon / embedded engine 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).

Detect() reports lease-based liveness, a network-free proxy: a wedged process can still hold a fresh lease. Probe() adds the real reachability ping over the runtime's gRPC transport — it confirms the lease holder actually answers and is the instance serving the endpoint, downgrading a wedged owner to unreachable. Probe imports the runtime transport client (not modeld).

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)")
	ErrUnreachable  = errors.New("modeld holds a lease but does not answer a health probe")
)

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.

func PreferredBackend

func PreferredBackend(root string) (string, error)

PreferredBackend reads the native backend selected by onboarding; absent state returns empty.

func SetBackendPreference

func SetBackendPreference(root, backend string) error

SetBackendPreference records the native backend used by successful onboarding.

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.

func (*Detector) LauncherArgs

func (d *Detector) LauncherArgs(string) []string

LauncherArgs returns the standalone daemon's startup arguments.

func (*Detector) Probe

func (d *Detector) Probe(ctx context.Context) Status

Probe resolves the state and, when a fresh lease names a live owner, confirms the owner actually answers a health ping on its advertised endpoint.

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
	// StateUnreachable means a fresh lease names a live owner, but its advertised
	// endpoint does not answer a health probe: the daemon is wedged, still
	// bringing up its transport, or the advertised endpoint is wrong. Only Probe
	// (not Detect) can report this, because it requires a network round-trip.
	StateUnreachable
)

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
	Backend  string // inference backend the owner serves ("llama"/"openvino"/"none"), when running
}

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