Documentation
¶
Overview ¶
Package dispatch is PARKED.
This package is not active in production. The TaskExecutor in internal/taskexecutor/ is the active execution engine. LoopDetector has been moved to internal/loopdetector/. This package exists for reference only and is not instantiated.
Index ¶
- Constants
- type ActionRecord
- type AutoBugRouter
- type BugRouteInfo
- type DispatchResult
- type Dispatcher
- func (d *Dispatcher) DispatchOnce(ctx context.Context, projectID string) (*DispatchResult, error)
- func (d *Dispatcher) GetSystemStatus() SystemStatus
- func (d *Dispatcher) SetContainerOrchestrator(orch *containers.Orchestrator)
- func (d *Dispatcher) SetDatabase(db *database.Database)
- func (d *Dispatcher) SetEscalator(escalator Escalator)
- func (d *Dispatcher) SetLifecycleContext(ctx context.Context)
- func (d *Dispatcher) SetMaxDispatchHops(maxHops int)
- func (d *Dispatcher) SetMemoryManager(mgr *memory.MemoryManager)
- func (d *Dispatcher) SetMessageBus(mb MessageBus)
- func (d *Dispatcher) SetReadinessCheck(check func(context.Context, string) (bool, []string))
- func (d *Dispatcher) SetReadinessMode(mode ReadinessMode)
- func (d *Dispatcher) SetSwarmManager(mgr *swarm.Manager)
- func (d *Dispatcher) SetTaskTimeout(timeout time.Duration)
- func (d *Dispatcher) SetUseNATSDispatch(enabled bool)
- func (d *Dispatcher) SetWorkflowEngine(engine *workflow.Engine)
- func (d *Dispatcher) SetWorktreeManager(wm *gitops.GitWorktreeManager)
- type ErrorRecord
- type Escalator
- type LessonsProvider
- func (lp *LessonsProvider) GetLessonsForPrompt(projectID string) string
- func (lp *LessonsProvider) GetRelevantLessons(projectID, taskContext string, topK int) string
- func (lp *LessonsProvider) RecordLesson(projectID, category, title, detail, beadID, agentID string) error
- func (lp *LessonsProvider) SetEmbedder(e memory.Embedder)
- type LoopDetector
- func (ld *LoopDetector) GetActionHistoryJSON(bead *models.Bead) string
- func (ld *LoopDetector) GetAgentCommitRange(bead *models.Bead) (firstSHA, lastSHA string, count int)
- func (ld *LoopDetector) GetProgressSummary(bead *models.Bead) string
- func (ld *LoopDetector) IsStuckInLoop(bead *models.Bead) (bool, string)
- func (ld *LoopDetector) RecordAction(bead *models.Bead, action ActionRecord) error
- func (ld *LoopDetector) ResetProgress(bead *models.Bead)
- func (ld *LoopDetector) SetRepeatThreshold(threshold int)
- func (ld *LoopDetector) SuggestNextSteps(bead *models.Bead, loopReason string) []string
- type MessageBus
- type PendingTask
- type PersonaMatcher
- type ProgressMetrics
- type ReadinessMode
- type ResultHandler
- type StatusState
- type SystemStatus
Constants ¶
const DefaultTaskTimeout = 30 * time.Minute
DefaultTaskTimeout is the default maximum duration for task execution.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionRecord ¶
type ActionRecord struct {
Timestamp time.Time `json:"timestamp"`
AgentID string `json:"agent_id"`
ActionType string `json:"action_type"` // e.g., "read_file", "run_tests", "edit_file"
ActionData map[string]interface{} `json:"action_data"` // Specific details
ResultHash string `json:"result_hash"` // Hash of action result
ProgressKey string `json:"progress_key"` // Key identifying the action pattern
}
ActionRecord represents a single action taken by an agent
type AutoBugRouter ¶
type AutoBugRouter struct{}
AutoBugRouter handles intelligent routing of auto-filed bugs to appropriate coding agents
func NewAutoBugRouter ¶
func NewAutoBugRouter() *AutoBugRouter
func (*AutoBugRouter) AnalyzeBugForRouting ¶
func (r *AutoBugRouter) AnalyzeBugForRouting(bead *models.Bead) *BugRouteInfo
AnalyzeBugForRouting analyzes an auto-filed bug and determines routing
type BugRouteInfo ¶
type BugRouteInfo struct {
ShouldRoute bool // Whether this bug should be auto-dispatched
PersonaHint string // Which persona/role should handle it
UpdatedTitle string // Title with persona hint added
RoutingReason string // Why this routing was chosen
}
BugRouteInfo contains information about how to route a bug
type DispatchResult ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is responsible for selecting ready work and executing it using agents/providers. For now it focuses on turning beads into LLM tasks and storing the output back into bead context.
func NewDispatcher ¶
func (*Dispatcher) DispatchOnce ¶
func (d *Dispatcher) DispatchOnce(ctx context.Context, projectID string) (*DispatchResult, error)
DispatchOnce finds at most one ready bead and asks an idle agent to work on it.
func (*Dispatcher) GetSystemStatus ¶
func (d *Dispatcher) GetSystemStatus() SystemStatus
func (*Dispatcher) SetContainerOrchestrator ¶ added in v0.1.3
func (d *Dispatcher) SetContainerOrchestrator(orch *containers.Orchestrator)
SetContainerOrchestrator sets the container orchestrator for per-project containers
func (*Dispatcher) SetDatabase ¶
func (d *Dispatcher) SetDatabase(db *database.Database)
SetDatabase sets the database for conversation context management
func (*Dispatcher) SetEscalator ¶
func (d *Dispatcher) SetEscalator(escalator Escalator)
SetEscalator sets the escalator used for CEO escalation.
func (*Dispatcher) SetLifecycleContext ¶ added in v0.1.11
func (d *Dispatcher) SetLifecycleContext(ctx context.Context)
SetLifecycleContext sets the dispatcher's lifecycle context for graceful shutdown. Task goroutines derive their context from this, enabling cancellation propagation when Loom is shutting down.
func (*Dispatcher) SetMaxDispatchHops ¶
func (d *Dispatcher) SetMaxDispatchHops(maxHops int)
SetMaxDispatchHops configures the max hop limit before escalation.
func (*Dispatcher) SetMemoryManager ¶ added in v0.1.3
func (d *Dispatcher) SetMemoryManager(mgr *memory.MemoryManager)
SetMemoryManager injects the per-project memory manager used for context enrichment.
func (*Dispatcher) SetMessageBus ¶ added in v0.1.3
func (d *Dispatcher) SetMessageBus(mb MessageBus)
SetMessageBus sets the message bus for async agent communication
func (*Dispatcher) SetReadinessCheck ¶
func (*Dispatcher) SetReadinessMode ¶
func (d *Dispatcher) SetReadinessMode(mode ReadinessMode)
func (*Dispatcher) SetSwarmManager ¶ added in v0.1.3
func (d *Dispatcher) SetSwarmManager(mgr *swarm.Manager)
SetSwarmManager sets the swarm manager used for dynamic service discovery. When set, the dispatcher consults the swarm registry to route tasks to remote agent instances before falling back to in-process workers.
func (*Dispatcher) SetTaskTimeout ¶ added in v0.1.11
func (d *Dispatcher) SetTaskTimeout(timeout time.Duration)
SetTaskTimeout sets the maximum duration for a single task execution. If not set, defaults to 30 minutes.
func (*Dispatcher) SetUseNATSDispatch ¶ added in v0.1.5
func (d *Dispatcher) SetUseNATSDispatch(enabled bool)
SetUseNATSDispatch enables or disables NATS-only task routing for this dispatcher instance. This replaces the former package-level UseNATSDispatch global, allowing per-instance configuration and safe test isolation.
func (*Dispatcher) SetWorkflowEngine ¶
func (d *Dispatcher) SetWorkflowEngine(engine *workflow.Engine)
SetWorkflowEngine sets the workflow engine for workflow-aware dispatching
func (*Dispatcher) SetWorktreeManager ¶ added in v0.1.3
func (d *Dispatcher) SetWorktreeManager(wm *gitops.GitWorktreeManager)
SetWorktreeManager sets the git worktree manager for parallel agent isolation.
type ErrorRecord ¶ added in v0.1.3
type ErrorRecord struct {
Timestamp time.Time `json:"timestamp"`
Error string `json:"error"`
Dispatch int `json:"dispatch"`
}
ErrorRecord tracks an error occurrence
type Escalator ¶
type Escalator interface {
EscalateBeadToCEO(beadID, reason, returnedTo string) (*models.DecisionBead, error)
}
Escalator provides CEO escalation for dispatcher guardrails.
type LessonsProvider ¶
type LessonsProvider struct {
// contains filtered or unexported fields
}
LessonsProvider retrieves and records lessons from the database. It implements the worker.LessonsProvider interface.
func NewLessonsProvider ¶
func NewLessonsProvider(db *database.Database) *LessonsProvider
NewLessonsProvider creates a new LessonsProvider backed by the given database. It uses a hash-based embedder by default for semantic search.
func (*LessonsProvider) GetLessonsForPrompt ¶
func (lp *LessonsProvider) GetLessonsForPrompt(projectID string) string
GetLessonsForPrompt retrieves lessons for a project and formats them as markdown suitable for injection into the system prompt.
func (*LessonsProvider) GetRelevantLessons ¶ added in v0.1.2
func (lp *LessonsProvider) GetRelevantLessons(projectID, taskContext string, topK int) string
GetRelevantLessons retrieves the top-K lessons most semantically relevant to the given task context. Falls back to GetLessonsForPrompt on any error.
func (*LessonsProvider) RecordLesson ¶
func (lp *LessonsProvider) RecordLesson(projectID, category, title, detail, beadID, agentID string) error
RecordLesson creates a new lesson from observed agent behavior. It also embeds the lesson text for future semantic search.
func (*LessonsProvider) SetEmbedder ¶ added in v0.1.2
func (lp *LessonsProvider) SetEmbedder(e memory.Embedder)
SetEmbedder replaces the default hash embedder with a provider-backed one.
type LoopDetector ¶
type LoopDetector struct {
// contains filtered or unexported fields
}
LoopDetector detects stuck loops vs. productive investigation
func NewLoopDetector ¶
func NewLoopDetector() *LoopDetector
NewLoopDetector creates a new loop detector with default settings
func (*LoopDetector) GetActionHistoryJSON ¶
func (ld *LoopDetector) GetActionHistoryJSON(bead *models.Bead) string
GetActionHistoryJSON returns the action history as JSON string
func (*LoopDetector) GetAgentCommitRange ¶
func (ld *LoopDetector) GetAgentCommitRange(bead *models.Bead) (firstSHA, lastSHA string, count int)
GetAgentCommitRange returns the first and last commit SHAs for the current agent's dispatch cycle by reading the dispatch_count and commit metadata from bead context.
func (*LoopDetector) GetProgressSummary ¶
func (ld *LoopDetector) GetProgressSummary(bead *models.Bead) string
GetProgressSummary returns a human-readable progress summary
func (*LoopDetector) IsStuckInLoop ¶
func (ld *LoopDetector) IsStuckInLoop(bead *models.Bead) (bool, string)
IsStuckInLoop checks if the bead is stuck in a non-productive loop
func (*LoopDetector) RecordAction ¶
func (ld *LoopDetector) RecordAction(bead *models.Bead, action ActionRecord) error
RecordAction adds an action to the bead's dispatch history
func (*LoopDetector) ResetProgress ¶
func (ld *LoopDetector) ResetProgress(bead *models.Bead)
ResetProgress clears progress tracking for a bead
func (*LoopDetector) SetRepeatThreshold ¶
func (ld *LoopDetector) SetRepeatThreshold(threshold int)
SetRepeatThreshold configures how many repeats before flagging as a loop
func (*LoopDetector) SuggestNextSteps ¶
func (ld *LoopDetector) SuggestNextSteps(bead *models.Bead, loopReason string) []string
SuggestNextSteps analyzes the situation and suggests actions for the CEO/human
type MessageBus ¶ added in v0.1.3
type MessageBus interface {
PublishTask(ctx context.Context, projectID string, task *messages.TaskMessage) error
PublishTaskForRole(ctx context.Context, projectID, role string, task *messages.TaskMessage) error
}
MessageBus defines the interface for publishing task messages
type PendingTask ¶ added in v0.1.3
type PendingTask struct {
CorrelationID string
ProjectID string
BeadID string
AgentID string
Role string
DispatchedAt time.Time
LastUpdate time.Time
}
PendingTask tracks a task that was dispatched and is awaiting a result
type PersonaMatcher ¶
type PersonaMatcher struct {
// contains filtered or unexported fields
}
PersonaMatcher provides fuzzy matching for persona-based routing
func NewPersonaMatcher ¶
func NewPersonaMatcher() *PersonaMatcher
func (*PersonaMatcher) ExtractPersonaHint ¶
func (pm *PersonaMatcher) ExtractPersonaHint(bead *models.Bead) string
ExtractPersonaHint tries to extract persona hints from a bead. Checks (in priority order): bead context requires_persona field, title patterns, description patterns, and tags.
func (*PersonaMatcher) FindAgentByPersonaHint ¶
FindAgentByPersonaHint finds the best matching agent for a persona hint
type ProgressMetrics ¶
type ProgressMetrics struct {
FilesRead int `json:"files_read"`
FilesModified int `json:"files_modified"`
TestsRun int `json:"tests_run"`
CommandsExecuted int `json:"commands_executed"`
LastProgress time.Time `json:"last_progress"`
}
ProgressMetrics tracks progress indicators for a bead
type ReadinessMode ¶
type ReadinessMode string
const ( ReadinessBlock ReadinessMode = "block" ReadinessWarn ReadinessMode = "warn" )
type ResultHandler ¶ added in v0.1.3
type ResultHandler struct {
// contains filtered or unexported fields
}
ResultHandler tracks dispatched tasks and correlates incoming results.
func NewResultHandler ¶ added in v0.1.3
func NewResultHandler() *ResultHandler
NewResultHandler creates a new result handler
func (*ResultHandler) GetPending ¶ added in v0.1.3
func (rh *ResultHandler) GetPending() []*PendingTask
GetPending returns a copy of all pending tasks
func (*ResultHandler) HandleResult ¶ added in v0.1.3
func (rh *ResultHandler) HandleResult(result *messages.ResultMessage) *PendingTask
HandleResult matches a result to its pending task and returns it. Returns nil if no matching pending task is found.
func (*ResultHandler) PendingCount ¶ added in v0.1.3
func (rh *ResultHandler) PendingCount() int
PendingCount returns the number of tasks currently awaiting results
func (*ResultHandler) Track ¶ added in v0.1.3
func (rh *ResultHandler) Track(correlationID, projectID, beadID, agentID, role string)
Track registers a dispatched task for correlation tracking
type StatusState ¶
type StatusState string
const ( StatusActive StatusState = "active" StatusParked StatusState = "parked" )
type SystemStatus ¶
type SystemStatus struct {
State StatusState `json:"state"`
Reason string `json:"reason"`
UpdatedAt time.Time `json:"updated_at"`
}