feat(scorer): add scorer extension with heuristic and composite implementations#97
Merged
Conversation
…mentations Add scorer extension with ChangeStats entity and Scorer interface. Heuristic scorer buckets a single metric into probability ranges. Composite scorer combines multiple scorers via reduce functions (Min, Max, Avg). Both constructors validate inputs, return errors for nil functions or empty scorers, and return the Scorer interface. Individual stat functions provided for all ChangeStats fields.
sbalabanov
approved these changes
Feb 27, 2026
- Generalize Scorer interface to Score(ctx, entity.Change) instead of Score(ctx, ChangeStats), making it agnostic to input data shape - Heuristic scorer takes a ValueFunc to extract numeric value from Change - Composite scorer uses named scorers (map[string]Scorer) so ReduceFunc receives map[string]float64 for domain-aware aggregation - Constructors panic on contract violations instead of returning errors - Add extension/scorer/README.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
SubmitQueue needs a way to estimate the success probability of a code change before landing it. Different heuristics (file count, dependency count, lines changed) each provide a signal, but no single metric is sufficient. We need a pluggable scoring system that can combine multiple signals into a single probability.
What?
Adds a new
extension/scorerpackage with:scorer.Scorerinterface — definesScore(ctx, ChangeStats) (float64, error)returning a probability between 0.0 and 1.0scorer.ChangeStatsentity — aggregates code change metrics (files changed, lines added/deleted/modified, build targets added/removed/changed, dependency count)extension/scorer/heuristic/) — buckets a single extracted metric into probability ranges using configurableBucketdefinitions andStatFuncextractorsextension/scorer/composite/) — wraps multipleScorerinstances and combines their results with aReduceFunc(built-in:Min,Max,Avg)extension/scorer/mock/) — build-time generated mocks for theScorerinterfaceBoth constructors return the
scorer.Scorerinterface and validate inputs (nil functions, empty scorers) by returning errors.Test Plan
bazel build //extension/scorer/...— all 5 targets compilebazel test //extension/scorer/heuristic:heuristic_test— table-driven tests covering bucket matching, boundary conditions, multiple stat functions, no-match errors, and nil statFunc validationbazel test //extension/scorer/composite:composite_test— table-driven tests covering Min/Max/Avg reduce, single scorer passthrough, child error propagation, three-scorer average, empty scorers error, and nil reduce error