Each of these modules contains a number of expected components: (...) lib.php: any/all functions defined by the module should be in here.
Looking into existing code of some modules, this rule seems to be never completely followed. A lot of functions are defined in other module files as well. So, should the rule just be re-defined into something like
all functions defined by the module and used within more than one module file should be in here
? I am asking this because I see places where functions are indeed defined in lib.php, but only used by one other file which is loaded only in rare cases. So IMO it would make more sense to move such a function out of lib.php into the file in question. This would also speed up the code since there is no need to load all the contents of lib.php every time if parts of them are never used.
Here is an example: in mod/data, the function data_presets_export() is defined in lib.php, but only used out from preset.php which is not used at normal work with the database activity (reading or writing entries).