Have you looked into Trinamic’s fancy stepper drivers that have feedback for step counting and skipped steps and other things? They might be suitable because industrial optical encoders are like $800 and I’ve never seen one small enough to go on a nema 17 stepper.
Also, what tolerances are you trying to hold here? My ender 3 repeats within a thousandth of an inch. I haven’t upgraded the limit switches, but I got a new main board with trinamic drivers.
Given the physical properties of FDM, I don’t think chasing tolerances lower than that will actually improve the quality of prints at all, and surely one thou is close enough for what you’re trying to do.