Files
archie/cmd/archied/model_catalog_test.go
T
sam 4b340d2b56 fix: harden task and chat execution
Task runs now preserve real model context limits, provider usage, baseline-repair spend, commit identity, durable agent-finish telemetry, and useful timeline details without imposing a token cap. Dashboard forge links are canonical per owning GitHub or Gitea identity. Chat turn claims acquire SQLite writer intent before reading, eliminating the concurrent SQLITE_BUSY snapshot race.
2026-08-25 05:48:17 +10:00

56 lines
1.9 KiB
Go

package main
import (
"reflect"
"testing"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog"
)
func TestApplyModelCatalogNormalizesEveryExecutionScope(t *testing.T) {
cfg := config.Config{
Providers: map[string]config.Provider{
"openai": {Class: "custom", APIKeyEnv: "CUSTOM_KEY"},
},
Identities: []config.IdentityConfig{
{Name: "one", Providers: map[string]config.Provider{
"identity-only": {Class: "openai-compatible"},
}},
},
}
snapshot := modelcatalog.Snapshot{Providers: []modelcatalog.Provider{
{
ID: "openai", Class: "openai", APIKeyEnv: "OPENAI_API_KEY",
BaseURL: "https://api.openai.test/v1",
Models: []modelcatalog.Model{{ID: "gpt-tool", ContextWindow: 128_000, MaxOutputTokens: 16_000}},
},
{
ID: "anthropic", Class: "anthropic", APIKeyEnv: "ANTHROPIC_API_KEY",
Models: []modelcatalog.Model{{ID: "claude-tool"}},
},
}}
models := applyModelCatalog(&cfg, snapshot)
if got := cfg.Providers["openai"]; got.Class != "custom" || got.APIKeyEnv != "CUSTOM_KEY" {
t.Fatalf("explicit global provider was overwritten: %#v", got)
}
if _, ok := cfg.Providers["anthropic"]; !ok {
t.Fatal("discovered provider missing from global execution config")
}
if _, ok := cfg.Identities[0].Providers["anthropic"]; !ok {
t.Fatal("discovered provider missing from identity execution config")
}
if _, ok := cfg.Identities[0].Providers["identity-only"]; !ok {
t.Fatal("explicit identity provider was removed")
}
wantModels := []string{"anthropic/claude-tool", "openai/gpt-tool"}
if !reflect.DeepEqual(models, wantModels) {
t.Fatalf("models = %v, want %v", models, wantModels)
}
if got := cfg.ModelLimits["openai/gpt-tool"]; got.ContextWindow != 128_000 || got.MaxOutputTokens != 16_000 {
t.Fatalf("model limits = %+v, want catalog capacity", got)
}
}