The Home Office never wanted this report. It was only after a string of stories about abusive guards and sexual attacks that Stephen Shaw's inquiry into Britain's immigration detention centres was even commissioned.

Even then, they tried to narrow its remit. It was limited to assessing detainees' welfare and there was to be no discussion about the principle of detention itself.

As if that weren't restrictive enough, officials also didn't want Shaw addressing the issue of how long detainees are held. Under the current system, they never know how long they'll be imprisoned. It could be hours or it could be years. That uncertainty can sometimes drive them mad. It is a uniquely bureaucratic form of mental torture.

Shaw refused to comply. It is simply impossible to assess detainee welfare without taking into account how long they're detained and the oppressive uncertainty of indefinite detention. "I have seen nothing in my terms of reference to prevent me discussing the length of detention," he wrote in the foreword, "and I have done so".

He's proved a more robust investigator than they anticipated. The report, which was published yesterday afternoon, is damning. It vindicates almost every argument made by campaigners against immigration detention centres. Its findings suggest that the current detention system fails on moral, practical, and financial grounds.

But Shaw is keen to spare Theresa May's blushes, so he doesn't make these findings explicit. They need some decoding.

In his conclusion, he finds that the academic literature "demonstrates incontrovertibly that detention in and of itself undermines welfare and contributes to vulnerability". He then says something very interesting:

"I need hardly say that a policy resulting in such outcomes will only be ethical if everything is done to mitigate the impact, and if countervailing benefits of the policy can be shown."

Shaw stops there. He doesn't say whether those conditions are met. So we have to piece together whether they are from the rest of his report.

It isn't hard. The sections on mitigating the impact of detention are pretty clear.

Campaigners attend a protest at Yarl's Wood detention centre in Bedfordshire

Shaw's review of the international evidence concludes:

"There is a consistent finding from all the studies carried out across the globe and from different academic viewpoints that immigration detention has a negative impact on detainees' mental health. The impact on mental health increases the longer detention continues."

That is particularly alarming given the UK has no time limit on detention and the Conservatives flatly refuse to institute one.

Shaw also finds that Rule 35, which is supposed to prevent victims of torture being forced into detention, "does not do what it is intended to do". He calls for a ban on pregnant women in detention and a "presumption against detention" for victims of sexual violence or female genital mutilation, people with learning difficulties, transgender people or those suffering from post-traumatic stress disorder.

So according to Shaw's own report, the impact of detention has not been mitigated.

On the "countervailing benefits" of the policy, Shaw is, if anything, even more critical. Detention is supposed to be a last resort to secure someone's deportation. But as public concern over immigration has increased, so has the size of the detention estate. It held 200 asylum seekers in 1987 and now has over 3,000. The number of people detained at one time or another during the year is ten times that.

Shaw concludes:

"My analysis calls into question whether there is… any correlation at all between the size of the detainee population and the number of successful removals of those with no right to remain in the UK."

He then adds, rather pointedly: "In this light, it is particularly surprising that the Home Office makes so little use of alternatives to detention."

So even on its own terms – as a method of ensuring deportations – the detention system is a failure.

Shaw's answer to his question is clear: no, everything is not being done to mitigate the impact of detention and no, the Home Office can't show the countervailing benefits of the policy. The conclusion is inevitable, by the standards he himself has set: Britain's immigration detention system is unethical.

The report recommends a reduction in the number of people being detained. "Immigration detention has increased, is increasing, and it ought to be reduced," Shaw writes. "If ministers and their officials decide to follow the direction pointed by my report, I trust they will do so boldly and without delay."

That demand couldn't come at a better time. The Home Office has been quietly putting the brakes on the expansion of the detention estate for months now. One centre was recently closed while another had its expansion cancelled. Campaigners suspect that the top of the department has become alarmed at the stories coming out the detention centres and the escalating costs of maintaining them. A series of internal reviews were commissioned. And then today's report came out.

The government response is encouraging – which isn't something you say very often when it comes to detention. It says it accepts "the broad thrust of [Shaw's] recommendations". It lists a series of reforms (the devil will be in the details) and then concludes:

"The government expects these reforms… to lead to a reduction in the number of those detained."

It is a sentence anti-detention campaigners have waited a long time for. The government is now explicitly aiming to detain fewer people.

It's not a total victory. There is nothing in the report – or the government response – about a time limit. And the managed decline of the detention estate will undoubtedly be done in the usual haphazard manner which the Home Office does everything. But the ship has started to turn.

Shaw may have spared the home secretary's blushes, but his report could be a turning point in the secret world of Britain's detention centres.