There are many cases where you want to trap your dwarf alone behind a wall. The site is fraught with stories of the one or more (or sometimes fewer, depending on the medical state of the one dwarf) manages to wall himself up while his comrades are slaughtered to the dwarf, and subsists on vermin until migrants come. I've done it myself.
Usually, however, it's just that moment when you find out that one of more of your legendary dwarves just died of starvation after sitting behind a wall they had constructed in their way, but had not told you the player.
I think there may be a basic way to get around that: path endpoints which the player can set. Points on the map that, whenever a dwarf is building something that could block their movement, check to make sure that once the object is built they will be able to get to the nearest endpoint. They will build so that this is the case, choosing the side that will keep them in access, once the thing is built, to this set point. So that wall? They won't automatically stand north of it, if that would wall them in WITH the forgotten beast, but would instead stand south of it so as to ensure that they are safely on the opposite side from said beast, because the player set the endpoint to be inside the fort. If more than 1 endpoint is set, they would use the nearest, of course, OR perhaps dwarves could even be set to specific endpoints so as to make sure they always stay in the right area regardless of construction...