Documentation
¶
Overview ¶
Package orchestrator composes services into workflows.
Package orchestrator provides session orchestration services.
Index ¶
- Variables
- func BuildWaves(subPlans []domain.TaskPlan) [][]domain.TaskPlan
- func EnsureSessionDir(workspaceDir, sessionID string) (domain.SessionDirInfo, error)
- func GenerateBranchName(externalID, title string) string
- func PublishQuestionAnswered(ctx context.Context, eventBus event.Publisher, questionID, sessionID string) error
- func ReadWorkspaceAgentsMd(workspaceDir string) (string, error)
- func ValidateBranchName(branch string) bool
- type CorrectionTemplateData
- type Discoverer
- func (d *Discoverer) DiscoverRepos(ctx context.Context, _ string, repoPaths []string) ([]domain.RepoPointer, error)
- func (d *Discoverer) PreflightCheck(ctx context.Context, workspaceDir string) (domain.WorkspaceHealthCheck, error)
- func (d *Discoverer) PullMainWorktrees(ctx context.Context, repoPaths []string) RepoUpdateResults
- type ExecutionState
- func (s *ExecutionState) AdvanceWave() bool
- func (s *ExecutionState) AllWavesCompleted() bool
- func (s *ExecutionState) CompleteSubPlan(subPlanID string, completedAt int64)
- func (s *ExecutionState) CompleteWave(waveIndex int, endedAt int64)
- func (s *ExecutionState) CurrentWaveComplete() bool
- func (s *ExecutionState) FailSubPlan(subPlanID string, completedAt int64, err error)
- func (s *ExecutionState) FailWave(waveIndex int, endedAt int64)
- func (s *ExecutionState) GetWaveSubPlans(waveIndex int) []string
- func (s *ExecutionState) HasFailed() bool
- func (s *ExecutionState) StartSubPlan(subPlanID string, startedAt int64)
- func (s *ExecutionState) StartWave(waveIndex int, startedAt int64)
- type FollowUpData
- type FollowUpSessionResult
- type Foreman
- func (f *Foreman) Ask(ctx context.Context, q domain.Question) <-chan string
- func (f *Foreman) IsRunning() bool
- func (f *Foreman) LastPlanID() string
- func (f *Foreman) LastSessionID() string
- func (f *Foreman) ResolveEscalated(ctx context.Context, questionID, answer string) error
- func (f *Foreman) SendUserMessage(ctx context.Context, questionID, text string) (newProposal string, uncertain bool, err error)
- func (f *Foreman) SessionID() string
- func (f *Foreman) Start(ctx context.Context, planID string, followUpContext string) error
- func (f *Foreman) Stop(ctx context.Context) error
- type ImplementResult
- type ImplementationConfig
- type ImplementationService
- type ImplementationWarning
- type ManualSessionService
- func (s *ManualSessionService) Abort(ctx context.Context, sessionID string) error
- func (s *ManualSessionService) FollowUpManualSession(ctx context.Context, completed domain.AgentSession, message string) (domain.AgentSession, error)
- func (s *ManualSessionService) ResumeManualSession(ctx context.Context, interrupted domain.AgentSession, initialMessage string, ...) (domain.AgentSession, error)
- func (s *ManualSessionService) SendAnswer(ctx context.Context, sessionID, answer string) error
- func (s *ManualSessionService) SendMessage(ctx context.Context, sessionID, message string) error
- func (s *ManualSessionService) StartManualSession(ctx context.Context, req StartManualSessionRequest) (domain.AgentSession, error)
- func (s *ManualSessionService) Steer(ctx context.Context, sessionID, message string) error
- type PlanParser
- func (p *PlanParser) Parse(content string) (domain.RawPlanOutput, domain.ParseErrors)
- func (p *PlanParser) ParseAndValidate(content string, discoveredRepos []domain.RepoPointer) (domain.RawPlanOutput, domain.ParseErrors)
- func (p *PlanParser) Validate(output domain.RawPlanOutput, discoveredRepos []domain.RepoPointer) domain.ParseErrors
- type PlanningConfig
- type PlanningError
- type PlanningService
- func (s *PlanningService) FollowUpPlan(ctx context.Context, workItemID, feedback string) (*domain.PlanningResult, error)
- func (s *PlanningService) Plan(ctx context.Context, workItemID string) (*domain.PlanningResult, error)
- func (s *PlanningService) PlanWithFeedback(ctx context.Context, workItemID, oldPlanID, feedback string) (*domain.PlanningResult, error)
- func (s *PlanningService) UpdateReviewedPlan(ctx context.Context, planID, rawContent string) (domain.Plan, []domain.TaskPlan, error)
- type PlanningTemplates
- type QuestionRouter
- type RepoFinalizationResult
- type RepoResultSummary
- type RepoUpdateResults
- type ResumeSessionResult
- type Resumption
- func (r *Resumption) AbandonSession(ctx context.Context, id string) error
- func (r *Resumption) FollowUpFailedSession(ctx context.Context, failedSession domain.AgentSession, ...) (FollowUpSessionResult, error)
- func (r *Resumption) FollowUpSession(ctx context.Context, completedSession domain.AgentSession, ...) (FollowUpSessionResult, error)
- func (r *Resumption) ResumeSession(ctx context.Context, interrupted domain.AgentSession, currentInstanceID string) (ResumeSessionResult, error)
- func (r *Resumption) WaitAndComplete(ctx context.Context, sessionID string, harnessSession adapter.AgentSession)
- type ReviewPipeline
- type ReviewResult
- type RevisionData
- type SessionRegistry
- func (r *SessionRegistry) AbortAndDeregister(ctx context.Context, sessionID string)
- func (r *SessionRegistry) Deregister(sessionID string)
- func (r *SessionRegistry) IsRunning(sessionID string) bool
- func (r *SessionRegistry) Register(sessionID string, session adapter.AgentSession)
- func (r *SessionRegistry) SendAnswer(ctx context.Context, sessionID string, answer string) error
- func (r *SessionRegistry) SendMessage(ctx context.Context, sessionID string, msg string) error
- func (r *SessionRegistry) Steer(ctx context.Context, sessionID string, msg string) error
- type SessionResult
- type StartManualSessionRequest
- type SubPlanExecution
- type SubPlanOutcome
- type WaveState
- type WaveStatus
- type WorktreeCreatedPayload
- type WorktreeCreatingPayload
Constants ¶
This section is empty.
Variables ¶
var ErrQuestionNotEscalated = errors.New("question not in escalated channels")
ErrQuestionNotEscalated is returned by ResolveEscalated and SendUserMessage when no in-flight answer channel exists for the given question ID. This happens if the Foreman was restarted after escalation, or if the question was not escalated through the Foreman at all.
var ErrSessionNotRunning = errors.New("session is not running or not registered")
ErrSessionNotRunning indicates the target session is not in the registry.
Functions ¶
func BuildWaves ¶
BuildWaves groups sub-plans by Order into sequential execution waves. Sub-plans within a wave run concurrently; waves execute sequentially.
Example: SubPlans with Order values [0, 0, 1] produce 2 waves:
- Wave 0: 2 parallel sub-plans
- Wave 1: 1 sub-plan (runs after all wave 0 sub-plans complete)
func EnsureSessionDir ¶
func EnsureSessionDir(workspaceDir, sessionID string) (domain.SessionDirInfo, error)
EnsureSessionDir creates the session directory and returns its info.
func GenerateBranchName ¶
GenerateBranchName creates a branch name from external ID and title. Format: sub-<sanitized-externalID>-<short-slug>
Example:
externalID: "LIN-FOO-123"
title: "Fix auth flow for OAuth2"
result: "sub-LIN-FOO-123-fix-auth-flow-for-oauth2"
externalID: "gh:issue:rtk-ai/rtk#591"
title: "Add support for Oh My Pi"
result: "sub-gh-issue-rtk-ai-rtk-591-add-support-for-oh-my-pi"
func PublishQuestionAnswered ¶ added in v0.0.34
func ReadWorkspaceAgentsMd ¶
ReadWorkspaceAgentsMd reads the workspace-root AGENTS.md file if it exists.
func ValidateBranchName ¶
ValidateBranchName checks if a branch name is valid per git check-ref-format rules. A valid branch name: - Starts with "sub-" - Contains no sequences invalid in git ref names (/, :, #, .., @{) - Does not end with . or .lock - Has non-empty content after "sub-" with no leading or trailing dash
Types ¶
type CorrectionTemplateData ¶
type CorrectionTemplateData struct {
Errors string
DiscoveredRepos []string
SessionDraftPath string
}
CorrectionTemplateData is data for the correction template.
type Discoverer ¶
type Discoverer struct {
// contains filtered or unexported fields
}
Discoverer handles workspace scanning and repo discovery.
func NewDiscoverer ¶
func NewDiscoverer(gitClient *gitwork.Client, cfg *config.Config) *Discoverer
NewDiscoverer creates a new Discoverer.
func (*Discoverer) DiscoverRepos ¶
func (d *Discoverer) DiscoverRepos(ctx context.Context, _ string, repoPaths []string) ([]domain.RepoPointer, error)
DiscoverRepos discovers git-work repos and builds RepoPointers with metadata.
func (*Discoverer) PreflightCheck ¶
func (d *Discoverer) PreflightCheck(ctx context.Context, workspaceDir string) (domain.WorkspaceHealthCheck, error)
PreflightCheck scans the workspace for health issues. It identifies git-work repos, plain git clones, and other directories.
func (*Discoverer) PullMainWorktrees ¶
func (d *Discoverer) PullMainWorktrees(ctx context.Context, repoPaths []string) RepoUpdateResults
PullMainWorktrees pulls the main worktree of each git-work repo and then runs gw sync to prune stale worktrees whose remote branches have been deleted. Failures are recorded but don't stop the process.
Calls within pullCooldown of the previous pull are skipped; this prevents redundant network I/O when multiple sessions start in rapid succession. The cooldown gates both the pull and sync passes as a unit.
type ExecutionState ¶
type ExecutionState struct {
PlanID string
CurrentWave int
WaveStates []WaveState
Executions map[string]*SubPlanExecution // sub-plan ID -> execution
// contains filtered or unexported fields
}
ExecutionState tracks the overall state of plan implementation.
func NewExecutionState ¶
func NewExecutionState(planID string, subPlans []domain.TaskPlan) *ExecutionState
NewExecutionState creates a new execution state for a plan. Completed sub-plans are filtered out by BuildWaves, so the execution state only tracks sub-plans that still need work.
func (*ExecutionState) AdvanceWave ¶
func (s *ExecutionState) AdvanceWave() bool
AdvanceWave moves to the next wave if the current one is complete. Returns true if advanced, false if no more waves or current not complete.
func (*ExecutionState) AllWavesCompleted ¶
func (s *ExecutionState) AllWavesCompleted() bool
AllWavesCompleted returns true if all waves have completed successfully.
func (*ExecutionState) CompleteSubPlan ¶
func (s *ExecutionState) CompleteSubPlan(subPlanID string, completedAt int64)
CompleteSubPlan marks a sub-plan as completed.
func (*ExecutionState) CompleteWave ¶
func (s *ExecutionState) CompleteWave(waveIndex int, endedAt int64)
CompleteWave marks a wave as completed.
func (*ExecutionState) CurrentWaveComplete ¶
func (s *ExecutionState) CurrentWaveComplete() bool
CurrentWaveComplete returns true if the current wave has completed.
func (*ExecutionState) FailSubPlan ¶
func (s *ExecutionState) FailSubPlan(subPlanID string, completedAt int64, err error)
FailSubPlan marks a sub-plan as failed.
func (*ExecutionState) FailWave ¶
func (s *ExecutionState) FailWave(waveIndex int, endedAt int64)
FailWave marks a wave as failed.
func (*ExecutionState) GetWaveSubPlans ¶
func (s *ExecutionState) GetWaveSubPlans(waveIndex int) []string
GetWaveSubPlans returns the sub-plan IDs for the given wave index.
func (*ExecutionState) HasFailed ¶
func (s *ExecutionState) HasFailed() bool
HasFailed returns true if any wave or sub-plan has failed.
func (*ExecutionState) StartSubPlan ¶
func (s *ExecutionState) StartSubPlan(subPlanID string, startedAt int64)
StartSubPlan marks a sub-plan as in progress.
func (*ExecutionState) StartWave ¶
func (s *ExecutionState) StartWave(waveIndex int, startedAt int64)
StartWave marks a wave as running.
type FollowUpData ¶
type FollowUpData struct {
Feedback string
CurrentPlan string
RepoResults []RepoResultSummary
NewSessionDraftPath string
}
FollowUpData provides context for the follow-up planning template.
type FollowUpSessionResult ¶
type FollowUpSessionResult struct {
Session domain.AgentSession
HarnessSession adapter.AgentSession
}
FollowUpSessionResult holds the outputs of a successful follow-up.
type Foreman ¶
type Foreman struct {
// contains filtered or unexported fields
}
Foreman manages a persistent oh-my-pi session for answering sub-agent questions.
func NewForeman ¶
func NewForeman( cfg *config.Config, harness adapter.AgentHarness, planSvc *service.PlanService, questionSvc *service.QuestionService, sessionSvc *service.AgentSessionService, eventBus event.Publisher, ) *Foreman
NewForeman creates a new Foreman instance.
func (*Foreman) IsRunning ¶
IsRunning reports whether the Foreman has an active session. Safe for concurrent use.
func (*Foreman) LastPlanID ¶
LastPlanID returns the plan ID associated with the most recently stopped foreman session.
func (*Foreman) LastSessionID ¶
LastSessionID returns the session ID of the most recently stopped foreman session. This allows the TUI to display the foreman's session log even after the foreman has been stopped. Returns "" if no session has ever run.
func (*Foreman) ResolveEscalated ¶
ResolveEscalated delivers a human-approved answer for a previously escalated question. Called by the TUI after the human iterates with the Foreman and presses [A]pprove. Records the answer in the DB and unblocks the waiting sub-agent.
func (*Foreman) SendUserMessage ¶
func (f *Foreman) SendUserMessage(ctx context.Context, questionID, text string) (newProposal string, uncertain bool, err error)
SendUserMessage sends human follow-up text to the running Foreman session, waits for an updated proposed answer, persists it with UpdateProposal, and returns the new proposal so the TUI can refresh the question UI. The answer channel remains registered — the human must still call ResolveEscalated (or SkipQuestion) to actually unblock the sub-agent.
func (*Foreman) SessionID ¶
SessionID returns the ID of the currently running foreman session. Returns "" if the Foreman has not been started or has been stopped.
type ImplementResult ¶
type ImplementResult struct {
PlanID string
WorkItemID string
State *ExecutionState
Sessions []SessionResult
Warnings []ImplementationWarning
ReviewResults map[string]*SubPlanOutcome // keyed by sub-plan ID
CompletedAt time.Time
}
ImplementResult contains the result of implementation execution.
type ImplementationConfig ¶
ImplementationConfig contains configuration for the implementation service.
func DefaultImplementationConfig ¶
func DefaultImplementationConfig() *ImplementationConfig
DefaultImplementationConfig returns the default implementation configuration.
type ImplementationService ¶
type ImplementationService struct {
// contains filtered or unexported fields
}
ImplementationService orchestrates the implementation phase after plan approval. It manages wave-based execution of sub-plans, worktree creation, and agent sessions.
func NewImplementationService ¶
func NewImplementationService( cfg *config.Config, harness adapter.AgentHarness, gitClient *gitwork.Client, eventBus event.Publisher, planSvc *service.PlanService, workItemSvc *service.SessionService, sessionSvc *service.AgentSessionService, workspaceSvc *service.WorkspaceService, registry *SessionRegistry, reviewPipeline *ReviewPipeline, foreman *Foreman, questionSvc *service.QuestionService, reviewSvc *service.ReviewService, hookRegistry *worktree.HookRegistry, ) *ImplementationService
func (*ImplementationService) FinalizeWorkItem ¶ added in v0.0.35
func (s *ImplementationService) FinalizeWorkItem(ctx context.Context, workItemID string) (*ImplementResult, error)
FinalizeWorkItem retries the final commit/push/completion step for a work item whose repo tasks already finished.
func (*ImplementationService) Implement ¶
func (s *ImplementationService) Implement(ctx context.Context, planID string) (result *ImplementResult, err error)
Implement starts the implementation phase for an approved plan. It executes sub-plans in waves, creating worktrees and spawning agent sessions.
type ImplementationWarning ¶
type ImplementationWarning struct {
Type string // "worktree_exists", "session_failed", etc.
Message string
RepoName string
SessionID string
}
ImplementationWarning represents a non-fatal issue during implementation.
type ManualSessionService ¶ added in v0.1.1
type ManualSessionService struct {
// contains filtered or unexported fields
}
ManualSessionService orchestrates manual agent sessions within an existing work item. Unlike implementation sessions, manual sessions have no sub-plan context, no automatic commit/push, and no Foreman involvement. Questions are routed to the operator inline.
func NewManualSessionService ¶ added in v0.1.1
func NewManualSessionService( cfg *config.Config, harness adapter.AgentHarness, gitClient *gitwork.Client, sessionSvc *service.AgentSessionService, workItemSvc *service.SessionService, workspaceSvc *service.WorkspaceService, registry *SessionRegistry, questionRouter *QuestionRouter, eventBus event.Publisher, ) *ManualSessionService
NewManualSessionService creates a new ManualSessionService.
func (*ManualSessionService) Abort ¶ added in v0.1.1
func (s *ManualSessionService) Abort(ctx context.Context, sessionID string) error
Abort aborts a running manual session.
func (*ManualSessionService) FollowUpManualSession ¶ added in v0.1.1
func (s *ManualSessionService) FollowUpManualSession(ctx context.Context, completed domain.AgentSession, message string) (domain.AgentSession, error)
FollowUpManualSession sends a follow-up message to a completed manual session. It reuses the same session row (completed → running) when native resume is available, otherwise starts a new session and links old→new via EventAgentSessionResumed.
func (*ManualSessionService) ResumeManualSession ¶ added in v0.1.1
func (s *ManualSessionService) ResumeManualSession(ctx context.Context, interrupted domain.AgentSession, initialMessage string, ownerInstanceID *string) (domain.AgentSession, error)
ResumeManualSession resumes an interrupted manual session with a new harness instance. It creates a new DB row in pending/running state and links to the interrupted session's resume info for native conversation resumption.
func (*ManualSessionService) SendAnswer ¶ added in v0.1.1
func (s *ManualSessionService) SendAnswer(ctx context.Context, sessionID, answer string) error
SendAnswer sends an operator answer to resolve a pending question in a manual session.
func (*ManualSessionService) SendMessage ¶ added in v0.1.1
func (s *ManualSessionService) SendMessage(ctx context.Context, sessionID, message string) error
SendMessage sends a follow-up message to a running manual session.
func (*ManualSessionService) StartManualSession ¶ added in v0.1.1
func (s *ManualSessionService) StartManualSession(ctx context.Context, req StartManualSessionRequest) (domain.AgentSession, error)
StartManualSession starts a new manual agent session in the deterministic worktree for the given work item and repository.
type PlanParser ¶
type PlanParser struct{}
PlanParser parses planning agent output into structured data.
func (*PlanParser) Parse ¶
func (p *PlanParser) Parse(content string) (domain.RawPlanOutput, domain.ParseErrors)
Parse reads plan content and extracts structured data.
func (*PlanParser) ParseAndValidate ¶
func (p *PlanParser) ParseAndValidate(content string, discoveredRepos []domain.RepoPointer) (domain.RawPlanOutput, domain.ParseErrors)
ParseAndValidate combines parsing and validation.
func (*PlanParser) Validate ¶
func (p *PlanParser) Validate(output domain.RawPlanOutput, discoveredRepos []domain.RepoPointer) domain.ParseErrors
Validate checks that the parsed plan is consistent with discovered repos.
type PlanningConfig ¶
PlanningConfig contains configuration for the planning pipeline.
func DefaultPlanningConfig ¶
func DefaultPlanningConfig() *PlanningConfig
DefaultPlanningConfig returns the default planning configuration.
func PlanningConfigFromConfig ¶
func PlanningConfigFromConfig(cfg *config.Config) *PlanningConfig
PlanningConfigFromConfig extracts planning config from global config.
type PlanningError ¶
type PlanningError struct {
Err error
ParseErrors *domain.ParseErrors
}
PlanningError represents a planning failure with optional parse errors.
func (*PlanningError) Error ¶
func (e *PlanningError) Error() string
func (*PlanningError) Unwrap ¶
func (e *PlanningError) Unwrap() error
type PlanningService ¶
type PlanningService struct {
// contains filtered or unexported fields
}
PlanningService orchestrates the planning pipeline.
func NewPlanningService ¶
func NewPlanningService( cfg *PlanningConfig, discoverer *Discoverer, gitClient *gitwork.Client, harness adapter.AgentHarness, planSvc *service.PlanService, workItemSvc *service.SessionService, sessionSvc *service.AgentSessionService, eventBus event.Publisher, workspaceSvc *service.WorkspaceService, registry *SessionRegistry, questionSvc *service.QuestionService, globalCfg *config.Config, ) (*PlanningService, error)
func (*PlanningService) FollowUpPlan ¶
func (s *PlanningService) FollowUpPlan(ctx context.Context, workItemID, feedback string) (*domain.PlanningResult, error)
FollowUpPlan transitions a completed work item back to planning with differential context. It captures the current plan, implementation results, and user feedback to produce an updated plan.
func (*PlanningService) Plan ¶
func (s *PlanningService) Plan(ctx context.Context, workItemID string) (*domain.PlanningResult, error)
Plan executes the planning pipeline for a work item, transitioning it to planning state.
func (*PlanningService) PlanWithFeedback ¶
func (s *PlanningService) PlanWithFeedback(ctx context.Context, workItemID, oldPlanID, feedback string) (*domain.PlanningResult, error)
PlanWithFeedback runs a revision planning session for a work item in plan_review state. It rejects the existing plan and re-plans with the human's feedback. When the prior planning session produced resume data, the session is resumed natively so the model retains full conversation context of what it planned.
type PlanningTemplates ¶
type PlanningTemplates struct {
// contains filtered or unexported fields
}
PlanningTemplates holds compiled templates.
func NewPlanningTemplates ¶
func NewPlanningTemplates() (*PlanningTemplates, error)
NewPlanningTemplates creates compiled templates.
type QuestionRouter ¶ added in v0.0.33
type QuestionRouter struct {
// contains filtered or unexported fields
}
QuestionRouter is the single stage-aware routing point for normalized agent questions.
func NewQuestionRouter ¶ added in v0.0.33
func NewQuestionRouter(questionSvc *service.QuestionService, sessionSvc *service.AgentSessionService, registry *SessionRegistry, foreman *Foreman, eventBus event.Publisher) *QuestionRouter
func (*QuestionRouter) Route ¶ added in v0.0.33
func (r *QuestionRouter) Route(ctx context.Context, stage domain.AgentSessionPhase, evt adapter.AgentEvent, sessionID string) error
type RepoFinalizationResult ¶ added in v0.1.0
type RepoFinalizationResult struct {
SubPlanID string
Repository string
WorktreePath string
Branch string
Review domain.ReviewRef
Err error
}
RepoFinalizationResult contains the result of finalizing a single repo's branch. Used by the orchestrator to emit EventSubPlanPRReady per sub-plan after successful push.
type RepoResultSummary ¶
RepoResultSummary holds the implementation outcome for a single repository.
type RepoUpdateResults ¶
type RepoUpdateResults struct {
PullFailures []domain.PullFailure
}
RepoUpdateResults holds the outcomes of a combined pull-and-sync pass over all git-work repos. Sync failures are logged internally and not returned; they are maintenance-only and must not surface as planning warnings or toasts.
type ResumeSessionResult ¶
type ResumeSessionResult struct {
NewSession domain.AgentSession
HarnessSession adapter.AgentSession
}
ResumeSessionResult holds the outputs of a successful resume.
type Resumption ¶
type Resumption struct {
// contains filtered or unexported fields
}
Resumption handles Resume and Abandon workflows for interrupted agent sessions.
func NewResumption ¶
func NewResumption( harness adapter.AgentHarness, sessionSvc *service.AgentSessionService, planSvc *service.PlanService, eventBus event.Publisher, registry *SessionRegistry, questionRouter *QuestionRouter, ) *Resumption
NewResumption creates a Resumption instance.
func (*Resumption) AbandonSession ¶
func (r *Resumption) AbandonSession(ctx context.Context, id string) error
AbandonSession transitions an interrupted session to failed. Terminal operation.
func (*Resumption) FollowUpFailedSession ¶
func (r *Resumption) FollowUpFailedSession(ctx context.Context, failedSession domain.AgentSession, feedback, currentInstanceID string) (FollowUpSessionResult, error)
FollowUpFailedSession creates a new agent session to retry a failed session with user feedback. The failed session row is preserved as audit trail; a fresh AgentSession row is created for the retry.
func (*Resumption) FollowUpSession ¶
func (r *Resumption) FollowUpSession(ctx context.Context, completedSession domain.AgentSession, feedback, currentInstanceID string) (FollowUpSessionResult, error)
FollowUpSession restarts a completed session with a user follow-up message. Reuses the same AgentSession row (same ID/log file), transitions completed → running, and resumes the native OMP session if available.
func (*Resumption) ResumeSession ¶
func (r *Resumption) ResumeSession(ctx context.Context, interrupted domain.AgentSession, currentInstanceID string) (ResumeSessionResult, error)
ResumeSession starts a new agent session to continue work from an interrupted one. The interrupted session remains in the DB as interrupted (audit trail). The new session links to the same SubPlan and reuses the existing worktree. currentInstanceID becomes the owner of the new session. EventAgentSessionResumed is emitted by AgentSessionService.Resume().
func (*Resumption) WaitAndComplete ¶ added in v0.0.28
func (r *Resumption) WaitAndComplete(ctx context.Context, sessionID string, harnessSession adapter.AgentSession)
WaitAndComplete blocks until harnessSession finishes, then transitions sessionID to the appropriate terminal state in the DB and saves resume info. It deregisters the session from the registry on completion. Callers must have previously registered the session via registry.Register. Intended for follow-up sessions where the TUI command goroutine drives the wait.
type ReviewPipeline ¶
type ReviewPipeline struct {
// contains filtered or unexported fields
}
ReviewPipeline orchestrates the review process for agent sessions.
func NewReviewPipeline ¶
func NewReviewPipeline( cfg *config.Config, harness adapter.AgentHarness, reviewSvc *service.ReviewService, sessionSvc *service.AgentSessionService, planSvc *service.PlanService, workItemSvc *service.SessionService, eventBus event.Publisher, registry *SessionRegistry, ) *ReviewPipeline
NewReviewPipeline creates a new ReviewPipeline instance.
func (*ReviewPipeline) ReviewSession ¶
func (p *ReviewPipeline) ReviewSession(ctx context.Context, agentSession domain.AgentSession) (*ReviewResult, error)
ReviewSession reviews an agent session's output.
type ReviewResult ¶
type ReviewResult struct {
Passed bool
Critiques []domain.Critique
CycleNumber int
NeedsReimpl bool
Escalated bool
SessionID string // review agent session ID — log at config.SessionsDir()/<SessionID>.log
}
ReviewResult contains the result of a review.
type RevisionData ¶
RevisionData contains data for the revision template.
type SessionRegistry ¶
type SessionRegistry struct {
// contains filtered or unexported fields
}
SessionRegistry maps session IDs to running adapter.AgentSession handles. It is safe for concurrent use.
func NewSessionRegistry ¶
func NewSessionRegistry() *SessionRegistry
func (*SessionRegistry) AbortAndDeregister ¶
func (r *SessionRegistry) AbortAndDeregister(ctx context.Context, sessionID string)
AbortAndDeregister aborts the agent session identified by sessionID and removes it from the registry. If the session is not registered this is a no-op. Abort errors are logged but not returned because the caller's intent is to tear down the session unconditionally.
func (*SessionRegistry) Deregister ¶
func (r *SessionRegistry) Deregister(sessionID string)
Deregister removes a session from the registry.
func (*SessionRegistry) IsRunning ¶
func (r *SessionRegistry) IsRunning(sessionID string) bool
IsRunning reports whether the given session ID is registered.
func (*SessionRegistry) Register ¶
func (r *SessionRegistry) Register(sessionID string, session adapter.AgentSession)
Register adds a running session to the registry.
func (*SessionRegistry) SendAnswer ¶
SendAnswer sends an answer to resolve a pending ask_foreman tool call. Returns ErrSessionNotRunning if the session is not registered.
func (*SessionRegistry) SendMessage ¶
SendMessage sends a follow-up message to a running session. Returns ErrSessionNotRunning if the session is not registered.
type SessionResult ¶
type SessionResult struct {
SessionID string
SubPlanID string
Repository string
WorktreePath string
Branch string
Status domain.AgentSessionStatus
StartedAt time.Time
CompletedAt *time.Time
ExitCode *int
Summary string
Errors []string
Outcome *SubPlanOutcome // populated after review loop completes
}
SessionResult contains the result of a single agent session.
type StartManualSessionRequest ¶ added in v0.1.1
type StartManualSessionRequest struct {
WorkItemID string
WorkspaceID string
RepositoryName string
InitialMessage string
SubPlanID string // optional context only
OwnerInstanceID *string
}
StartManualSessionRequest contains the parameters for starting a manual session.
type SubPlanExecution ¶
type SubPlanExecution struct {
SubPlanID string
Order int
WaveIndex int
Status domain.TaskPlanStatus
StartedAt int64 // Unix nano timestamp
CompletedAt int64 // Unix nano timestamp
Error error
}
SubPlanExecution represents the execution state of a single sub-plan.
type SubPlanOutcome ¶
type SubPlanOutcome struct {
SubPlanID string
Repository string
Passed bool
Escalated bool
Failed bool
ReviewResult *ReviewResult // nil when review was skipped (impl failed or no pipeline)
Cycles int // total impl→review cycles executed
}
SubPlanOutcome captures the final state of a sub-plan after the full implement→review→reimpl cycle.
type WaveState ¶
type WaveState struct {
Index int
Status WaveStatus
SubPlanIDs []string
StartedAt int64 // Unix nano timestamp
EndedAt int64 // Unix nano timestamp
}
WaveState tracks the execution state of a single wave.
type WaveStatus ¶
type WaveStatus string
WaveStatus represents the status of a wave during execution.
const ( WavePending WaveStatus = "pending" WaveRunning WaveStatus = "running" WaveCompleted WaveStatus = "completed" WaveFailed WaveStatus = "failed" )
type WorktreeCreatedPayload ¶
type WorktreeCreatedPayload struct {
WorkspaceID string `json:"workspace_id"`
WorkItemID string `json:"work_item_id"`
Repository string `json:"repository"`
Branch string `json:"branch"`
WorktreePath string `json:"worktree_path"`
WorkItemTitle string `json:"work_item_title"`
SubPlan string `json:"sub_plan"`
TrackerRefs []domain.TrackerReference `json:"tracker_refs"`
Review domain.ReviewRef `json:"review"`
}
type WorktreeCreatingPayload ¶
type WorktreeCreatingPayload struct {
WorkspaceID string `json:"workspace_id"`
WorkItemID string `json:"work_item_id"`
Repository string `json:"repository"`
Branch string `json:"branch"`
WorkItemTitle string `json:"work_item_title"`
SubPlan string `json:"sub_plan"`
Review domain.ReviewRef `json:"review"`
}