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.
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package store
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestPutResourceRejectsStaleVersion(t *testing.T) {
|
|
s := OpenTest(t)
|
|
defer s.Close()
|
|
ctx := t.Context()
|
|
first, err := s.PutResource(ctx, ResourceWrite{Kind: "settings", Value: []byte(`{"v":1}`), Actor: "a", Source: "test", RequestID: "r1", ExpectedVersion: 0, At: time.Now()})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = s.PutResource(ctx, ResourceWrite{Kind: "settings", Value: []byte(`{"v":2}`), Actor: "a", Source: "test", RequestID: "r2", ExpectedVersion: 0, At: time.Now()})
|
|
if !errors.Is(err, ErrResourceVersionConflict) {
|
|
t.Fatalf("PutResource() error = %v, want ErrResourceVersionConflict (current %d)", err, first.Version)
|
|
}
|
|
}
|
|
|
|
func TestPutResourceDuplicateRequestIsIdempotent(t *testing.T) {
|
|
s := OpenTest(t)
|
|
defer s.Close()
|
|
ctx := t.Context()
|
|
write := ResourceWrite{Kind: "settings", Value: []byte(`{"v":1}`), Actor: "a", Source: "test", RequestID: "same", ExpectedVersion: 0, At: time.Now()}
|
|
first, err := s.PutResource(ctx, write)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
write.Value = []byte(`{"v":999}`)
|
|
second, err := s.PutResource(ctx, write)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if first.Version != second.Version || string(second.Value) != string(first.Value) {
|
|
t.Fatalf("duplicate = (%d, %s), want (%d, %s)", second.Version, second.Value, first.Version, first.Value)
|
|
}
|
|
}
|