It’s definitely not perfect, like I can grab a nap and not have it notice sometimes so I assume there are a bunch of heuristics at play that create a “best guess”.
That said, how rested I feel does typically line up with the number of hours it shows (regardless of how long I’ve actually spent in bed), and it has a short description about the quality of sleep like “restorative” or “not enough rem” that further lines up with how I feel.
It’s an old term from the car customisation scene, but I’ve seen it in use for referring to custom desktop setups for more than 10 years now. The unixporn subreddit was the first place I ran into it.