Hmm interesting. So the gdalgetrastermaximum function that is called here doesn’t do any computation, but gets it from the metadata if it exists. So apparently the metadata in your file was set to the percentile and not the max.
If you want to compute the max, you can call maximum(band) (Base.maximum).