The Petraeus affair — like some Ethics 101 thought experiment — is an exceptionally difficult test case in determining the proper relationship between personal ethics and public trust. When should you forgive an indispensable leader a fatal flaw?

Retired Gen. David Petraeus has made a career of indispensability. He defined and implemented the counterinsurgency doctrines that brought about a decent outcome in Iraq — avoiding a setback at the heart of American interests that would have been more demoralizing than Vietnam. He left his imprint on a generation of officers who have emulated his strategic flexibility and intellectual rigor.

There is a reason Petraeus generally received good press, even from those skeptical of American military involvement in Iraq and Afghanistan. During briefings and discussions, he was supremely informed and often breathtakingly candid — an attribute that involves risks but establishes credibility. He possesses a comprehensive knowledge of leaders and events in the Middle East and Central Asia. His career had not only been successful; it demonstrated that America is capable of complex international responsibilities. Petraeus is a generator of national confidence.

So why, exactly, should marital infidelity be disqualifying? This is not an easy or simple determination in any field of public leadership and responsibility. With human beings, it is necessary to leave room for complication. A person who cheats on his or her spouse can show courage on the battlefield or loyalty to his or her country. Faithlessness in one area does not extend to every area. Most people have hidden flaws and failures of various kinds, which may or may not have broader relevance to their work.

So we are forced to make professional judgments. It matters little if our surgeon is prideful or our airline pilot is a miser. It matters greatly if either abuses alcohol. A priest can’t be a gossip. A CFO can’t be forgiven just a little embezzlement.

We also make practical distinctions on sexual issues such as adultery. All infidelity involves personal betrayal. Innocent people — spouses and children — suffer unfairly. But some adultery also involves exploitation, compulsiveness and the abuse of power — failures we rightly judge more harshly.

Expectations of personal behavior in the national security professions have generally been higher than other fields, particularly for officers and leaders. In the military, sexual intrigue can undermine morale and discipline. Adultery can land you in prison for up to a year — though the rule is seldom enforced in the absence of other crimes such as lying to superiors or disobeying orders. In the intelligence world, sex has long been used as bait and blackmail — the “honey trap” — though I’d imagine that plain old infidelity at the CIA is not unknown or uniformly punished.

By all accounts, Petraeus’s personal failure did not involve the abuse of power, criminal acts or security breaches. But his case also demonstrates how messy infidelity can quickly become — messy enough to involve harassing e-mails and to attract the attention of the FBI. People at their most ardent are also at their least rational. And this is most damaging in fields, such as intelligence, where the essence of leadership is judgment.

Petraeus might have fought for his job. America’s 42nd president, after all, once did the same. Instead, Petraeus admitted to showing “extremely poor judgment.” And it is hard to argue with him. “Such behavior,” he told the employees of CIA, “is unacceptable, both as a husband and as the leader of an organization such as ours.” After a career dedicated to high standards, Petraeus chose to apply those standards to himself.

The rest of us, unfortunately, are left without the services of an exceptional public servant. We are also left to ponder the conflicted nature of many successful leaders. There seems to be some connection between self-confidence, charisma and personal recklessness. For some, it is the expression of hubris — the thrill of living by a different set of rules than normal mortals. For Petraeus, it seems more like hamartia — the fatal flaw or error of an honorable man, resulting in disproportionate misfortune. This is the essence of tragedy — in this case, a tragedy for himself, his family and his country.

Yet an exceptional life cannot be reduced to its lowest moment. Petraeus’s judgment was poor. His career was needlessly shortened. But nothing that Petraeus has contributed to his nation has been undone.