Documentation
¶
Index ¶
- Constants
- func HandleCommentResolutionTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
- func HandleGitHubCommentTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
- func HandleGitHubResolveThreadTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
- func HandleImportPRTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
- func HandleTaskError(ctx context.Context, proj *project.Project, task *db.ScheduledTask, ...)
- func ProcessAllDueTasks(ctx context.Context, proj *project.Project)
- func ProcessAllDueTasksWithControlPlane(ctx context.Context, proj *project.Project, cp *ControlPlane)
- func RunControlPlaneLoop(ctx context.Context, proj *project.Project, procManager *procmon.Manager) error
- func RunControlPlaneLoopWithControlPlane(ctx context.Context, proj *project.Project, procManager *procmon.Manager, ...) error
- func ScheduleDestroyWorktree(ctx context.Context, proj *project.Project, workID string) error
- func ScheduleWatchWorkflowRun(ctx context.Context, proj *project.Project, workID string, runID int64, ...) error
- func SpawnWorkflowWatchers(ctx context.Context, proj *project.Project, ghClient github.ClientInterface, ...) (int, error)
- func TriggerPRFeedbackCheck(ctx context.Context, proj *project.Project, workID string) error
- type ControlPlane
- func (cp *ControlPlane) GetTaskHandlers() map[string]TaskHandler
- func (cp *ControlPlane) HandleCreateWorktreeTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
- func (cp *ControlPlane) HandleDestroyWorktreeTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
- func (cp *ControlPlane) HandleGitPushTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
- func (cp *ControlPlane) HandlePRFeedbackTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
- func (cp *ControlPlane) HandleSpawnOrchestratorTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
- func (cp *ControlPlane) HandleWatchWorkflowRunTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
- type DefaultOrchestratorSpawner
- type DefaultWorkDestroyer
- type InitResult
- type OrchestratorSpawner
- type TaskHandler
- type WorkDestroyer
Constants ¶
const ControlPlaneTabName = "control"
ControlPlaneTabName is the name of the control plane tab in zellij
Variables ¶
This section is empty.
Functions ¶
func HandleCommentResolutionTask ¶
func HandleCommentResolutionTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
HandleCommentResolutionTask handles a scheduled comment resolution check. Returns nil on success, error on failure (caller handles retry/completion).
func HandleGitHubCommentTask ¶
func HandleGitHubCommentTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
HandleGitHubCommentTask handles a scheduled GitHub comment posting task. Returns nil on success, error on failure (caller handles retry/completion).
func HandleGitHubResolveThreadTask ¶
func HandleGitHubResolveThreadTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
HandleGitHubResolveThreadTask handles a scheduled GitHub thread resolution task. Returns nil on success, error on failure (caller handles retry/completion).
func HandleImportPRTask ¶
HandleImportPRTask handles a scheduled PR import task. This sets up a worktree from an existing GitHub PR.
func HandleTaskError ¶
func HandleTaskError(ctx context.Context, proj *project.Project, task *db.ScheduledTask, errMsg string)
HandleTaskError handles an error for a task, rescheduling with backoff if appropriate.
func ProcessAllDueTasks ¶
ProcessAllDueTasks checks for and executes any scheduled tasks that are due across all works. This uses the default ControlPlane with production dependencies.
func ProcessAllDueTasksWithControlPlane ¶
func ProcessAllDueTasksWithControlPlane(ctx context.Context, proj *project.Project, cp *ControlPlane)
ProcessAllDueTasksWithControlPlane checks for and executes any scheduled tasks with provided dependencies.
func RunControlPlaneLoop ¶
func RunControlPlaneLoop(ctx context.Context, proj *project.Project, procManager *procmon.Manager) error
RunControlPlaneLoop runs the main control plane event loop with default dependencies.
func RunControlPlaneLoopWithControlPlane ¶
func RunControlPlaneLoopWithControlPlane(ctx context.Context, proj *project.Project, procManager *procmon.Manager, cp *ControlPlane) error
RunControlPlaneLoopWithControlPlane runs the main control plane event loop with provided dependencies. This allows testing with mock dependencies.
func ScheduleDestroyWorktree ¶
ScheduleDestroyWorktree schedules a worktree destruction task for the control plane. This is the preferred way to destroy a worktree as it runs asynchronously with retry support.
func ScheduleWatchWorkflowRun ¶
func ScheduleWatchWorkflowRun(ctx context.Context, proj *project.Project, workID string, runID int64, repo string) error
ScheduleWatchWorkflowRun schedules a task to watch a workflow run. Uses the run_id as the idempotency key to prevent duplicate watchers.
func SpawnWorkflowWatchers ¶
func SpawnWorkflowWatchers(ctx context.Context, proj *project.Project, ghClient github.ClientInterface, workID, prURL string) (int, error)
SpawnWorkflowWatchers checks for in-progress workflow runs and spawns watchers for them. This can be called immediately when a PR is created to catch fast CI runs that would otherwise complete before the first PR feedback poll. Returns the number of watchers spawned.
Types ¶
type ControlPlane ¶
type ControlPlane struct {
Git git.Operations
Worktree worktree.Operations
Zellij zellij.SessionManager
Mise func(dir string) mise.Operations
FeedbackProcessor feedback.Processor
OrchestratorSpawner OrchestratorSpawner
WorkDestroyer WorkDestroyer
GitHubClient github.ClientInterface
}
ControlPlane manages the execution of scheduled tasks with injectable dependencies. It allows for testing without actual CLI tools, services, or file system operations.
func NewControlPlane ¶
func NewControlPlane(proj *project.Project) *ControlPlane
NewControlPlane creates a new ControlPlane with default production dependencies.
func NewControlPlaneWithDeps ¶
func NewControlPlaneWithDeps( gitOps git.Operations, wtOps worktree.Operations, zellijMgr zellij.SessionManager, miseOps func(dir string) mise.Operations, feedbackProc feedback.Processor, orchestratorSpawner OrchestratorSpawner, workDestroyer WorkDestroyer, githubClient github.ClientInterface, ) *ControlPlane
NewControlPlaneWithDeps creates a new ControlPlane with provided dependencies for testing.
func (*ControlPlane) GetTaskHandlers ¶
func (cp *ControlPlane) GetTaskHandlers() map[string]TaskHandler
GetTaskHandlers returns the task handler map for the control plane.
func (*ControlPlane) HandleCreateWorktreeTask ¶
func (cp *ControlPlane) HandleCreateWorktreeTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
HandleCreateWorktreeTask handles a scheduled worktree creation task
func (*ControlPlane) HandleDestroyWorktreeTask ¶
func (cp *ControlPlane) HandleDestroyWorktreeTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
HandleDestroyWorktreeTask handles a scheduled worktree destruction task
func (*ControlPlane) HandleGitPushTask ¶
func (cp *ControlPlane) HandleGitPushTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
HandleGitPushTask handles a scheduled git push task with retry support. Returns nil on success, error on failure (caller handles retry/completion).
func (*ControlPlane) HandlePRFeedbackTask ¶
func (cp *ControlPlane) HandlePRFeedbackTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
HandlePRFeedbackTask handles a scheduled PR feedback check. Returns nil on success, error on failure (caller handles retry/completion).
func (*ControlPlane) HandleSpawnOrchestratorTask ¶
func (cp *ControlPlane) HandleSpawnOrchestratorTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
HandleSpawnOrchestratorTask handles a scheduled orchestrator spawn task
func (*ControlPlane) HandleWatchWorkflowRunTask ¶
func (cp *ControlPlane) HandleWatchWorkflowRunTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error
HandleWatchWorkflowRunTask watches a GitHub Actions workflow run until completion. When the run completes (success or failure), it schedules a PRFeedback task to run immediately. This replaces polling for workflow runs that are in-progress.
Required metadata: - run_id: The GitHub Actions workflow run ID to watch - repo: The repository in owner/repo format
type DefaultOrchestratorSpawner ¶
type DefaultOrchestratorSpawner struct {
// contains filtered or unexported fields
}
DefaultOrchestratorSpawner implements OrchestratorSpawner using the work package.
func NewOrchestratorSpawner ¶
func NewOrchestratorSpawner(database *db.DB) *DefaultOrchestratorSpawner
NewOrchestratorSpawner creates a new DefaultOrchestratorSpawner with the given database.
func (*DefaultOrchestratorSpawner) SpawnWorkOrchestrator ¶
func (d *DefaultOrchestratorSpawner) SpawnWorkOrchestrator(ctx context.Context, workID, projectName, workDir, friendlyName string, w io.Writer) error
SpawnWorkOrchestrator implements OrchestratorSpawner.
type DefaultWorkDestroyer ¶
type DefaultWorkDestroyer struct {
// contains filtered or unexported fields
}
DefaultWorkDestroyer implements WorkDestroyer using the work package.
func NewWorkDestroyer ¶
func NewWorkDestroyer(proj *project.Project) *DefaultWorkDestroyer
NewWorkDestroyer creates a new DefaultWorkDestroyer with a WorkService.
func (*DefaultWorkDestroyer) DestroyWork ¶
DestroyWork implements WorkDestroyer.
type InitResult ¶
type InitResult struct {
// SessionCreated is true if a new zellij session was created
SessionCreated bool
// SessionName is the name of the zellij session (e.g., "co-myproject")
SessionName string
}
InitResult contains information about session initialization
func EnsureControlPlane ¶
EnsureControlPlane ensures the zellij session and control plane are running. Creates the session if needed, spawns control plane if missing, restarts if dead. Returns information about whether a new session was created.
type OrchestratorSpawner ¶
type OrchestratorSpawner interface {
SpawnWorkOrchestrator(ctx context.Context, workID, projectName, workDir, friendlyName string, w io.Writer) error
}
OrchestratorSpawner defines the interface for spawning work orchestrators. This abstraction enables testing without actual zellij operations.
type TaskHandler ¶
TaskHandler is the signature for all scheduled task handlers.
Source Files
¶
- handler_comment_resolution.go
- handler_create_worktree.go
- handler_destroy_worktree.go
- handler_error.go
- handler_git_push.go
- handler_github_comment.go
- handler_github_resolve_thread.go
- handler_import_pr.go
- handler_pr_feedback.go
- handler_spawn_orchestrator.go
- handler_watch_run.go
- loop.go
- plane.go
- scheduler.go
- spawn.go