Remove bundled catalog integration
This commit is contained in:
@@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// OpenRouterID identifies the maintained OpenRouter backend.
|
||||
// OpenRouterID is the conventional OpenRouter backend identifier.
|
||||
OpenRouterID = "openrouter"
|
||||
// RakestrawHomeID identifies the maintained Rakestrawhome backend.
|
||||
// RakestrawHomeID is the conventional Rakestrawhome backend identifier.
|
||||
RakestrawHomeID = "rakestrawhome"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
// Package catalog selects the maintained configuration assets supplied with
|
||||
// PromptKit. ConfigKit owns their composition and effective validation.
|
||||
package catalog
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
|
||||
"gitea.maximumdirect.net/eric/ConfigKit"
|
||||
openrouter "gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3"
|
||||
rakestrawhome "gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/backend"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/filecatalog"
|
||||
)
|
||||
|
||||
// Underlays selects external catalogs followed by PromptKit-owned profiles.
|
||||
// Neither group is interpreted before the final effective configuration loads.
|
||||
func Underlays() ([]configkit.Underlay, error) {
|
||||
openrouterInputs, err := assetInputs("OpenRouter catalog", openrouter.FS(), openrouter.Root)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rakestrawhomeInputs, err := assetInputs("Rakestrawhome catalog", rakestrawhome.FS(), rakestrawhome.Root)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
catalogInputs := append(openrouterInputs, rakestrawhomeInputs...)
|
||||
openrouterSmokeTestInputs, err := assetInputs("OpenRouter smoke-test catalog", openrouter.FS(), openrouter.SmokeTestsRoot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rakestrawhomeSmokeTestInputs, err := assetInputs("Rakestrawhome smoke-test catalog", rakestrawhome.FS(), rakestrawhome.SmokeTestsRoot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
catalogInputs = append(catalogInputs, openrouterSmokeTestInputs...)
|
||||
catalogInputs = append(catalogInputs, rakestrawhomeSmokeTestInputs...)
|
||||
owned := configkit.Input{Source: configkit.Mapping("PromptKit-owned profiles", map[string]any{
|
||||
"profiles": map[string]any{
|
||||
"promptkit-openrouter-standard": map[string]any{"extends": "gemini-flash-latest"},
|
||||
"promptkit-openrouter-auto": map[string]any{"backend": backend.OpenRouterID, "model": "openrouter/auto"},
|
||||
},
|
||||
})}
|
||||
return []configkit.Underlay{{Inputs: catalogInputs}, {Inputs: []configkit.Input{owned}}}, nil
|
||||
}
|
||||
|
||||
func assetInputs(label string, filesystem fs.FS, root string) ([]configkit.Input, error) {
|
||||
files, err := filecatalog.FindFSYAMLFiles(context.Background(), filesystem, root)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("discover %s configuration: %w", label, err)
|
||||
}
|
||||
namespace := configkit.NewFilesystem(label, filesystem)
|
||||
inputs := make([]configkit.Input, 0, len(files))
|
||||
for _, name := range files {
|
||||
inputs = append(inputs, configkit.Input{
|
||||
Source: namespace.File(name),
|
||||
Filesystem: &configkit.FilesystemContext{FS: &namespace, Root: root},
|
||||
})
|
||||
}
|
||||
return inputs, nil
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package catalog
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/ConfigKit"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/configuration"
|
||||
)
|
||||
|
||||
func TestSelectedCatalogsResolveThroughEffectiveConfiguration(t *testing.T) {
|
||||
underlays, err := Underlays()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
state, err := configuration.Load(configkit.Input{Source: configkit.NoSource()}, underlays)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
openrouter, err := state.GetBackend("openrouter")
|
||||
if err != nil || openrouter.Endpoint != "https://openrouter.ai/api/v1" || openrouter.ConcurrencyLimit != 16 || openrouter.QueueCapacity != 1024 {
|
||||
t.Fatalf("OpenRouter backend: %+v, %v", openrouter, err)
|
||||
}
|
||||
if openrouter.SmokeTests == nil || openrouter.SmokeTests.DefaultProfile == nil ||
|
||||
*openrouter.SmokeTests.DefaultProfile != "promptkit-openrouter-standard" ||
|
||||
openrouter.SmokeTests.Authentication == nil || openrouter.SmokeTests.Authentication.Kind == nil ||
|
||||
*openrouter.SmokeTests.Authentication.Kind != "openrouter_key" {
|
||||
t.Fatalf("OpenRouter smoke-test defaults: %+v", openrouter.SmokeTests)
|
||||
}
|
||||
rakestrawhome, err := state.GetBackend("rakestrawhome")
|
||||
if err != nil || rakestrawhome.Endpoint != "https://inference.ai.rakestrawhome.com/v1" || rakestrawhome.ConcurrencyLimit != 4 {
|
||||
t.Fatalf("Rakestrawhome backend: %+v, %v", rakestrawhome, err)
|
||||
}
|
||||
if rakestrawhome.SmokeTests == nil || rakestrawhome.SmokeTests.DefaultProfile == nil ||
|
||||
*rakestrawhome.SmokeTests.DefaultProfile != "rakestrawhome-gemma-4-31b" ||
|
||||
rakestrawhome.SmokeTests.Authentication == nil || rakestrawhome.SmokeTests.Authentication.Kind == nil ||
|
||||
*rakestrawhome.SmokeTests.Authentication.Kind != "none" {
|
||||
t.Fatalf("Rakestrawhome smoke-test defaults: %+v", rakestrawhome.SmokeTests)
|
||||
}
|
||||
for id, want := range map[string]string{
|
||||
"promptkit-openrouter-standard": "~google/gemini-flash-latest",
|
||||
"promptkit-openrouter-auto": "openrouter/auto",
|
||||
"rakestrawhome-gemma-4-31b": "google/gemma-4-31b-it",
|
||||
} {
|
||||
profile, err := state.GetProfile(context.Background(), id)
|
||||
if err != nil || profile.ResolvedTarget.Model != want {
|
||||
t.Fatalf("profile %s: %+v, %v", id, profile, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsumerCanReplaceOrClearSmokeTestDefaults(t *testing.T) {
|
||||
underlays, err := Underlays()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
replacement := configkit.Input{Source: configkit.Mapping("operator replacement", map[string]any{
|
||||
"backends": map[string]any{"openrouter": map[string]any{
|
||||
"smoke_tests": map[string]any{
|
||||
"default_profile": "operator-profile",
|
||||
"authentication": nil,
|
||||
},
|
||||
}},
|
||||
})}
|
||||
state, err := configuration.Load(replacement, underlays)
|
||||
if err != nil {
|
||||
t.Fatalf("load replacement: %v", err)
|
||||
}
|
||||
backend, err := state.GetBackend("openrouter")
|
||||
if err != nil || backend.SmokeTests == nil || backend.SmokeTests.DefaultProfile == nil ||
|
||||
*backend.SmokeTests.DefaultProfile != "operator-profile" || backend.SmokeTests.Authentication != nil {
|
||||
t.Fatalf("caller smoke-test replacement/null was not effective: %+v, %v", backend.SmokeTests, err)
|
||||
}
|
||||
|
||||
cleared := configkit.Input{Source: configkit.Mapping("operator null", map[string]any{
|
||||
"backends": map[string]any{"openrouter": map[string]any{"smoke_tests": nil}},
|
||||
})}
|
||||
state, err = configuration.Load(cleared, underlays)
|
||||
if err != nil {
|
||||
t.Fatalf("load null smoke_tests: %v", err)
|
||||
}
|
||||
backend, err = state.GetBackend("openrouter")
|
||||
if err != nil || backend.SmokeTests != nil {
|
||||
t.Fatalf("caller null did not clear smoke-test defaults: %+v, %v", backend.SmokeTests, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsumerOverlayReplacesCatalogDefaultsBeforeValidation(t *testing.T) {
|
||||
underlays, err := Underlays()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
underlays = append(underlays, configkit.Underlay{Inputs: []configkit.Input{{Source: configkit.Mapping("operator", map[string]any{
|
||||
"backends": map[string]any{"openrouter": map[string]any{"endpoint": "invalid lower value"}},
|
||||
})}}})
|
||||
main := configkit.Input{Source: configkit.Mapping("application", map[string]any{
|
||||
"backends": map[string]any{"openrouter": map[string]any{"endpoint": "https://alternate.example/v1"}},
|
||||
"profiles": map[string]any{"gemini-flash-latest": map[string]any{"model": "consumer-model"}},
|
||||
})}
|
||||
state, err := configuration.Load(main, underlays)
|
||||
if err != nil {
|
||||
t.Fatalf("replaced lower-layer value failed final validation: %v", err)
|
||||
}
|
||||
profile, err := state.GetProfile(context.Background(), "promptkit-openrouter-standard")
|
||||
if err != nil || profile.ResolvedTarget.Model != "consumer-model" || profile.ResolvedTarget.Endpoint != "https://alternate.example/v1" {
|
||||
t.Fatalf("maintained profile did not observe final configuration: %+v, %v", profile, err)
|
||||
}
|
||||
_, err = configuration.Load(configkit.Input{Source: configkit.Mapping("invalid final", map[string]any{
|
||||
"backends": map[string]any{"openrouter": map[string]any{"endpoint": "invalid final value"}},
|
||||
})}, underlays[:2])
|
||||
var loadError *configkit.LoadError
|
||||
if !errors.As(err, &loadError) {
|
||||
t.Fatalf("invalid final backend did not produce a ConfigKit load error: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"gitea.maximumdirect.net/eric/ConfigKit"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/artifact"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/capacity"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/catalog"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/configuration"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/defaults"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/domain"
|
||||
@@ -98,11 +97,7 @@ func New(cfg Config, options Options) (*Engine, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
underlays, err := catalog.Underlays()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("select maintained configuration: %w", err)
|
||||
}
|
||||
underlays = append(underlays, cfg.Sources.Underlays...)
|
||||
underlays := cfg.Sources.Underlays
|
||||
main := configkit.Input{Source: configkit.NoSource()}
|
||||
if cfg.Sources.Main != nil {
|
||||
main = *cfg.Sources.Main
|
||||
|
||||
Reference in New Issue
Block a user