Skip to content

fix(teams): clamp bid award scores to 0-10 - #256

Open
BlueX888 wants to merge 1 commit into
OpenBMB:mainfrom
BlueX888:fix/teams-bid-award-score-clamp
Open

fix(teams): clamp bid award scores to 0-10#256
BlueX888 wants to merge 1 commit into
OpenBMB:mainfrom
BlueX888:fix/teams-bid-award-score-clamp

Conversation

@BlueX888

@BlueX888 BlueX888 commented Sep 2, 2026

Copy link
Copy Markdown

Summary

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.0 or -3.0) therefore flowed into the persisted bid record and into candidate_hp, which computes HP loss as 10 - score (see service.py:746) — an over-10 score could push an already-eliminated candidate's HP back above zero.

Why

The same bid.score field is written from two parsing paths:

  • parse_bid_scores clamps: score: min(10.0, max(0.0, score)) (line 239)
  • parse_bid_award does 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: clamp parse_bid_award scores to [0, 10], matching parse_bid_scores.
  • backend/tests/test_teams_bidding.py: new regression test asserting 12.0 clamps to 10.0 and -3.0 clamps to 0.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.
  • Sabotage check: removing the clamp makes the new test fail; restoring it makes it pass.

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).

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.
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.

1 participant