Documentation
¶
Overview ¶
Package assignment provides assignment tracking for bead-to-agent mappings.
Index ¶
- Variables
- func StorageDir() string
- type Assignment
- type AssignmentStats
- type AssignmentStatus
- type AssignmentStore
- func (s *AssignmentStore) Assign(beadID, beadTitle string, pane int, agentType, agentName, prompt string) (*Assignment, error)
- func (s *AssignmentStore) Clear()
- func (s *AssignmentStore) Get(beadID string) *Assignment
- func (s *AssignmentStore) GetAll() []Assignment
- func (s *AssignmentStore) List() []*Assignment
- func (s *AssignmentStore) ListActive() []*Assignment
- func (s *AssignmentStore) ListByPane(pane int) []*Assignment
- func (s *AssignmentStore) ListByStatus(status AssignmentStatus) []*Assignment
- func (s *AssignmentStore) Load() error
- func (s *AssignmentStore) MarkCompleted(beadID string) error
- func (s *AssignmentStore) MarkFailed(beadID, reason string) error
- func (s *AssignmentStore) MarkWorking(beadID string) error
- func (s *AssignmentStore) Reassign(beadID string, newPane int, newAgentType, newAgentName string) (*Assignment, error)
- func (s *AssignmentStore) Remove(beadID string)
- func (s *AssignmentStore) Save() error
- func (s *AssignmentStore) Stats() AssignmentStats
- func (s *AssignmentStore) UpdateStatus(beadID string, newStatus AssignmentStatus) error
- type InvalidTransitionError
- type PersistenceError
Constants ¶
This section is empty.
Variables ¶
var ValidTransitions = map[AssignmentStatus][]AssignmentStatus{ StatusAssigned: {StatusWorking, StatusFailed}, StatusWorking: {StatusCompleted, StatusFailed, StatusReassigned}, StatusFailed: {StatusAssigned}, StatusCompleted: {}, StatusReassigned: {}, }
ValidTransitions defines valid state transitions
Functions ¶
func StorageDir ¶
func StorageDir() string
StorageDir returns the path to the assignment storage directory. Uses ~/.ntm/sessions/ (assignments are stored within session directories).
Types ¶
type Assignment ¶
type Assignment struct {
BeadID string `json:"bead_id"`
BeadTitle string `json:"bead_title"`
Pane int `json:"pane"`
AgentType string `json:"agent_type"` // claude, codex, gemini
AgentName string `json:"agent_name,omitempty"` // Agent Mail name if registered
Status AssignmentStatus `json:"status"`
AssignedAt time.Time `json:"assigned_at"`
StartedAt *time.Time `json:"started_at,omitempty"` // When agent started working
CompletedAt *time.Time `json:"completed_at,omitempty"`
FailedAt *time.Time `json:"failed_at,omitempty"`
FailReason string `json:"fail_reason,omitempty"`
FailureReason string `json:"failure_reason,omitempty"` // Detailed failure reason
RetryCount int `json:"retry_count,omitempty"` // Number of retry attempts
PromptSent string `json:"prompt_sent,omitempty"` // The actual prompt sent
}
Assignment represents a bead assigned to an agent
type AssignmentStats ¶
type AssignmentStats struct {
Total int `json:"total"`
Assigned int `json:"assigned"`
Working int `json:"working"`
Completed int `json:"completed"`
Failed int `json:"failed"`
Reassigned int `json:"reassigned"`
}
AssignmentStats contains summary statistics
type AssignmentStatus ¶
type AssignmentStatus string
AssignmentStatus represents the current state of an assignment
const ( StatusAssigned AssignmentStatus = "assigned" // Prompt sent, waiting to start StatusWorking AssignmentStatus = "working" // Agent actively working StatusCompleted AssignmentStatus = "completed" // Bead closed successfully StatusFailed AssignmentStatus = "failed" // Agent crashed or gave up StatusReassigned AssignmentStatus = "reassigned" // Moved to different agent )
type AssignmentStore ¶
type AssignmentStore struct {
SessionName string `json:"session_name"`
Assignments map[string]*Assignment `json:"assignments"` // bead_id -> assignment
UpdatedAt time.Time `json:"updated_at"`
Version int `json:"version"` // Schema version for migrations
// contains filtered or unexported fields
}
AssignmentStore manages bead-to-agent assignments for a session
func LoadStore ¶
func LoadStore(sessionName string) (*AssignmentStore, error)
LoadStore loads an AssignmentStore from disk, creating a new one if it doesn't exist
func NewStore ¶
func NewStore(sessionName string) *AssignmentStore
NewStore creates a new AssignmentStore for a session
func (*AssignmentStore) Assign ¶
func (s *AssignmentStore) Assign(beadID, beadTitle string, pane int, agentType, agentName, prompt string) (*Assignment, error)
Assign creates or updates an assignment for a bead
func (*AssignmentStore) Clear ¶
func (s *AssignmentStore) Clear()
Clear removes all assignments from the store
func (*AssignmentStore) Get ¶
func (s *AssignmentStore) Get(beadID string) *Assignment
Get retrieves an assignment by bead ID
func (*AssignmentStore) GetAll ¶
func (s *AssignmentStore) GetAll() []Assignment
GetAll returns all assignments as values
func (*AssignmentStore) List ¶
func (s *AssignmentStore) List() []*Assignment
List returns all assignments
func (*AssignmentStore) ListActive ¶
func (s *AssignmentStore) ListActive() []*Assignment
ListActive returns all assignments that are assigned or working
func (*AssignmentStore) ListByPane ¶
func (s *AssignmentStore) ListByPane(pane int) []*Assignment
ListByPane returns all assignments for a specific pane
func (*AssignmentStore) ListByStatus ¶
func (s *AssignmentStore) ListByStatus(status AssignmentStatus) []*Assignment
ListByStatus returns all assignments with a specific status
func (*AssignmentStore) Load ¶
func (s *AssignmentStore) Load() error
Load reads the assignment store from disk
func (*AssignmentStore) MarkCompleted ¶
func (s *AssignmentStore) MarkCompleted(beadID string) error
MarkCompleted marks an assignment as completed
func (*AssignmentStore) MarkFailed ¶
func (s *AssignmentStore) MarkFailed(beadID, reason string) error
MarkFailed marks an assignment as failed with a reason
func (*AssignmentStore) MarkWorking ¶
func (s *AssignmentStore) MarkWorking(beadID string) error
MarkWorking marks an assignment as actively working
func (*AssignmentStore) Reassign ¶
func (s *AssignmentStore) Reassign(beadID string, newPane int, newAgentType, newAgentName string) (*Assignment, error)
Reassign moves an assignment to a different agent
func (*AssignmentStore) Remove ¶
func (s *AssignmentStore) Remove(beadID string)
Remove removes an assignment from the store
func (*AssignmentStore) Save ¶
func (s *AssignmentStore) Save() error
Save writes the assignment store to disk with backup
func (*AssignmentStore) Stats ¶
func (s *AssignmentStore) Stats() AssignmentStats
Stats returns summary statistics about assignments
func (*AssignmentStore) UpdateStatus ¶
func (s *AssignmentStore) UpdateStatus(beadID string, newStatus AssignmentStatus) error
UpdateStatus changes the status of an assignment with validation
type InvalidTransitionError ¶
type InvalidTransitionError struct {
BeadID string
From AssignmentStatus
To AssignmentStatus
}
InvalidTransitionError represents an invalid state transition
func (*InvalidTransitionError) Error ¶
func (e *InvalidTransitionError) Error() string
type PersistenceError ¶
PersistenceError represents an error during persistence operations
func (*PersistenceError) Error ¶
func (e *PersistenceError) Error() string
func (*PersistenceError) Unwrap ¶
func (e *PersistenceError) Unwrap() error