--- title: internal/supervisor description: Go API reference for the supervisor package. --- # supervisor ```go import "github.com/jbcom/radioactive-ralph/internal/supervisor" ``` Package supervisor is the per\-variant brain of radioactive\-ralph. One Supervisor instance runs per live \`radioactive\_ralph run \-\-variant X\` invocation. It owns: - A PID flock at Paths.Sessions/\.pid so only one Supervisor\-per\-variant runs at a time in the same repo. - The Unix socket listener at Paths.Sessions/\.sock and its heartbeat marker .alive. - The SQLite event log at Paths.StateDB. On boot, the event log is replayed to rebuild in\-memory state. - The workspace.Manager that owns mirror/worktree lifecycle. - The session pool of claude subprocesses. Lifecycle: ``` New() → resolve state paths, validate variant Run(ctx) → blocks; does flock acquire, db open, socket bind, event replay, workspace init, session pool spawn, IPC request loop; returns nil on graceful shutdown or a descriptive error on startup failure. Shutdown(ctx) → asks the running supervisor to stop gracefully. ``` ## Index - [type Options](<#Options>) - [type Supervisor](<#Supervisor>) - [func New\(opts Options\) \(\*Supervisor, error\)](<#New>) - [func \(s \*Supervisor\) Run\(ctx context.Context\) error](<#Supervisor.Run>) - [func \(s \*Supervisor\) Shutdown\(\)](<#Supervisor.Shutdown>) ## type [Options]() Options configure a Supervisor. ```go type Options struct { // RepoPath is the operator's repo (mandatory). RepoPath string // Variant profile to drive. Mandatory. Variant variant.Profile // Workspace is the workspace manager for this variant run. Caller // constructs it (we can't — it needs resolved knobs from config). Workspace *workspace.Manager // HeartbeatInterval controls how often the supervisor touches the // .alive file. Default 10s. HeartbeatInterval time.Duration // ShutdownTimeout is the max wall time to wait for graceful // shutdown before force-killing sessions. Default 30s. ShutdownTimeout time.Duration } ``` ## type [Supervisor]() Supervisor coordinates a single variant's run. ```go type Supervisor struct { // contains filtered or unexported fields } ``` ### func [New]() ```go func New(opts Options) (*Supervisor, error) ``` New constructs a Supervisor without starting it. Returns an error if the options are structurally invalid; all runtime failures surface from Run. ### func \(\*Supervisor\) [Run]() ```go func (s *Supervisor) Run(ctx context.Context) error ``` Run blocks until the supervisor shuts down. Returns nil for a graceful stop, error for any startup or fatal runtime failure. ### func \(\*Supervisor\) [Shutdown]() ```go func (s *Supervisor) Shutdown() ``` Shutdown requests a graceful stop. Safe to call from a signal handler or another goroutine. Run\(\) returns after internal cleanup completes. Generated by [gomarkdoc]()