I'm trying to understand what the pattern is in determining what upgrades/research you have access to when replaying a level and it seems pretty random. For example in The Outlaws (the second Mar Sara level), you get the Orbital Command but not any other upgrade as far as I can tell. However in the very next level (Zero Hour), you don't get any upgrades at all.
Then for some of the later levels it doesn't even give me the research/upgrades that I had at the time I first beat the level. (I started Media Blitz for the speed achievement, but when I saw no Tech Reactors I just ragequit

I'm wondering if anyone has managed to see a pattern here? What determines which upgrades, research or even units you'll get to use in a mission played from the mission archives?