Your analysis is posited on the assumption that the NK leadership is "quite rational." I differ on that assessment as 3 generations of despots have viewed themselves as divine under the political-religious philosophy known as Juche. Perceiving him to be God-like and having divine prerogative, it is doubtful that Kim Jong Un sees himself or his country as vulnerable to any threats posed by the USA. Therefore their development of nuclear capability is not seen as a deterrent as you suppose but rather their god-given right and anyone who opposes that idea of course faces "god's wrath."