So toxic is the atmosphere in Westminster about the Northern Ireland Protocol and the forthcoming bill to overturn it, that senior figures in Brussels and elsewhere feel they have been here before.

"This is like all the s***-stirring that went on in 2018, when people were briefing and counter briefing," says one UK official. "It makes it bloody hard for those of us who are trying to find a solution."

Boris Johnson has courted the hardline European Research Group (ERG) to try to cling to his position following his worse than expected confidence motion win on Monday, while one of his challengers, the Foreign Secretary Liz Truss, has courted the ERG precisely to take Johnson's place if he is ousted during the summer.

There were reports this week that Truss was reprimanded by Johnson at a divisive cabinet meeting for taking too hard a line on the bill. Michael Gove and Rishi Sunak also raised their concerns, fearful that a trade war with the EU is not what the UK economy - which the OECD warned would next year have the slowest growth and highest inflation of any developed country - does not currently need.

"This isn't just cabinet ministers versus cabinet ministers," said the official. "There is department versus department. There are people within the civil service who are uncomfortable being asked to do stuff they're uncomfortable doing."

Liz Truss listens as Boris Johnson speaks during a Cabinet meeting on 17 May

Worsening the atmosphere is a row over whether the bill will break international law or not.

When the UK introduced the Internal Market Bill (IMB) in 2020, the Northern Ireland Secretary Brandon Lewis admitted to the House of Commons it would break international law "in a very specific and limited way".

This time around Liz Truss has told the House of Commons the new bill, which would breach the Protocol in an even more fundamental way, "is legal in international law".

As the legal expert David Allen Green has written in his Law and Policy blog, ministers want cover to tell the MPs who will vote for the bill that they are voting for something which is legal.

However, governments sometimes shop around for legal advice if the advice they are given by their own most senior law officers does not comply with their political objectives.

This was the case with the then Attorney General Lord Goldsmith on the legality of the Iraq War. The Chilcot Inquiry found that Goldsmith’s shopping around for the right advice was "far from satisfactory".

On 11 May, the Times reported that the current Attorney General Suella Braverman had decided the bill to rip up the Protocol was legal in international law, because the Good Friday Agreement (GFA) had "primordial" superiority over the Protocol.

This was because the EU had created "a barrier in the Irish Sea and [was] fuelling civil unrest".

In other words, the GFA was a more "important" treaty than the Withdrawal Agreement.

As David Allen Green suggests, British governments normally turn to a senior external legal figure, known as the First Treasury Counsel, for advice on a particularly tricky piece of legislation if there is a constitutional dimension.

According to reports by Sam Coates of Sky News and Adam Payne of Politics Home, the government had, indeed, turned to the current First Treasury Counsel James Eadie QC.

However, he was not asked for a legal opinion as to whether the bill broke international law or not. Instead, he was asked to simply confirm that the government had received a range of advice from other lawyers.

He had been asked only to "assume" that there was a "respectable legal basis" on which to support the arguments made by the other lawyers, according to the reports.

However, according to the Sam Coates report, Mr Eadie left something of a fly in the ointment by saying that the advice of one particular lawyer was "considerably easier to follow and more convincing", and that lawyer had argued that it would be "very difficult" for the UK to argue it was not breaching international law.

According to David Allen Green, this is an unholy mess.

"Somebody senior internally is insisting that the First Treasury Counsel be consulted, and that the Attorney General’s convenient advice cannot be accepted on the nod," he wrote.

Mr Eadie’s arms-length role provoked questions in the House.

SDLP leader Colum Eastwood challenged Boris Johnson on Wednesday to respond to reports Johnson had "refused to consult the First Treasury Counsel on his plans to rip up the Protocol".

Johnson responded that the reports were not correct. But he doubled down on the Braverman idea that the GFA was a superior treaty.

"The most important commitment that I think everybody in this House has made is to the balance and symmetry of the Belfast/Good Friday agreement. That is our highest legal international priority," Johnson said.

Johnson told parliament that the Good Friday Agreement was his highest legal international priority

On Thursday the Liberal Democrat MP Alastair Carmichael said Johnson’s answer was, at the very least, "incomplete".

He asked Minister of State James Cleverly to clarify the situation.

"While Sir James [Eadie] was consulted on aspects of the proposals, he was in fact asked not to give an opinion on whether the plan would breach international law and was told to assume that there was a respectable legal basis for the government’s position."

Cleverly replied the government was "confident our actions are legal under international law". He said it was a long-standing tradition that governments did not publish legal advice.

On the BBC’s World at One on Thursday, Jonathan Jones, the former chief legal officer in Johnson’s government who resigned over the Internal Market Bill, himself cast doubt on the legality of the bill.

