// Package supervisor runs and watches engine processes (plan ยง5.4). package supervisor import "fmt" // State is where a shard is in its lifecycle. // // Loading is separate from Starting because model loading dominates startup: // a 70B model takes minutes, and an operator watching a shard sit in one state // for ten minutes needs to know whether that is normal. type State int const ( // Pending means the shard is known but not started. Pending State = iota // Starting means the process has been launched but has not opened its port. Starting // Loading means the port is open but the model is not ready. Loading // Ready means health checks pass and the model is served. Ready // Draining means no new work; existing requests finish. Draining // Stopped means the process exited as intended. Stopped // Failed means the process exited unexpectedly or never became ready. Failed ) func (s State) String() string { switch s { case Pending: return "pending" case Starting: return "starting" case Loading: return "loading" case Ready: return "ready" case Draining: return "draining" case Stopped: return "stopped" case Failed: return "failed" default: return fmt.Sprintf("unknown(%d)", int(s)) } } // Terminal reports whether the shard has finished for good. func (s State) Terminal() bool { return s == Stopped || s == Failed } // Live reports whether a process should be running in this state. func (s State) Live() bool { return s == Starting || s == Loading || s == Ready || s == Draining }