Who, ultimately is responsible for an installation meeting code?

Scenario #1-
A large facility hires a contractor to install electrical equipment, but doesn't bother to oversee the project. The installation doesn't satisfy code requirements, but is accepted and paid for. Who is (ultimately) at fault?


Scenario #2-
A bid is submitted and accepted based on faulty drawings. During construction, the problem is discovered. It will add 10% to the overall cost. Who eats the 10?