fix(workflow): pin the roots, drop the dead vocabulary, guard the nil manager
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.
This commit is contained in:
18 files changed
+398
-96
No files matched your search
@@ -1,10 +1,13 @@
|
||||
// Package workflowsteps is the compiled-in workflow step-type provider set:
|
||||
// the one place a step type is bundled into every Archie binary.
|
||||
//
|
||||
// Both composition roots import it — internal/app/archied (which serves the
|
||||
// State Store's validating side) and internal/app/agentworker (the executing
|
||||
// side) — so the two sides register the same vocabulary by construction rather
|
||||
// than by convention. Neither root keeps a package-level registry of its own.
|
||||
// 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 (
|
||||
@@ -38,9 +41,13 @@ func (shippedStages) StepTypes() []workflow.StepType {
|
||||
// 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 the Yaegi-interpreted plugins internal/plugin loads
|
||||
// satisfy plugin.Plugin's metadata contract but cannot hand the host a working
|
||||
// workflow.StepFactory. archie-agent links its own binary in any case.
|
||||
// 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{}}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
||||
)
|
||||
|
||||
@@ -39,11 +41,12 @@ func TestShippedVocabularyCoversEveryShippedStage(t *testing.T) {
|
||||
|
||||
// TestShippedStagesKeepTheirBehaviourThroughTheManager pins that the provider
|
||||
// hands the builtin factories through unchanged. The shipped stages are typed,
|
||||
// non-interpreted steps: each compiles to the stage the builtin registry
|
||||
// carries and refuses settings. The one way this enumeration could keep every
|
||||
// name and lose that guard is to rebuild the factories instead of forwarding
|
||||
// them, and definition_test.go's assertion cannot see it -- that test drives
|
||||
// BuiltinStepRegistry, which production no longer calls.
|
||||
// non-interpreted steps: each compiles to the stage the builtin registry's own
|
||||
// factory builds for that step type -- the same name, and Run present or absent
|
||||
// the same way -- and refuses settings. The one way this enumeration could keep
|
||||
// every name and lose that guard is to rebuild the factories instead of
|
||||
// forwarding them, and definition_test.go's assertion cannot see it -- that test
|
||||
// drives BuiltinStepRegistry, which production no longer calls.
|
||||
func TestShippedStagesKeepTheirBehaviourThroughTheManager(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -66,9 +69,19 @@ func TestShippedStagesKeepTheirBehaviourThroughTheManager(t *testing.T) {
|
||||
t.Fatalf("%s compiled %d stages, want %d", entry.ID, len(compiled.Stages), len(definition.Steps))
|
||||
}
|
||||
for i, step := range definition.Steps {
|
||||
want := strings.TrimPrefix(step.Type, entry.ID+".")
|
||||
if compiled.Stages[i].Name != want {
|
||||
t.Errorf("%s step %d (%s) compiled to stage %q, want the shipped stage %q: the registered factory is not the builtin one", entry.ID, i, step.Type, compiled.Stages[i].Name, want)
|
||||
// The expectation is the stage the builtin registry's own factory
|
||||
// builds for this step type, not a name derived from the step type:
|
||||
// that is what "the registered factory is the builtin one" means
|
||||
// for a Stage, which is a name plus an uncomparable func.
|
||||
shipped, err := workflow.BuiltinStepRegistry()[step.Type](yaml.Node{})
|
||||
if err != nil {
|
||||
t.Fatalf("build shipped stage %s: %v", step.Type, err)
|
||||
}
|
||||
if compiled.Stages[i].Name != shipped.Name {
|
||||
t.Errorf("%s step %d (%s) compiled to stage %q, want the shipped stage %q: the registered factory is not the builtin one", entry.ID, i, step.Type, compiled.Stages[i].Name, shipped.Name)
|
||||
}
|
||||
if (compiled.Stages[i].Run != nil) != (shipped.Run != nil) {
|
||||
t.Errorf("%s step %d (%s) compiled to a stage whose Run is present=%t, want the shipped stage's present=%t", entry.ID, i, step.Type, compiled.Stages[i].Run != nil, shipped.Run != nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user