'testing', 'APP_DEBUG' => 'true', 'APP_URL' => $qaUrl, 'APP_KEY' => 'base64:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=', 'DB_CONNECTION' => 'pgsql', 'DB_HOST' => '127.0.0.1', 'DB_PORT' => '55441', 'DB_DATABASE' => $qaDatabase, 'DB_USERNAME' => 'postgres', 'DB_PASSWORD' => '', 'DB_URL' => '', 'SESSION_DRIVER' => 'file', 'SESSION_COOKIE' => 'investmoz_guidance_qa', 'CACHE_STORE' => 'array', 'QUEUE_CONNECTION' => 'sync'] as $key => $value) { putenv($key.'='.$value); $_ENV[$key] = $_SERVER[$key] = $value; } require $root.'/vendor/autoload.php'; $app = require $root.'/bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); $connection = config('database.connections.'.config('database.default')); if (config('database.default') !== 'pgsql' || ($connection['host'] ?? null) !== '127.0.0.1' || (string) ($connection['port'] ?? '') !== '55441' || ($connection['database'] ?? null) !== $qaDatabase || ! in_array($connection['url'] ?? null, [null, ''], true)) { throw new RuntimeException('Refusing a non-QA configuration before connecting.'); } $identity = DB::selectOne('select current_database() as name, inet_server_port() as port'); if ($identity->name !== $qaDatabase || (int) $identity->port !== 55441) { throw new RuntimeException('Refusing a non-QA database identity.'); } $private = $root.($v2 ? '/storage/app/private/investmoz-v2' : '/storage/app/private/virtual-desk'); if (! is_dir($private.'/qa-sessions')) { mkdir($private.'/qa-sessions', 0700, true); } config(['session.files' => $private.'/qa-sessions', 'portal.managers' => ['guidance-qa-manager@example.invalid'], 'suitecrm.enabled' => false, 'investmoz_ai.enabled' => false]); Vite::useHotFile($root.'/storage/framework/guidance-qa-absent-hot'); if ($v2 && PHP_SAPI === 'cli' && ($argv[1] ?? '') === 'migrate') { $result = $app->make(Kernel::class)->call('migrate', ['--force' => true]); echo 'V2 QA migrations exit '.$result.'; target '.$identity->name.':'.$identity->port."\n"; exit($result); } if (PHP_SAPI === 'cli' && ($argv[1] ?? '') === 'seed') { foreach (($v2 ? ['investor', 'manager', 'other'] : ['investor', 'manager']) as $role) { $user = User::updateOrCreate(['email' => 'guidance-qa-'.$role.'@example.invalid'], ['name' => 'Guidance QA '.$role, 'password' => Hash::make('QA-Guidance-2026!')]); $user->forceFill(['email_verified_at' => now()])->save(); } $manager = User::where('email', 'guidance-qa-manager@example.invalid')->firstOrFail(); $request = Request::create('/management/balcao/servicos', 'POST', ['code' => 'project-preparation', 'confirm' => true]); $request->setUserResolver(fn () => $manager); app(VirtualDeskInstallationController::class)->publishService($request); if ($v2) { require $root.'/tools/investmoz-v2-qa-fixtures.php'; } echo "QA fixtures seeded; no active database connection.\n"; exit; } if (PHP_SAPI === 'cli' && ($argv[1] ?? '') === 'evidence') { if ($v2) { throw new RuntimeException('V2 evidence must be produced by the checks, not asserted by a seed command.'); } $evidence = ['passed' => true, 'database' => $identity->name, 'port' => (int) $identity->port, 'code_hash' => app(VirtualDeskInstallation::class)->fingerprint(), 'recorded_at' => gmdate('c'), 'checks' => ['PHPUnit feature and regression suite', 'Frontend deterministic calculator tests', 'TypeScript', 'PHPStan', 'Production build', 'Authenticated local browser cycle']]; file_put_contents($private.'/guidance-qa-evidence.json', json_encode($evidence, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)); echo "QA evidence recorded for this code fingerprint.\n"; exit; } $path = rawurldecode(parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/'); $asset = realpath($root.'/public'.$path); $public = realpath($root.'/public'); if ($path !== '/' && $asset && $public && str_starts_with($asset, $public.DIRECTORY_SEPARATOR) && is_file($asset)) { return false; } header('X-Investmoz-QA-Target: '.$identity->name.':'.$identity->port); $app->handleRequest(Request::capture());