In a sad irony, the uproar over how the military justice system handles sexual crimes may have cost the Pentagon one of its most impressive female leaders. Just before Veterans Day, the “permanent hold” placed by Sen. Claire McCaskill (D-Mo.) on Lt. Gen. Susan Helms’ nomination to co-lead Air Force Space Command prompted the general to request retirement.

Thus the Air Force loses the first U.S. military woman in space and the world record-holder for spacewalk duration.

Helms earned the ire of the senator last year by exercising her authority under the Uniform Code of Military Justice to overturn an officer’s court-martial conviction and impose nonjudicial punishment for a lesser offense.

Alas, the original crime was sexual assault, which became a radioactive issue after a series of shocking incidents and negative reports reflected poorly on the military. Given the narrative of a rape epidemic within the ranks, the kind of posttrial discretion that Helms possessed will soon be curtailed by Congress.

The question now is how much, not if, the system will change. The current proposals range from measured steps to increase transparency, to radical schemes aimed at upending the military justice system entirely.

But at the time Helms made her decision regarding the officer’s conviction, she clearly acted pursuant to her obligation to review matters submitted by the defense and her ability to modify court-martial results accordingly.

Nonetheless, McCaskill took the general to task for ripping away justice “with the stroke of a pen.” There was no discussion of whether Helms’ action was reasonable in light of the facts, only of the “damaging message” that clemency sends to victims writ large. The senator vowed to apply the same “great scrutiny” to commanders who do not rubber-stamp convictions in the future.

Given such a threat, the pending reforms before Congress to roll back command prerogative are probably unneeded. The few officers who reach ranks high enough to convene felony-level courts-martial will be deterred from using their clemency authority.

THE ATTORNEY’S ROLE

Worse, the criticism of Helms focused heavily on her supposed rejection of legal advice. In a floor speech that was only 413 words long, McCaskill denounced the general four times for ignoring the counsel of her staff judge advocate, or senior military lawyer. That lawyer later disputed this characterization, telling The Wall Street Journal that he agreed with Helms’ “evaluation of the case.”

Attorneys advise clients to help them make informed and lawful decisions. The attorney-client privilege exists specifically to encourage full and frank communications in this endeavor. But military lawyers don’t make commanders’ calls for them. Otherwise, there would be no need for commanding officers, and the armed forces would be run by lawyers.

This is just what some of the extreme proposals to remove criminal cases from the chain of command seek to do. For example, legislation sponsored by Sen. Kirsten Gillibrand (D-N.Y.) vests lawyers, rather than commanders, with responsibility for good order and discipline. McCaskill has wisely opposed Gillibrand’s amendment on the ground that commanding officers are best positioned to solve the sexual assault problem.

Second-guessing commanders for overruling their lawyers upends the latter’s advisory role and severs the trust that makes judge advocates so valuable to the military’s mission. Why should officers proactively engage their attorneys if failing to invariably heed their advice will be a black mark come promotion time?

What critics overlook is that commanders sometimes do act against the recommendation of counsel in ways that aggressively confront sexual crimes. Prosecutors evaluate whether to pursue a case based on the prospect of proving guilt beyond a reasonable doubt. Commanders, on the other hand, are primarily concerned with promoting discipline.

It is unexceptional for a commanding officer to refer a case to court-martial in order to send a message to the unit, even when the staff judge advocate believes the evidence is insufficient to obtain a conviction. In the civilian system, where lawyers decide if and how to charge the defendant, some of the cases that garnered negative headlines for the military may never have seen the inside of a courtroom.

Helms decided to convene a court-martial, discharged her statutory duty to review the result, and ultimately determined based upon the 1,054-page trial record that the government had not met its burden of proof. Those who cry “How dare she?” fail to understand that the court-martial is not a standing court, but a tool invoked by the commander to ensure a combat-ready force.

I cannot know whether the general’s conclusion was correct, but I am relatively certain that failing to follow her convictions would have spared Helms much subsequent grief. It would also have gotten us no closer to eradicating the scourge of sexual assault from the armed forces.

Recently, President Obama posthumously awarded the Presidential Medal of Freedom to astronaut Sally Ride, the first American woman in space. In the meantime, a fellow trailblazer in the NASA pantheon has ungraciously been shown the door after more than 30 years of military service.

That — not Helms’ legitimate exercise of posttrial clemency — is the real “damaging message” to America’s armed ­forces.

Charles G. Kels is a major in the Air Force Reserve and an attorney for the Department of Homeland Security. The opinions expressed are his own.