Documentation
¶
Overview ¶
Package config loads flockd configuration from defaults, an optional TOML file, and FLOCKD_-prefixed environment variables (koanf). Every knob is documented in docs/config.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LimitsPath ¶ added in v0.3.0
LimitsPath is the daemon-owned governor-limits overlay location.
func SaveLimits ¶ added in v0.3.0
func SaveLimits(dataDir string, g Governor, l LiveLimits) error
SaveLimits persists live-edited limits to the overlay file that Load applies on the next start. Only the operator-facing limit knobs are written; poll_interval and the rest stay wherever the operator set them.
Types ¶
type Budget ¶
type Budget struct {
MaxVRAMPercent int `koanf:"max_vram_percent"`
// MaxRAMMB is the memory budget for loaded models; 0 = auto (half of
// physical memory on unified-memory machines, vram × max_vram_percent
// on discrete GPUs). Loads beyond it unload idle models first, then
// are refused (mesh placements stay on disk as `cached`).
MaxRAMMB int64 `koanf:"max_ram_mb"`
MaxConcurrent int `koanf:"max_concurrent"`
}
type Config ¶
type Config struct {
DataDir string `koanf:"data_dir"`
Log Log `koanf:"log"`
LocalAPI LocalAPI `koanf:"local_api"`
Runtime Runtime `koanf:"runtime"`
Governor Governor `koanf:"governor"`
Budget Budget `koanf:"budget"`
Models Models `koanf:"models"`
Tunnel Tunnel `koanf:"tunnel"`
Enroll Enroll `koanf:"enroll"`
Update Update `koanf:"update"`
}
Config is the fully resolved daemon configuration.
type Enroll ¶
type Enroll struct {
// LoginURL is the browser URL opened by `tera login`.
LoginURL string `koanf:"login_url"`
}
type Governor ¶
type Governor struct {
// ServePolicy: "always", "idle-only" or "scheduled".
ServePolicy string `koanf:"serve_policy"`
// IdleAfter is how long input must be quiet before the node counts as
// idle (idle-only policy).
IdleAfter time.Duration `koanf:"idle_after"`
// YieldGrace is the drain-or-cancel window on operator activity
// (SPEC §4.1 instant-yield). Default 2s.
YieldGrace time.Duration `koanf:"yield_grace"`
// PollInterval is how often idle/power signals are sampled.
PollInterval time.Duration `koanf:"poll_interval"`
// ServeOnBattery: never serve on battery by default.
ServeOnBattery bool `koanf:"serve_on_battery"`
// MaxTempCelsius pauses serving above this temperature (0 disables).
MaxTempCelsius float64 `koanf:"max_temp_celsius"`
// Schedule windows for serve_policy=scheduled, e.g. ["22:00-08:00"].
Schedule []string `koanf:"schedule"`
}
type LiveLimits ¶ added in v0.4.0
type LiveLimits struct {
MeshManaged bool
MaxDiskMB int64
RetentionDays int
IdleUnloadS int
MaxRAMMB int64
}
LiveLimits are the non-governor knobs the limits API edits live; they ride the same overlay as the governor policy.
type LocalAPI ¶
type LocalAPI struct {
// Listen address. Loopback only by default; changing this is dangerous
// and documented with warnings in docs/config.md.
Listen string `koanf:"listen"`
// RequireAuthV1 requires the bearer token on the OpenAI-compatible /v1
// endpoints too (the daemon-management /api/v1 always requires it).
RequireAuthV1 bool `koanf:"require_auth_v1"`
}
type Models ¶
type Models struct {
// ManifestPath or ManifestURL locates the model catalog (YAML/JSON,
// teraflock/models format).
ManifestPath string `koanf:"manifest_path"`
ManifestURL string `koanf:"manifest_url"`
// Default is the model id served in standalone mode.
Default string `koanf:"default"`
// MaxDiskMB is the model-cache disk budget; LRU eviction below it.
MaxDiskMB int64 `koanf:"max_disk_mb"`
// Pin lists model ids exempt from eviction; Exclude are never assigned.
Pin []string `koanf:"pin"`
Exclude []string `koanf:"exclude"`
// MeshManaged lets the coordinator place models on this node (download,
// load, and later evict what it placed) inside max_disk_mb, minus pin
// and exclude. Off = the node serves only what the operator installed.
// Default on: an enrolled node that never takes placements never earns.
MeshManaged bool `koanf:"mesh_managed"`
// IdleUnloadS unloads a loaded model after this many seconds without a
// request (0 = never; the default model is exempt). Reload is a mmap
// re-open, seconds not a download.
IdleUnloadS int `koanf:"idle_unload_s"`
// RetentionDays evicts unpinned, unloaded models unused for this many
// days (0 = never). Mesh and operator models alike.
RetentionDays int `koanf:"retention_days"`
}
type Runtime ¶
type Runtime struct {
// Kind selects the runtime adapter: "llamacpp" or "mock".
Kind string `koanf:"kind"`
// LlamaServerPath, when set, uses an existing llama-server binary
// instead of downloading one from the artifact manifest.
LlamaServerPath string `koanf:"llama_server_path"`
// ArtifactManifestURL points at the JSON manifest of pinned, SHA-verified
// llama-server builds (see internal/runtime/llamacpp/artifact.go).
ArtifactManifestURL string `koanf:"artifact_manifest_url"`
// MockTokensPerSec controls the synthetic generation speed of the mock
// runtime (tests, --standalone demos).
MockTokensPerSec float64 `koanf:"mock_tokens_per_sec"`
// ContextLength override passed to llama-server (0 = model default,
// capped by MaxContext).
ContextLength int `koanf:"context_length"`
// MaxContext caps the context window handed to llama-server, in
// tokens, shared across the `--parallel` slots (0 = no cap). The KV
// cache scales with it: a 3B model at its 131072-token training window
// reserves ~14 GB, at 16384 about 1.8 GB. Per-request context is
// MaxContext / budget.max_concurrent.
MaxContext int `koanf:"max_context"`
}
type Tunnel ¶
type Tunnel struct {
// CoordinatorAddr is the coordinator endpoint (host:port).
CoordinatorAddr string `koanf:"coordinator_addr"`
// Standalone runs the in-process fake coordinator (Phase 0).
Standalone bool `koanf:"standalone"`
// HeartbeatInterval between heartbeats (coordinator may override).
HeartbeatInterval time.Duration `koanf:"heartbeat_interval"`
// ReconnectMin/Max bound the jittered exponential backoff.
ReconnectMin time.Duration `koanf:"reconnect_min"`
ReconnectMax time.Duration `koanf:"reconnect_max"`
// InsecureSkipVerify disables server cert verification (dev only).
InsecureSkipVerify bool `koanf:"insecure_skip_verify"`
// Insecure dials the coordinator over plaintext gRPC instead of TLS.
// The dev coordinator (`just run-coordinator`) serves plaintext until
// mTLS termination lands; never enable this against a real deployment.
Insecure bool `koanf:"insecure"`
}