fix(teams): clamp bid award scores to 0-10 - #256
Open
BlueX888 wants to merge 1 commit into
Open
Conversation
parse_bid_award wrote TL verdict scores straight to bid.score without the 0-10 clamp that parse_bid_scores applies. An out-of-range verdict score (e.g. 12 or -3) therefore flowed into the persisted bid record and into candidate_hp, which computes HP loss as 10 - score and could nudge an eliminated candidate back above zero. Align the award path with the scoring path so the score domain is consistent everywhere. Add a regression test asserting 12.0 clamps to 10.0 and -3.0 clamps to 0.0.
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.
Summary
parse_bid_awardwrote TL verdict scores straight tobid.scorewithout the 0–10 clamp thatparse_bid_scoresapplies. An out-of-range verdict score (e.g.12.0or-3.0) therefore flowed into the persisted bid record and intocandidate_hp, which computes HP loss as10 - score(seeservice.py:746) — an over-10 score could push an already-eliminated candidate's HP back above zero.Why
The same
bid.scorefield is written from two parsing paths:parse_bid_scoresclamps:score: min(10.0, max(0.0, score))(line 239)parse_bid_awarddoes not clamp (line 269)Only the clamp-on-scores path is exercised in normal flow; the award path still fills in any bid that missed a round score, so the inconsistency is reachable. The fix aligns both paths so the score's 0–10 domain holds everywhere.
Changes
backend/app/teams/service.py: clampparse_bid_awardscores to[0, 10], matchingparse_bid_scores.backend/tests/test_teams_bidding.py: new regression test asserting12.0clamps to10.0and-3.0clamps to0.0.Testing
pytest backend/tests/test_teams_bidding.py— 23 passed (includes the new test).pytest backend/tests/test_teams_api.py tests/test_teams_conversations.py tests/test_teams_ops.py tests/test_teams_bidding.py— 90 passed.ruff check backend/app/teams/service.py— clean.Related: #229 (its Q3 asks about the recommended way for a delivery manager to see member-task status; this fixes one defect in that area — an in-range score contract for team bidding).