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('Guard did not refuse');}catch(Symfony\Component\HttpKernel\Exception\HttpException $e){if($e->getStatusCode()!==$status||$queries!==$before)throw new RuntimeException($name);$checks[]=$name;}};config(['receipt_qa.requests_enabled'=>false]);$probe(fn()=>$runtime->run('purchasing_requests.prepare',fn()=>true),404,'disabled requests runtime refuses before SQL');$probe(fn()=>(new App\Modules\Purchasing\RequestController)->preview(1,new Illuminate\Http\Request,$runtime),404,'disabled requests preview refuses before validation or SQL');config(['receipt_qa.requests_enabled'=>true]);$app->instance('env','production');$probe(fn()=>$runtime->run('purchasing_requests.prepare',fn()=>true),403,'production cannot activate synthetic requests');file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'database_queries'=>0,'business_writes'=>0],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));