traffic lights/stop lights are marked on the map. if it's not mapped, no detection is attempted. I hae a couple of unmapped lights that I noticed around. One installed a couple months ago, one I am not sure why it's unmapped. These are never detected. The mapped ones - when you are in vicinity, the car shows the gray icon and then once it's seen and signal is know, the signal state is added. Similarly with the stop signs.
They had v2 maps that had per lane information and stuff and it looks like they now have v3 maps with even more stuff, but I did not look into it with any sort of details, since it seems to be mostly in CA only anyway. Most of the mappign data hey use is in the form of v1 adas tiles we looked at in the past and the teslamaps data (I think this is where the traffic lights info is stored today, no detection works if you do not have teslamaps of the right vintage or region)