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.
59 lines
1.6 KiB
Go
59 lines
1.6 KiB
Go
package identity
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestSystemIdentityCannotBeMutated(t *testing.T) {
|
|
t.Parallel()
|
|
system := System()
|
|
for name, command := range map[string]Command{
|
|
"rename": {Type: CommandRename, DisplayName: "Other"},
|
|
"suspend": {Type: CommandSuspend},
|
|
"reactivate": {Type: CommandReactivate},
|
|
"retire": {Type: CommandRetire},
|
|
} {
|
|
t.Run(name, func(t *testing.T) {
|
|
if _, _, err := Apply(system, command); !errors.Is(err, ErrSystemImmutable) {
|
|
t.Fatalf("Apply() error = %v, want ErrSystemImmutable", err)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestLifecycleTransitions(t *testing.T) {
|
|
t.Parallel()
|
|
id, err := New(StableID("reviewer"), KindBot, "Reviewer")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, command := range []Command{{Type: CommandSuspend}, {Type: CommandReactivate}, {Type: CommandRetire}} {
|
|
var event Event
|
|
id, event, err = Apply(id, command)
|
|
if err != nil {
|
|
t.Fatalf("Apply(%s): %v", command.Type, err)
|
|
}
|
|
if event.IdentityID != id.ID {
|
|
t.Fatalf("event identity = %q, want %q", event.IdentityID, id.ID)
|
|
}
|
|
}
|
|
if id.Lifecycle != LifecycleRetired {
|
|
t.Fatalf("lifecycle = %q, want retired", id.Lifecycle)
|
|
}
|
|
if _, _, err = Apply(id, Command{Type: CommandReactivate}); !errors.Is(err, ErrIllegalTransition) {
|
|
t.Fatalf("reactivate retired error = %v, want ErrIllegalTransition", err)
|
|
}
|
|
}
|
|
|
|
func TestStableIDIsNameStableAndNotDisplayName(t *testing.T) {
|
|
t.Parallel()
|
|
first := StableID(" ReviewER ")
|
|
if first != StableID("reviewer") {
|
|
t.Fatalf("stable IDs differ: %q", first)
|
|
}
|
|
if first == IdentityID("reviewer") {
|
|
t.Fatal("stable ID aliases the legacy display name")
|
|
}
|
|
}
|