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.
90 lines
2.4 KiB
Go
90 lines
2.4 KiB
Go
package gateway
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestPersonaRegistryDefault(t *testing.T) {
|
|
r := NewPersonaRegistry(DefaultPersonas())
|
|
if len(r.List()) != 6 {
|
|
t.Errorf("expected 6 default personas, got %d", len(r.List()))
|
|
}
|
|
if prompt := r.GetActive("new-session"); !strings.Contains(prompt, "You are Archie") {
|
|
t.Errorf("new sessions must receive Archie's identity prompt, got %q", prompt)
|
|
}
|
|
}
|
|
|
|
func TestPersonaRegistrySetAndGetActive(t *testing.T) {
|
|
r := NewPersonaRegistry(DefaultPersonas())
|
|
|
|
if !r.SetActive("session-1", "concise") {
|
|
t.Error("SetActive should succeed for valid persona")
|
|
}
|
|
if r.SetActive("session-1", "nonexistent") {
|
|
t.Error("SetActive should fail for unknown persona")
|
|
}
|
|
|
|
prompt := r.GetActive("session-1")
|
|
if prompt == "" {
|
|
t.Error("GetActive should return prompt for active persona")
|
|
}
|
|
if !strings.Contains(prompt, "You are Archie") || !strings.Contains(prompt, "concise assistant") {
|
|
t.Errorf("selected styles must modify Archie's baseline identity, got %q", prompt)
|
|
}
|
|
|
|
if prompt := r.GetActive("session-2"); !strings.Contains(prompt, "You are Archie") {
|
|
t.Errorf("GetActive should return the Archie default for unset sessions, got %q", prompt)
|
|
}
|
|
}
|
|
|
|
func TestPersonaRegistryGet(t *testing.T) {
|
|
r := NewPersonaRegistry(DefaultPersonas())
|
|
p, ok := r.Get("helpful")
|
|
if !ok || p.Name != "helpful" {
|
|
t.Error("Get helpful should succeed")
|
|
}
|
|
_, ok = r.Get("nonexistent")
|
|
if ok {
|
|
t.Error("Get nonexistent should fail")
|
|
}
|
|
}
|
|
|
|
func TestPersonaRegistryEmpty(t *testing.T) {
|
|
r := NewPersonaRegistry(nil)
|
|
if len(r.List()) != 0 {
|
|
t.Error("empty registry should have no personas")
|
|
}
|
|
}
|
|
|
|
func TestPersonaRegistryReplaceFallsBackToNewDefault(t *testing.T) {
|
|
r := NewPersonaRegistry(DefaultPersonas())
|
|
if !r.SetActive("session", "creative") {
|
|
t.Fatal("select creative")
|
|
}
|
|
r.Replace([]Persona{{Name: "archie", Prompt: "new baseline"}, {Name: "concise", Prompt: "brief"}}, "concise")
|
|
if got := r.ActiveName("session"); got != "concise" {
|
|
t.Fatalf("ActiveName() = %q, want concise", got)
|
|
}
|
|
if got := r.GetActive("session"); got != "brief" {
|
|
t.Fatalf("GetActive() = %q, want brief", got)
|
|
}
|
|
}
|
|
|
|
func TestPersonaRegistryConcurrent(t *testing.T) {
|
|
r := NewPersonaRegistry(DefaultPersonas())
|
|
done := make(chan struct{})
|
|
go func() {
|
|
for range 100 {
|
|
r.SetActive("s1", "concise")
|
|
r.SetActive("s1", "helpful")
|
|
}
|
|
close(done)
|
|
}()
|
|
for range 50 {
|
|
_ = r.GetActive("s1")
|
|
_ = r.List()
|
|
}
|
|
<-done
|
|
}
|