Samantha Power has always had a self-righteous streak. She freely admits the “certitude” and “sanctimony” of her younger self. After a few years as a correspondent covering the Bosnian war, she found that her new Harvard Law School classmates didn’t know or care about the genocide unfolding there, so she stuffed a New York Times report on the Srebrenica massacre into every first-year’s mailbox. Her scholarship and activism on that topic culminated in “A Problem From Hell,” her incredible 2002 history of American apathy during the 20th century’s worst ethnic conflicts. The Pulitzer Prize-winning book held that officials justified noninterference when even minimal efforts, from public shaming to sanctions, could have saved countless lives. “Decent men and women chose to look away,” she wrote. Power was, in this period, a voice of piercing moral clarity.

Then she went to work for Barack Obama.

During her stints with him in the Senate, on the presidential campaign and inside the White House, pundits and critics wondered how the human rights advocate would reconcile her belief that America must act to protect vulnerable people with the dirty business of policymaking, where concessions taint every action. She finally answers in “The Education of an Idealist,” her new memoir. It’s a confusing title, because Power never becomes disillusioned, never sheds her views, never admits that governing and certitude are awkward bedfellows. It’s unclear what “education” she received; scales do not fall from these eyes. “The old and new Samantha know each other quite well,” she writes. “They talk all the time.”

That’s a difficult proposition to swallow from someone who worked for an administration that assassinated hundreds of enemies (and bystanders) by drone and failed to take any action when Syria gassed its own citizens, crossing Obama’s declared “red line.” What happened to holding killers accountable? Had a decent woman chosen to look away?

Yet Power’s apologia is insistent — and unexpectedly compelling. She cannot justify every administration policy, and she flays many of its most cynical decisions, such as Obama’s broken campaign promise to recognize the Armenian genocide. This tale is filled with half-measures, disappointments and bureaucratic defeats (a far cry from the usual autobiographical victory tour). But Power argues that activism on the inside, even when it fails, is no betrayal of pressure from the outside. “The reason I was exercising my voice before was to influence people in jobs like the one I now have,” she tells friends. “A voice is not an end in itself.” Power uses her position to agitate for refugees, rape victims, persecuted LGBT populations, political prisoners and oppressed minorities everywhere. She isn’t in charge, and she often fails to persuade her colleagues. (“We’ve all read your book, Samantha,” Obama snaps during one Situation Room meeting.) But she walks away with a list of real human rights accomplishments that may not have happened if she hadn’t joined up. “Better is good, and better is actually a lot harder than worse,” Obama reassures her.

Government service is a big adjustment, and at first Power hates it. Some of her co-workers believe that human rights are “in tension with, if not antithetical to, our traditional security concerns,” she writes, a challenge to her work overseeing multilateral affairs and human rights for the National Security Council. She is annoyed that regional experts, government lawyers, press officials and congressional liaisons all get to weigh in on (and dilute) her every proposal: “I was stunned by the number of cooks in the kitchen.” And on big topics — whether to join a land-mine treaty or how to partner with the authoritarian Chinese government to contain North Korea — she complains that she is “not respected, not effective.” “I did not have the relationships, the clout, or the mastery of bureaucratic processes I needed to maximize my impact.”

In a chapter called “Turnaround,” she explains how she found her groove. The late diplomat Richard Holbrooke tells her not to waste time where she can’t make a difference: “Go where they ain’t.” She realizes that doggedness really leads to progress, so she picks her goals more judiciously. As a result, she opens America’s doors to Iraqi refugees who had aided the U.S. reconstruction effort. She makes friends with several female National Security Council aides, and they confide in each other and share tips, even when they disagree on policy matters. (Obama’s council “was the most male-dominated place I had ever been in the United States.”) She sets up an atrocity-prevention unit, so the government has a mechanism for spotting massacres around the world before they happen. In her telling, she rescues a lackluster draft of Obama’s Nobel acceptance speech with a new framework, and they pull an all-nighter with his speechwriters revising it. She sends her husband, Cass Sunstein, another Obama aide who worked on domestic policy, a one-line email. “Revelation: I love my job.”

The greatest challenge to Power’s idealism comes out of Damascus in 2013. When Syria’s government kills 1,400 civilians with sarin in an opposition-held suburb, Obama initially surprises her by ordering unilateral airstrikes. She is by then the U.S. ambassador at the United Nations, and he tells her to get U.N. officials out of Syria. But the secretary general declines — he doesn’t want to seem like he’s paving the way for American bombs — and by the time the officials conclude their work, 10 days later, Obama has changed his mind. Now he wants permission from Congress for a strike.

