Rules-Sound Code Transitions