The absolute most fail-safe way to create a trading hall is to have the villager locked in with their bed and crafting station. Make a complete block casing around their bed, leave one block in the front, then put the crafting station in front of that empty block. and seal up the sides. It should look like this:
Leave a one-block layer of air on top of those, then add a roof so the villager can't jump out of that. I have had a trading hall with 80+ villagers locked in this format and they never break unless someone sleeps in a bed by accident and rips a villager out of it, in which case a glitch can sometimes happen where the villager can't claim the bed back for a very long time.