Skip to content

Commit 7068a1b

Browse files
committed
fix(speculation): reject ranking fields on content scorers
## Summary ### Why? A factors map or nested base under heuristic/composite used to load and then be ignored, so a misplaced pathPassed looked configured while ranking stayed at 1. ### What? Fail those configs in normalizeContent, including composite components and a queue overlay base. ## Test Plan ✅ `go test ./service/submitqueue/orchestrator/server/ -run TestLoadProfilesConfig_RejectsBadScorers`
1 parent 84ca524 commit 7068a1b

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

service/submitqueue/orchestrator/server/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,9 @@ func validateFactors(where string, factors map[string]float64) error {
616616
}
617617

618618
func (s *scorerConfig) normalizeContent(where string) error {
619+
if len(s.Factors) > 0 || s.Base != nil {
620+
return fmt.Errorf("%s: factors and base belong on the ranking scorer, not under base", where)
621+
}
619622
if s.Type == "" {
620623
s.Type = scorerTypeHeuristic
621624
}

service/submitqueue/orchestrator/server/config_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,10 @@ func TestLoadProfilesConfig_RejectsBadScorers(t *testing.T) {
667667
{name: "unknown combine", contents: "defaults:\n scorer:\n base:\n type: composite\n combine: median\n components: {a: {type: heuristic}}\n"},
668668
{name: "score out of range", contents: "defaults:\n scorer:\n base:\n type: heuristic\n buckets: [{min: 0, max: 10, score: 2.0}]\n"},
669669
{name: "inverted bucket", contents: "defaults:\n scorer:\n base:\n type: heuristic\n buckets: [{min: 10, max: 1, score: 0.5}]\n"},
670+
{name: "factors under heuristic base", contents: "defaults:\n scorer:\n base:\n type: heuristic\n factors: {pathPassed: 10}\n"},
671+
{name: "nested base under heuristic", contents: "defaults:\n scorer:\n base:\n type: heuristic\n base: {type: heuristic}\n"},
672+
{name: "factors on a composite component", contents: "defaults:\n scorer:\n base:\n type: composite\n components:\n a:\n type: heuristic\n factors: {pathPassed: 10}\n"},
673+
{name: "factors under queue overlay base", contents: "defaults: {}\nqueues:\n - name: q\n scorer:\n base:\n type: heuristic\n factors: {pathPassed: 10}\n"},
670674
}
671675
for _, tt := range tests {
672676
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)