Implements escalation chains per skill with three-layer priority: 1. Caller override (model param) — no escalation 2. Per-skill chain from models.yaml 3. default_chain fallback New APIs: - Verifier() — fixed verifier for output validation - LlamaSwapURL() — base URL for warm-state probing - ChainFor(skill, override) — ordered model list for escalation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
81 lines
2.0 KiB
Go
81 lines
2.0 KiB
Go
package config_test
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/mathiasbq/supervisor/internal/config"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
const testYAML = `
|
|
verifier: claude-sonnet-4-6
|
|
llama_swap_url: http://koala:8080
|
|
|
|
default_chain:
|
|
- ollama/qwen3-coder-30b-tuned
|
|
- claude-sonnet-4-6
|
|
|
|
skills:
|
|
review:
|
|
chain:
|
|
- ollama/devstral-tuned
|
|
- ollama/gemma4
|
|
- claude-sonnet-4-6
|
|
spec:
|
|
chain:
|
|
- ollama/phi4
|
|
- claude-opus-4-6
|
|
`
|
|
|
|
func writeModels(t *testing.T, content string) string {
|
|
t.Helper()
|
|
f := filepath.Join(t.TempDir(), "models.yaml")
|
|
require.NoError(t, os.WriteFile(f, []byte(content), 0644))
|
|
return f
|
|
}
|
|
|
|
func TestModelsVerifier(t *testing.T) {
|
|
m, err := config.LoadModels(writeModels(t, testYAML))
|
|
require.NoError(t, err)
|
|
assert.Equal(t, "claude-sonnet-4-6", m.Verifier())
|
|
}
|
|
|
|
func TestModelsLlamaSwapURL(t *testing.T) {
|
|
m, err := config.LoadModels(writeModels(t, testYAML))
|
|
require.NoError(t, err)
|
|
assert.Equal(t, "http://koala:8080", m.LlamaSwapURL())
|
|
}
|
|
|
|
func TestModelsChainForSkillOverride(t *testing.T) {
|
|
m, err := config.LoadModels(writeModels(t, testYAML))
|
|
require.NoError(t, err)
|
|
|
|
chain := m.ChainFor("review", "")
|
|
require.Len(t, chain, 3)
|
|
assert.Equal(t, "ollama/devstral-tuned", chain[0])
|
|
assert.Equal(t, "ollama/gemma4", chain[1])
|
|
assert.Equal(t, "claude-sonnet-4-6", chain[2])
|
|
}
|
|
|
|
func TestModelsChainForDefaultFallback(t *testing.T) {
|
|
m, err := config.LoadModels(writeModels(t, testYAML))
|
|
require.NoError(t, err)
|
|
|
|
chain := m.ChainFor("trainer", "") // not in skills map
|
|
require.Len(t, chain, 2)
|
|
assert.Equal(t, "ollama/qwen3-coder-30b-tuned", chain[0])
|
|
assert.Equal(t, "claude-sonnet-4-6", chain[1])
|
|
}
|
|
|
|
func TestModelsChainForCallerOverride(t *testing.T) {
|
|
m, err := config.LoadModels(writeModels(t, testYAML))
|
|
require.NoError(t, err)
|
|
|
|
chain := m.ChainFor("review", "claude-opus-4-6")
|
|
require.Len(t, chain, 1)
|
|
assert.Equal(t, "claude-opus-4-6", chain[0])
|
|
}
|