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

+12 -2
View File
@@ -55,7 +55,12 @@ func (s *Server) handleBindingCreate(w http.ResponseWriter, r *http.Request) {
http.Error(w, "invalid request body: "+err.Error(), http.StatusBadRequest)
return
}
if !s.hasWorkflow(req.Workflow) {
available, err := s.hasWorkflow(r.Context(), req.Workflow)
if err != nil {
http.Error(w, "workflow definitions unavailable", http.StatusServiceUnavailable)
return
}
if !available {
http.Error(w, "binding: workflow not found: "+req.Workflow, http.StatusBadRequest)
return
}
@@ -136,7 +141,12 @@ func (s *Server) handleBindingUpdate(w http.ResponseWriter, r *http.Request) {
http.Error(w, "invalid request body: "+err.Error(), http.StatusBadRequest)
return
}
if !s.hasWorkflow(req.Workflow) {
available, err := s.hasWorkflow(r.Context(), req.Workflow)
if err != nil {
http.Error(w, "workflow definitions unavailable", http.StatusServiceUnavailable)
return
}
if !available {
http.Error(w, "binding: workflow not found: "+req.Workflow, http.StatusBadRequest)
return
}
+6 -6
View File
@@ -26,12 +26,12 @@ func bindingTestServer(t *testing.T) *Server {
}
t.Cleanup(func() { _ = s.Close() })
return &Server{
Store: s,
Log: slog.New(slog.DiscardHandler),
Mappings: s,
Captures: s,
Bindings: s,
Workflows: []workflow.Definition{{ID: "implement", Name: "implement", Enabled: true}},
Store: s,
Log: slog.New(slog.DiscardHandler),
Mappings: s,
Captures: s,
Bindings: s,
ControlPlane: workflowControlPlane(t, workflow.WorkflowDefinitionCollection{Definitions: []workflow.WorkflowDefinitionEntry{{ID: "implement", YAML: "id: implement\nsteps:\n - type: implement.prepare\n"}}}),
}
}
+171
View File
@@ -0,0 +1,171 @@
package webui
import (
"crypto/rand"
"encoding/hex"
"encoding/json"
"errors"
"io"
"net/http"
"strconv"
"time"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
)
const (
controlPlaneActor = "operator:web"
controlPlaneSource = "archie-ui"
)
type controlPlaneCommandRequest struct {
Value json.RawMessage `json:"value"`
ExpectedVersion int64 `json:"expected_version"`
}
type controlPlaneResource struct {
Kind string `json:"kind"`
Version int64 `json:"version"`
Value json.RawMessage `json:"value"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
type controlPlaneResourceResponse struct {
Resource controlPlaneResource `json:"resource"`
}
func (s *Server) handleControlPlaneCatalog(w http.ResponseWriter, r *http.Request) {
if s.ControlPlane == nil {
http.Error(w, "control plane unavailable", http.StatusServiceUnavailable)
return
}
response, err := s.ControlPlane.Catalog(r.Context(), &controlpb.CatalogRequest{})
if err != nil {
writeControlPlaneError(w, err)
return
}
writeJSON(w, response)
}
func (s *Server) handleControlPlaneQuery(w http.ResponseWriter, r *http.Request) {
if s.ControlPlane == nil {
http.Error(w, "control plane unavailable", http.StatusServiceUnavailable)
return
}
response, err := s.ControlPlane.Query(r.Context(), &controlpb.QueryRequest{Kind: r.PathValue("kind")})
if err != nil {
writeControlPlaneError(w, err)
return
}
writeJSON(w, controlPlaneResourceResponse{Resource: controlPlaneResourceView(response.Resource)})
}
func (s *Server) handleControlPlaneCommand(w http.ResponseWriter, r *http.Request) {
if s.ControlPlane == nil {
http.Error(w, "control plane unavailable", http.StatusServiceUnavailable)
return
}
var request controlPlaneCommandRequest
if err := json.NewDecoder(r.Body).Decode(&request); err != nil || len(request.Value) == 0 {
http.Error(w, "invalid request body", http.StatusBadRequest)
return
}
requestID, err := newControlPlaneRequestID()
if err != nil {
http.Error(w, "cannot create request ID", http.StatusInternalServerError)
return
}
response, err := s.ControlPlane.Command(r.Context(), &controlpb.CommandRequest{
Kind: r.PathValue("kind"), Command: r.PathValue("command"), ValueJson: request.Value,
ExpectedVersion: request.ExpectedVersion, Actor: controlPlaneActor,
Source: controlPlaneSource, RequestId: requestID,
})
if err != nil {
writeControlPlaneError(w, err)
return
}
writeJSON(w, controlPlaneResourceResponse{Resource: controlPlaneResourceView(response.Resource)})
}
func (s *Server) handleControlPlaneWatch(w http.ResponseWriter, r *http.Request) {
if s.ControlPlane == nil {
http.Error(w, "control plane unavailable", http.StatusServiceUnavailable)
return
}
after, err := strconv.ParseInt(r.URL.Query().Get("after"), 10, 64)
if err != nil && r.URL.Query().Get("after") != "" {
http.Error(w, "invalid after version", http.StatusBadRequest)
return
}
stream, err := s.ControlPlane.Watch(r.Context(), &controlpb.WatchRequest{Kind: r.PathValue("kind"), AfterVersion: after})
if err != nil {
writeControlPlaneError(w, err)
return
}
flusher, ok := w.(http.Flusher)
if !ok {
http.Error(w, "streaming unsupported", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "text/event-stream")
w.Header().Set("Cache-Control", "no-cache")
for {
response, recvErr := stream.Recv()
if errors.Is(recvErr, io.EOF) || r.Context().Err() != nil {
return
}
if recvErr != nil {
return
}
payload, marshalErr := json.Marshal(controlPlaneResourceResponse{Resource: controlPlaneResourceView(response.Resource)})
if marshalErr != nil {
return
}
if _, err = w.Write(append(append([]byte("data: "), payload...), '\n', '\n')); err != nil {
return
}
flusher.Flush()
}
}
func controlPlaneResourceView(resource *controlpb.Resource) controlPlaneResource {
if resource == nil {
return controlPlaneResource{}
}
view := controlPlaneResource{Kind: resource.Kind, Version: resource.Version, Value: resource.ValueJson}
if resource.UpdatedAt != nil {
updatedAt := resource.UpdatedAt.AsTime()
view.UpdatedAt = &updatedAt
}
return view
}
func newControlPlaneRequestID() (string, error) {
var value [16]byte
if _, err := rand.Read(value[:]); err != nil {
return "", err
}
return "ui-" + hex.EncodeToString(value[:]), nil
}
func writeControlPlaneError(w http.ResponseWriter, err error) {
code := http.StatusInternalServerError
switch status.Code(err) {
case codes.InvalidArgument:
code = http.StatusBadRequest
case codes.NotFound:
code = http.StatusNotFound
case codes.Aborted:
code = http.StatusConflict
case codes.Unavailable, codes.DeadlineExceeded:
code = http.StatusServiceUnavailable
}
message := status.Convert(err).Message()
if message == "" {
message = http.StatusText(code)
}
http.Error(w, message, code)
}
+88
View File
@@ -0,0 +1,88 @@
package webui
import (
"bytes"
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"strings"
"testing"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
)
type controlPlaneClientStub struct {
command *controlpb.CommandRequest
query *controlpb.Resource
err error
}
func (f *controlPlaneClientStub) Catalog(context.Context, *controlpb.CatalogRequest, ...grpc.CallOption) (*controlpb.CatalogResponse, error) {
return &controlpb.CatalogResponse{}, f.err
}
func (f *controlPlaneClientStub) Query(context.Context, *controlpb.QueryRequest, ...grpc.CallOption) (*controlpb.QueryResponse, error) {
return &controlpb.QueryResponse{Resource: f.query}, f.err
}
func (f *controlPlaneClientStub) Command(_ context.Context, request *controlpb.CommandRequest, _ ...grpc.CallOption) (*controlpb.CommandResponse, error) {
f.command = request
if f.err != nil {
return nil, f.err
}
return &controlpb.CommandResponse{Resource: &controlpb.Resource{Kind: request.Kind, Version: 2, ValueJson: request.ValueJson}}, nil
}
func (f *controlPlaneClientStub) Watch(context.Context, *controlpb.WatchRequest, ...grpc.CallOption) (grpc.ServerStreamingClient[controlpb.WatchResponse], error) {
return nil, f.err
}
func TestControlPlaneCommandSuppliesTrustedAttribution(t *testing.T) {
client := &controlPlaneClientStub{}
server := &Server{ControlPlane: client}
body := bytes.NewBufferString(`{"value":{"max_model_tool_steps":12},"expected_version":1,"actor":"browser"}`)
request := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/control-plane/resources/workflow-execution-settings/commands/replace", body)
request.Header.Set("Content-Type", "application/json")
request.Header.Set("X-Archie-CSRF", "1")
response := httptest.NewRecorder()
server.Handler().ServeHTTP(response, request)
if response.Code != http.StatusOK {
t.Fatalf("status = %d, body = %q", response.Code, response.Body.String())
}
if client.command.Actor != controlPlaneActor || client.command.Source != controlPlaneSource {
t.Fatalf("attribution = %q/%q", client.command.Actor, client.command.Source)
}
if !strings.HasPrefix(client.command.RequestId, "ui-") || client.command.ExpectedVersion != 1 {
t.Fatalf("request = %+v", client.command)
}
var got struct {
Resource controlPlaneResource `json:"resource"`
}
if err := json.Unmarshal(response.Body.Bytes(), &got); err != nil {
t.Fatal(err)
}
if got.Resource.Version != 2 || string(got.Resource.Value) != `{"max_model_tool_steps":12}` {
t.Fatalf("resource = %+v", got.Resource)
}
}
func TestControlPlaneConflictMapsToHTTPConflict(t *testing.T) {
server := &Server{ControlPlane: &controlPlaneClientStub{err: status.Error(codes.Aborted, "version conflict")}}
request := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/control-plane/resources/settings/commands/replace", strings.NewReader(`{"value":{},"expected_version":1}`))
request.Header.Set("Content-Type", "application/json")
request.Header.Set("X-Archie-CSRF", "1")
response := httptest.NewRecorder()
server.Handler().ServeHTTP(response, request)
if response.Code != http.StatusConflict {
t.Fatalf("status = %d, want 409", response.Code)
}
}
+144
View File
@@ -0,0 +1,144 @@
package webui
import (
"crypto/rand"
"encoding/hex"
"encoding/json"
"errors"
"net/http"
"strings"
"time"
"github.com/samcharles93/archie-core/internal/domain/identity"
)
type identityRequest struct {
DisplayName string `json:"display_name"`
Kind identity.Kind `json:"kind"`
ExpectedVersion int64 `json:"expected_version"`
}
func (s *Server) handleIdentitiesList(w http.ResponseWriter, r *http.Request) {
if s.Identities == nil {
http.Error(w, "identity store unavailable", http.StatusServiceUnavailable)
return
}
values, err := s.Identities.List(r.Context())
if err != nil {
writeIdentityError(w, err)
return
}
if values == nil {
values = []identity.Identity{}
}
writeJSON(w, map[string]any{"identities": values})
}
func (s *Server) handleIdentitiesWatch(w http.ResponseWriter, r *http.Request) {
if s.Identities == nil {
http.Error(w, "identity store unavailable", http.StatusServiceUnavailable)
return
}
flusher, ok := w.(http.Flusher)
if !ok {
http.Error(w, "streaming unsupported", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "text/event-stream")
w.Header().Set("Cache-Control", "no-cache")
ticker := time.NewTicker(time.Second)
defer ticker.Stop()
var previous string
for {
values, err := s.Identities.List(r.Context())
if err != nil {
return
}
if values == nil {
values = []identity.Identity{}
}
payload, err := json.Marshal(map[string]any{"identities": values})
if err != nil {
return
}
if current := string(payload); current != previous {
if _, err = w.Write(append(append([]byte("data: "), payload...), '\n', '\n')); err != nil {
return
}
flusher.Flush()
previous = current
}
select {
case <-r.Context().Done():
return
case <-ticker.C:
}
}
}
func (s *Server) handleIdentityCreate(w http.ResponseWriter, r *http.Request) {
var request identityRequest
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
http.Error(w, "invalid request body", http.StatusBadRequest)
return
}
id, err := randomIdentityID()
if err != nil {
http.Error(w, "cannot create identity ID", http.StatusInternalServerError)
return
}
value, err := identity.New(id, request.Kind, request.DisplayName)
if err == nil {
value, err = s.Identities.Create(r.Context(), value, webIdentityAudit())
}
if err != nil {
writeIdentityError(w, err)
return
}
w.WriteHeader(http.StatusCreated)
writeJSON(w, value)
}
func (s *Server) handleIdentityCommand(w http.ResponseWriter, r *http.Request) {
var request identityRequest
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
http.Error(w, "invalid request body", http.StatusBadRequest)
return
}
command := identity.Command{Type: identity.CommandType(r.PathValue("command")), DisplayName: request.DisplayName}
value, err := s.Identities.Apply(r.Context(), identity.IdentityID(r.PathValue("id")), request.ExpectedVersion, command, webIdentityAudit())
if err != nil {
writeIdentityError(w, err)
return
}
writeJSON(w, value)
}
func webIdentityAudit() identity.Audit {
id, _ := newControlPlaneRequestID()
return identity.Audit{ActorID: identity.SystemID, Source: "archie-ui", RequestID: id}
}
func randomIdentityID() (identity.IdentityID, error) {
var value [16]byte
if _, err := rand.Read(value[:]); err != nil {
return "", err
}
value[6] = value[6]&0x0f | 0x40
value[8] = value[8]&0x3f | 0x80
encoded := hex.EncodeToString(value[:])
return identity.IdentityID(encoded[:8] + "-" + encoded[8:12] + "-" + encoded[12:16] + "-" + encoded[16:20] + "-" + encoded[20:]), nil
}
func writeIdentityError(w http.ResponseWriter, err error) {
code := http.StatusInternalServerError
switch {
case errors.Is(err, identity.ErrNotFound):
code = http.StatusNotFound
case errors.Is(err, identity.ErrConflict):
code = http.StatusConflict
case errors.Is(err, identity.ErrInvalid), errors.Is(err, identity.ErrIllegalTransition), errors.Is(err, identity.ErrSystemImmutable):
code = http.StatusBadRequest
}
http.Error(w, strings.TrimSpace(err.Error()), code)
}
+1 -1
View File
@@ -218,7 +218,7 @@ func TestWorkRequestOriginProxy(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"}}})
srv.TrustForwardedHeaders = true
body := `{"identity":"archie","repository":"acme/widget","workflow":"implement","title":"Fix login","instructions":"Reproduce and fix it."}`
+48 -7
View File
@@ -1,16 +1,21 @@
package webui
import (
"context"
"encoding/json"
"errors"
"io"
"net/http"
"strings"
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/events"
)
const workflowDefinitionsKind = "workflow-definitions"
// handleWorkflows returns per-workflow and per-stage statistics: run counts,
// outcome breakdowns and spend per workflow, plus duration and failure counts
// per stage -- "where does it get stuck" for the workflows page.
@@ -26,10 +31,15 @@ func (s *Server) handleWorkflows(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
definitions, err := s.workflowDefinitions(ctx)
if err != nil {
http.Error(w, "workflow definitions unavailable", http.StatusServiceUnavailable)
return
}
writeJSON(w, map[string]any{
"workflows": workflows,
"stages": stages,
"definitions": s.Workflows,
"definitions": definitions,
})
}
@@ -74,7 +84,12 @@ func (s *Server) handleWorkRequest(w http.ResponseWriter, r *http.Request) {
http.Error(w, "identity, repository, workflow, title, and instructions are required", http.StatusBadRequest)
return
}
if !s.hasWorkflow(request.Workflow) {
available, err := s.hasWorkflow(r.Context(), request.Workflow)
if err != nil {
http.Error(w, "workflow definitions unavailable", http.StatusServiceUnavailable)
return
}
if !available {
http.Error(w, "workflow is not enabled", http.StatusConflict)
return
}
@@ -91,11 +106,37 @@ func (s *Server) handleWorkRequest(w http.ResponseWriter, r *http.Request) {
writeJSON(w, map[string]any{"ok": true, "task_id": taskID})
}
func (s *Server) hasWorkflow(id string) bool {
for _, workflow := range s.Workflows {
if workflow.ID == id && workflow.Enabled {
return true
func (s *Server) hasWorkflow(ctx context.Context, id string) (bool, error) {
definitions, err := s.workflowDefinitions(ctx)
if err != nil {
return false, err
}
for _, definition := range definitions {
if definition.ID == id {
return true, nil
}
}
return false
return false, nil
}
func (s *Server) workflowDefinitions(ctx context.Context) ([]task.Definition, error) {
if s.ControlPlane == nil {
return nil, nil
}
response, err := s.ControlPlane.Query(ctx, &controlpb.QueryRequest{Kind: workflowDefinitionsKind})
if err != nil {
return nil, err
}
if response.Resource == nil {
return nil, errors.New("workflow definitions missing")
}
var collection task.WorkflowDefinitionCollection
if err := json.Unmarshal(response.Resource.ValueJson, &collection); err != nil {
return nil, err
}
definitions := make([]task.Definition, 0, len(collection.Definitions))
for _, entry := range collection.Definitions {
definitions = append(definitions, task.Definition{ID: entry.ID, Name: entry.ID, Origin: "database", Enabled: true})
}
return definitions, nil
}
+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")
+16 -3
View File
@@ -16,10 +16,11 @@ import (
"sync"
"github.com/samcharles93/archie-core/internal/channels/status"
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
"github.com/samcharles93/archie-core/internal/domain/health"
"github.com/samcharles93/archie-core/internal/domain/identity"
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/logging"
"github.com/samcharles93/archie-core/ui"
@@ -35,8 +36,6 @@ type Server struct {
// from the configuration it holds (LocalConfigView).
ConfigSource ConfigViewSource
// Workflows is the executable registry snapshot supplied by composition.
Workflows []task.Definition
// WorkRequests admits dashboard requests through the same task-creation
// boundary used by chat; it never invokes a workflow runner directly.
WorkRequests messaging.TaskCreator
@@ -103,6 +102,12 @@ type Server struct {
// deployment that has not wired probes never looks healthy by accident.
Health *health.Registry
// ControlPlane is the State Store's versioned runtime administration
// contract. The HTTP adapter supplies operator attribution; browser JSON
// never carries actor, source, or request IDs.
ControlPlane controlpb.ControlPlaneServiceClient
Identities identity.Repository
// Token gates access. Empty means no check, which is how loopback binds
// stay frictionless -- see IsLoopback.
Token string
@@ -262,6 +267,14 @@ func (s *Server) registerMappingAndBindingRoutes(mux *http.ServeMux) {
}
func (s *Server) registerConfigAndLogRoutes(mux *http.ServeMux) {
mux.HandleFunc("GET /api/control-plane/catalog", s.handleControlPlaneCatalog)
mux.HandleFunc("GET /api/control-plane/resources/{kind}", s.handleControlPlaneQuery)
mux.HandleFunc("POST /api/control-plane/resources/{kind}/commands/{command}", s.handleControlPlaneCommand)
mux.HandleFunc("GET /api/control-plane/watch/{kind}", s.handleControlPlaneWatch)
mux.HandleFunc("GET /api/identities", s.handleIdentitiesList)
mux.HandleFunc("GET /api/identities/watch", s.handleIdentitiesWatch)
mux.HandleFunc("POST /api/identities", s.handleIdentityCreate)
mux.HandleFunc("POST /api/identities/{id}/{command}", s.handleIdentityCommand)
mux.HandleFunc("GET /api/config", s.handleConfig)
mux.HandleFunc("PATCH /api/config", s.handleConfigUpdate)
mux.HandleFunc("POST /api/config/reset", s.handleConfigReset)