How do Bitcoin devs make sure that their modifications do not affect the consensus rules or the running network protocol?
&quot;Best-effort&quot;. Formal proofs don't help. All one can do is to write tests, like any other well-written piece of software.
They also maintain forks of some dependencies such as LevelDB and don't update some of them such as BerkeleyDB.
See What Went Wrong. Especially the 2013 hardfork wouldn't have happened if they could ensure an unchanged consensus protocol.