Skip to content

feat(scorer): add scorer extension with heuristic and composite implementations#97

Merged
behinddwalls merged 3 commits into
mainfrom
preetam/scorer
Mar 1, 2026
Merged

feat(scorer): add scorer extension with heuristic and composite implementations#97
behinddwalls merged 3 commits into
mainfrom
preetam/scorer

Conversation

@behinddwalls
Copy link
Copy Markdown
Collaborator

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/scorer package with:

  • scorer.Scorer interface — defines Score(ctx, ChangeStats) (float64, error) returning a probability between 0.0 and 1.0
  • scorer.ChangeStats entity — aggregates code change metrics (files changed, lines added/deleted/modified, build targets added/removed/changed, dependency count)
  • Heuristic scorer (extension/scorer/heuristic/) — buckets a single extracted metric into probability ranges using configurable Bucket definitions and StatFunc extractors
  • Composite scorer (extension/scorer/composite/) — wraps multiple Scorer instances and combines their results with a ReduceFunc (built-in: Min, Max, Avg)
  • Gomock setup (extension/scorer/mock/) — build-time generated mocks for the Scorer interface

Both constructors return the scorer.Scorer interface and validate inputs (nil functions, empty scorers) by returning errors.

Test Plan

  • bazel build //extension/scorer/... — all 5 targets compile
  • bazel test //extension/scorer/heuristic:heuristic_test — table-driven tests covering bucket matching, boundary conditions, multiple stat functions, no-match errors, and nil statFunc validation
  • bazel 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

…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.
@behinddwalls behinddwalls requested review from a team and sbalabanov as code owners February 26, 2026 22:34
Comment thread extension/scorer/scorer.go Outdated
Comment thread extension/scorer/composite/BUILD.bazel
Comment thread extension/scorer/composite/scorer.go Outdated
Comment thread extension/scorer/composite/scorer.go
- 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>
@behinddwalls behinddwalls enabled auto-merge March 1, 2026 18:51
@behinddwalls behinddwalls added this pull request to the merge queue Mar 1, 2026
Merged via the queue into main with commit 92500ce Mar 1, 2026
8 checks passed
@behinddwalls behinddwalls deleted the preetam/scorer branch June 2, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants