(score: CandidateScore)
| 1045 | selected_rank = quality_rank(selected.served_quality) |
| 1046 | |
| 1047 | def fallback_key(score: CandidateScore) -> tuple[int, int, float, float]: |
| 1048 | rank_delta = quality_rank(score.served_quality) - selected_rank |
| 1049 | overbuy = 1 if rank_delta > 0 else 0 |
| 1050 | return (overbuy, abs(rank_delta), score.predicted_cost, -score.total) |
| 1051 | |
| 1052 | remaining = [score for score in ranked if score.model != selected.model] |
| 1053 | remaining.sort(key=fallback_key) |
nothing calls this directly
no test coverage detected