IN A major vindication for Edward Snowden - and a blow for the national security policy pursued by Republicans and Democrats alike - the US Court of Appeals for the Second Circuit ruled last Thursday that the National Security Agency's (NSA) metadata collection programme is unlawful.
This is the most serious blow to date for the legacy of the Patriot Act and the surveillance overreach that followed 9/11.
The central question depended on the meaning of the word "relevant": Was the government's collection relevant to an investigation when it collects all the metadata for any phone call made to or from anywhere in the United States?
The court said no. That was the right decision - not so much because it protects privacy, as because it broke the bad precedent of secret law created by the NSA and endorsed by the secret national security court known as the Foreign Intelligence Surveillance Court.
The first striking thing about the court's opinion was how openly it relied on Snowden's revelations of classified material. The court described how the programme was known - by Snowden's leaks.
It also analysed the NSA order to Verizon, leaked by Snowden, that proved the existence of the programme and revealed indirectly the legal reasoning that the government relied on to authorise the metadata collection.
The Second Circuit seemed supremely untroubled by the origin of the information in a violation of classification laws.
At one point, it noted that the government disputed the claim that virtually all metadata are being collected - then dismissed the government's suggestion as unconvincing in the light of the evidence.
Today, it would seem, the Snowden revelations are treated as judicially knowable facts, at least in this court.
Then, there's the legal reasoning, which was equally striking. To get to the conclusion of unlawfulness, the Second Circuit initially had to find that anyone who has had metadata collected - that is, anyone in the US - has the right to sue and challenge the statute. The government said no one could challenge the NSA programme except the telephone companies, like Verizon, who received the order.
Its logic was particularly Orwellian. The Department of Justice argued that the Patriot Act demanded secrecy in reviewing challenges to the surveillance programme.
The secrecy, in turn, implied that the statute meant to preclude anyone from challenging the programme under the non-secret provisions of the Administrative Procedure Act, the catch-all statute for challenging unlawful government programs.
The Second Circuit wisely rejected what it called this "argument from secrecy". It reversed a lower district court that had refused to allow the suit to proceed, and set the stage for an analysis of relevance under the statute.
Relevance, the court said, should be measured the way the idea is used in ordinary grand jury investigations. That standard of relevant documents or objects to be brought under subpoena is pretty broad. It is often said a prosecutor could indict a ham sandwich. Well, a prosecutor can also subpoena the recipe the cook used to make it.
The government argued that this broad standard of relevance covered the metadata it has been gathering. After all, once the metadata is in hand, the government uses it to look for patterns connected to terrorism or other national security threats - so the body of data must be in this sense relevant to the investigation.
The court was not buying this expansive notion of relevance. It pointed out that only some of the metadata collected turns out to be relevant to investigations - meaning most or all of it does not matter at all.
Although the court did not use this language, it was essentially saying that the collection of all metadata is an over-broad search, well beyond even the most expansive conception of relevance.
The court did not address the question of whether it would be constitutional for Congress to order such broad searches; it just held that Congress did not intend to authorise them. That left Congress and the President with the option of changing the law to authorise the metadata collection, assuming political will were to exist.
This was the right result - but not necessarily because of privacy, which the court did not address directly at all. What was most wrong with the secret NSA orders was that they depended on a secret interpretation of the law, according to which "relevant" was assigned the broadest possible meaning. By implication, the secret intelligence court endorsed this interpretation. But the public never knew about it, at least not until Snowden.
Secret laws are anathema to democracy. The text of the Patriot Act was not secret, but the government's legal interpretation of it was. Secret interpretations of laws have the same effect as secret laws - and are, therefore, just as bad. The public cannot approve or disapprove of what it does not know.
Now that we do know, the Second Circuit will push the government to pass its next law, if any, with full public knowledge. That is democracy - and we have the courts to thank for it.
The Ninth and DC circuits have similar cases before them now. Here's hoping they rule the same way, and that the Supreme Court can then stay out of it. The legal story may or may not be over. But it should be.