Documentation
¶
Overview ¶
Package service contains state machines and domain logic.
Index ¶
- type ErrAlreadyExists
- type ErrConstraintViolation
- type ErrInvalidInput
- type ErrInvalidTransition
- type ErrNotFound
- type EventService
- func (s *EventService) Create(ctx context.Context, e domain.SystemEvent) error
- func (s *EventService) ListByType(ctx context.Context, eventType string, limit int) ([]domain.SystemEvent, error)
- func (s *EventService) ListByWorkspaceID(ctx context.Context, workspaceID string, limit int) ([]domain.SystemEvent, error)
- type GithubPRService
- func (s *GithubPRService) Get(ctx context.Context, id string) (domain.GithubPullRequest, error)
- func (s *GithubPRService) GetByNumber(ctx context.Context, owner, repo string, number int) (domain.GithubPullRequest, error)
- func (s *GithubPRService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.GithubPullRequest, error)
- func (s *GithubPRService) ListNonTerminal(ctx context.Context, workspaceID string) ([]domain.GithubPullRequest, error)
- func (s *GithubPRService) Upsert(ctx context.Context, pr domain.GithubPullRequest) error
- type GitlabMRService
- func (s *GitlabMRService) Get(ctx context.Context, id string) (domain.GitlabMergeRequest, error)
- func (s *GitlabMRService) GetByIID(ctx context.Context, projectPath string, iid int) (domain.GitlabMergeRequest, error)
- func (s *GitlabMRService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.GitlabMergeRequest, error)
- func (s *GitlabMRService) ListNonTerminal(ctx context.Context, workspaceID string) ([]domain.GitlabMergeRequest, error)
- func (s *GitlabMRService) Upsert(ctx context.Context, mr domain.GitlabMergeRequest) error
- type InstanceService
- func (s *InstanceService) CleanupStaleInstances(ctx context.Context, workspaceID string, threshold time.Duration) (int, error)
- func (s *InstanceService) Create(ctx context.Context, inst domain.SubstrateInstance) error
- func (s *InstanceService) Delete(ctx context.Context, id string) error
- func (s *InstanceService) FindStaleInstances(ctx context.Context, workspaceID string, threshold time.Duration) ([]domain.SubstrateInstance, error)
- func (s *InstanceService) Get(ctx context.Context, id string) (domain.SubstrateInstance, error)
- func (s *InstanceService) IsAlive(ctx context.Context, id string, threshold time.Duration) (bool, error)
- func (s *InstanceService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.SubstrateInstance, error)
- func (s *InstanceService) UpdateHeartbeat(ctx context.Context, id string) error
- type PlanService
- func (s *PlanService) AllSubPlansCompleted(ctx context.Context, planID string) (bool, error)
- func (s *PlanService) AppendFAQ(ctx context.Context, entry domain.FAQEntry) error
- func (s *PlanService) ApplyReviewedPlanOutput(ctx context.Context, id string, rawOutput domain.RawPlanOutput) (domain.Plan, []domain.TaskPlan, error)
- func (s *PlanService) ApprovePlan(ctx context.Context, id string) error
- func (s *PlanService) CompleteSubPlan(ctx context.Context, id string) error
- func (s *PlanService) CreatePlan(ctx context.Context, plan domain.Plan) error
- func (s *PlanService) CreatePlanAtomic(ctx context.Context, replacePlanID string, plan *domain.Plan, ...) error
- func (s *PlanService) CreateSubPlan(ctx context.Context, sp domain.TaskPlan) error
- func (s *PlanService) CreateSubPlansBatch(ctx context.Context, subPlans []domain.TaskPlan) error
- func (s *PlanService) DeletePlan(ctx context.Context, id string) error
- func (s *PlanService) DeleteSubPlan(ctx context.Context, id string) error
- func (s *PlanService) FailSubPlan(ctx context.Context, id string) error
- func (s *PlanService) GetPlan(ctx context.Context, id string) (domain.Plan, error)
- func (s *PlanService) GetPlanByWorkItemID(ctx context.Context, workItemID string) (domain.Plan, error)
- func (s *PlanService) GetSubPlan(ctx context.Context, id string) (domain.TaskPlan, error)
- func (s *PlanService) ListSubPlansByPlanID(ctx context.Context, planID string) ([]domain.TaskPlan, error)
- func (s *PlanService) RejectPlan(ctx context.Context, id string) error
- func (s *PlanService) RetrySubPlan(ctx context.Context, id string) error
- func (s *PlanService) StartSubPlan(ctx context.Context, id string) error
- func (s *PlanService) SubmitForReview(ctx context.Context, id string) error
- func (s *PlanService) TransitionPlan(ctx context.Context, id string, to domain.PlanStatus) error
- func (s *PlanService) TransitionSubPlan(ctx context.Context, id string, to domain.TaskPlanStatus) error
- func (s *PlanService) UpdatePlanContent(ctx context.Context, id string, content string) error
- func (s *PlanService) UpdateSubPlanContent(ctx context.Context, id string, content string) error
- type QuestionService
- func (s *QuestionService) Answer(ctx context.Context, id string, answer string, answeredBy string) error
- func (s *QuestionService) Create(ctx context.Context, q domain.Question) error
- func (s *QuestionService) Escalate(ctx context.Context, id string) error
- func (s *QuestionService) EscalateWithProposal(ctx context.Context, id string, proposedAnswer string) error
- func (s *QuestionService) Get(ctx context.Context, id string) (domain.Question, error)
- func (s *QuestionService) HasPendingQuestions(ctx context.Context, sessionID string) (bool, error)
- func (s *QuestionService) ListBySessionID(ctx context.Context, sessionID string) ([]domain.Question, error)
- func (s *QuestionService) Transition(ctx context.Context, id string, to domain.QuestionStatus) error
- func (s *QuestionService) UpdateContext(ctx context.Context, id string, questionContext string) error
- func (s *QuestionService) UpdateProposal(ctx context.Context, id, proposedAnswer string) error
- type ReviewService
- func (s *ReviewService) CompleteReimplementation(ctx context.Context, id string) error
- func (s *ReviewService) CountMajorCritiques(ctx context.Context, cycleID string) (int, error)
- func (s *ReviewService) CreateCritique(ctx context.Context, critique domain.Critique) error
- func (s *ReviewService) CreateCritiquesBatch(ctx context.Context, critiques []domain.Critique) error
- func (s *ReviewService) CreateCycle(ctx context.Context, cycle domain.ReviewCycle) error
- func (s *ReviewService) FailReviewCycle(ctx context.Context, id string) error
- func (s *ReviewService) GetCritique(ctx context.Context, id string) (domain.Critique, error)
- func (s *ReviewService) GetCycle(ctx context.Context, id string) (domain.ReviewCycle, error)
- func (s *ReviewService) HasUnresolvedCritiques(ctx context.Context, cycleID string) (bool, error)
- func (s *ReviewService) ListCritiquesByCycleID(ctx context.Context, cycleID string) ([]domain.Critique, error)
- func (s *ReviewService) ListCyclesBySessionID(ctx context.Context, sessionID string) ([]domain.ReviewCycle, error)
- func (s *ReviewService) PassReview(ctx context.Context, id string) error
- func (s *ReviewService) RecordCritiques(ctx context.Context, id string) error
- func (s *ReviewService) ResolveCritique(ctx context.Context, id string) error
- func (s *ReviewService) StartReimplementation(ctx context.Context, id string) error
- func (s *ReviewService) TransitionCritique(ctx context.Context, id string, to domain.CritiqueStatus) error
- func (s *ReviewService) TransitionCycle(ctx context.Context, id string, to domain.ReviewCycleStatus) error
- func (s *ReviewService) UpdateCycleSummary(ctx context.Context, id string, summary string) error
- type SessionFilterLockService
- func (s *SessionFilterLockService) Acquire(ctx context.Context, filterID, instanceID string, leaseDuration time.Duration) (domain.NewSessionFilterLock, bool, error)
- func (s *SessionFilterLockService) Release(ctx context.Context, filterID, instanceID string) error
- func (s *SessionFilterLockService) Renew(ctx context.Context, filterID, instanceID string, leaseDuration time.Duration) (domain.NewSessionFilterLock, bool, error)
- type SessionFilterService
- func (s *SessionFilterService) Create(ctx context.Context, filter domain.NewSessionFilter) error
- func (s *SessionFilterService) Delete(ctx context.Context, id string) error
- func (s *SessionFilterService) Get(ctx context.Context, id string) (domain.NewSessionFilter, error)
- func (s *SessionFilterService) GetByWorkspaceProviderName(ctx context.Context, workspaceID, provider, name string) (domain.NewSessionFilter, error)
- func (s *SessionFilterService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.NewSessionFilter, error)
- func (s *SessionFilterService) ListByWorkspaceProvider(ctx context.Context, workspaceID, provider string) ([]domain.NewSessionFilter, error)
- func (s *SessionFilterService) Update(ctx context.Context, filter domain.NewSessionFilter) error
- type SessionReviewArtifactService
- func (s *SessionReviewArtifactService) ListByWorkItemID(ctx context.Context, workItemID string) ([]domain.SessionReviewArtifact, error)
- func (s *SessionReviewArtifactService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.SessionReviewArtifact, error)
- func (s *SessionReviewArtifactService) Upsert(ctx context.Context, link domain.SessionReviewArtifact) error
- type SessionService
- func (s *SessionService) ApprovePlan(ctx context.Context, id string) error
- func (s *SessionService) CompleteWorkItem(ctx context.Context, id string) error
- func (s *SessionService) Create(ctx context.Context, item domain.Session) error
- func (s *SessionService) Delete(ctx context.Context, id string) error
- func (s *SessionService) FailWorkItem(ctx context.Context, id string) error
- func (s *SessionService) Get(ctx context.Context, id string) (domain.Session, error)
- func (s *SessionService) List(ctx context.Context, filter repository.SessionFilter) ([]domain.Session, error)
- func (s *SessionService) RejectPlan(ctx context.Context, id string) error
- func (s *SessionService) RequestReimplementation(ctx context.Context, id string) error
- func (s *SessionService) RetryFailedWorkItem(ctx context.Context, id string) error
- func (s *SessionService) RollbackPlanningInterrupt(ctx context.Context, id string) error
- func (s *SessionService) StartFollowUpPlanning(ctx context.Context, id string) error
- func (s *SessionService) StartImplementation(ctx context.Context, id string) error
- func (s *SessionService) StartPlanning(ctx context.Context, id string) error
- func (s *SessionService) SubmitForReview(ctx context.Context, id string) error
- func (s *SessionService) SubmitPlanForReview(ctx context.Context, id string) error
- func (s *SessionService) Transition(ctx context.Context, id string, to domain.SessionState) error
- func (s *SessionService) Update(ctx context.Context, item domain.Session) error
- type TaskService
- func (s *TaskService) Complete(ctx context.Context, id string) error
- func (s *TaskService) Create(ctx context.Context, task domain.Task) error
- func (s *TaskService) Delete(ctx context.Context, id string) error
- func (s *TaskService) Fail(ctx context.Context, id string, exitCode *int) error
- func (s *TaskService) FindInterruptedByWorkspace(ctx context.Context, workspaceID string) ([]domain.Task, error)
- func (s *TaskService) FindRunningByOwner(ctx context.Context, instanceID string) ([]domain.Task, error)
- func (s *TaskService) FollowUpRestart(ctx context.Context, id string) error
- func (s *TaskService) Get(ctx context.Context, id string) (domain.Task, error)
- func (s *TaskService) Interrupt(ctx context.Context, id string) error
- func (s *TaskService) ListBySubPlanID(ctx context.Context, subPlanID string) ([]domain.Task, error)
- func (s *TaskService) ListByWorkItemID(ctx context.Context, workItemID string) ([]domain.Task, error)
- func (s *TaskService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.Task, error)
- func (s *TaskService) Resume(ctx context.Context, id string) error
- func (s *TaskService) ResumeFromAnswer(ctx context.Context, id string) error
- func (s *TaskService) SearchHistory(ctx context.Context, filter domain.SessionHistoryFilter) ([]domain.SessionHistoryEntry, error)
- func (s *TaskService) SetPlanID(ctx context.Context, id string, planID string) error
- func (s *TaskService) Start(ctx context.Context, id string) error
- func (s *TaskService) Transition(ctx context.Context, id string, to domain.TaskStatus) error
- func (s *TaskService) UpdateOwnerInstance(ctx context.Context, id string, instanceID string) error
- func (s *TaskService) UpdatePID(ctx context.Context, id string, pid int) error
- func (s *TaskService) UpdateResumeInfo(ctx context.Context, id string, info map[string]string) error
- func (s *TaskService) WaitForAnswer(ctx context.Context, id string) error
- type WorkspaceService
- func (s *WorkspaceService) Archive(ctx context.Context, id string) error
- func (s *WorkspaceService) Create(ctx context.Context, ws domain.Workspace) error
- func (s *WorkspaceService) Delete(ctx context.Context, id string) error
- func (s *WorkspaceService) Get(ctx context.Context, id string) (domain.Workspace, error)
- func (s *WorkspaceService) MarkError(ctx context.Context, id string) error
- func (s *WorkspaceService) MarkReady(ctx context.Context, id string) error
- func (s *WorkspaceService) Recover(ctx context.Context, id string) error
- func (s *WorkspaceService) Transition(ctx context.Context, id string, to domain.WorkspaceStatus) error
- func (s *WorkspaceService) Update(ctx context.Context, ws domain.Workspace) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrAlreadyExists ¶
ErrAlreadyExists is returned when an entity already exists.
func (ErrAlreadyExists) Error ¶
func (e ErrAlreadyExists) Error() string
type ErrConstraintViolation ¶
type ErrConstraintViolation struct {
Message string
}
ErrConstraintViolation is returned when a business constraint is violated.
func (ErrConstraintViolation) Error ¶
func (e ErrConstraintViolation) Error() string
type ErrInvalidInput ¶
ErrInvalidInput is returned when input validation fails.
func (ErrInvalidInput) Error ¶
func (e ErrInvalidInput) Error() string
type ErrInvalidTransition ¶
ErrInvalidTransition is returned when a state transition is not allowed.
func (ErrInvalidTransition) Error ¶
func (e ErrInvalidTransition) Error() string
type ErrNotFound ¶
ErrNotFound is returned when an entity is not found.
func (ErrNotFound) Error ¶
func (e ErrNotFound) Error() string
type EventService ¶
type EventService struct {
// contains filtered or unexported fields
}
EventService provides business logic for system events.
func NewEventService ¶
func NewEventService(transacter atomic.Transacter[repository.Resources]) *EventService
NewEventService creates a new EventService.
func (*EventService) Create ¶
func (s *EventService) Create(ctx context.Context, e domain.SystemEvent) error
Create persists a system event.
func (*EventService) ListByType ¶
func (s *EventService) ListByType(ctx context.Context, eventType string, limit int) ([]domain.SystemEvent, error)
ListByType retrieves events by type.
func (*EventService) ListByWorkspaceID ¶
func (s *EventService) ListByWorkspaceID(ctx context.Context, workspaceID string, limit int) ([]domain.SystemEvent, error)
ListByWorkspaceID retrieves events by workspace ID.
type GithubPRService ¶
type GithubPRService struct {
// contains filtered or unexported fields
}
GithubPRService provides business logic for GitHub pull requests.
func NewGithubPRService ¶
func NewGithubPRService(transacter atomic.Transacter[repository.Resources]) *GithubPRService
NewGithubPRService creates a new GithubPRService.
func (*GithubPRService) Get ¶
func (s *GithubPRService) Get(ctx context.Context, id string) (domain.GithubPullRequest, error)
Get retrieves a GitHub pull request by ID.
func (*GithubPRService) GetByNumber ¶
func (s *GithubPRService) GetByNumber(ctx context.Context, owner, repo string, number int) (domain.GithubPullRequest, error)
GetByNumber retrieves a GitHub pull request by owner, repo, and number.
func (*GithubPRService) ListByWorkspaceID ¶
func (s *GithubPRService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.GithubPullRequest, error)
ListByWorkspaceID retrieves GitHub pull requests by workspace ID.
func (*GithubPRService) ListNonTerminal ¶
func (s *GithubPRService) ListNonTerminal(ctx context.Context, workspaceID string) ([]domain.GithubPullRequest, error)
ListNonTerminal retrieves non-terminal GitHub pull requests by workspace ID.
func (*GithubPRService) Upsert ¶
func (s *GithubPRService) Upsert(ctx context.Context, pr domain.GithubPullRequest) error
Upsert creates or updates a GitHub pull request.
type GitlabMRService ¶
type GitlabMRService struct {
// contains filtered or unexported fields
}
GitlabMRService provides business logic for GitLab merge requests.
func NewGitlabMRService ¶
func NewGitlabMRService(transacter atomic.Transacter[repository.Resources]) *GitlabMRService
NewGitlabMRService creates a new GitlabMRService.
func (*GitlabMRService) Get ¶
func (s *GitlabMRService) Get(ctx context.Context, id string) (domain.GitlabMergeRequest, error)
Get retrieves a GitLab merge request by ID.
func (*GitlabMRService) GetByIID ¶
func (s *GitlabMRService) GetByIID(ctx context.Context, projectPath string, iid int) (domain.GitlabMergeRequest, error)
GetByIID retrieves a GitLab merge request by project path and IID.
func (*GitlabMRService) ListByWorkspaceID ¶
func (s *GitlabMRService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.GitlabMergeRequest, error)
ListByWorkspaceID retrieves GitLab merge requests by workspace ID.
func (*GitlabMRService) ListNonTerminal ¶
func (s *GitlabMRService) ListNonTerminal(ctx context.Context, workspaceID string) ([]domain.GitlabMergeRequest, error)
ListNonTerminal retrieves non-terminal GitLab merge requests by workspace ID.
func (*GitlabMRService) Upsert ¶
func (s *GitlabMRService) Upsert(ctx context.Context, mr domain.GitlabMergeRequest) error
Upsert creates or updates a GitLab merge request.
type InstanceService ¶
type InstanceService struct {
// contains filtered or unexported fields
}
InstanceService provides business logic for substrate instances.
func NewInstanceService ¶
func NewInstanceService(transacter atomic.Transacter[repository.Resources]) *InstanceService
NewInstanceService creates a new InstanceService.
func (*InstanceService) CleanupStaleInstances ¶
func (s *InstanceService) CleanupStaleInstances(ctx context.Context, workspaceID string, threshold time.Duration) (int, error)
CleanupStaleInstances removes all stale instance records for a workspace. Returns the count of successfully deleted instances and an error if any deletions failed. If some deletions fail, the error will be a joined error containing all individual errors.
func (*InstanceService) Create ¶
func (s *InstanceService) Create(ctx context.Context, inst domain.SubstrateInstance) error
Create creates a new instance record.
func (*InstanceService) Delete ¶
func (s *InstanceService) Delete(ctx context.Context, id string) error
Delete removes an instance record (on clean shutdown).
func (*InstanceService) FindStaleInstances ¶
func (s *InstanceService) FindStaleInstances(ctx context.Context, workspaceID string, threshold time.Duration) ([]domain.SubstrateInstance, error)
FindStaleInstances finds all instances with stale heartbeats for a workspace.
func (*InstanceService) Get ¶
func (s *InstanceService) Get(ctx context.Context, id string) (domain.SubstrateInstance, error)
Get retrieves an instance by ID.
func (*InstanceService) IsAlive ¶
func (s *InstanceService) IsAlive(ctx context.Context, id string, threshold time.Duration) (bool, error)
IsAlive checks if an instance is alive based on heartbeat. An instance is considered alive if its last heartbeat is within the threshold.
func (*InstanceService) ListByWorkspaceID ¶
func (s *InstanceService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.SubstrateInstance, error)
ListByWorkspaceID retrieves all instances for a workspace.
func (*InstanceService) UpdateHeartbeat ¶
func (s *InstanceService) UpdateHeartbeat(ctx context.Context, id string) error
UpdateHeartbeat updates the last heartbeat timestamp for an instance.
type PlanService ¶
type PlanService struct {
// contains filtered or unexported fields
}
PlanService provides business logic for plans and sub-plans.
func NewPlanService ¶
func NewPlanService(transacter atomic.Transacter[repository.Resources]) *PlanService
NewPlanService creates a new PlanService.
func (*PlanService) AllSubPlansCompleted ¶
AllSubPlansCompleted checks if all sub-plans for a plan are completed.
func (*PlanService) ApplyReviewedPlanOutput ¶
func (s *PlanService) ApplyReviewedPlanOutput(ctx context.Context, id string, rawOutput domain.RawPlanOutput) (domain.Plan, []domain.TaskPlan, error)
ApplyReviewedPlanOutput updates the persisted orchestration plan and sub-plans from a fully parsed review document.
func (*PlanService) ApprovePlan ¶
func (s *PlanService) ApprovePlan(ctx context.Context, id string) error
ApprovePlan transitions a plan from pending_review to approved.
func (*PlanService) CompleteSubPlan ¶
func (s *PlanService) CompleteSubPlan(ctx context.Context, id string) error
CompleteSubPlan transitions a sub-plan from in_progress to completed.
func (*PlanService) CreatePlan ¶
CreatePlan creates a new plan in draft status.
func (*PlanService) CreatePlanAtomic ¶
func (s *PlanService) CreatePlanAtomic(ctx context.Context, replacePlanID string, plan *domain.Plan, subPlans []domain.TaskPlan) error
CreatePlanAtomic atomically supersedes the old plan (when replacePlanID is non-empty) and creates the new plan and sub-plans in a single transaction. The partial unique index on plans(work_item_id) WHERE status != 'superseded' ensures at most one active plan per work item. The old plan and its sub-plans remain in the database for historical reference.
func (*PlanService) CreateSubPlan ¶
CreateSubPlan creates a new sub-plan in pending status.
func (*PlanService) CreateSubPlansBatch ¶
CreateSubPlansBatch creates multiple sub-plans in a single call.
func (*PlanService) DeletePlan ¶
func (s *PlanService) DeletePlan(ctx context.Context, id string) error
DeletePlan deletes a plan.
func (*PlanService) DeleteSubPlan ¶
func (s *PlanService) DeleteSubPlan(ctx context.Context, id string) error
DeleteSubPlan deletes a sub-plan.
func (*PlanService) FailSubPlan ¶
func (s *PlanService) FailSubPlan(ctx context.Context, id string) error
FailSubPlan transitions a sub-plan from in_progress to failed.
func (*PlanService) GetPlanByWorkItemID ¶
func (s *PlanService) GetPlanByWorkItemID(ctx context.Context, workItemID string) (domain.Plan, error)
GetPlanByWorkItemID retrieves a plan by work item ID.
func (*PlanService) GetSubPlan ¶
GetSubPlan retrieves a sub-plan by ID.
func (*PlanService) ListSubPlansByPlanID ¶
func (s *PlanService) ListSubPlansByPlanID(ctx context.Context, planID string) ([]domain.TaskPlan, error)
ListSubPlansByPlanID retrieves all sub-plans for a plan.
func (*PlanService) RejectPlan ¶
func (s *PlanService) RejectPlan(ctx context.Context, id string) error
RejectPlan transitions a plan from pending_review to rejected.
func (*PlanService) RetrySubPlan ¶
func (s *PlanService) RetrySubPlan(ctx context.Context, id string) error
RetrySubPlan transitions a failed sub-plan back to pending.
func (*PlanService) StartSubPlan ¶
func (s *PlanService) StartSubPlan(ctx context.Context, id string) error
StartSubPlan transitions a sub-plan from pending to in_progress.
func (*PlanService) SubmitForReview ¶
func (s *PlanService) SubmitForReview(ctx context.Context, id string) error
SubmitForReview transitions a plan from draft to pending_review.
func (*PlanService) TransitionPlan ¶
func (s *PlanService) TransitionPlan(ctx context.Context, id string, to domain.PlanStatus) error
TransitionPlan transitions a plan to a new status.
func (*PlanService) TransitionSubPlan ¶
func (s *PlanService) TransitionSubPlan(ctx context.Context, id string, to domain.TaskPlanStatus) error
TransitionSubPlan transitions a sub-plan to a new status.
func (*PlanService) UpdatePlanContent ¶
UpdatePlanContent updates the plan content without changing status.
func (*PlanService) UpdateSubPlanContent ¶
UpdateSubPlanContent updates the sub-plan content without changing status.
type QuestionService ¶
type QuestionService struct {
// contains filtered or unexported fields
}
QuestionService provides business logic for questions.
func NewQuestionService ¶
func NewQuestionService(transacter atomic.Transacter[repository.Resources]) *QuestionService
NewQuestionService creates a new QuestionService.
func (*QuestionService) Answer ¶
func (s *QuestionService) Answer(ctx context.Context, id string, answer string, answeredBy string) error
Answer transitions a question from pending to answered and records the answer.
func (*QuestionService) Escalate ¶
func (s *QuestionService) Escalate(ctx context.Context, id string) error
Escalate transitions a question from pending to escalated.
func (*QuestionService) EscalateWithProposal ¶
func (s *QuestionService) EscalateWithProposal(ctx context.Context, id string, proposedAnswer string) error
EscalateWithProposal transitions a question from pending to escalated and records the Foreman's proposed answer so the TUI can pre-fill the human review form.
func (*QuestionService) HasPendingQuestions ¶
HasPendingQuestions checks if there are any pending questions for a session.
func (*QuestionService) ListBySessionID ¶
func (s *QuestionService) ListBySessionID(ctx context.Context, sessionID string) ([]domain.Question, error)
ListBySessionID retrieves all questions for a session.
func (*QuestionService) Transition ¶
func (s *QuestionService) Transition(ctx context.Context, id string, to domain.QuestionStatus) error
Transition transitions a question to a new status.
func (*QuestionService) UpdateContext ¶
func (s *QuestionService) UpdateContext(ctx context.Context, id string, questionContext string) error
UpdateContext updates the context for a pending question.
func (*QuestionService) UpdateProposal ¶
func (s *QuestionService) UpdateProposal(ctx context.Context, id, proposedAnswer string) error
UpdateProposal replaces the Foreman's proposed answer for an already-escalated question. Uses UpdateProposedAnswer (conditional SQL: WHERE status='escalated') so a concurrent ResolveEscalated that already answered the question results in a no-op rather than reverting the row's status back to 'escalated'.
type ReviewService ¶
type ReviewService struct {
// contains filtered or unexported fields
}
ReviewService provides business logic for review cycles and critiques.
func NewReviewService ¶
func NewReviewService(transacter atomic.Transacter[repository.Resources]) *ReviewService
NewReviewService creates a new ReviewService.
func (*ReviewService) CompleteReimplementation ¶
func (s *ReviewService) CompleteReimplementation(ctx context.Context, id string) error
CompleteReimplementation transitions a review cycle from reimplementing to reviewing.
func (*ReviewService) CountMajorCritiques ¶
CountMajorCritiques counts the number of major or critical critiques in a cycle.
func (*ReviewService) CreateCritique ¶
CreateCritique creates a new critique in open status.
func (*ReviewService) CreateCritiquesBatch ¶
func (s *ReviewService) CreateCritiquesBatch(ctx context.Context, critiques []domain.Critique) error
CreateCritiquesBatch creates multiple critiques in a single call.
func (*ReviewService) CreateCycle ¶
func (s *ReviewService) CreateCycle(ctx context.Context, cycle domain.ReviewCycle) error
CreateCycle creates a new review cycle in reviewing status.
func (*ReviewService) FailReviewCycle ¶
func (s *ReviewService) FailReviewCycle(ctx context.Context, id string) error
FailReviewCycle transitions a review cycle to failed.
func (*ReviewService) GetCritique ¶
GetCritique retrieves a critique by ID.
func (*ReviewService) GetCycle ¶
func (s *ReviewService) GetCycle(ctx context.Context, id string) (domain.ReviewCycle, error)
GetCycle retrieves a review cycle by ID.
func (*ReviewService) HasUnresolvedCritiques ¶
HasUnresolvedCritiques checks if there are any unresolved critiques in a cycle.
func (*ReviewService) ListCritiquesByCycleID ¶
func (s *ReviewService) ListCritiquesByCycleID(ctx context.Context, cycleID string) ([]domain.Critique, error)
ListCritiquesByCycleID retrieves all critiques for a review cycle.
func (*ReviewService) ListCyclesBySessionID ¶
func (s *ReviewService) ListCyclesBySessionID(ctx context.Context, sessionID string) ([]domain.ReviewCycle, error)
ListCyclesBySessionID retrieves all review cycles for a session.
func (*ReviewService) PassReview ¶
func (s *ReviewService) PassReview(ctx context.Context, id string) error
PassReview transitions a review cycle from reviewing to passed.
func (*ReviewService) RecordCritiques ¶
func (s *ReviewService) RecordCritiques(ctx context.Context, id string) error
RecordCritiques transitions a review cycle from reviewing to critiques_found.
func (*ReviewService) ResolveCritique ¶
func (s *ReviewService) ResolveCritique(ctx context.Context, id string) error
ResolveCritique transitions a critique from open to resolved.
func (*ReviewService) StartReimplementation ¶
func (s *ReviewService) StartReimplementation(ctx context.Context, id string) error
StartReimplementation transitions a review cycle from critiques_found to reimplementing.
func (*ReviewService) TransitionCritique ¶
func (s *ReviewService) TransitionCritique(ctx context.Context, id string, to domain.CritiqueStatus) error
TransitionCritique transitions a critique to a new status.
func (*ReviewService) TransitionCycle ¶
func (s *ReviewService) TransitionCycle(ctx context.Context, id string, to domain.ReviewCycleStatus) error
TransitionCycle transitions a review cycle to a new status.
func (*ReviewService) UpdateCycleSummary ¶
UpdateCycleSummary updates the review cycle summary.
type SessionFilterLockService ¶
type SessionFilterLockService struct {
// contains filtered or unexported fields
}
SessionFilterLockService coordinates lock leases for active New Session filters.
func NewSessionFilterLockService ¶
func NewSessionFilterLockService(transacter atomic.Transacter[repository.Resources]) *SessionFilterLockService
NewSessionFilterLockService creates a SessionFilterLockService.
func (*SessionFilterLockService) Acquire ¶
func (s *SessionFilterLockService) Acquire(ctx context.Context, filterID, instanceID string, leaseDuration time.Duration) (domain.NewSessionFilterLock, bool, error)
type SessionFilterService ¶
type SessionFilterService struct {
// contains filtered or unexported fields
}
SessionFilterService provides business logic for saved New Session filters.
func NewSessionFilterService ¶
func NewSessionFilterService(transacter atomic.Transacter[repository.Resources]) *SessionFilterService
NewSessionFilterService creates a SessionFilterService.
func (*SessionFilterService) Create ¶
func (s *SessionFilterService) Create(ctx context.Context, filter domain.NewSessionFilter) error
func (*SessionFilterService) Delete ¶
func (s *SessionFilterService) Delete(ctx context.Context, id string) error
func (*SessionFilterService) Get ¶
func (s *SessionFilterService) Get(ctx context.Context, id string) (domain.NewSessionFilter, error)
func (*SessionFilterService) GetByWorkspaceProviderName ¶
func (s *SessionFilterService) GetByWorkspaceProviderName(ctx context.Context, workspaceID, provider, name string) (domain.NewSessionFilter, error)
func (*SessionFilterService) ListByWorkspaceID ¶
func (s *SessionFilterService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.NewSessionFilter, error)
func (*SessionFilterService) ListByWorkspaceProvider ¶
func (s *SessionFilterService) ListByWorkspaceProvider(ctx context.Context, workspaceID, provider string) ([]domain.NewSessionFilter, error)
func (*SessionFilterService) Update ¶
func (s *SessionFilterService) Update(ctx context.Context, filter domain.NewSessionFilter) error
type SessionReviewArtifactService ¶
type SessionReviewArtifactService struct {
// contains filtered or unexported fields
}
SessionReviewArtifactService provides business logic for session review artifacts.
func NewSessionReviewArtifactService ¶
func NewSessionReviewArtifactService(transacter atomic.Transacter[repository.Resources]) *SessionReviewArtifactService
NewSessionReviewArtifactService creates a new SessionReviewArtifactService.
func (*SessionReviewArtifactService) ListByWorkItemID ¶
func (s *SessionReviewArtifactService) ListByWorkItemID(ctx context.Context, workItemID string) ([]domain.SessionReviewArtifact, error)
ListByWorkItemID retrieves session review artifacts by work item ID.
func (*SessionReviewArtifactService) ListByWorkspaceID ¶
func (s *SessionReviewArtifactService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.SessionReviewArtifact, error)
ListByWorkspaceID retrieves session review artifacts by workspace ID.
func (*SessionReviewArtifactService) Upsert ¶
func (s *SessionReviewArtifactService) Upsert(ctx context.Context, link domain.SessionReviewArtifact) error
Upsert creates or updates a session review artifact.
type SessionService ¶
type SessionService struct {
// contains filtered or unexported fields
}
SessionService provides business logic for work items.
func NewSessionService ¶
func NewSessionService(transacter atomic.Transacter[repository.Resources]) *SessionService
NewSessionService creates a new WorkItemService.
func (*SessionService) ApprovePlan ¶
func (s *SessionService) ApprovePlan(ctx context.Context, id string) error
ApprovePlan transitions a work item from plan_review to approved.
func (*SessionService) CompleteWorkItem ¶
func (s *SessionService) CompleteWorkItem(ctx context.Context, id string) error
CompleteWorkItem transitions a work item from reviewing to completed.
func (*SessionService) Delete ¶
func (s *SessionService) Delete(ctx context.Context, id string) error
Delete deletes a work item.
func (*SessionService) FailWorkItem ¶
func (s *SessionService) FailWorkItem(ctx context.Context, id string) error
FailWorkItem transitions a work item to failed from any applicable state.
func (*SessionService) List ¶
func (s *SessionService) List(ctx context.Context, filter repository.SessionFilter) ([]domain.Session, error)
List retrieves work items based on filter.
func (*SessionService) RejectPlan ¶
func (s *SessionService) RejectPlan(ctx context.Context, id string) error
RejectPlan transitions a work item from plan_review back to planning.
func (*SessionService) RequestReimplementation ¶
func (s *SessionService) RequestReimplementation(ctx context.Context, id string) error
RequestReimplementation transitions a work item from reviewing to implementing.
func (*SessionService) RetryFailedWorkItem ¶
func (s *SessionService) RetryFailedWorkItem(ctx context.Context, id string) error
RetryFailedWorkItem transitions a failed work item back to implementing for retry.
func (*SessionService) RollbackPlanningInterrupt ¶
func (s *SessionService) RollbackPlanningInterrupt(ctx context.Context, id string) error
RollbackPlanningInterrupt transitions a work item from planning back to ingested when its planning task was interrupted. Idempotent: if the work item is already in a different state (rolled back by a prior call or already advanced), it is a no-op.
func (*SessionService) StartFollowUpPlanning ¶
func (s *SessionService) StartFollowUpPlanning(ctx context.Context, id string) error
StartFollowUpPlanning transitions a completed work item back to planning for a follow-up round.
func (*SessionService) StartImplementation ¶
func (s *SessionService) StartImplementation(ctx context.Context, id string) error
StartImplementation transitions a work item from approved to implementing.
func (*SessionService) StartPlanning ¶
func (s *SessionService) StartPlanning(ctx context.Context, id string) error
StartPlanning transitions a work item from ingested to planning.
func (*SessionService) SubmitForReview ¶
func (s *SessionService) SubmitForReview(ctx context.Context, id string) error
SubmitForReview transitions a work item from implementing to reviewing.
func (*SessionService) SubmitPlanForReview ¶
func (s *SessionService) SubmitPlanForReview(ctx context.Context, id string) error
SubmitPlanForReview transitions a work item from planning to plan_review.
func (*SessionService) Transition ¶
func (s *SessionService) Transition(ctx context.Context, id string, to domain.SessionState) error
Transition transitions a work item to a new state.
type TaskService ¶
type TaskService struct {
// contains filtered or unexported fields
}
TaskService provides business logic for repo-scoped tasks.
func NewTaskService ¶
func NewTaskService(transacter atomic.Transacter[repository.Resources]) *TaskService
NewTaskService creates a new TaskService.
func (*TaskService) Complete ¶
func (s *TaskService) Complete(ctx context.Context, id string) error
Complete transitions a task from running to completed.
func (*TaskService) Delete ¶
func (s *TaskService) Delete(ctx context.Context, id string) error
Delete deletes a task.
func (*TaskService) FindInterruptedByWorkspace ¶
func (s *TaskService) FindInterruptedByWorkspace(ctx context.Context, workspaceID string) ([]domain.Task, error)
FindInterruptedByWorkspace finds all interrupted tasks for a workspace.
func (*TaskService) FindRunningByOwner ¶
func (s *TaskService) FindRunningByOwner(ctx context.Context, instanceID string) ([]domain.Task, error)
FindRunningByOwner finds all running tasks owned by an instance.
func (*TaskService) FollowUpRestart ¶
func (s *TaskService) FollowUpRestart(ctx context.Context, id string) error
FollowUpRestart transitions a completed task back to running for a follow-up session. Unlike Start(), this preserves the original StartedAt and clears CompletedAt.
func (*TaskService) Interrupt ¶
func (s *TaskService) Interrupt(ctx context.Context, id string) error
Interrupt transitions a task from running to interrupted.
func (*TaskService) ListBySubPlanID ¶
ListBySubPlanID retrieves all child agent sessions for a sub-plan.
func (*TaskService) ListByWorkItemID ¶
func (s *TaskService) ListByWorkItemID(ctx context.Context, workItemID string) ([]domain.Task, error)
ListByWorkItemID retrieves all child agent sessions for a work item.
func (*TaskService) ListByWorkspaceID ¶
func (s *TaskService) ListByWorkspaceID(ctx context.Context, workspaceID string) ([]domain.Task, error)
ListByWorkspaceID retrieves all child agent sessions for a workspace.
func (*TaskService) Resume ¶
func (s *TaskService) Resume(ctx context.Context, id string) error
Resume transitions a task from interrupted to running.
func (*TaskService) ResumeFromAnswer ¶
func (s *TaskService) ResumeFromAnswer(ctx context.Context, id string) error
ResumeFromAnswer transitions a task from waiting_for_answer to running.
func (*TaskService) SearchHistory ¶
func (s *TaskService) SearchHistory(ctx context.Context, filter domain.SessionHistoryFilter) ([]domain.SessionHistoryEntry, error)
SearchHistory retrieves searchable session-history entries for the requested scope.
func (*TaskService) Start ¶
func (s *TaskService) Start(ctx context.Context, id string) error
Start transitions a task from pending to running.
func (*TaskService) Transition ¶
func (s *TaskService) Transition(ctx context.Context, id string, to domain.TaskStatus) error
Transition transitions a task to a new status.
func (*TaskService) UpdateOwnerInstance ¶
UpdateOwnerInstance updates the owner instance ID for a task.
func (*TaskService) UpdateResumeInfo ¶
func (s *TaskService) UpdateResumeInfo(ctx context.Context, id string, info map[string]string) error
UpdateResumeInfo stores harness-specific resume data on the task record. The info map is harness-defined; callers must not interpret individual keys.
func (*TaskService) WaitForAnswer ¶
func (s *TaskService) WaitForAnswer(ctx context.Context, id string) error
WaitForAnswer transitions a task from running to waiting_for_answer.
type WorkspaceService ¶
type WorkspaceService struct {
// contains filtered or unexported fields
}
WorkspaceService provides business logic for workspaces.
func NewWorkspaceService ¶
func NewWorkspaceService(transacter atomic.Transacter[repository.Resources]) *WorkspaceService
NewWorkspaceService creates a new WorkspaceService.
func (*WorkspaceService) Archive ¶
func (s *WorkspaceService) Archive(ctx context.Context, id string) error
Archive transitions a workspace from ready to archived.
func (*WorkspaceService) Delete ¶
func (s *WorkspaceService) Delete(ctx context.Context, id string) error
Delete deletes a workspace.
func (*WorkspaceService) MarkError ¶
func (s *WorkspaceService) MarkError(ctx context.Context, id string) error
MarkError transitions a workspace from creating to error.
func (*WorkspaceService) MarkReady ¶
func (s *WorkspaceService) MarkReady(ctx context.Context, id string) error
MarkReady transitions a workspace from creating to ready.
func (*WorkspaceService) Recover ¶
func (s *WorkspaceService) Recover(ctx context.Context, id string) error
Recover transitions a workspace from error to ready.
func (*WorkspaceService) Transition ¶
func (s *WorkspaceService) Transition(ctx context.Context, id string, to domain.WorkspaceStatus) error
Transition transitions a workspace to a new status.