"The government knew about the Good Friday Agreement when it entered into the Withdrawal Agreement, including the Protocol. It has since argued in litigation in the Northern Ireland courts, that the Protocol was deliberately and carefully designed so as to protect the integrity of the Good Friday Agreement."

This gets back to the secondary charge: that the problem, therefore, is the way the EU has implemented the Protocol.

"If the argument is the EU side is failing properly to implement the agreement," said Jones, "which is another way of saying the EU itself is in breach, then that would give rise to different remedies for the UK. But it would not be a justification for the UK itself unilaterally to rewrite whole swathes of the Protocol."

Despite this, MP Conor Burns, who is Minister of State for Northern Ireland and Boris Johnson’s unofficial envoy to Washington, insisted the UK was "taken by surprise" by the way the EU was implementing the Protocol.

"There was a degree of surprise at the scale of implementation versus the perceived risk, that is absolutely fair to say," he told the Northern Ireland Affairs Committee on Wednesday.

"We did not believe that the EU would insist on the full panoply of checks on product moving to stay in the Northern Ireland marketplace to be sold and consumed in Northern Ireland, which poses zero risk to the single market… we remain the most aligned nation on earth to the EU’s regulatory model."

However, what the UK has argued since the spring of last year, and what Monday’s bill will legislate for, is an entirely new Protocol, not a better way of implementing the one that exists.

Indeed, the bill is expected to strip out a swathe of provisions, not because they make the EU implement the Protocol more zealously, but because the UK does not like them.

This is what has caused EU capitals to harden their position.

"From what has been leaked about the nature of what they're going to do," says one EU diplomat, "the European Commission is quite taken aback about the extent to which they're rewriting the Protocol. It’s not just tinkering or removing elements that may cause irritation, it's a wholesale rewrite. It's just riding a coach and horses through the whole thing."

As such, France and Germany in particular are increasingly furious at what Boris Johnson is poised to do. "The big member states are incandescent with rage," said the diplomat. "They're extremely annoyed that a country could take this attitude to an international agreement."

Diplomats complain that at the same time, the UK is becoming increasingly truculent at being denied access to the EU’s Horizon science funding programme, insisting that this is part of the Trade and Cooperation Agreement (TCA) and nothing to do with the Protocol.

"So far, London just seems to be involved in its own internal debate. It's a bit like the good old days when London negotiated with itself"

"The Commission is basically saying, well, we have profound legal concerns about your commitment to fulfilling your legal obligations under the Protocol," says one diplomat. "So, we can't admit somebody where we've got such profound concerns about their capacity to abide by their legal obligations."

The Irish Government, meanwhile, has been quietly lobbying leading political figures to convey the implications of the current course of action. "Anyone you can think of who may have had influence, or has influence, in the Conservative Party," says one Irish source.

And yet the machinations in Westminster suggest that such warnings are having no impact. "So far, London just seems to be involved in its own internal debate. It’s a bit like the good old days when London negotiated with itself," says the source.

The bill has been drafted since last autumn, and various hard and soft versions have evolved with the final course of action being chosen by Boris Johnson, with cabinet approval coming during the week.

In simple terms, a key choice has been whether the bill would immediately disapply aspects of the Protocol, or whether it will enable ministers in future to do that through secondary legislation.

As of Thursday, the drafting was finished, but there were still different versions there for the taking.

"Everything's been drafted," says one source familiar with the process. "Lawyers haven't been asked to draft anything new, so this is all now about the politicians putting the jigsaw together and deciding what bits they're going to put in and what they want to leave out."

On Tuesday, with most of the drafting done, there was a call between the Northern Ireland Office, the Foreign Office, the UK department of Agriculture (DEFRA) and a range of Northern Ireland stakeholders.

The presence of DEFRA officials appeared to be significant. For those who believed that the appearance of the bill itself would simply be to shock the European Commission into bigger concessions on how the Protocol works, this signalled a degree of detail surrounding a "dual regulatory regime".

This was announced by Liz Truss in the House of Commons on 17 May. It would be the engine to prioritise the UK internal market over the EU single market, by largely abolishing checks and controls on goods moving from Britain to Northern Ireland.

Under this idea, traders in Britain who were selling into the single market could choose to follow EU standards, and those who were just selling into Northern Ireland would follow UK ones.

Either way, the means of reassuring the EU that unregulated goods were not leaking into the single market across the land border would be to have robust "in-market surveillance" and criminal sanctions against traders who breached the arrangement.

However, Northern Ireland businesses, especially on the agri-food side, immediately saw where this might lead.

"DEFRA were talking about what needs to happen in a dual regulatory regime," said one source who joined the call. "Northern Ireland businesses say this will help businesses in Britain, but not Northern Ireland ones."

