Files
archie/internal/infrastructure/workflowsteps/workflowsteps.go
T
sam c265b07ec7 refactor(workflow): stop assuming a human decides
An approval, ask or park can be resolved by an operator, a rule, a
classifier or automatically, so the vocabulary stops naming a person:

- step type human.approve -> workflow.approve
- park class needs_human -> needs_decision (ParkNeedsDecision)
- event kinds human_* -> operator_*
- alert kind task.needs_human -> task.needs_decision
- status grouping "needs you" -> "needs attention"

0061 rewrites the stored values, including the approval step type in the
workflow-definitions resource and each task's pinned definition, with the
digest recomputed so resumed tasks still match.
2026-10-25 17:31:16 +11:00

80 lines
2.7 KiB
Go

// Package workflowsteps is the compiled-in set of workflow step-type
// providers, registered by every process that resolves step types.
package workflowsteps
import (
"fmt"
"github.com/samcharles93/archie-core/internal/domain/workflow"
)
// reviewSteps provides the pull request review and remediation step types.
type reviewSteps struct{}
func (reviewSteps) Name() string { return "review" }
func (reviewSteps) StepTypes() []workflow.StepType { return workflow.ReviewStepTypes() }
// repoHooks provides the gate.diff-rules step type.
type repoHooks struct{}
func (repoHooks) Name() string { return "repo-hooks" }
func (repoHooks) StepTypes() []workflow.StepType {
return []workflow.StepType{workflow.DiffRulesStepType()}
}
// eventSteps is the provider for step types that event-started workflows
// use: steps that need no repository, so a workflow declaring repository none
// or optional has something to run.
type eventSteps struct{}
func (eventSteps) Name() string { return "event" }
func (eventSteps) StepTypes() []workflow.StepType {
return []workflow.StepType{workflow.AgentRunStepType(), workflow.WorkflowCallStepType(), workflow.FinishStepType()}
}
// commandSteps provides the command.run step type: operator-authored commands
// from the stored workflow definition. It is separate from repoHooks, which
// carries repository-authored gate rules.
type commandSteps struct{}
func (commandSteps) Name() string { return "command" }
func (commandSteps) StepTypes() []workflow.StepType {
return []workflow.StepType{workflow.CommandRunStepType()}
}
// repositorySteps provides the general repository step types: prepare,
// commit, open a PR, and the repository and diff-size gates.
type repositorySteps struct{}
func (repositorySteps) Name() string { return "repository" }
func (repositorySteps) StepTypes() []workflow.StepType { return workflow.RepoStepTypes() }
// controlSteps provides the step types that route the task: handoff, approval,
// and forge issue actions.
type controlSteps struct{}
func (controlSteps) Name() string { return "control" }
func (controlSteps) StepTypes() []workflow.StepType { return workflow.ControlStepTypes() }
// Providers returns the step-type providers to register.
func Providers() []workflow.StepTypeProvider {
return []workflow.StepTypeProvider{reviewSteps{}, repoHooks{}, eventSteps{}, commandSteps{}, repositorySteps{}, controlSteps{}}
}
// NewManager returns a new manager with Providers registered.
func NewManager() (*workflow.Manager, error) {
manager := workflow.NewManager()
for _, provider := range Providers() {
if err := manager.Register(provider); err != nil {
return nil, fmt.Errorf("register workflow step type provider %q: %w", provider.Name(), err)
}
}
return manager, nil
}