assignment

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package assignment provides assignment tracking for bead-to-agent mappings.

Index

Constants

This section is empty.

Variables

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

type PersistenceError struct {
	Operation string
	Path      string
	Cause     error
}

PersistenceError represents an error during persistence operations

func (*PersistenceError) Error

func (e *PersistenceError) Error() string

func (*PersistenceError) Unwrap

func (e *PersistenceError) Unwrap() error

Jump to

Keyboard shortcuts

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