Power is aghast, and she rues not criticizing this move more forcefully. “I phrased my apprehension as a question,” she says, recounting a key meeting. “What happens if Congress doesn’t support you? Does that mean Assad could just keep using chemical weapons, and they would become like a conventional weapon of war?” Obama is convinced that lawmakers will back him. Of course, they don’t; their constituents revile the idea of another conflict. (As Power had written in “A Problem From Hell,” “It is in the realm of domestic politics that the battle to stop genocide is lost.”) So President Bashar al-Assad suffers no consequences. “Assad could reasonably conclude that, going forward, he could starve his people into submission, carpet bomb hospitals and schools, and eventually even resume chemical weapons attacks.”

She mulls whether to quit, but a mentor points out that “there will just be more like-minded people in the Situation Room.” And so she otherwise plays the good soldier. As the administration rushes to normalize relations with junta-led Myanmar, she objects that the country isn’t changing quickly enough to justify dropping sanctions. The dissident Nobelist Aung San Suu Kyi agrees, arguing that a planned visit by Obama would reward the regime. But when Obama dispatches Power to convince Suu Kyi — who horrifies Power by essentially excusing the slaughter of Muslim Rohingya — Power does as she’s told. Later, she partly redeems Obama’s inaction in Syria by negotiating a U.N. Security Council resolution, alongside her Russian counterpart (an avuncular but stubborn foil during her years in Turtle Bay), to destroy some of Assad’s chemical weapons.

A leitmotif is Power’s changing relationship with Obama as the presidency weighs on him. The two grow authentically close during his Senate years, and they swap jokes and emails. Then he wins the White House. The warmth isn’t gone, but responsibility crowds it out. One time, he stops by for a friendly hello, and she blurts out her position on something. “I saw his shoulders stiffen, and he said he had to get to another meeting,” she laments. “He had the power to order officials in the government to take action on almost any issue in the world. This meant that when I raised a foreign policy topic with him, I wasn’t launching an interesting discussion. Rather, I was making an implicit demand.” Uneasy lies the head that wears the crown.

Still, Obama seems to want her around to needle him. He asks her to lunch so he can learn “what ideals we have betrayed lately.” When conservative pundits say that Power blasted Russia’s 2014 Ukraine invasion more eloquently than Obama had, White House aides tell her to “dial it back.” She asks Ben Rhodes, Obama’s top confidante, if that’s really what the president wants. “Why the hell do you think I put Samantha up there?” Obama tells him. “She is doing exactly what she should be doing.”

She guards her integrity covetously. Power refuses to become “a Washington a--hole” by dodging questions at her ambassadorial confirmation hearing, exasperating the aide seeing her through the process. And in the book’s most astonishing anecdote, she disobeys instructions from the White House to vote for Russia’s accession to the U.N. Human Rights Council. (The United States and Russia always vote for each other to join various bodies, as an established “courtesy.”) She can’t bring herself to do it, so she picks Croatia instead, and that nation wins. For Power, who doesn’t tell us how her administration colleagues reacted to this revolt, mutiny is not too high a price to pay for honor.

Power writes with heart about her upbringing — in Ireland, Pittsburgh and Atlanta — and she is especially poignant when recounting a few traumatic episodes: the deaths of her alcoholic father and of Toussaint Birwe, a Cameroonian 6-year-old killed when a car in her convoy strikes him. Still, the book is suffused with humor, and the president furnishes the funniest anecdotes that don’t come from her charming children. “Cass?! Cass Sunstein? He’s a total slob,” Obama exclaims when he learns of her new romantic interest. Then he thinks better of this outburst and offers that Sunstein is “brilliant, creative, and kind.” After she and Sunstein move in together, they make a deal. Every time he leaves the apartment, “he has to carry at least one item with him to the dumpster (eg, argyle sweaters and ‘Members Only’ jackets, Red Sox season guides from the pre-steroids era, his prior tenant’s water color paintings, 1993 University of Chicago environmental law exams . . .).”

Most matters that demand Power’s moral clarity get it: She skewers the misogynistic metaphors of government (why must a country “show some leg” to telegraph interest in a deal?), for instance, and regrets not heading off a Weinstein-like situation when the Bosnian prime minister greets the young reporter for a hotel-room interview wearing his bathrobe.

A few issues, though, receive a more muddled treatment. Power notes that Obama decided not to publicly back Iran’s Green Revolution, “fearing that offering his vocal support would allow the Iranian government to caricature protesters as American-backed agents.” We never learn what she thinks of his silence. She spends long passages recounting Obama’s reasons for not doing more to help Syrian rebels or Libyan civilians after the fall of Moammar Gaddafi, even when it’s clear she believes these are rationalizations. In a baffling choice, Power says nothing at all about the administration’s favorite tactic for battling Islamist militants: targeted assassination.

Even so, “The Education of an Idealist” is a moving account of how to serve righteously, or at least how to try. It’s true that Power never travels any kind of character arc; she does not meaningfully change, even as she accepts the exigencies necessary to govern — and that is to her credit. Her education is not about compromising her ideals for influence but about figuring out how to deploy them to move a bureaucracy. Isn’t that what we should expect from our public servants?

Twitter: @AdamBKushner