Documentation
¶
Overview ¶
Package worker implements the Worker lifecycle state machine (FSM).
A Worker ties together the worktree manager, Smith (Claude) spawner, prompt builder, and state database to manage the full lifecycle:
pending → running → reviewing → done
↘ failed
↘ timeout
Index ¶
- func ActiveCount(db *state.DB, anvilName string) (int, error)
- func CanSpawn(db *state.DB, anvilName string, maxSmiths int) (bool, error)
- func CanSpawnGlobal(db *state.DB, maxTotal int) (bool, error)
- func DispatchActiveCount(db *state.DB, anvilName string) (int, error)
- func DispatchTotalActiveCount(db *state.DB) (int, error)
- func TotalActiveCount(db *state.DB) (int, error)
- type Params
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveCount ¶
ActiveCount returns the number of active workers for an anvil from the state DB.
func CanSpawn ¶
CanSpawn checks if a new worker can be spawned for the given anvil, respecting the max_smiths limit. Only dispatch pipeline workers count; lifecycle workers (cifix, reviewfix) are excluded.
func CanSpawnGlobal ¶
CanSpawnGlobal checks if a new worker can be spawned globally, respecting the max_total_smiths limit. Only dispatch pipeline workers count; lifecycle workers (cifix, reviewfix) are excluded.
func DispatchActiveCount ¶
DispatchActiveCount returns the number of active dispatch pipeline workers for an anvil, excluding lifecycle workers (cifix, reviewfix). This is the correct value to compare against max_smiths.
func DispatchTotalActiveCount ¶
DispatchTotalActiveCount returns the total number of active dispatch pipeline workers across all anvils, excluding lifecycle workers (cifix, reviewfix). This is the correct value to compare against max_total_smiths.
Types ¶
type Params ¶
type Params struct {
DB *state.DB
WorktreeManager *worktree.Manager
PromptBuilder *prompt.Builder
AnvilName string
AnvilConfig config.AnvilConfig
Bead poller.Bead
ExtraFlags []string
}
Params holds the dependencies needed to create a Worker.
type Worker ¶
type Worker struct {
// ID is a unique identifier for this worker session.
ID string
// Bead is the bead being worked on.
Bead poller.Bead
// AnvilName is the name of the anvil this bead belongs to.
AnvilName string
// AnvilConfig is the anvil configuration.
AnvilConfig config.AnvilConfig
// Status is the current lifecycle state.
Status state.WorkerStatus
// contains filtered or unexported fields
}
Worker represents a single bead being worked on by a Smith.