PM as in “project” or “product” manager? I’ve never experienced the former that wasn’t an oxygen thief, but I’ve heard unicorns exist. My current product manager is quite good imo: shields engineers from idea ferries from all levels; talks to support and customers; has good track record of picking projects that successfully increases product adoption; etc. I wish our product manager took the time to understand our codebases as the op here does. I think with that knowledge it would be easier to convince the PM of the importance of certain refactors and why certain requests estimates are more difficult and or tedious that the PM expects.
Maybe a mixed role is the fabled unicorn “project” manager.