How to route a menu click to a document command

If the user selects a menu item, how does that get connected to a command in the frontmost document?

You set it’s action via the First Responder icon, which lists all available action methods/handlers. When selected, the menu will look in the responder chain for the first object that implements the action method/handler.