So there’s a mod that does something similar, and of course there is the guard command, but here’s my 3 points for my suggestion for an Assignable Patrol Area mechanic:
Put it under the Zoning Tab, and have it look and place just like any of the other areas. (farming, storage, etc)
Allow specific hearthlings to be assigned there. Mechanically, this could work just like picking which crop grows on which farm plot, simply check off which of your hearthlings you would like to patrol there. So you could assign Archers to patrol towers or walls, and leave your footmen and knights at ground level or in open spaces.
Allow the patrolling hearthlings to take breaks for sleeping and eating. As of right now, a hearthling on guard duty is the only job that doesn’t let the hearthling go off and perform the necessary eating and sleeping, and I think that you could keep that type of command available, but the patrol areas would allow you to keep your hearthlings that can fight more precisely where you want them without having to worry about them starving. I think it would be a nice middle ground to have.