Starting from the Treaty of Rapallo in 1922 there was cooperation between Germany and Soviets. Recent archival research has reviled that this cooperation was far deep then initially assumed. Until a short while ago we mostly looked at diplomatic treaties. However the reality is, German Army was basically operating as a shadow government in Germany and they very intensively interact with Russia on a massive scale.
There certainty were rough patches in the relationship and the didn't like each other, but strategically from 1922 on Russia was mostly supportive of Germany.
And of course Stalin hated the SPD and he thought they were more dangerous then the Rightists. But that doesn't mean that the core relationship was always that Germany had to be support as long as they were aggressive towards the other 'capitalist powers'.
> France, or the UK, neither country of which was interested
They were interested. But the cost of such an agreement was basically to give Stalin power over pretty much all of Eastern and Southern Europe.
And such an agreement would only have been a tool in Stalin attempt to create war between France and Germany that he could stay out off.
The French were very suspicious of Soviet intentions (far more so then they used to be of Imperial Russia) and that is why the French never came even close to such an agreement.
> In 1939 the USSR and Germany signed a peace treaty, which Germany would break within two years, but it gave the Soviet Union enough time to prepare for invasion. Also Germany having a western front helped the Soviet Union.
Yeah sure it helped that Germany spent resources fighting Britain. But not getting invaded by 1.5 million Germans at all would have helped far more.
The reality is, Germany can't invaded Soviet Union without Soviet Union or Britain support. They likely couldn't even have invaded France without Soviet Support. So had Stalin adopted a different strategy, Germany would have never seriously invaded the Soviet Union.
> Lenin did not have global goals with himself at the center
Sure. Until the moment he has the option to be.
> Stalin's goals were even more modest
No they weren't. Both of their goals was global revolution and Soviet Leadership of global communism.