i found the reason why pkg.stats result is not returned as an array: RET_ARRAY flag was missing from the export. pkg.stats export needs to be defined like this:
rpc_export_t kex_pkg_rpc[] = { {"pkg.stats", rpc_pkg_stats, rpc_pkg_stats_doc, RET_ARRAY}, {0, 0, 0, 0} };
i'll make the commit shortly. looks like there are other rpc functions too where the flag should be there, but is missing.
-- juha