Possibly. Since we've yet to see this tried at any scale, we don't know if the contract is capable of staving off the tyrant.
Discussion
America has lots of "gated communities", surrounded by walls and with security manning the gates and patrolling the streets.
My parents' house in Maryland is like that. Mostly black people living there.
One of the few neighborhoods near DC where women and children are out playing and walking alone, even at night.
This is a pretty minor application of the concept, but, gosh I hate HOAs. Most of them suck. I can certainly see Daev's point, since, we do have the examples of HOAs going off the rail. So, that's certainly something to watch out for.
. . . . .and?
It's still not fixing a problem that will eventually come through your facade barriers.
You're literally proposing what you disrespect about refugees, aren't you? Fleeing for shelter, instead of fixing the issue forcing you to flee for shelter.