THE hard men and women of the Democratic Unionist Party get a pretty bad press, understandably given their attitudes to issues like abortion and gay rights. But when the history of last week is written, the DUP may be credited with saving Britain from a hard Brexit. The pro-Brexit DUP leader, Arlene Foster, ended up doing more to keep Britain in the single market than Gina Miller, Nicola Sturgeon or the Labour Party combined.

It was Foster's dramatic intervention on Monday, wrecking Theresa May's celebratory lunch with the EU President, Jean-Claude Juncker, that forced the British PM to accept regulatory alignment with the EU Customs Union and the European Single Market – not just for Ireland, but for the entire UK. The DUP leader insisted there must be no hard border, or regulatory divergence, between Northern Ireland and the UK after Brexit. That would have created a border in the Irish Sea, and perhaps reunited Ireland.

But the Irish government had already won a categoric assurance from the UK government that there would be “no hard border between Ireland and Northern Ireland”. The only way to resolve this contradiction was to accept that there should be no hard border between the UK and the EU. In other words, that Britain was to remain in regulatory alignment with the Customs Union and the European Single Market. For all the weasel words and caveats, that is the inescapable conclusion from the document published on Friday.

The breakfast breakthrough was a humiliating defeat for the hard Brexiteers and a brutal lesson in the realities of Britain's standing in Europe. Theresa May accepted nearly all the conditions laid down by the Brussels negotiator, Michel Barnier, last summer. Instead of telling the EU to “go whistle” as Boris Johnson promised, Britain meekly agreed to pay the €50bn divorce bill. There was never the remotest chance of avoiding this if Britain wished to be regarded as a country that honoured its contractual obligations.

Next: citizenship. Theresa May should never have held the fate of EU citizens living in Britain hostage to the money talks. The UK would have gained moral authority from unilaterally honouring the right of the three million, and their children, to remain here – as it has now done. They'll be under the protection of EU law for at least eight years. British citizens, especially in Scotland, will wonder why we should have the protections of EU law on employment and discrimination removed – especially since the Government has promised that people in Northern Ireland will retain their EU citizenship indefinitely.

The big issue was always the Irish border, or rather avoiding one. Hitherto, Britain had persevered with the bizarre fiction that, after leaving the EU and “taking back control”, we could somehow remain border-free with the countries of the Single Market. In other words, that the EU would rewrite the rules of the club to give Britain “friction-free” access to the European Single Market without being a member. Only in those circumstances could there be no border checks or regulatory divergences between Ireland, in the EU, and the UK after leaving the Customs Union and Single Market.

So let’s be clear: we are not leaving it. There is no way to reconcile hard Brexit with paragraph 49 of the joint agreement published on Friday. “The United Kingdom,” it says, “remains committed to protecting North-South cooperation and to its guarantee of avoiding a hard border. Any future arrangements must be compatible with these overarching requirements.” It goes on: "In the absence of agreed solutions [ie if no deal with Brussels], the United Kingdom will maintain full alignment with those rules of the Internal Market and the Customs Union which, now or in the future, support North-South co-operation, the all-island economy and the protection of the 1998 [Belfast] Agreement."

Cynics may say the UK Government can't be trusted as far as it you can throw it. Remember how the inclusion of that weasel word “normally” in the 2016 Scotland Act effectively negated the promise that the Sewel Convention, preventing Westminster legislating on devolved matters, would be placed on a statutory basis. Presumably the word-salad at the end of the last sentence about “North-South co-operation” is intended to give the UK Government wriggle room. But it's hard to see where.

The junior minister, Greg Hands tried to argue last Tuesday on BBC Daily Politics that regulatory alignment only applies to agriculture, transport and energy and “not trade and the Customs Union”. But there is no ambiguity in the final document. As Leo Varadkar, the Irish Taoiseach, puts it: “There will be full alignment with the rules of the Customs Union and the Single Market ... such that North and South will continue to trade as they do now.” The Belfast Agreement of 1998 is incompatible with a hard border and the UK Government has given an unequivocal guarantee there will not be one. This means no border checks, tariffs and divergent regulations on goods passing the border between Northern Ireland and the EU.

This now applies, not just to Ireland, but defacto to the entire UK. As the Irish Times columnist, Fintan O'Toole put it, paraphrasing Henry Ford: “The UK can now have any colour of Brexit it wants provided it is green.” It may be called “regulatory alignment” but it effectively means remaining under the rules of the Single Market. There is no other way of reading Friday's document.

Even if alignment was somehow confined just to agriculture, transport and energy, that would still mean substantial acceptance of EU rules – and Brussels has repeatedly said that there can be no “pick and mix” approach to the single market. After all the huffing and puffing, bluster and threats, the UK Government has given a promise to remain effectively in the EU internal market even if we fail to negotiate re-entry to it.

Where stands Scotland now? Well, this outcome seems pretty much what Nicola Sturgeon called for in the Scottish Government White Paper in December 2016. She should be claiming copyright infringement. The Scottish Government always argued that the best option would be for the UK as a whole to remain in the Single Market, or as close to it as possible to prevent there being any hard border. She and Theresa May should be having a breakthrough breakfast of their own.

Of course, there is an air of unreality about all this. The UK still says it is leaving the Customs Union. But if there is any backsliding on the alignment issue there will be hell to pay: not just in Scotland, but in Dublin, Belfast and Brussels. Indeed, you could argue that this process has brought all the nations of the British Isles, Scotland, Wales, Ireland and England together again, in a new and common union, as members of the continuing EU internal market.

It's not what Nigel Farage expected, and it seems bizarre to me that the Brexiteer Tory MPs have been so agreeable to this. But after an agonising 18 months, Britain has taken a long hard look at the whole Brexit project, and decided that it is a non-runner. It looks like Christmas has come early for Remainers.