For JPEG/TIFF files, we:
- Use the input color space as working color space (supposing that it is somehow similar to AdobeRGB);
- Almost at the end of the processing pipeline, we compute the histogram and highlight/shadow clipping indicators;
- Finally, at the very end, we convert the image to the display color space.
That’s why your histogram above shows red as the brightest channel, but the sky is displayed blue.
So, yes, the histogram is based on the working color space – which is identical to the input color space – and not on the display color space.
Br,
Wolf