…I'm looking to learn the exact mechanics….
A laudable goal. :>:
https://minecraft.gamepedia.com is one of the better resources [Although not all articles are as up-to-date as one might hope].
Information is also sometimes found in articles one would not normally think to search...
...somewhat true in this case where https://minecraft.gamepedia.com/Villager#Farming does not include the key fact:
"If a villager finds itself outside the village boundary, or a villager without a village detects a village boundary within 32 blocks, it will move quickly back within the boundary. A villager taken more than 32 blocks away from its village boundary will forget the village within about 6 seconds. " that is found a few sections higher on the page ( https://minecraft.gamepedia.com/Villager#Movement_patterns )
This is amazing. Exactly what I was looking for. I was using that wiki, and yes, I didn't see this paragraph in movement patterns. Thanks so much.