From 968c74d148ad8e0628aeb219ddf5eb4e0aba6f5a Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Fri, 30 Oct 2026 00:50:55 +1100 Subject: [PATCH] chore(workflow): finish dropping the unread step-type catalogue accessors (#1014) Manager.StepTypes and Providers had no reader; the catalogue they were meant to feed is not missing -- Registry/Settings serve it as x-step-types in the workflow-definitions schema, read by the dashboard workflow editor and the gateway's workflow_step_types tool. Remove the write-only providers field the accessor deletion left behind, and pin that production reader in controlplanerpc so a dropped schema extension fails the gate. --- internal/domain/workflow/vocabulary.go | 6 +- .../controlplanerpc/workflows_test.go | 67 ++++++++++++++++++- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/internal/domain/workflow/vocabulary.go b/internal/domain/workflow/vocabulary.go index 87a3020f7..81174f216 100644 --- a/internal/domain/workflow/vocabulary.go +++ b/internal/domain/workflow/vocabulary.go @@ -40,9 +40,8 @@ type Manager struct { mu sync.Mutex registry StepRegistry // owners maps each step type to the provider that registered it. - owners map[string]string - settings map[string]any - providers []string + owners map[string]string + settings map[string]any } // NewManager builds an empty family manager. It holds no vocabulary of its own: @@ -96,7 +95,6 @@ func (m *Manager) Register(provider StepTypeProvider) error { m.settings[stepType] = settings[stepType] m.owners[stepType] = name } - m.providers = append(m.providers, name) return nil } diff --git a/internal/infrastructure/controlplanerpc/workflows_test.go b/internal/infrastructure/controlplanerpc/workflows_test.go index c59f3235a..5ab85350a 100644 --- a/internal/infrastructure/controlplanerpc/workflows_test.go +++ b/internal/infrastructure/controlplanerpc/workflows_test.go @@ -2,6 +2,7 @@ package controlplanerpc import ( "context" + "errors" "strings" "testing" @@ -17,13 +18,22 @@ import ( // way the control plane does when a field it audits is missing. type fakeControlPlane struct { pb.ControlPlaneServiceClient - commands []*pb.CommandRequest + commands []*pb.CommandRequest + catalog *pb.CatalogResponse + catalogErr error } func (*fakeControlPlane) Query(context.Context, *pb.QueryRequest, ...grpc.CallOption) (*pb.QueryResponse, error) { return &pb.QueryResponse{Resource: &pb.Resource{ValueJson: []byte(`{"drafts":[]}`), Version: 3}}, nil } +func (f *fakeControlPlane) Catalog(context.Context, *pb.CatalogRequest, ...grpc.CallOption) (*pb.CatalogResponse, error) { + if f.catalogErr != nil { + return nil, f.catalogErr + } + return f.catalog, nil +} + func (f *fakeControlPlane) Command(_ context.Context, request *pb.CommandRequest, _ ...grpc.CallOption) (*pb.CommandResponse, error) { f.commands = append(f.commands, request) if request.GetActor() == "" || request.GetSource() == "" || request.GetRequestId() == "" { @@ -87,3 +97,58 @@ func TestPutDraftAttributesTheCaller(t *testing.T) { }) } } + +// TestStepTypesReadsTheServedVocabulary pins the catalogue's production +// reader: StepTypes returns the x-step-types extension of the +// workflow-definitions descriptor the control plane's catalog serves, the +// payload the dashboard workflow editor and the workflow_step_types tool +// consume, and it reports an absent catalogue or an unavailable control +// plane rather than inventing an empty one. +func TestStepTypesReadsTheServedVocabulary(t *testing.T) { + vocabulary := `[{"name":"agent.run","needs_repository":true,"settings":{"type":"object"}}]` + for _, tt := range []struct { + name string + resources []*pb.ResourceDescriptor + catalogErr error + want string + wantErr bool + wantUnavailable bool + }{ + { + name: "the workflow-definitions descriptor serves the vocabulary", + resources: []*pb.ResourceDescriptor{ + {Kind: "workflow-drafts", SchemaJson: `{"x-step-types":[{"name":"not.a.step"}]}`}, + {Kind: "workflow-definitions", SchemaJson: `{"x-step-types":` + vocabulary + `}`}, + }, + want: vocabulary, + }, + { + name: "the catalog serves no workflow definitions", + resources: []*pb.ResourceDescriptor{{Kind: "workflow-drafts", SchemaJson: `{}`}}, + wantErr: true, + }, + { + name: "the control plane is unavailable", + catalogErr: errors.New("connection refused"), + wantErr: true, + wantUnavailable: true, + }, + } { + t.Run(tt.name, func(t *testing.T) { + client := &fakeControlPlane{catalog: &pb.CatalogResponse{Resources: tt.resources}, catalogErr: tt.catalogErr} + got, err := NewWorkflows(client).StepTypes(t.Context()) + if (err != nil) != tt.wantErr { + t.Fatalf("StepTypes() error = %v, want error %t", err, tt.wantErr) + } + if tt.wantErr { + if unavailable := errors.Is(err, ErrUnavailable); unavailable != tt.wantUnavailable { + t.Fatalf("error is ErrUnavailable = %t, want %t (err %v)", unavailable, tt.wantUnavailable, err) + } + return + } + if string(got) != tt.want { + t.Fatalf("StepTypes() = %s, want %s", got, tt.want) + } + }) + } +}