Skip to main content

Crate runtime

Crate runtime 

Source
Expand description

The Hedos runtime layer: executing models. Currently the sidecar wire protocol; the supervisor, governor, and job scheduler build on it.

Re-exports§

pub use facade::Kernel;

Modules§

adapters
The runtime adapter interface: how the kernel drives a model through some concrete backend (a Python sidecar, a local daemon over HTTP, a manifest command, …). Every adapter turns a ModelRecord + a request into a uniform CapabilityChunk (or JobRuntimeEvent) stream, so the layers above don’t care what runs underneath.
audio
PCM ↔ WAV conversion for generated speech.
bench
Driving the bench: clear a model from memory, run it, measure, repeat, and report each step as it happens.
boot
The composition root: assemble a production Kernel — registry, artifacts, governor, job history, and the full built-in adapter set — plus the default install service and the discovery-settings bridge, so a front end (the CLI, and later the TUI) stays a thin shell. State lives under a per-user data dir; configuration comes from the shared hedos.toml.
chip
The machine’s processor, as it names itself. Shown beside a bench’s figures, since a rate means nothing without the chip that produced it.
environment
Python environment provisioning: one virtual environment per runtime, keyed by the SHA-256 of its lockfile so a changed lock rebuilds and an unchanged one short-circuits to a relink. The build itself is injectable (the default shells out to uv), and honest-failure process running lives here too.
facade
The Kernel facade: the runtime’s dependency-injection entry point. It owns the registry, governor, job scheduler, artifact store, and the adapter list, and exposes the surface the gateway/cli drive — invoke (streaming), submit/rerun/vary (jobs), and the capability queries around them.
frame_codec
The length-prefixed framing used to talk to Python sidecars.
governed
Governed load helpers: the orchestration between the memory governor and the sidecar supervisor. warm_load_acquire admits a model, holds the GPU gate while it loads, marks it a governed resident, and hands back the producer lease held for the generation; governed_one_shot brackets a one-off body in a generation lease and the producer gate. The governor unit deferred these until the sidecar existed.
governor
Memory and GPU governance: admission against a RAM budget, a fair GPU gate, per-model leases, and warm-window residency. Every engine funnels model loading and generation through here.
install
Installing models: the HTTP fetch layer over the kernel’s pure install types. The Hugging Face hub client lands first; the fetch providers + install service build on it.
jobs
The async job scheduler: runs discrete units of work one at a time, against an injected admission authority, artifact sink, and per-job runner. The pure data model (Job/JobEvent/JobHistoryStore/seeding) lives in the kernel; this crate drives it.
manifests
Support logic for manifest-declared runtimes: resolving a model’s on-disk paths, substituting the {model}/{prompt}/{workdir}/{outputs}/{python} placeholders in a manifest command, generating a starter manifest for a model, and the small string/JSON helpers the manifest adapters share.
process
Host-side process containment: enumerate a process tree, terminate it gracefully then forcefully, and drain a child’s stdout/stderr into bounded buffers. The sidecar supervisor spawns and reaps subprocesses through here.
python_runtime
The governed streaming driver shared by every Python-sidecar adapter. A Descriptor says how to prepare the environment and build the spec; run then yields the preparing status, warm-loads the sidecar through the governor, opens the supervisor stream, and forwards its events — releasing the producer gate and ending the generation lease on every exit path.
removal
Running a model deletion: trashing the files a non-daemon model owns, or asking the Ollama daemon to delete a tag. The pure preview/path logic lives in kernel::removal; this drives it.
resolution
The runtime-bid auction: given the adapters wired into this process, decide which one serves each model. ResolutionEngine identifies a record (via kernel::resolution::identify), collects a bid from every adapter, ranks them, and writes the winning runtime — plus the runner-up alternatives and the identified modality/capabilities/params — back onto the record.
settings
Persistent settings, stored as one human-editable TOML file at <config-dir>/hedos.toml (config dir = XDG_CONFIG_HOME, else ~/.config, else %APPDATA%). A single file with [models]/[chat]/[voice]/ [gateway]/[pull]/[advanced] tables, not a per-domain store.
sidecar
The sidecar machinery: managed Python child processes spoken to over a length-prefixed frame protocol. SidecarSupervisor owns process lifecycle, the ready handshake, exclusive per-process sessions, progress/cancel watchdogs, and the two pumps that turn frames into CapabilityChunk and JobRuntimeEvent streams.