But he must have been a heretic, since otherwise election to the papacy would have turned him from being a Catholic into a raging heretic, which seems contrary to the nature of the papacy and possibly against the promises of Christ. It's sort of a matter of eliminating the other alternatives, to some extent.
Be that as it may, his heresy would have remained occult, and occult heresy doesn't remove one from membership in the Church and therefore would not have precluded legitimate election. In other words, he would have remained pope until his heresy became manifest.
And I absolutely agree with you that the promises of Christ would prevent a Pope who was legitimate at his election from wrecking the Church, but would either cause him to drop dead or would convert him.
This, IMO, is why the sedevacantist thesis regarding Montini is completely unsatisfactory ... and why I favor the Siri Thesis. One might also contend that Montini was being blackmailed due to his sodomy, which would render his acts null and void since they wouldn't have been free.
Way too much emphasis is placed on the personal manifest heresy angle by the SVs, and the establishment of manifest heresy must somehow happen a priori to the Pope's Magisterium, because the problem then becomes, "Oh, here's Pope Pius XIII. He just issued and Encyclical. It contains heresy. He's not the pope." So, in order to reject any teaching of the Magisterium you don't like or decide is heretical, all you have to do is to declare the See vacant. Old Catholics could have just done the same thing.
We know that the Conciliar Church is not the Catholic Church and could not have been the result of legitimate papal authority FREELY EXERCISED. That's the "dogmatic" aspect of SVism. BUT, as to what actually caused it or how it happened and what mechanisms were in play? Only God knows.