HSLuv is defined as a conversion to and from CIELUV LCh. For both HSLuv and HPLuv, the first step is to find the chroma bounds for a given lightness. These are lines, crossing which will push the color out of the RGB gamut. We define a function, getBounds(L) which returns 6 straight lines in slope-intercept format. Each of them represents one of three RGB channels being pushed either below 0 or above 1.
The equations were built and solved using Maxima, and the Maxima files are bundled with the code explaining how to get the bounding lines. The rest is simple geometry you can see in the reference implementation.