In December 2016 a young offender was found guilty of hitting another inmate over the head with a meal tray at the Edmonton Young Offender Centre (EYOC).

But provincial court Judge Geoffrey Ho has stayed the charge after concluding Brandon was unlawfully placed in solitary confinement for about two years starting when he was 16.

In his 20-page decision released on Tuesday, Ho said Brandon's segregation, which he described as a "prison within a prison," contravened Canada's obligations under the United Nations Convention on the Rights of the Child, and violated the Youth Criminal Justice Act.

A pseudonym is being used because Brandon, now 19, was a youth at the time of the July 2016 offence. In court documents he's referred to as CCN.

"CCN was unlawfully placed in solitary confinement for long periods of time before and after the date of offence," concluded Ho. "This has prejudiced the integrity of the justice system and the only way to disassociate the justice system from the unlawful solitary confinement of CCN is to order a stay.

"Corrections officials chose to place CCN in solitary confinement rather than provide the appropriate programs to assist in his rehabilitation and reintegration," said Ho. "The likely result of this approach was to make CCN a greater risk to the public."

Ho added "this is not a momentary detention or an isolated issue. It is systemic."

He said it was noteworthy that unlike Alberta, Ontario places legislative restrictions on the maximum time a young person can spend in segregation.

This is not a momentary detention or an isolated issue. It is systemic - Judge Geoffrey Ho

As Ho wrapped up his decision, defence lawyer Karen McGowan turned toward her client, who smiled and gave a thumbs-up sign from the prisoner's box.

Brandon, dressed in an orange prison jumpsuit with a new blue cross tattooed prominently at his eyebrow centre, is back in custody. He was released last November but he's now awaiting trial on robbery charges and has also served short sentences for possession of a dangerous weapon, obstructing a peace officer and breaching conditions.

Tuesday's ruling came after three days of testimony last November and April from Brandon, his long-time caseworker, and a neuropsychologist.

They were called by McGowan, who argued Brandon's ongoing solitary confinement amounted to "physical and psychological abuse."

McGowan also cross-examined EYOC director Shawn Rainault after court was notified on the day he was scheduled to testify he would no longer be a Crown witness.

Lawyer Karen McGowan says her client wasn't given the opportunity to be rehabilitated because of his ongoing placement in segregation. (CBC/John Shypitka) Crown prosecutor Aleisha Bartier, who was seeking time served for the tray-assault, presented no evidence.

In his summary of the evidence Tuesday, Ho said Brandon was segregated from August 2015 to July 2017 in Edmonton as well as the Calgary Young Offender Centre. That ended when he was transferred to the Edmonton Remand Centre at his own request, when he turned 18.

Ho said evidence showed Brandon was "repeatedly effectively solitarily confined for more than 22 hours per day without meaningful human contact."

In Edmonton units, "they are not allowed to talk to other young persons," said Ho. Court heard Brandon would create disruptions to be moved to a specific unit monitored by video, rather than guards, where he could talk to other young offenders under the door.

Out of boredom, Brandon acknowledged he would act out, including assaulting and threatening guards and inmates, Ho said.

"He has hit an inmate over the head with a meal tray during lunch on more than one occasion," Ho said.

'Nelson Mandela rules'

Ho said Rainault was "very reluctant" to acknowledge that Brandon's confinement of up to 23 hours a day constituted solitary confinement or segregation.

But the judge stated 22 hours a day or more without meaningful human contact is considered the international standard for solitary confinement, also known as the "Nelson Mandela rules."

Ho said Rainault testified that "dorm confinement" of 23 hours a day is regulated by policy that requires the executive director to approve beyond 72 hours.

But the judge said "youth are not advised of any right to have an advocate or lawyer present" before a behavioural incident review panel.

Court also heard Brandon was denied visits on occasion from a case worker and a youth facilitator.

The judge said such evidence contradicted "Rainault's assertion that generous time is provided to persons in segregation outside of the two one-half-hour periods they are allowed to be outside their cells."

Hopefully these kind of things won't happen in the future - Lawyer Karen McGowan

Ho also highlighted neuropsychologist Jacqueline Pei's expert testimony that concluded isolation is the opposite of what should be done for high-risk youths such as Brandon.

When asked about behaviors following segregation, Pei described the impact of high stress of someone who sees the world as a threat and needs to control the situation, Ho noted.

"There will be increased likelihood of aggressiveness, and increased likelihood of violence, increased likelihood of provocative statements that could lead to an altercation," concluded Pei.

McGowan said after the decision, she gave Brandon a hug. She said Ho did a "thorough job" and she was elated by his ruling.

"It would appear at least as far as Brandon's situation is concerned that they violated not only local law but international law as well and hopefully these kind of things won't happen in the future," said McGowan.

Kathleen Ganley's press secretary said the Alberta justice minister was unavailable for an interview.