Services was a struct with one field per service, so each service's name was stated three times: the field, the loader's defaulting branch, and every consumer's field access. Adding one meant editing all three, and nothing stopped them disagreeing. The drift was already there: stateStoreResolvedToken and gatewayResolvedToken were identical apart from the env var each hard-coded. Services becomes map[string]ServiceConnection, and RegisterService declares a service once with the five fields it has. Everything that differs between services is now an argument rather than a branch elsewhere: an empty registered target means the operator must supply one, which is how services.state.target stays required while the gateway's is defaulted, and the registered token env var replaces the two copied resolvers with Services.ResolvedToken. Defaulting iterates the registry, so a new service needs no loader edit. Consumers read Services.Get(name). Keeping a typo'd section reported took explicit work. [services.gatway] used to land in toml.MetaData.Undecoded() because the struct had no such field; a map decodes any section, so it would have loaded silently and left the daemon dialing the default. unregisteredServiceKeys asks the registry which names are real, and the test for it fails with an empty UnknownKeys when that check is removed. The TOML shape is unchanged, so no deployment profile, config.example.toml or install.sh edit is needed. Refs: archie-core-u23g
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package archied
|
|
|
|
import (
|
|
"log/slog"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
"github.com/samcharles93/archie-core/internal/gateway"
|
|
"github.com/samcharles93/archie-core/internal/store"
|
|
)
|
|
|
|
func TestRemoteChatCompositionPreservesChannelTurnLedger(t *testing.T) {
|
|
cfg := config.Config{
|
|
DBPath: filepath.Join(t.TempDir(), "tasks.db"),
|
|
Services: config.Services{config.ServiceNameGateway: {Target: "127.0.0.1:1"}},
|
|
}
|
|
st, err := store.Open(t.Context(), filepath.Join(t.TempDir(), "state-store.db"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Cleanup(func() { _ = st.Close() })
|
|
b := &boot{cfg: cfg, log: slog.Default(), cfgHolder: config.NewHolder(cfg), stateStore: st}
|
|
t.Cleanup(b.cleanup)
|
|
if err := b.openStores(t.Context()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if b.chatSessionStore == nil {
|
|
t.Fatal("startup did not open the channel conversation store")
|
|
}
|
|
sessions := b.chatSessionStore
|
|
if err := b.setupLLMAndChat(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if b.chatSessionStore != sessions {
|
|
t.Fatal("remote web chat replaced the channel conversation store")
|
|
}
|
|
ledger, ok := b.chatSessionStore.(gateway.TurnLedger)
|
|
if !ok {
|
|
t.Fatal("channel conversation store does not implement TurnLedger")
|
|
}
|
|
if err := ledger.RecoverTurns(t.Context(), "test-owner"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|