Criminal court proceedings are held in public and on the record for a reason: You can’t have a free society with secret arrests, secret trials and secret imprisonment. There are times when a detail here and there can be suppressed, but the default position should always be openness, even if that means some people are embarrassed.

District Court Judge Jeffrey Moskowitz appears to have temporarily forgotten this bedrock principle when he ordered journalists, including Scott Dolan of the Portland Press Herald, not to report on some testimony in a change-of-plea hearing Monday. The judge was persuaded to grant a demand of the defendant  – a prominent attorney – that the public be kept in the dark as part of a plea deal.

But the public’s right to know was not the judge’s to bargain with. Helping a defendant protect his reputation should not have outweighed the very strong public interest in holding criminal proceedings in full view of the community.

Moskowitz reversed himself Wednesday, rightly admitting that the gag order was a mistake. Moskowitz unsealed the case file and apologized to Dolan, calling his original order to be “clearly unlawful.”

The case involved charges of domestic violence, sadly an all-too-regular occurrence in Maine courts. But the identity of the defendant made this one stand out: Anthony J. Sineni III is a well-known criminal defense attorney who regularly appears in courtrooms around the state on behalf of his clients.

He entered the Cumberland County Courthouse on Monday facing five charges, including four felonies. He left with a sentence for two misdemeanors, both of which could be dismissed if he stays out of trouble for the next 24 months.

Such a deal is a sign that prosecutors had a weak case, and Sineni was able to bargain away the most serious charges by acknowledging that there would have been enough evidence to find him guilty of assault and disorderly conduct, though he did not admit to any wrongdoing.

Moskowitz, the judge, began Monday’s change-of-plea hearing with an order that the media not report testimony by Winona Hichborn, Sineni’s ex-girlfriend and the mother of his three children. The Press Herald defied the gag order and reported that in her testimony, Hichborn described her 11-year relationship with Sineni and made claims of domestic abuse.

Because of the outsized attention this case has received due to Sineni’s prominence and the involvement of children, the judge said he felt it necessary to keep that testimony from the public eye.

But in a judicial system that depends on transparency, that’s not his decision to make. The law is clear that these kinds of court proceedings are public, in cases large and small, high-profile and relatively anonymous. Charges are allegations of crimes not only against particular victims but also against the whole state. The public is a party to the case and has the right to know how it is resolved.

In ordering even partial media silence, Moskowitz took those rights away. He also granted Sineni a courtesy almost without precedent.

Moskowitz did the right thing Wednesday and reopened the case making sure that all of the information that should be public is finally put before the public, where it belongs.