Skip to content

Conversation

@squadgazzz
Copy link
Contributor

@squadgazzz squadgazzz commented Dec 26, 2025

Description

Refactors the driver Participant struct's score field, which makes it non-optional by introducing new ranking types: Unscored and Scored, that also replace the Unranked type. The Ranked type now only contains participants with scores. One of the prerequisites for #4010 before extracting this logic into a separate crate.

Changes

  • Unranked -> Unscored + Scored
  • Participant's score is non-optional now
  • No more panics/expectations

How to test

Existing tests

@squadgazzz squadgazzz marked this pull request as ready for review December 26, 2025 14:23
@squadgazzz squadgazzz requested a review from a team as a code owner December 26, 2025 14:23
Copilot AI review requested due to automatic review settings December 26, 2025 14:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the participant score management from an optional field on Solution to a mandatory part of the participant state, introducing a type-state pattern that tracks scoring status through the type system: UnscoredScoredRanked. This eliminates the need for runtime score validation (expects/panics) by making invalid states unrepresentable at compile time.

Key Changes:

  • Introduced Scored state type containing a non-optional score, replacing the Unranked type
  • Moved score from Solution to Participant state, making it type-safe
  • Renamed Ranked enum to RankType and created a new Ranked state struct containing both rank type and score

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/autopilot/src/domain/competition/participant.rs Core refactor: Added Scored state type, split Ranked into RankType enum and Ranked state, added score() methods on Scored and Ranked, replaced set_score() with type-safe with_score() transition
crates/autopilot/src/domain/competition/mod.rs Removed optional score field from Solution and its associated score() method, updated public exports to include new types
crates/autopilot/src/domain/competition/winner_selection.rs Updated arbitration logic to use type-state transitions, refactored compute_scores_by_solution to return scored participants, updated all score access to use participant.score() instead of solution().score()
crates/autopilot/src/run_loop.rs Updated type signatures to use Unscored instead of Unranked, changed score access from solution().score() to score()
crates/autopilot/src/shadow.rs Updated imports and type signatures, changed score access pattern
crates/autopilot/src/infra/persistence/mod.rs Updated score access from solution().score() to score()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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