So I have completely removed and re-added all my settlement beds at Sanctuary, manually assigned each NPC to an individual bed, and verified that at night, they all go to where they are supposed to.
HOWEVER, as soon as I leave the settlement my data tab shows my beds down to 4 (from 23) and my power and water also drop to 0 when the bed number glitches. This is NOT just cosmetic, as my happiness will drop as long as I am gone.
As soon as I come back and enter build mode everything returns to normal and happiness begins to rise. But leave and it all starts again.
Also, once this cycle of bed glitching starts random NPC's will just ignore their bed assignment and pick a random empty bed, which seems to make the glitch worse. I have deleted all beds, and left only assigned beds (1 per settler), and after re-assigning them all the problem persists.
Maddening for a borderline OCD like me.