The AI-agent guard silently does nothing — destructive commands still run
- When
After wiring laravel/pao's
AgentDetectorintoDB::prohibitDestructiveCommands()via a dedicated service provider, when that provider is registered beforeAppServiceProviderinbootstrap/providers.php.- Why it happens
The React/Vue/Livewire starter kits ship an
AppServiceProviderthat already callsDB::prohibitDestructiveCommands(app()->isProduction()). Providers boot in registration order andprohibitDestructiveCommands()is a plain static setter, so the last call wins. A guard provider listed aboveAppServiceProvidersets the flag totrue, thenAppServiceProviderimmediately resets it tofalsein any non-production environment — the guard looks correctly installed and is completely inert.- Fix
Register the guard provider last in
bootstrap/providers.phpso it boots afterAppServiceProvider, or fold the agent check into the existingAppServiceProvidercall:DB::prohibitDestructiveCommands(app()->isProduction() || AgentDetector::detect()->isAgent);Verify for real with
sail artisan migrate:fresh— it must warn and refuse.AgentGuardConfigureappends the provider at the end of the array for exactly this reason.
Still stuck? Open an issue with your --log transcript.