Better type checking for commands

This long set of commits implement a validation DSL, and use it to implement better type checking for commands.  This attempt to fully automate that validation showed up a lot of places where the code was not uniform -- so various commits improve that to allow our code to treat all internal objects that are "similar" identically.