I've looked through both Metadata Docs and Metadata Keys Docs, as well as reached out to technical support, but I am still not able to determine if I can extract the below sleep features, REM, light, and deep sleep, (reliably) from multiple data sources without first having or knowing about the data from the provider.
In this Personal Healthkit Sleep Metadata Example, there is one data source that pushes REM, light, and deep sleep. I know about the keys and can pull the data easily, but what about when I want to analyze multiple sources of data? Is there any documentation that shows what each device's metadata might look like beforehand so I can plan for it? I find it hard to believe that Apple is pushing data without any documentation, which would defeat the purpose of being able to collect user data from any number of data sources.
As you saw by reading the metadata documentation, Apple has not published any official metadata keys related to the sleep features you're interested in. In your example, the metadata values are associated with sleep samples using custom keys determined by the app that saved the samples. HealthKit allows apps to use arbitrary metadata keys to store additional information on samples that is not necessarily structured in a standardized way.