modelbuilder: add `check_subtype` and `check_sametype`