If you were an ATF agent or prosecutor handling the case of Joseph Roh, you probably lost quite a bit of sleep over the past five years. That’s because Roh, who was charged in 2014 with illegally manufacturing and selling AR-15 rifles in California, recently almost forced a judge to upend decades of ATF precedent and policy by recognizing the AR-15 rifle doesn’t technically meet the legal definition of a firearm.

Mr. Roh’s attorney made a surprisingly simple argument in court that got him off the hook — and it almost demolished the ATF’s very definition of what a gun is, too. Through a series of concessions and deal-making, Roh walked free. The ATF agreed conditionally to drop all charges, thus avoiding setting a precedent that could have (and perhaps still could) theoretically de-regulate every AR-15 currently in existence. Yes, that’s correct.

Understanding how one man and his attorney nearly tore down decades of legal precedent (rather than being convicted for a crime that is patently illegal) means going back to 2012, seven years before the judge’s final ruling. Joseph Roh owned and operated a machine shop in Los Angeles, taking advantage of a little-known statute in the Gun Control Act of 1968: One section of the Act allows any private individual to build a firearm at home for personal use if they can otherwise legally own a gun. No paperwork is required by the ATF to do this. Since the parts needed to build a gun aren’t regulated by federal law, anyone can purchase them.

Roh sought to exploit this.

He purchased firearm receiver blanks in bulk, often called 80% lower receivers by the gun community. With some basic cutting and drilling, such blanks can be transformed into a functional receiver, an item that is legally considered a gun in the eyes of the ATF. Roh offered his warehouse as a workshop to fabricate these blanks and assemble their guns. But the law requires that the gun-owner-to-be must perform the work, not a machine shop or gunsmith. To argue the case that his customers were building their own guns and not him, Roh programmed an automatic milling machine to cut and drill the receivers. He would instruct customers to put the receiver in the machine, press a button, and let it go to work.

Roh also charged customers $25 to claim he was renting the equipment and not gunsmithing for the general public. With a customer’s receiver fabricated, Roh could then provide all the other parts required to complete the gun — barrels, triggers, bolts, and everything else needed to make the gun functional. The ATF had been monitoring Roh’s operation for years before descending on his workshop in 2014. Agents sent Roh a cease-and-desist letter (which he disregarded) before setting up a sting operation to purchase one of his home-brewed rifles. Prosecutors charged him with illegally manufacturing guns a month later.

Few facts were disputed in this case. Roh opted for a bench trial, avoiding the nuances of a jury trial and allowing for a single judge to interpret and apply the relevant laws. He was ultimately charged and convicted of selling completed firearms without a license (FFL), which he served no time for. We’ll explain why shortly. The bombshell, however, was that Roh couldn’t be charged with illegally manufacturing firearms — and it wasn’t because his customers were the ones pressing the button. Confusing? Very. The reason for your likely confusion is also the reason why the ATF agents and prosecutors handling this case likely lost quite a bit of sleep.

Joseph Roh is seen on a hidden body camera showing off a freshly minted AR pistol to undercover ATF agents at his workshop. Roh was later charged with manufacturing firearms without a license.

The ATF’s definition of a firearm, which it has relied on for decades to set policy and charge individuals like Roh with certain gun crimes, is most likely invalid. This fact has been a long-held-but-open secret for some time, and the case of Joseph Roh almost put this discrepancy up against a legal test that it couldn’t defeat. Prosecutors in North Carolina also abandoned a case against a convicted felon named Alejandro Jimenez after a judge found that the AR-15 lower receiver he was accused of illegally purchasing didn’t meet the definition of a receiver (a firearm) under federal law. Save for then-Attorney General Loretta Lynch advising lawmakers of the issue, the case and its subsequent dismissal drew little attention.

That’s why this same disconnect between federal law and ATF policy applies to Roh’s case.

Roh was on the ATF’s radar for two years before his indictment in 2014. In 2012, he was selling 80% lowers but wasn’t yet manufacturing. He met with ATF representatives and provided a sample of one of his unfinished receivers, asking the agency to provide a determination as to whether it constituted a firearm. He was told it did not. Roh was in the clear. And had he restricted his business operations to merely selling these gun parts, no indictment would have came. No case would have gone to court. Plenty of legitimate online retailers sell gun parts like Roh did, even in California. In fact, the state now runs an entire program to facilitate the sale of these parts while meeting their strict gun laws, and that includes frame blanks for handguns and 80% lowers for rifles.

