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'); $access = app(PortalProfileAccess::class); $record = Opportunity::findOrFail(54); $canonical = app(OpportunityManagement::class)->values($record)['canonical']; throw_unless($record->owner_user_id === 21 && $record->opportunity_category === 'real_estate' && $access->state($record) === 'draft', RuntimeException::class, 'Correct private investor/organization/category required.'); throw_unless($canonical['real_estate']['transaction_type'] === 'lease' && $canonical['real_estate']['rent'] === 4500 && $canonical['real_estate']['rent_periodicity'] === 'monthly', RuntimeException::class, 'Lease values did not persist.'); throw_unless(empty($record->workflow_context['submission']) && empty($record->workflow_context['approval']) && empty($record->workflow_context['publication']), RuntimeException::class, 'An incomplete draft cannot imply submission/approval/publication.'); throw_unless(! $access->canView(User::findOrFail(23), $record), RuntimeException::class, 'Other organization must remain unauthorized.'); $contexts = $access->navigation(User::findOrFail(21))['contexts']; $keys = array_map(fn ($c) => ($c['organization_id'] ?? 'individual').'|'.$c['type'], $contexts); throw_unless(count($keys) === count(array_unique($keys)), RuntimeException::class, 'Duplicate context remained.'); $sale = Opportunity::findOrFail(31); $previous = 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); $baseline = array_values(array_filter($previous['categories'], fn ($r) => $r['id'] === 31))[0]; throw_unless($sale->management_version === $baseline['version'] && ($sale->workflow_context['publication']['hash'] ?? null) === $baseline['publication_hash'], RuntimeException::class, 'Sale case must remain unchanged.'); return ['result' => 'passed', 'at' => gmdate('c'), 'target' => $target, 'opportunity_id' => 54, 'owner_user_id' => 21, 'organization_id' => $record->organization_id, 'category' => $record->opportunity_category, 'state' => 'draft', 'transaction_type' => 'lease', 'rent' => 4500, 'rent_periodicity' => 'monthly', 'other_organization_denied_by_policy' => true, 'submission_approval_publication_absent' => true, 'visible_contexts' => count($contexts), 'colleague_contexts' => count($access->navigation(User::findOrFail(22))['contexts']), 'sale_31_unchanged' => true, 'active_writes' => 0]; }); file_put_contents($private.'/functional-lease-persistence-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;