When the Pennsylvania Supreme Court tossed out Bill Cosby’s conviction for sexually assaulting Andrea Constand and barred his retrial for that crime, Cosby’s survivors reacted with shock, outrage and sorrow. Their anguish was entirely reasonable: As survivors’ advocates have declared, the court’s decision does not exonerate Cosby.

But the stunning reversal shows that our criminal justice system is too often not ruled by law — it’s ruled by prosecutors.

The court concluded that it was unfair to secure justice for Constand because former prosecutor Bruce Castor promised in 2005 never to charge Cosby for raping her. Castor says he did that to help Constand win her civil suit against Cosby. If Cosby faced no criminal liability for the rape, the prosecutor claims he reasoned, Cosby could not invoke his Fifth Amendment privilege to avoid being deposed in the civil case. In the court’s view, Cosby relied on that promise when he testified at his civil deposition in 2005 and 2006. This made it unfair — indeed, a denial of Cosby’s right to due process of law — for subsequent prosecutors to use his deposition when their office ultimately decided to try him for sexual assault after all.

Commentators have struggled to make the court’s analysis intelligible to non-lawyers, with many calling the reasoning spurious and the evidence flimsy. Some allege that Cosby was freed on a technicality. Other critics point the finger at Castor. Still others express regret at Castor’s failure to take Cosby’s rapes seriously, but they uncritically praise the court for issuing a decision that upholds the rule of law.

These explanations are incomplete. Cosby was freed not for technical reasons but because upholding Castor’s promise promotes the substantive interests of the rich and powerful men whom our regime exists to protect. As tempting as it is to single out Castor, he is not solely responsible for a system that unabashedly gives men like him unfettered discretion to choose who should go to prison and who should not. There is a fundamental irony here: The court reversed a conviction on prosecutorial-misconduct grounds, but it did so in a way that reinforces — rather than checks — prosecutorial control over criminal cases.

Understanding the Cosby case requires examining the vast power entrusted to American prosecutors. Prosecutors call the shots in criminal cases. All of the shots. They decide who should be investigated, who should be charged, who let off the hook and what the precise charges, if any, should be. Prosecutors’ charging choices determine the severity of criminal sentences, giving them the upper hand — usually, the only hand — in the plea bargains that settle the overwhelming majority of criminal cases.

What mechanisms check the prosecutor’s work? One conventional answer is provided in an often-cited and ostensibly optimistic 1940 speech by Robert Jackson, who was then attorney general of the United States and went on to serve as a Supreme Court justice and the U.S. chief prosecutor at the international military tribunal at Nuremberg, Germany. In remarks to the Conference of United States Attorneys, Jackson asserted that our criminal justice system can be fair, even though it gives prosecutors “more control over life, liberty, and reputation than any other person in America.”

Jackson spoke bluntly about the dangers posed by the “immense power” our prosecutors wield. In his words, “the prosecutor at his best is one of the most beneficent forces in our society,” but “when he acts from malice or other base motives, he is one of the worst.” Moreover, Jackson said, the primary, if elusive, safeguard against prosecutorial abuse is the character of the prosecutor himself. We need not fear this “most dangerous power,” he reckoned, as long as prosecutors possess the qualities “which mark a gentleman,” are sensitive “to fair play and sportsmanship” and approach their “task with humility.” Jackson encouraged prosecutors to represent “all groups in [their] community,” including “those who are disadvantaged in the struggle for existence.” However, his rhetoric — the ideal prosecutor is a “gentleman” and a “sportsman” to boot — inevitably conjures up a privileged White man.

The Cosby debacle reveals some of the dire and all-too-real shortcomings in that vision, by exposing one form of damage inflicted by a system that vests unfettered discretion in one man when that man turns out to be both hubristic and sexist.

In fact, the crux of the court’s decision is that it is imperative to uphold prosecutorial hubris. In the court’s telling, about six weeks after Constand first complained to police about Cosby, Castor made the judgment that “Cosby was not getting prosecuted at all ever.” He never met with or consulted Constand before deciding that her rapist “would not be prosecuted no matter what.” When Castor issued a news release stating that he would not take Cosby to trial, he did so with the intent to act “as the sovereign Commonwealth of Pennsylvania” and with the belief that he had the power “to remove ‘for all time’ the possibility of prosecution.” In the court’s view, Castor’s confidence in his supreme authority was not misplaced: Indeed, the court declared, its own job was not to question, but to uphold, the prosecutor’s vast and “widely recognized power.”

Likewise, the opinion unapologetically testifies to prosecutorial misogyny. Again, without ever talking to Constand, Castor says he determined that a criminal conviction was “unattainable” because no jury would credit her testimony. His misgivings about her reliability rest on ancient — and thoroughly debunked — myths about the appropriate behavior of the truthful rape complainant.

As the court explained, Castor was troubled by Constand’s decision to wait almost a year before filing a police report. He was troubled when told that, over the course of numerous interviews by police, Constand said some inconsistent things. He was troubled that, after the assault, she remained in contact with Cosby. Weirder still, he claims he wanted to help Constand win civil damages — but he figured that a jury might think that she was just trying to get Cosby to pay her. In short, Castor invoked a whole array of false and sexist stereotypes to conclude that a jury would not believe Constand’s word about the crime.

There is one final irony that must be painful to the prosecutors who strive to be good ones, many of whom claim to have been inspired by Jackson’s advice. In the Cosby case, the court invoked Jackson’s “historic” and “eloquent” address when upholding Castor’s “exclusive authority and absolute discretion” over charging decisions. But the court never acknowledged that a system that valorizes the unchecked authority of the gentleman prosecutor also will be forced to uphold the damage inflicted by a prosecutor who, like Castor, acts without humility or respect for all members of the community. Now the results are plain to see.