100% VW's fault, could be costly!
First some background -- starting around 1995 or so, large diesel engine manufacturers (i.e. the ones making engines for semis, a.k.a. lorries) were expected to start meeting some somewhat tighter emissions standards. They were basically using 1950s-era engine technology, and would just inject diesel in reaction to the "go pedal" (either fully mechanical fuel injection, or electronic fuel injection but with very simple software.) Well, fast forward a year or two, and people found it odd that their Volvos would occasionally suddenly lose power, run like crap for a while, then perk right back up. Well, the EPA found that the Volvo (and one or two other vendors) had done nothing legitimate to meet emissions, they would switch to barely meeting emissions (but barely running) if and only if they detected the EXACT parameters of an EPA test. If they started an EPA test, but then went, say, 37MPH instead of 40MPH, all of a sudden it'd start running dirty as all hell. A few others may not have been intentionally cheating, but were disabling emissions controls on extended cruise conditions. The companies fined (over $1 billion total) were Caterpillar Inc., Cummins Engine Co. Inc., Navistar International Corp., the Detroit Diesel Corp., Mack Trucks, its corporate parent Renault SA, and Volvo.
"Cost of billions? Maybe. You have to remember that the EPA is led by the worst sort of political hacks, whose lies can rarely be distinguished from their incompetence."
Cost of billions? Maybe. VW got caught out intentionally violating EPA standards, and effectively committing fraud against the EPA by making their software detect the EPA test and only even attempt to meet emissions under these circumstances. They know (I assume) that vendors got caught doing just this less than 20 years ago, got huge fines for it, and choose to try their luck anyway.
" It passes the test as written then."
No it doesn't, the EPA rules specify an overall limit an engine should meet (and cold start is given a lower weight than the other conditions... since engines do run dirtier cold) as well as "do not exceed" limits. It doesn't specify "meet limits under EPA test and then do whatever you want the rest of the time." Making 40x the NOx limit means it's making 40x the NOx limit, a violation of the test as written.
"So it detects when it's stood still idling and runs in low performance low emission mode. When under normal use you get decent performance but a bit more emission. Surely it's a pass. Unless you ban them from varying the engine map for different situations."
Nope, the EPA test is not sitting there idling; the city test involves driving for about 10 minutes from a cold start (this part's given below-average weight since cold engines run dirty), then about 15 minutes driving around; then 10 minute shut off, then the first 10 minutes drive on the warm-start engine. The highway test is done from a warm engine, accelerating and driving at (rather sluggish) highway speeds. In fact (thank goodness I'm not in a smog test state), even in smog test states... a few areas just stick a sniffer up the pipe while idling, but most test on a dyno at several RPM/load conditions. Regarding "a bit more emission"... a) 40x the limit is not a bit more emissions. b) You can make "a bit more emission" if you're under the limit, the limit is a limit. Cadillac had to recall some cars (and change the software), as well as pay a fine, in the 1990s because the cars were maybe 10% over the limit (not 40x the limit, 1.1x the limit) if and only if the air conditioning was on (the EPA test is done with A/C off.) And yes, you can use different engine maps, but all are required to meet the emissions standards. It is banned to use a totally different engine map depending on if you're on an EPA test or not. (One exemption... I think federal rules exempt emissions at full throttle, but California does not.)
"They say "up to 40 times the standard". Not on average 40 times the standard. It could be as simple as VW responding to 100% accelerator pedal input before the catalytic converter has warmed up, at high altitude and high air temperature. The fix could be a trivial loss of peak power under rare start up conditions. The EPA's press release is deliberately thin on information to vilify VW."
The EPA press release precisely and clearly says "A sophisticated software algorithm on certain Volkswagen vehicles detects when the car is undergoing official emissions testing, and turns full emissions controls on only during the test." I can assure you no engine is going to peak at 40x the limit but stay within limits the rest of the time, that's simply not how NOx production works.