In other words, a dual regulatory regime for agri-food would be seriously problematic because of tightly-woven cross-border supply chains, and the mixing of ingredients from north and south, especially when it came to finished products being sent to the rest of the single market, or taking part in future EU-third country free trade deals.

The dairy industry was immediately alarmed. Northern Ireland sends one third of its raw milk (800 million litres per year) across the border for processing, but if Northern dairy cows were fed on British grain which was not produced to EU standards, then that milk would not qualify for processing in the South.

"It works currently because the whole of the supply chain is working to EU standards," says a senior Northern Ireland Dairy Council figure. "But if you have part of the supply chain that isn't working to EU standards then you can see the problem we have."

According to a number of sources on the call, the UK idea would be that the in-market surveillance would be such that the EU would not feel the need to put up a customs or regulatory border anywhere.

Such an approach is, as the sources pointed out, redolent of the "magical thinking" and "alternative arrangements" of 2017 and 2018.

Among the risks are the UK following through on its plans to diverge from EU standards.

"Say you have divergence in pesticide residue in food," says one senior agri-food industry source. "We bring it into Northern Ireland, but it doesn't comply with EU rules. So, it's circulating in Northern Ireland. What's to stop a farmer coming north to fill his trailer with wheat from Northern Ireland?

"He can't get it from England through Dublin because they're using banned pesticides. It’s more expensive elsewhere, so he comes north to get it.

"What does Ireland do when that happens? You can’t have that sort of stuff in the single market. Explain to me how we don't have a [sanitary and phytosanitary] land border, if we're running with one set of standards in Northern Ireland that Europe would not accept in the single market."

The source adds: "If the UK is going to make a success of this, they need to deliver in terms of internal market controls that prevent that happening. The degree to which they need to be robust is not to manage 70% of the risk when you're dealing with food. You need to deal with 100% of the risk."

However, with the furious back-and-forth on the drafts, it appears Liz Truss was receptive to the lobbying of the ERG and DUP who wanted to make sure the bill was not watered down.

Both the Financial Times and the Unionist Voice website reported talks between those groups and the Foreign Secretary on Tuesday. They wanted stronger language on the removal of VAT and the European Court of Justice (ECJ) from the Protocol, drafting which held up the publication of the bill on Thursday.

Unionist Voice suggested that the enabling powers the bill will give future ministers will be enshrined in a "constitutional framework" so that any trade between Britain and Northern Ireland (and vice versa) must ensure the "constitutional integrity" of the United Kingdom and be compliant with the 1801 Act of Union.

Needless to say, all these legislative moves will be regarded by EU member states as the UK entirely rewriting the Protocol on its own terms, to placate both the DUP and the ERG.

As of Friday, it appeared that the bill had dropped some of the detail of how the dual regulatory regime would work, and had placed more emphasis on powers that ministers could have in future, rather than what powers they would have immediately.

"That tells me they're looking for a get-out-of-jail card," says one official familiar with the drafting process. "It's heavier on the implied powers to ministers than giving them direct powers. That’s a way of saying, we're giving you powers but it's up to ministers how to use them.

"With the passing of the bill, it will allow the UK to soften its approach, rather than going in all guns blazing," said the official.

It is also likely that describing a dual regulatory regime in great detail in the bill will be a treacherous exercise, given how vividly Northern Ireland stakeholders have said it cannot possibly work.

Maros Šefčovič meets Liz Truss earlier this year

None of this is likely to reassure EU capitals. Maros Šefčovič, the chief Protocol negotiator, will issue a statement on Monday after the bill is published, and will brief EU ambassadors on Wednesday.

It's understood that the EU could unfreeze legal action against the UK shortly after that, and perhaps add more infringement proceedings to the list of non-compliance cases that were frozen.

What then?

The bill could be given a second reading on 20 June, at which point the UK government would spell out further detail on the bill’s intention. Downing Street would then hope the bill could reach committee stage before the summer recess.

That would mean amendments being added in the autumn (a febrile time with party conference season). This is where rebels could put hurdles in the way of the regulations that would start to disapply key parts of the Protocol, such as requiring a report by the Northern Ireland Affairs committees in both the Commons and the Lords.

This then turns Parliament into a bear-pit, reminiscent of 2018. Once again, the EU will see this as London brawling with itself.

There is some hope, albeit faint, that, as the bill makes its way through the Commons and to the Lords, negotiations will resume on the EU’s October proposals to make the Protocol more flexible.

"In that period, there would be a hope that some sort of continuation of discussion will be found before the legislation is actually enacted," says one EU diplomat, "and that London would see some sense and be prepared to investigate with the Commission more fully what the flexibilities the EU has in mind would actually look like if they were put into operation."

Given the hardening demands by the ERG and DUP, that seems unlikely. This is the corner that the UK under Boris Johnson has painted itself into.