require $file)($plan['source'].'/tools/portal-stability-runtime.php'); $target = DB::selectOne('select current_database() as database,inet_server_port() as port'); throw_unless($target->database === 'stability_consumers_20261011_084534_test' && (int) $target->port === 55441, RuntimeException::class, 'Exact isolated QA required.'); $proof = DB::transaction(function () use ($target): array { DB::statement('SET TRANSACTION READ ONLY'); $service = app(PortalProfileAccess::class); $record = Opportunity::findOrFail(31); $old = json_decode(file_get_contents(dirname(__DIR__).'/storage/app/private/investmoz-v2/portal-audit/functional-final-persistence-qa-20261011.json'), true, 512, JSON_THROW_ON_ERROR); $sale = array_values(array_filter($old['categories'], fn ($row) => $row['id'] === 31))[0]; throw_unless((int) $record->management_version === $sale['version'] && ($record->workflow_context['publication']['hash'] ?? null) === $sale['publication_hash'], RuntimeException::class, 'Previously demonstrated sale case changed.'); $contexts = []; foreach ([21, 22] as $id) { $contexts[$id] = $service->navigation(User::findOrFail($id))['contexts']; } return ['result' => 'passed', 'at' => gmdate('c'), 'target' => $target, 'creation_contexts' => $contexts, 'existing_real_estate_drafts' => DB::table('opportunities')->where('opportunity_category', 'real_estate')->where('owner_user_id', 21)->whereRaw("COALESCE(workflow_context->>'working_state',status)='draft'")->get(['id', 'organization_id'])->all(), 'sale_31_unchanged' => true, 'active_writes' => 0]; }); file_put_contents($private.'/functional-lease-permissions-qa-20261011.json', json_encode($proof, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR)); echo json_encode($proof, JSON_THROW_ON_ERROR).PHP_EOL;