Third review pass on the step-vocabulary shape, one fix per finding. P1, roots unpinned. The agreement test built its own manager and injected it, so it pinned the resolution sites and not the roots that decide the provider set; a root regressed to workflow.NewManager() (no shipped stages) left go test green. archied now resolves through one unit, stepVocabulary (step_vocabulary.go), and agentworker's productionWorkerDependencies is exercised directly: internal/app/agentworker/step_vocabulary_test.go and internal/app/archied/step_vocabulary_test.go assert each root's manager resolves the shared provider set's shipped stages and accepts a provider registered through it. RunStateStore and openStateStoreAdapter own a SQLite file and a gRPC dial, so their calls are pinned by source position, the way composition_order_test.go pins the memory-engine ordering. P2-B, dead vocabulary. archie-messaging registered a step vocabulary it never resolved (its only control-plane call is RuntimeChatConfig) and could fail startup on it before the State Store target guard. The workflow-definitions surface is now its own type, controlplane.WorkflowDefinitionsClient, so the vocabulary is a constructor dependency of the one surface that resolves step types and of nothing else. The messaging root no longer imports workflowsteps. P2-C, nil manager. A nil *workflow.Manager dereferenced on every resolution path. stepRegistry and CompilePinnedWorkflow now refuse with an error naming the wiring mistake; TestNilStepVocabularyFailsClosedAtEveryResolutionSite pins the refusal. Claim-vs-code corrections: agreement is stated as within one build (vocabulary.go, stepRegistry, openStateStoreControlPlane, openStateStoreAdapter); the Yaegi claim now says no bridge to StepFactory has been built and cites internal/secret/secretextract; the provider set names its three roots; Manager.Register's ordering is documented as a constraint with its consequence, and the shape rule no longer claims to reserve shipped stage names; the shipped-stage test compares against the builtin factory's own stage.
69 lines
3.0 KiB
Go
69 lines
3.0 KiB
Go
// Package workflowsteps is the compiled-in workflow step-type provider set:
|
|
// the one place a step type is bundled into every Archie binary.
|
|
//
|
|
// Three composition roots import it, and each resolves a workflow step type:
|
|
// archied's RunStateStore (the State Store's validating side), archied's
|
|
// openStateStoreAdapter (the daemon's workflow-definitions client) and
|
|
// agentworker's productionWorkerDependencies (the executing side). Sharing one
|
|
// package is what keeps them registering the same vocabulary rather than one
|
|
// of them keeping a provider set of its own. archie-messaging resolves no step
|
|
// type and does not import it.
|
|
package workflowsteps
|
|
|
|
import (
|
|
"fmt"
|
|
"maps"
|
|
"slices"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
|
)
|
|
|
|
// shippedStages is the provider that contributes every stage of the shipped
|
|
// workflows (bootstrap, implement, tdd, feasibility, triage, remediate) as a
|
|
// workflow step type. It is what makes the shipped vocabulary arrive by
|
|
// registration rather than by the manager implying it, so the vocabulary a
|
|
// process resolves is always the vocabulary a provider set claimed.
|
|
type shippedStages struct{}
|
|
|
|
func (shippedStages) Name() string { return "shipped" }
|
|
|
|
func (shippedStages) StepTypes() []workflow.StepType {
|
|
registry := workflow.BuiltinStepRegistry()
|
|
stepTypes := make([]workflow.StepType, 0, len(registry))
|
|
for _, name := range slices.Sorted(maps.Keys(registry)) {
|
|
stepTypes = append(stepTypes, workflow.StepType{Name: name, Factory: registry[name]})
|
|
}
|
|
return stepTypes
|
|
}
|
|
|
|
// Providers returns the provider set every Archie process registers at its
|
|
// composition root, before the first resolution. A step type added here becomes
|
|
// reachable from the validating side and the executing side at once.
|
|
//
|
|
// The set is a compiled-in constant rather than a directory scan: a step type
|
|
// is a Go factory, and no bridge has been built from the Yaegi-interpreted
|
|
// plugins internal/plugin loads to workflow.StepFactory -- those plugins
|
|
// satisfy plugin.Plugin's metadata contract only. Such a bridge is possible:
|
|
// internal/secret/secretextract wraps an interpreted Engine into the typed
|
|
// contract secret.Registry.LoadDir registers (internal/app/archied/
|
|
// provider_secrets.go). Until one exists for step types, adding a step type
|
|
// means adding a provider here.
|
|
func Providers() []workflow.StepTypeProvider {
|
|
return []workflow.StepTypeProvider{shippedStages{}}
|
|
}
|
|
|
|
// NewManager builds this process's workflow step-type manager by registering
|
|
// the provider set. Every call constructs an independent manager: there is no
|
|
// package-level registry and nothing registers at init(), so building the
|
|
// vocabulary twice in one process — as `-count=2` does — cannot collide with
|
|
// the first build.
|
|
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
|
|
}
|