After a decade of being able to do pretty much whatever it wants, whenever it wants, America’s top spy shop, the National Security Agency (NSA), is running into some roadblocks.

It’s about time.

First, the NSA’s extensive phone- and Internet-tapping intelligence programs are about to get reviewed in a public court of law. That’s thanks to an opinion handed down by U.S. District Court judge Richard Leon, which raises questions about whether the NSA’s surveillance is constitutional.

Second, the Obama administration’s review of the NSA’s surveillance programs has delivered its preliminary report to the president, and sources tell Politico that the report pulls no punches. Far from being the whitewash many of us expected, the report “recommends sweeping and far-reaching changes in the way the NSA conducts its electronic surveillance operations, from a greater degree of executive-branch oversight of the agency’s operations to the imposition of new limits on what data it can collect,” Politico writes.

First the judicial branch rebukes the NSA, then the executive branch does it. Will the legislative branch complete the circuit in 2014, delivering its own spanking to the agency via a congressional resolution or a new law? We can only hope.

The problem, as I see it, is that the NSA has operated pretty much without restraint since 2001.

While the agency has had plenty of facetime with lawyers and judges so far, most of them have been in secret meetings, as the New Yorker‘s Ryan Lizza recently reported in great detail. Take, for example, the Foreign Intelligence Surveillance Act (FISA), which specifies that a secret court must make decisions about any agency spying that happens in the U.S. But the FISA court is overseen by a single judge, with presentations made by a single lawyer (the NSA’s), and with no counterarguments. When the FISA court rules — as it repeatedly has — that the NSA can go ahead and collect all the data it wants, with almost no restraint, the legal grounding for that opinion is kept under lock and key.

The result is that no one — not even members of the Senate Intelligence Committee — knew exactly what the NSA was up to. At least until former NSA contractor Edward Snowden’s documents started appearing on the Guardian, the New York Times, and the Washington Post.

You can say what you want about the legality of Snowden’s “liberation” of NSA documents. It was probably illegal. But then, so was Daniel Ellsberg’s theft of the Pentagon Papers, and Ellsberg is considered a hero now, living in comfortable retirement in Berkeley, Calif. after having helped end one of the most useless wars in American history.

There’s a greater good to be considered in the Snowden case, too: keeping the country’s top surveillance and security agency in check.

When, in history, has a spy agency willingly regulated itself? Without serious oversight, even the most well-meaning intelligence agency can quickly overstep the bounds of what is reasonable and just. I’m certain that the NSA is full of well-meaning individuals, and I’m not questioning the urgency of their need to identify and stop terrorist plots.

It’s just not possible to have a meaningful democracy in a world where there is no possibility of private thought and conversation, as Dave Eggers’ book The Circle so chillingly showed — or as the residents of the former East Germany could also tell you.

Now, Judge Leon stopped short of saying that what the NSA is doing is unconstitutional, but he did say that there was enough evidence to allow plaintiff Larry Klayman’s lawsuit to go ahead — and that Klayman has standing to bring a constitutional suit.

This is a good thing. The problem is not so much that the NSA, and other spy agencies around the world, are collecting data on us — the problem is that their data collection is so unfettered and unavailable to public scrutiny. We don’t know what they’re collecting, how they’re gathering it, or how much of it they have.

It’s time for the NSA to bring its surveillance programs into the open just a bit more. Let it approach a panel of judges, instead of a single FISA court judge, and let the proceedings of those court dates be accessible to more people — at a minimum, to the members of congressional oversight committees. Let it defend the constitutionality of its programs in court. And give it some meaningful oversight by the administration.

And, here’s a radical suggestion: Declassify the NSA’s data-collection programs every five years. By then, technologies will have moved on enough that today’s techniques will no longer be useful, anyway — and the prospect of eventual accountability will help keep the nation’s top spy agencies just a little more honest.