SELECT DISTINCT with another table
If I understand your requirements correctly, you want to join the other table on polyname and then get the max() of poly_version, like

SELECT rule_name, rule_version, polyname, state, max(poly_version)
  FROM rule r JOIN gtest_version g ON r.polyname = g.polyname
 GROUP BY rule_name, rule_version, polyname, state
 ORDER BY rule_name, rule_version DESC;


However, your query and description does not tell how you want to pick the right row from the rule table.  My query will return all of these, while your DISTINCT ON will not...