REF: Pieces broken off of #24024
cc @TomAugspurger 

If I did this right, this shouldn't cause rebasing headaches.  LMK if I messed up on that and I'll try to fix.

Nearly everything here is verbatim from #24024.  I'll comment inline with pieces that are not.