President Barack Obama is under harsh attack for stating the obvious: No amount of government ingenuity will guarantee the American people 100 percent security, 100 percent privacy and zero inconvenience. He was answering a burst of more heated responses from left and right alike to the “news” that for years the National Security Agency has been collecting metadata about Americans’ phone calls and certain foreign Internet communications.

Legally, the president is on secure footing under the Patriot Act, which Congress passed shortly after 9/11 and has since reauthorized by large bipartisan majorities. As he stressed, the program has enjoyed the continued support of all three branches of the federal government. It has been free of political abuse since its inception. And as he rightly added, this nation has real problems if its people, at least here, can’t trust the combined actions of the executive branch and the Congress, backstopped by federal judges sworn to protect our individual liberties secured by the Bill of Rights.

In asking for our trust, Obama would be on stronger ground, of course, if the NSA controversy had not followed hard on the heels of the ongoing Benghazi, IRS and AP/​Fox News scandals — to say nothing of Attorney General Eric Holder’s problems. But give Obama due credit: We can recall no other instance in which he announced publicly that the responsibilities of his office have changed his mind. And for the better — here’s why.

In domestic and foreign affairs, the basic function of government is to protect our liberty, without unnecessarily violating that liberty in the process. The text of the Fourth Amendment grasps that essential trade-off by allowing searches, but not “unreasonable” ones. That instructive, albeit vague, accommodation has led courts to craft legal rules that, first, define what a search is and, second, indicate the circumstances under which one is justified. In the realm of foreign intelligence gathering, recognizing the need for secrecy and their own limitations, judges have shown an acute awareness of the strength of the public interest in national security. They have rightly deferred to Congress and the executive branch, allowing executive agencies to engage in the limited surveillance that lies at the opposite pole from ransacking a single person’s sensitive papers for political purposes.

That deference is especially appropriate now that Congress, through the Patriot Act, has set a delicate balance that enables the executive branch to carry out its basic duty to protect us from another 9/11 while respecting our privacy as much as possible. Obviously, reasonable people can have reasonable differences over how that balance is struck. But on this question, political deliberation has done its job, because everyone on both sides of the aisle is seeking the right constitutional balance.

In 1979, in Smith v. Maryland, the U.S. Supreme Court addressed that balance when it held that using a pen register to track telephone numbers did not count as an invasion of privacy, even in ordinary criminal cases. That’s just what the government is doing here on a grand scale. The metadata it examines in its effort to uncover suspicious patterns enables it to learn the numbers called, the locations of the parties, and the lengths of the calls. The government does not know — as some have charged — whether you’ve called your psychiatrist, lawyer or lover. The names linked to the phone numbers are not available to the government before a court grants a warrant on proof of probable cause, just as the Fourth Amendment requires. Indeed, once that warrant is granted to examine content, the content can be used only for national security issues, not even ordinary police work.

As the president said, the process involves some necessary loss of privacy. But it’s trivial, certainly in comparison to the losses that would have arisen if the government had failed to discern the pattern that let it thwart the 2009 New York subway bombing plot by Colorado airport shuttle driver Najibullah Zazi, an Afghan-American, who was prosecuted and ultimately pleaded guilty.

The critics miss the forest for the trees. Yes, government officials might conceivably misuse some of the trillions of bits of metadata they examine using sophisticated algorithms. But one abuse is no pattern of abuses. And even one abuse is not likely to happen given the safeguards in place. The cumulative weight of the evidence attests to the soundness of the program. The critics would be more credible if they could identify a pattern of government abuses. But after 12 years of continuous practice, they can’t cite even a single case. We should be thankful that here, at least, government has done its job and done it well.