make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();$queries=0;$checks=[];DB::listen(function()use(&$queries){$queries++;});$controller=new App\Modules\Purchasing\DossierController;$runtime=new App\Modules\Purchasing\ReceiptRuntime; $check=function($fn,$status,$name)use(&$checks){try{$fn();throw new RuntimeException('Unexpected access');}catch(Symfony\Component\HttpKernel\Exception\HttpException $e){if($e->getStatusCode()!==$status)throw $e;}$checks[]=$name;}; config(['receipt_qa.dossiers_enabled'=>false]);$check(fn()=>$controller->index(new Illuminate\Http\Request,$runtime),404,'disabled dossier list refuses before SQL');$check(fn()=>$controller->show(1,new Illuminate\Http\Request,$runtime),404,'disabled dossier detail refuses before SQL'); config(['receipt_qa.dossiers_enabled'=>true]);$app->instance('env','production');$check(fn()=>$controller->index(new Illuminate\Http\Request,$runtime),403,'production refuses synthetic dossier before SQL'); if($queries!==0||App\Shared\Context\ModuleNavigation::owner('api/purchasing-dossiers/1')!=='purchasing')throw new RuntimeException('Guard boundary');$checks[]='dossier route belongs to purchasing and guard probes issue zero SQL';file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'database_queries'=>0],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo count($checks)." dossier guard checks passed.\n";