A federal judge in Virginia has ruled that the government's terrorism screening database (TSDB) is unconstitutional because people on the list are not given an adequate opportunity to contest their inclusion. The ruling is a victory for a group of almost 20 Muslim Americans who sued the government over the list in 2016.

"There is no independent review of a person's placement on the TSDB by a neutral decisionmaker," Judge Anthony Trenga wrote on Wednesday. "Individuals are not told whether or not they were or remain on the TSDB watchlist and are also not told the factual basis for their inclusion."

As a result, the judge concluded, the watchlist system is unconstitutional.

The government maintains several different lists for suspected terrorists. These include the no-fly list, which, as its name implies, prohibits certain people from flying in the US. The TSDB is a larger list believed to hold more than a million names . People on the list aren't prohibited from flying, but they can face unpleasant consequences when they travel, especially internationally.

For example, in 2015, one of the plaintiffs, Anas Elhady, returned to the United States by car after a visit to Canada. According to Wednesday's decision, the American citizen "was surrounded by [Customs and Border Patrol] officers, handcuffed, and then escorted to a room where he was held for more than ten hours and repeatedly interrogated about his family members and other associates." During his interrogation, Elhady "required emergency medical attention" so he was taken in handcuffs to a nearby hospital, treated, and then taken back in handcuffs.

This was at least the third time Elhady had faced multi-hour detentions when trying to cross the border. He wasn't charged with a crime after any of the interrogations.

The government's position is that it can't tell Elhady if he's on the terrorism watchlist because doing so would compromise its counterterrorism efforts. If he is on the list, he doesn't have any way to find out why he is on the list or to provide the government with information to clear his name—for example, by demonstrating that the government has him confused with another person with the same name.

That, the judge said, violates the Constitution, which guarantees due process before someone can be deprived of his rights—including the right to travel.

The current system "provides no notice concerning whether a person has been included or remains in the TSDB, what criteria was applied in making that determination, or the evidence used to determine a person's TSDB status." The judge concludes that the current system "does not provide to a United States citizen a constitutionally adequate remedy under the Due Process Clause."

What's not yet clear is how much the government will need to change its system. Trenga acknowledged that full transparency—for example, notifying someone as soon as they were added to a list—could endanger national security. So the government will still be able to keep some aspects of the list secret.

But the details still need to be worked out. Judge Trenga ordered both sides in the lawsuit to propose changes that could address the system's constitutional defects. Based on those proposals, he'll issue a more detailed ruling in the future. We can also expect the federal government to appeal Trenga's ruling, so this legal fight is far from over.