The detention facility that the U.S. built in Afghanistan is state-of-the-art. Except for all of the faulty hinges on the cell doors. Or the locks that are, in the words of a new report from the Defense Department's inspector general, "incapable of locking either manually or electronically." Or the construction that's deemed "not up to the standard suitable for a detention facility."

The worst part? U.S. military commanders have known about these flaws since the prison opened its doors.

Built in 2009, the Detention Facility in Parwan is a sprawling campus of 14 buildings, capable of housing – once a planned expansion is completed – some 2,000 detainees. The U.S. spent $60 million to construct it, to demonstrate the professionalization of detention operations after years of scandals in Iraq and Afghanistan. What the U.S. military didn't reveal was that it has known from the start that the building has serious engineering flaws – flaws that lead to security liabilities. And all of this was the result of lackadaisical oversight of contractors hired by the U.S. Army Corps of Engineers.

The magnetic sensors and electronic locks on the "access doors" that prevent detainees from traveling between cell blocks, are "defective" and had to be removed, according to a report the Defense Department's inspector general released on Thursday. That removal caused the electronic systems integrating and remotely controlling the doors to be "ineffective."

"The integration system was supposed to monitor the status of all doors with electronic locks and magnetic sensors, thereby electronically monitoring the status of all detainees entering and exiting the secured areas," the inspector general found. "The lack of a final functional test on the building integration system was considered a deficiency when the building was accepted. However, [Pentagon inspector general] engineers noted during their inspection in July 2010 that the integration system was still not functioning. Instead of ensuring that the doors had magnetic sensors and locks so that the Integration System would work properly, a soldier was required to stand and guard the door, as a means of securing the rooms."

CAMP SABALU-HARRISON, Afghanistanâ�� Col. Robert M. Taradash, Commander TF Protector, guides Navy Rear Adm. Mark L. Tidd, United States Navy Chief of Chaplains, through a detainee housing unit, part of the Detention Facility in Parwan, April 4, 2012. Also on the tour were Air Force Brig. Gen. Howard Stendahl, United States Air Force Chief of Chaplains, and Army Brig. Gen. Kevin R. Turner, United States Army Chief of Chaplains. The chiefs of chaplains visited Camp Sabalu-Harrison to meet with chaplains and chaplain assistants on the forward operating base, as well as gain an understanding of detention operations in Afghanistan. "The call to serve is what drives us,â�� said Tidd, while addressing the chaplains and chaplain assistants. â��We serve soldiers and leadership through advice and encouragement," he said. The tour also included the on-site state-of-the-art medical facilities, legal operations and the detainee service branch. (Department of Defense photo by U.S. Army Capt. Eugene M. Bath) (20120404-A-B8948-003) Staff Sgt. Faiza Z. Evans

The doors themselves are shoddily built, too. The hinges on them were "incorrect," according to the inspector general. "The poorly constructed cell doors allowed detainees to damage the doors easily by repeated kicking," the report states. There are also problems with the fire-prevention and sewage systems that the inspector general says pose a "health and safety risk" to detainees.

The damage was not limited to minor areas of the prison, either. "The construction quality was not up to the standard suitable for a detention facility," the report concludes, "and ... the quality of construction of greatest interest was the areas where the detainees spent most of their time such as detention cells and the recreation yard."

No detainee appears to have escaped as a result of the construction woes. But that may be a matter of time. Afghan detainees have been able to literally tunnel out of another prison in the country – twice. And while the leadership of the prison reports that it doesn't have problems with the cells anymore, other construction problems with the prison persist: "The access doors

are still in disrepair and will be replaced as soon as new prison grade doors arrive in

theater from the United States."

Except that the U.S. won't run the Parwan prison for much longer. The Afghans signed a deal with NATO in March to take control of it by September. That means Afghan troops, less capable on average than their U.S. counterparts, will soon be in charge of hundreds of detainees in a giant prison with chronic security vulnerabilities.

That prison isn't in an isolated area. It's on the outskirts of Bagram airfield, one of the U.S.' major bases, housing over 10,000 U.S. troops. Bagram is about an hour's drive from the capital city of Kabul.

The Army basically pled nolo contendere to the Pentagon inspector general. While picking at nits, a senior Army Corps of Engineers official wrote to the inspector general on April 2 that his department "concurs with all but one" of the recommendations in the report – some of which are as simple as urging "continuous oversight" on the facility.

These days, Parwan is infamous for being the site where U.S. troops accidentally burned Korans, a February debacle that caused days of countrywide rioting. Needless to say, it wasn't supposed to be this way. I took a tour of the detention facility in August 2010, and officials boasted of the sophisticated security systems that would allow guards to humanely and firmly monitor and control detainee activity.

But this is the legacy that a decade's worth of U.S. detention operations will leave in Afghanistan: locks that don't lock. And across Afghanistan, even as U.S. troops withdraw from the country, the U.S. is still building jails.