test(slm): align HappyPath with task-type complexity floor

The Debug floor (0.4) added in eb0583f was bumping the SLM-returned
0.25 up, breaking the HappyPath assertion. Bump the SLM value to 0.55
so the test still verifies "SLM value preserved" (its original
intent), and add a dedicated TestClassifier_AppliesTaskTypeFloor that
exercises the under-reporting case the floor was added to handle.
This commit is contained in:
2026-05-19 20:54:27 +02:00
parent 43ea2e562d
commit 342b3903e1
+22 -3
View File
@@ -51,7 +51,9 @@ func (s *mockStream) Err() error { return nil }
func (s *mockStream) Close() error { return nil }
func TestClassifier_HappyPath(t *testing.T) {
p := &mockProvider{text: `{"task_type":"Debug","complexity":0.25,"requires_tools":false}`}
// SLM complexity 0.55 stays above the Debug floor (0.4), so the SLM
// value is preserved verbatim.
p := &mockProvider{text: `{"task_type":"Debug","complexity":0.55,"requires_tools":false}`}
cls := NewClassifier(p, "default", nil)
task, err := cls.Classify(context.Background(), "fix the failing test", nil)
@@ -61,14 +63,31 @@ func TestClassifier_HappyPath(t *testing.T) {
if task.Type != router.TaskDebug {
t.Errorf("Type = %s, want Debug", task.Type)
}
if task.ComplexityScore != 0.25 {
t.Errorf("ComplexityScore = %v, want 0.25", task.ComplexityScore)
if task.ComplexityScore != 0.55 {
t.Errorf("ComplexityScore = %v, want 0.55 (SLM value preserved above floor)", task.ComplexityScore)
}
if task.RequiresTools != false {
t.Errorf("RequiresTools = true, want false")
}
}
func TestClassifier_AppliesTaskTypeFloor(t *testing.T) {
// Debug floor is 0.4; SLM under-reports at 0.25. The classifier should
// bump ComplexityScore up to the floor so the SLM arm can't be picked
// for its own kind of misclassification.
p := &mockProvider{text: `{"task_type":"Debug","complexity":0.25,"requires_tools":false}`}
cls := NewClassifier(p, "default", nil)
task, err := cls.Classify(context.Background(), "fix the failing test", nil)
if err != nil {
t.Fatalf("Classify: %v", err)
}
floor := router.MinComplexityForType(router.TaskDebug)
if task.ComplexityScore != floor {
t.Errorf("ComplexityScore = %v, want floor %v", task.ComplexityScore, floor)
}
}
func TestClassifier_BlendHeuristic(t *testing.T) {
// SLM returns one type; other Task fields should come from heuristic.
p := &mockProvider{text: `{"task_type":"Boilerplate","complexity":0.1,"requires_tools":false}`}