But when agents suspected that a man named John Zawahri possibly obtained an AR-15 rifle by purchasing a receiver blank from Roh to later carry out a fatal shooting spree in Santa Monica in 2013, the gears of the judicial machine began churning against his operation. According to Santa Monica police, investigators found a letter from the Department of Justice in Zawahri’s bedroom that was drafted two years before the attack, informing him that he was not eligible to purchase a firearm.

Roh’s attorney said there was no evidence of any connection between Roh and the attacks, but prosecutors were able to collect customer invoices from Roh’s warehouse that included 19 convicted felons, six domestic abusers, and one person prohibited from owning guns “due to mental health unfitness.” Around that same time, Roh graduated from just selling receiver blanks to building them in his workshop. “We here at ROHG Industries have been doing build parties for quite some time,” he wrote, referencing the name of his workshop. “The customer installs the part into our machine and pushes the start button,” Roh explained. “Is this legal?” he asked.

The ATF’s Chief of Firearms Technology Branch responded by saying that he needed to obtain a federal firearms license for manufacturing. Roh did not heed that advice. Shortly after, ATF agents conducted their sting. Visiting the workshop to build a rifle, one ATF agent asked, “I’m not going to get into trouble or anything like that?” “No,” Roh said. “We’re legal, man.” Roh then directed the undercover agent to begin the machining process on an unfinished receiver loaded in his machining equipment. “Go ahead and press the green button,” Roh told the agent. “That basically means that you did it — believe it or not.”

When Roh’s case was presented in court, his attorney, Gregory Nicolaysen, was quick to challenge the ATF on federal gun laws and their own policy-making. Nicolaysen argued what the ATF feared most: That the definition of a receiver under the relevant federal code differed in various ways from the AR-15 component Roh was accused of manufacturing. The US Code of Federal Regulations defines a firearm frame or receiver as, “That part of a firearm which provides housing for the hammer, bolt or breechblock, and firing mechanism, and which is usually threaded at its forward portion to receive the barrel.”

But the ATF relies on the definition of a firearm provided by the Gun Control Act: “… Any weapon (including a starter gun) which will or is designed to or may readily be converted to expel a projectile by the action of an explosive; The frame or receiver of any such weapon; Any firearm muffler or firearm silencer; Or any destructive device. Such terms do not include an antique firearm.” The ATF’s definition lacks any of the defining features present in the federal law, including a bolt and threaded portion for attaching the barrel. Nicolaysen called the ATF’s decision to classify Roh’s receivers as firearms nonetheless, the result of “secret, in-house decision-making.” Prosecutors acknowledged there were technical differences between the regulations but argued that the ATF’s policies and wording satisfied the intent of federal law. They were quick to warn of the potential fall-out if the court adopted the defense’s position:

“The necessary result of this would be that the unregulated parts could be manufactured, sold, and combined with other commercially available parts to create completed, un-serialized firearms which would not be subject to background checks, and which would be untraceable,” the prosecutors wrote. “Defendant’s interpretation would mean that nearly every semi-automatic firearm could be purchased piece by piece with no regulation or background check before a prohibited person would have a firearm.” Ultimately, prosecutors said the reading of the law “should also receive deference from this court.” Deference is the law principle that compels a federal court to defer to an agency’s interpretation of an ambiguous or unclear statute or law. Unfortunately for the prosecution, the judge disagreed.

Although the bench trial lasted less than a week, Judge James V. Selna deliberated for more than a year. This April, Selna issued a tentative order determining that the ATF had improperly classified Roh’s AR-15 lower receivers as firearms. “There is a disconnect,” the judge wrote. Although the prosecution requested deference considering vagueness, Selna judged the law defining receivers as “unconstitutionally” vague — too much so to rely on existing wording. “No reasonable person would understand that a part constitutes a receiver where it lacks the components specified in the regulation,” Selna wrote. Ultimately, the judge determined that Roh did not violate the law by manufacturing AR-15 receivers.

The implications of this single ruling would have been potentially catastrophic for the ATF and headline-storming for many of the 10+ million AR-15s owned by Americans — except the prosecution acquiesced. Fearing the ruling would create such a precedent and draw publicity, the government struck a deal with Roh. He would have to plead guilty to the charges against him, but he would be allowed to withdraw his plea and have the charges dropped after staying out of trouble for one year. He accepted the deal to avoid permanent conviction and prison time. The ATF got their wish of avoiding that agency-breaking precedent.

Nicolaysen says his client no longer works with firearms but declined to comment further on the details of his activities, citing the pending agreement. But for the ATF and federal agents, it might be too late. “AR-15s, as we speak today, do not have a receiver by the definition of the existing law and that’s a huge issue,” Nicolaysen said. “It shows that the laws are obsolete and they’re out of sync with the realities of today’s firearms market.” By press time, the the ATF did not respond to requests for comment.