We thought he'd misspoken, lost the plot in a live interview with the LBC presenter, Iain Dale. But the Shadow chancellor John McDonnell didn’t retreat, retract or resile from his Edinburgh Festival bombshell that a future Labour government would no longer block a referendum on Scottish independence. Next day he doubled down and told ITV News that Jeremy Corbyn agreed with him. “If the Scottish people vote for a referendum,” he said, “we will not stand in the way.”

If anyone tells you that they'd expected this, they're lying. McDonnell's Edinburgh Declaration caught the Scottish political world completely by surprise. The SNP couldn't believe their ears. I initially thought his remarks, especially the reference to “the English Parliament”, were just a badly-briefed UK politician talking off the cuff. But no. It is now apparently UK Labour policy to accept the SNP’s call for “indyref2”. Gobs were well and truly smacked.

Most smacked of all were the Scottish Labour Party's. Their leader, Richard Leonard, was left speechless. The Shadow Chancellor had directly contradicted Labour's 2017 manifesto promise to oppose a repeat referendum. Only in March, Leonard made clear in an interview with the Daily Record, that a future Labour government would, like Theresa May, refuse any request for a “Section 30 Order” to trigger a legally-binding referendum on independence. No ifs; no buts.

READ MORE: Scottish Labour registers lowest level of income in nearly two decades

Not any more, it seems. The Branch Office, as the SNP like to call Scottish Labour, has been told to back the policy of their deadly enemy. Christmas has come early for Nicola Sturgeon, without the turkeys.

Many Scottish Labour MSPs were incandescent, as was the former Labour shadow Scottish secretary Ian Murray MP, who called McDonnell “ludicrous” and demanded that he “apologise to Richard Leonard” (he didn't), and reaffirm Labour's policy of opposition to a referendum (ditto). Off-the-record comments from Scottish Labour figures were unprintable. Unionist Labour MSPs put together a statement “deploring" the change in policy. This backfired when it emerged they hadn't cleared it with Richard Leonard's office.

The Labour MP, Paul Sweeney, then added to the confusion by calling for a multi-option referendum including federalism, or devo max as it used to be called. This was once proposed by Alex Salmond in 2012, and rejected by Labour and the Conservatives in favour of a binary Yes/No question. Saying Labour were all over the place would be an insult to geography.

So, what on earth is going on? Why was one of the key figures in the UK Labour party provoking a split on one of the most contentious issues in British politics? And right in the middle of the Brexit row. Labour is now divided every which way on the constitution: over Scottish independence and over leaving Europe. McDonnell has left the Scottish party an impossible task: trying to win Scottish votes without a policy on Scotland in a general election that's possibly weeks away.

READ MORE: Scottish Labour breaks silence over anti-semitism investigation by blasting "biased" BBC

What seems to have happened is this. Labour, at a UK level, has started to think about forming much wider political alliances in future in order to defeat the rising tide of the right. This has been discussed by a number of Labour people, including the former BBC economics editor Paul Mason in his book Clear Bright Future.

Mason has argues that Labour should abandon its traditional base in the white working class and the trades union movement, and look to creating a new progressive alliance, or “popular front”, with LGBT and BAME groups, and with other progressive political parties. Mason regards the SNP, unlike most other nationalist parties, as progressive and social democratic. On the eve of McDonnell's Edinburgh interview Mason called in The Guardian for “a penalty-free independence referendum whenever Holyrood chooses”.

I'm not saying that Paul Mason is writing Labour policy. Far from it. Many in the party regard him with suspicion, not least for appearing to abandon the working class. But it looks as if the Labour leadership has finally been persuaded that the SNP is not just a band of “tartan Tories”, and that Jeremy Corbyn could do business with Nicola Sturgeon.

Scottish Labour is anyway likely to be crushed again in the forthcoming General Wlection, while the SNP is in line for around 50 Westminster seats according to the polls. Its support would almost certainly be required if Labour is to try to form a government, and McDonnell's intervention could be an attempt to prepare the ground. There's been no love lost between Corbyn and the mostly Blairite rump of the Scottish Labour Party, so he probably regards them as expendable.

Not that Labour is admitting any of this. Indeed, the line from McDonnell in Edinburgh, echoed by the Shadow Business Secretary, Rebecca Long-Bailey on Newsnight, is that Labour will not form any “coalitions or pacts” with anyone. Labour is still smarting from those Tory election posters in 2015 which showed the then leader, Ed Miliband, in Alex Salmond's breast pocket. It is imperative for Labour, in England at least, to deny any hint of an alliance with the SNP.

But Scotland is a different. A functioning Labour government in Westminster would require the tacit assistance of the SNP, perhaps on a confidence and supply basis. At any rate, the UK party leadership seems to have decided that offering a referendum is a risk worth taking to help some future co-operation to happen. This is huge development and raises questions about whether Labour can still be called a Unionist party.

Paul Hutcheon: the biggest threat to the Union is Scottish Labour's disintegration

Last week felt as if a dam has broken. After three years in which Scottish politics has been in suspended animation, suddenly everyone was talking about independence again. Even Conservative commentators like The Times' Iain Martin are now calling for a referendum in five years. The Guardian's Simon Jenkins believes independence itself is now unavoidable, and called on Westminster to plan for it now.

Of course, a referendum may not deliver a Yes. The polls still show Scotland split down the middle on independence. But this is a vindication of Nicola Sturgeon's cautious, constitutional approach to winning independence. It is a blow to her critics, who had been calling for an unauthorised referendum, or even UDI. The former SNP MP, George Kerevan, had been calling for mass civil disobedience to obstruct London transport. But this is a blow her internal critics will be happy to take for there is now a real possibility of a referendum in the next couple of years.

That is if Labour manages to defeat Boris Johnson – a big ask, perhaps, but far from impossible. There will likely be a vote of no confidence the Tory PM next month, and he will almost certainly lose. If Labour fails to form an alternative government in 14 days, then Johnson has to call a General Election. He's hoping to delay polling day until after Brexit on October 31. But that is a risky tactic. Such constitutional jiggery pokery could easily alienate voters, many of whom are anyway unconvinced by Johnson's abilities.

Just about anything could happen in the next few weeks. But what is not in doubt is that Scottish independence, or at least a referendum, is back on the agenda. And almost exactly five years since the last one.