dog

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package dog manages Dogs - Deacon's helper workers for infrastructure tasks. Dogs are reusable workers with multi-rig worktrees, managed by the Deacon. Unlike polecats (single-rig, ephemeral), dogs handle cross-rig infrastructure work.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDogExists   = errors.New("dog already exists")
	ErrDogNotFound = errors.New("dog not found")
	ErrNoRigs      = errors.New("no rigs configured")
)

Common errors

Functions

This section is empty.

Types

type Dog

type Dog struct {
	Name       string            // Dog name (e.g., "alpha")
	State      State             // Current state
	Path       string            // Path to kennel dir (~/gt/deacon/dogs/<name>)
	Worktrees  map[string]string // Rig name -> worktree path
	LastActive time.Time         // Last activity timestamp
	Work       string            // Current work assignment (bead ID or molecule)
	CreatedAt  time.Time         // When dog was added to kennel
}

Dog represents a Deacon helper worker.

type DogState

type DogState struct {
	Name       string            `json:"name"`
	State      State             `json:"state"`
	LastActive time.Time         `json:"last_active"`
	Work       string            `json:"work,omitempty"`      // Current work assignment
	Worktrees  map[string]string `json:"worktrees,omitempty"` // Rig -> path (for verification)
	CreatedAt  time.Time         `json:"created_at"`
	UpdatedAt  time.Time         `json:"updated_at"`
}

DogState is the persistent state stored in .dog.json.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles dog lifecycle in the kennel.

func NewManager

func NewManager(townRoot string, rigsConfig *config.RigsConfig) *Manager

NewManager creates a new dog manager.

func (*Manager) Add

func (m *Manager) Add(name string) (*Dog, error)

Add creates a new dog in the kennel with worktrees into each rig. Each dog gets a worktree per rig (e.g., dogs/alpha/gastown/, dogs/alpha/beads/). Worktrees are created from each rig's bare repo (.repo.git) or mayor/rig.

func (*Manager) AssignWork

func (m *Manager) AssignWork(name, work string) error

AssignWork assigns work to a dog and sets it to working state.

func (*Manager) CleanupStaleBranches

func (m *Manager) CleanupStaleBranches() (int, error)

CleanupStaleBranches removes orphaned dog branches from all rigs. Returns total branches deleted across all rigs.

func (*Manager) ClearWork

func (m *Manager) ClearWork(name string) error

ClearWork clears a dog's work assignment and sets it to idle.

func (*Manager) Get

func (m *Manager) Get(name string) (*Dog, error)

Get returns a specific dog by name.

func (*Manager) GetIdleDog

func (m *Manager) GetIdleDog() (*Dog, error)

GetIdleDog returns an idle dog suitable for work assignment. Returns nil if no idle dogs are available.

func (*Manager) IdleCount

func (m *Manager) IdleCount() (int, error)

IdleCount returns the number of idle dogs.

func (*Manager) List

func (m *Manager) List() ([]*Dog, error)

List returns all dogs in the kennel.

func (*Manager) Refresh

func (m *Manager) Refresh(name string) error

Refresh recreates all worktrees for a dog with fresh branches. This is useful when worktrees have drifted or become stale.

func (*Manager) RefreshRig

func (m *Manager) RefreshRig(name, rigName string) error

RefreshRig recreates the worktree for a specific rig.

func (*Manager) Remove

func (m *Manager) Remove(name string) error

Remove deletes a dog from the kennel. Removes all worktrees and the dog directory.

func (*Manager) SetState

func (m *Manager) SetState(name string, state State) error

SetState updates a dog's state and last-active timestamp.

func (*Manager) WorkingCount

func (m *Manager) WorkingCount() (int, error)

WorkingCount returns the number of working dogs.

type State

type State string

State represents a dog's operational state.

const (
	// StateIdle means the dog is available for work.
	StateIdle State = "idle"
	// StateWorking means the dog is executing a task.
	StateWorking State = "working"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL