You are trying to make it look as if at least from 1939 (the moment USSR betrayed Poland and attacked Finland in violation of non-aggression treaty), Stalin had consciously been working to protect USSR against German invasion, as if he had foreseen it.
Indeed. How Clemanso say after Verssalies treaty? "We buy peace for twenty years"? Many people thinks in 20-30s that new war is immenent. And after Hitler come to power this is was obvious to almost all.
Pray tell me, if this was indeed the case, and it was foreseen two years in advance, why then was USSR taken completely by surprise, as witnessed within first few weeks of plan Barbarossa?
USSR wasn't taken by surprise. German concentration of forces was discovered in middle of the May of 1941.
But Soviet leaders did several errors:
1. They underestimated speed of german troops deployment. By soviet intelligence germans didn't had troops needed to attack USSR till the end of july. But Wermacht almost complete deployment of its first attack echelons in one week before invasion.
2. They thought than Hitler will put forward some demands (as he did with Poland, for example) and not attacks without trying diplomacy first.
3. Soviet command follow erroneous assumption that war starts with some limited action and that allows USSR to start fully mobilization.
4. Soviet army start it own hidden deployment in end of May, but because of far worse infrastructure troops were deployed with slower speed then their german counterparts.
So the first german strike by 130 divisions in three army groups was faced by 57 divisions undermanned and spread all around the border. Soviets weren't taken by surprise, they were beaten by parts because of some fundamental errors in war planning and preparations.
So the only possibility to prevent Germany from occupying entire Poland was to strike deal with Germany, stab Poland in its back without declaration of war
Red Army enters polish territories in 17 of september. In this time polish army was destroyed, Warsaw surrounded and polish government fled to Romania. Molotov several times try to call polish officials. but all they were "unavailable"
What about denouncing German aggression and offering support to Poland?
And drag USSR into the war with Germany? So England and France may continue to play "sitzkrieg" in german western borders?
And some other point - when USSR offer military support to Czehoslovakia in face of german demands Poland don't allow soviet troops to march through polish territories. Polish prefers to split Czehoslovakia with Nazis. In september of 1939 just was their turn.
Baltic states had to join the USSR just so Germany wouldn't occupy them?
Yep. Fully military
and political control was far better then just military control.
4) As I mentioned above, Finland had non-aggression treaty with USSR. Why would they have attacked Leningrad in 1941, if not for the fact that USSR violated it first in 1939?
USSR also had non-agression treaty with Germany. USSR not violated treaty with Finland. USSR denounced it several months beforehand.
Also USSR was attacked by Hungary, Slovakia and Italy. With all this countries USSR never been at war. Finland wasn't any better and USSR had 20 years lenght history of mutual provocations and border clashes with them.