make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();$checks=[];$queries=0;DB::listen(function()use(&$queries){$queries++;});$runtime=new App\Modules\Purchasing\ReceiptRuntime;$probe=function($fn,$status,$name)use(&$checks,&$queries){$before=$queries;try{$fn();throw new RuntimeException('Expected refusal');}catch(Symfony\Component\HttpKernel\Exception\HttpException $e){if($e->getStatusCode()!==$status||$before!==$queries)throw new RuntimeException($name);$checks[]=$name;}}; config(['receipt_qa.orders_enabled'=>false]);$probe(fn()=>$runtime->run('purchasing_orders.issue',fn()=>true),404,'disabled order runtime refuses before SQL');$probe(fn()=>(new App\Modules\Purchasing\OrderController)->index(new Illuminate\Http\Request,$runtime),404,'disabled order endpoint refuses before SQL');config(['receipt_qa.orders_enabled'=>true]);$app->instance('env','production');$probe(fn()=>$runtime->run('purchasing_orders.issue',fn()=>true),403,'production cannot activate QA issuance');file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'database_queries'=>0,'business_writes'=>0],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo count($checks)." order guard checks passed.\n";