Files
archie/internal/daemon/workflow_definition_test.go
T
sam 3944f544e8 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.
2026-09-21 08:17:42 +10:00

49 lines
1.7 KiB
Go

package daemon
import (
"context"
"testing"
"github.com/samcharles93/archie-core/internal/domain/workflow"
"github.com/samcharles93/archie-core/internal/store"
)
type workflowDefinitionsStub struct {
collection workflow.WorkflowDefinitionCollection
version int64
}
func (s *workflowDefinitionsStub) WorkflowDefinitions(context.Context) (workflow.WorkflowDefinitionCollection, int64, error) {
return s.collection, s.version, nil
}
func TestWorkflowDefinitionPinSurvivesActiveOverride(t *testing.T) {
resources := store.OpenTest(t)
defer resources.Close()
task, err := resources.EnqueueChatTask(t.Context(), "acme", "widget", "custom", "", "custom", "operator")
if err != nil {
t.Fatal(err)
}
first := "id: custom\nsteps:\n - type: bootstrap.apply\n"
provider := &workflowDefinitionsStub{collection: workflow.WorkflowDefinitionCollection{Definitions: []workflow.WorkflowDefinitionEntry{{ID: "custom", YAML: first}}}, version: 4}
d := &Daemon{Store: resources, WorkflowDefinitions: provider}
if err := d.pinWorkflowDefinition(t.Context(), task); err != nil {
t.Fatal(err)
}
provider.collection.Definitions[0].YAML = "id: custom\nsteps:\n - type: bootstrap.prepare\n"
provider.version = 5
if err := d.pinWorkflowDefinition(t.Context(), task); err != nil {
t.Fatal(err)
}
if task.WorkflowDefinitionYAML != first || task.WorkflowDefinitionVersion != 4 {
t.Fatalf("pin changed after override: version=%d yaml=%q", task.WorkflowDefinitionVersion, task.WorkflowDefinitionYAML)
}
stored, err := resources.TaskByID(t.Context(), task.ID)
if err != nil {
t.Fatal(err)
}
if stored.WorkflowDefinitionDigest != workflow.DigestDefinition(first) {
t.Fatal("persisted workflow digest does not identify the pinned YAML")
}
}