As long as Donald Trump is president, American criminal justice reform may depend on the states. So it’s significant that in one state, Massachusetts, a national model for remedying wrongful convictions has recently been created.

In late November, the Massachusetts Attorney General and state district attorneys — in response to a lawsuit by the state’s public defenders (the Committee for Public Counsel Services), the ACLU of Massachusetts, and the law firm Fick & Marx — agreed to move forward with the dismissal of more than 8,000 drug convictions tainted by the misconduct of Sonja Farak, a former state crime lab chemist, and by the misconduct of former state prosecutors. This news follows the record-setting dismissal, in April, of 21,839 drug convictions tainted by the misconduct of Annie Dookhan, another former crime lab chemist.

That’s roughly 30,000 tainted convictions that have been, or soon will be, dismissed. It’s an astonishing number. And it represents a dramatic turn of events.

In 2012, when news broke that Dookhan had falsified evidence in thousands of cases, prosecutors were not prepared to walk away from the convictions secured with Dookhan’s help. In the press, the district attorneys claimed their “primary concern” was to see “that justice is done.” But, in reality, as they later acknowledged in a 2016 court filing, they sought to “protect” convictions secured with Dookhan’s help.

Likewise, following Farak’s 2013 arrest, district attorneys pledged to be “proactive” in identifying tainted cases and notifying defense lawyers. But most DAs didn’t fulfill that pledge. Worse yet, the state’s Attorney General’s Office, which possessed crucial evidence about the extent of Farak’s misconduct, withheld that evidence and deceived a court about its existence.

So what turned rank intransigence into mass exoneration?

In short, civil rights litigation changed the legal rules for challenging Dookhan and Farak convictions, making it easier for people to challenge their wrongful convictions and harder for prosecutors to protect them.

Traditional litigation is ill-suited to clearing convictions tainted by government misconduct. There is no uniform protocol for notifying affected defendants, and defendants who do receive notice face a grueling path to justice. They need lawyers. Typically, they must bring cases one by one. And even if they clear their wrongful convictions, they may face re-prosecution.

These obstacles enable prosecutors to retain tainted convictions, and that’s exactly what happened in Massachusetts. Many DAs declined to notify wrongfully convicted people. And, through misconduct, the Attorney General’s Office prevented thousands of Farak defendants from learning that their cases were tainted.

In theory Dookhan and Farak defendants could challenge their convictions, but in reality, few defendants knew where to find the courthouse doors. The ones who did were afraid to knock.

That made no sense. The duty to address wrongful convictions should be on the state, not the wrongfully convicted defendants. So civil rights lawyers brought court cases designed to shift the burdens of addressing wrongful convictions. And, in a series of rulings, the Massachusetts Supreme Judicial Court did just that.

In 2014, the court announced a “conclusive presumption” of egregious government misconduct in every one of Dookhan’s cases. This presumption relieved each defendant of having to prove Dookhan’s misconduct in his or her case, a burden that the Supreme Judicial Court recognized was unfair and, in almost all cases, impossible to satisfy.

In 2015, the court created what has been called an “exposure cap.” The cap provided that when a defendant had a wrongful conviction successfully vacated, that defendant could not be sentenced to additional imprisonment in the same case, even if re-convicted at trial. The “exposure cap” was critical because, early on, prosecutors aggressively pursued people who challenged their wrongful convictions, and at least one person was re-convicted and sent back to prison to serve an even longer sentence.

Finally, in January 2017, the court gave prosecutors a deadline of 90 days to schedule “large numbers” of Dookhan’s cases for dismissal. This deadline flipped the customary rules that defendants must affirmatively challenge each conviction.

These rulings transformed the usual inertia sustaining wrongful convictions into new momentum favoring dismissals.

In April 2017, the district attorneys not only agreed to drop more than 21,000 Dookhan cases — the largest single dismissal of wrongful convictions in U.S. history — they also worked with defense attorneys on a first-of-its-kind notice campaign featuring a hotline, letters, a video from the court’s chief justice, and even prosecutor-funded Facebook ads.

With that model in place, it became impossible for Farak convictions to stand. CPCS, the ACLU, and Fick & Marx sued in September 2017, and the district attorneys have now agreed to thousands of additional dismissals. As a result, thousands of people across Massachusetts may have a better chance to rebuild their lives and free themselves of the crippling collateral consequences of tainted drug convictions.

There is still much to do. Some DAs argue that they can keep some Farak convictions. And although the Attorney General’s Office has finally admitted that two of its former state prosecutors exacerbated the Farak scandal by committing misconduct, it has yet to agree to a meaningful remedy for that misconduct — above and beyond the dismissals warranted by Farak’s misconduct.

But this litigation has already delivered a new, prosecutor-based model for addressing wrongful convictions. It has also delivered an important lesson: Remedying wrongful convictions isn’t just about good science, it’s also about good law.