The fretboard allows several possibilities, but how to choose them in order for the music to flow better and with good sound quality? In the pratical and correct way, of course. I see for example a lot of books on scales but where to put the fingers, sometimes there is confusion between the pinky and the ring for example. What is the "science" beyond that? The goal is music and efficiency playing. I know what tablature is. But tablature says where the notes are, and there is notation for fingerings but sometimes it is absent. Tabs aren't always right answer: sometimes there are other solutions. In the set of solutions I don't know what is exactly acceptable for finger strength and stretching. I could try until I find the most comfortable position sounding good but I want to construct good habits in the guitar for more fluency. Where to learn about these principles?
To some extent, to "try until I find the most comfortable position sounding good" is one of the good habits you should develop. See if you can reach all the notes from first position (from the nut up to the fourth fret). If that doesn't work (can't reach all the needed notes or don't like the sound), try shifting down one string and up to the next position. If your guitar has a cutaway, you can often shift again up to the 10th or 12th fret to try it there.
The book that helped me the most in learning to play music without the fingerings and positions marked is The Sor Method. But that may not be the best choice for a complete beginner. It is very densely written and was translated from Spanish many years ago. But he devotes an entire chapter to adapting orchestral and choral works to the guitar, with emphasis on choosing appropriate positions and fingering.
William Leavitt book "A modern method for guitar" has information about scales with fingerings, and documenting also finger strechs.
There are always 3 fingerings that can be employed for just about any conceivable idea. The first note can start on the index, pinky, or one of the two middle fingers. The second consideration is what string to start on. The third is whether or not the idea can be played comfortably in position or if its more convenient to shift mid way. Id recommend trying everything in position first, then finding ways to move as this requires more knowledge of the guitars geometry.
Find some well-established guitar tabs, watch videos of people playing songs you want to learn, and practice de-tuning your guitar and tuning into different open tunings so you can imitate a song with various finger-arrangements. Who knows, you may stumble onto a grip even more comfortable than the person who wrote the song knew!