feat(controlplane): runtime administration over the State Store's gRPC server

The Web UI and messaging channels now read and write Archie's runtime
settings through one versioned, audited control-plane API hosted on the
State Store's existing gRPC server: catalog, query, command, watch. Each
feature owns its resource, validation and commands; storage only writes
versions and audit records.

Workflows move with it. Definitions become portable YAML compiled through
a closed, typed step registry and stored as a control-plane resource, so
the yaegi interpretation paths (internal/gate, wfeval, wfextract,
gateeval, gateextract, skillbuild) are deleted rather than carried.

The UI process reads definitions as data: the JSON projection lives in
internal/domain/workflow/task so a dashboard decodes the stored
collection without linking the workflow engine, which cmd/archie-ui's
deletion gate forbids. Shipped definitions ride the catalog descriptor
rather than a bespoke REST route, keeping the API to its four operations.

archie-messaging gains -state-store-target/-state-store-token and reads
channel settings from the database, failing closed when the State Store
is unreachable: the database is authoritative for those settings.
This commit is contained in:
sam committed 2026-09-21 08:17:42 +10:00
1 parent 2e172c679c
commit 924b02a1b0
131 files changed
+8510 -3371

No files matched your search

+14 -4
View File
@@ -8,10 +8,20 @@ import (
"strings"
"testing"
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
"github.com/samcharles93/archie-core/internal/domain/workflow"
"github.com/samcharles93/archie-core/internal/gateway"
)
func workflowControlPlane(t *testing.T, definitions workflow.WorkflowDefinitionCollection) *controlPlaneClientStub {
t.Helper()
value, err := json.Marshal(definitions)
if err != nil {
t.Fatal(err)
}
return &controlPlaneClientStub{query: &controlpb.Resource{Kind: "workflow-definitions", Version: 1, ValueJson: value}}
}
type recordingWorkRequestCreator struct{ request gateway.SpawnRequest }
func (c *recordingWorkRequestCreator) CreateTask(_ context.Context, request gateway.SpawnRequest) (int64, error) {
@@ -21,7 +31,7 @@ func (c *recordingWorkRequestCreator) CreateTask(_ context.Context, request gate
func TestWorkflowsIncludeInstalledZeroRunDefinitions(t *testing.T) {
srv := newTestServer(t)
srv.Workflows = []workflow.Definition{{ID: "implement", Name: "Implement", Origin: "builtin", Enabled: true, Stages: []string{"prepare", "plan"}}}
srv.ControlPlane = workflowControlPlane(t, workflow.WorkflowDefinitionCollection{Definitions: []workflow.WorkflowDefinitionEntry{{ID: "custom", YAML: "id: custom\nsteps:\n - type: implement.prepare\n - type: implement.plan\n"}}})
w := httptest.NewRecorder()
srv.Handler().ServeHTTP(w, httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/workflows", nil))
@@ -34,7 +44,7 @@ func TestWorkflowsIncludeInstalledZeroRunDefinitions(t *testing.T) {
if err := json.Unmarshal(w.Body.Bytes(), &response); err != nil {
t.Fatal(err)
}
if len(response.Definitions) != 1 || response.Definitions[0].ID != "implement" || len(response.Definitions[0].Stages) != 2 {
if len(response.Definitions) != 1 || response.Definitions[0].ID != "custom" || response.Definitions[0].Origin != "database" {
t.Fatalf("definitions = %#v", response.Definitions)
}
}
@@ -43,7 +53,7 @@ func TestWorkRequestUsesNormalTaskAdmission(t *testing.T) {
srv := newTestServer(t)
creator := &recordingWorkRequestCreator{}
srv.WorkRequests = creator
srv.Workflows = []workflow.Definition{{ID: "implement", Name: "Implement", Enabled: true}}
srv.ControlPlane = workflowControlPlane(t, workflow.WorkflowDefinitionCollection{Definitions: []workflow.WorkflowDefinitionEntry{{ID: "implement", YAML: "id: implement\nsteps:\n - type: implement.prepare\n"}}})
body := `{"identity":"archie","repository":"acme/widget","workflow":"implement","title":"Fix login","instructions":"Reproduce and fix it."}`
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/work-requests", strings.NewReader(body))
@@ -64,7 +74,7 @@ func TestWorkRequestRejectsDisabledWorkflow(t *testing.T) {
srv := newTestServer(t)
creator := &recordingWorkRequestCreator{}
srv.WorkRequests = creator
srv.Workflows = []workflow.Definition{{ID: "implement", Enabled: false}}
srv.ControlPlane = workflowControlPlane(t, workflow.WorkflowDefinitionCollection{Definitions: []workflow.WorkflowDefinitionEntry{{ID: "custom", YAML: "id: custom\nsteps:\n - type: implement.prepare\n"}}})
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/work-requests", strings.NewReader(`{"identity":"archie","repository":"acme/widget","workflow":"implement","title":"Fix","instructions":"Do it"}`))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Archie-CSRF", "1")