refactor(routing): clarify Floor/Ceil semantics + extend test coverage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mathias Bergqvist
2026-05-04 15:34:22 +02:00
parent 69c038478b
commit ccf080db59
2 changed files with 14 additions and 0 deletions

View File

@@ -16,6 +16,12 @@ type RoutingConfig struct {
BrainURL string // BRAIN_URL, default http://ingestion.supervisor:3300
LocalModel string // HYPERGUILD_LOCAL_MODEL, default qwen35
ClaudeModel string // HYPERGUILD_CLAUDE_MODEL, default claude-sonnet-4-6
// RouteLocalFloor and RouteLocalCeil intentionally invert the usual
// floor < ceil mathematical convention: Floor (default 0.90) is the
// UPPER boundary — at/above it, always route local; Ceil (default 0.70)
// is the LOWER boundary — below it, always route Claude. The band in
// between is the 50/50 sample zone. The naming follows the spec's policy
// vocabulary; see internal/routing/policy.go for the consumer.
RouteLocalFloor float64 // HYPERGUILD_ROUTE_LOCAL_FLOOR, default 0.90
RouteLocalCeil float64 // HYPERGUILD_ROUTE_LOCAL_CEIL, default 0.70
PassRateTTLSeconds int // HYPERGUILD_PASS_RATE_TTL_SECONDS, default 60

View File

@@ -29,6 +29,7 @@ func TestLoadRoutingDefaults(t *testing.T) {
assert.InDelta(t, 0.90, cfg.RouteLocalFloor, 1e-9)
assert.InDelta(t, 0.70, cfg.RouteLocalCeil, 1e-9)
assert.Equal(t, 60, cfg.PassRateTTLSeconds)
assert.Equal(t, "", cfg.LiteLLMAPIKey)
}
func TestLoadRoutingFromEnv(t *testing.T) {
@@ -63,3 +64,10 @@ func TestLoadRoutingRejectsBadFloat(t *testing.T) {
require.Error(t, err)
assert.Contains(t, err.Error(), "HYPERGUILD_ROUTE_LOCAL_FLOOR")
}
func TestLoadRoutingRejectsBadInt(t *testing.T) {
t.Setenv("HYPERGUILD_PASS_RATE_TTL_SECONDS", "not-a-number")
_, err := config.LoadRouting()
require.Error(t, err)
assert.Contains(t, err.Error(), "HYPERGUILD_PASS_RATE_TTL_SECONDS")
}