make(Kernel::class)->bootstrap(); $identity = portalQaAssertTarget($target); $proof = DB::transaction(function () use ($identity) { DB::statement('SET TRANSACTION READ ONLY'); $case = LandAssistanceCase::query()->whereKey('01a12568-c330-73ec-a1ac-543ac0116a26')->firstOrFail(); $payload = $case->payload; $request = DB::table('interest_requests')->where('id', $case->interest_request_id)->first(); $metadata = json_decode($request->metadata, true, 512, JSON_THROW_ON_ERROR); $count = DB::table('interest_requests')->whereRaw("metadata->>'land_case_id' = ?", [$case->id])->count(); throw_unless($case->status === 'support_requested' && $case->user_id === 21 && $payload['country'] === 'MZ' && $payload['declared_origin_country_code'] === 'PT' && $request->country === 'MZ' && $metadata['declared_origin_country_code'] === 'PT' && $count === 1, RuntimeException::class, 'Support persistence differs.'); $o = DB::table('opportunities')->where('id', 31)->first(); $context = json_decode($o->workflow_context, true, 512, JSON_THROW_ON_ERROR); throw_unless($context['materiality']['reopened'] === ['property_review'] && count($context['materiality']['retained']) === 2, RuntimeException::class, 'Materiality persistence differs.'); $legacy = DB::table('portal_resources as r')->join('documents as d', 'd.id', '=', 'r.document_id')->where('r.id', 6)->first(['r.published', 'r.document_id', 'd.sha256', 'd.malware_scan_status', 'd.malware_scanned_sha256']); throw_unless($legacy->published && $legacy->malware_scan_status === 'clean' && trim($legacy->sha256) === trim($legacy->malware_scanned_sha256), RuntimeException::class, 'Legacy original/scan/publication not preserved.'); return ['result' => 'passed', 'target' => $identity, 'read_only' => true, 'active_writes' => 0, 'land_support' => ['case' => $case->id, 'owner' => 21, 'version' => $case->version, 'country' => $request->country, 'origin' => $metadata['declared_origin_country_code'], 'linked_requests' => $count, 'reference' => $request->reference], 'materiality' => ['opportunity' => 31, 'publication_state' => $o->status, 'reopened' => $context['materiality']['reopened'], 'retained' => $context['materiality']['retained'], 'final_approval_preserved' => isset($context['approval'])], 'library' => ['resource' => 6, 'published_restored' => true, 'document' => $legacy->document_id, 'sha256' => trim($legacy->sha256), 'scan' => $legacy->malware_scan_status, 'new_scan_performed' => false], 'response_version' => OpportunityCanonicalResponse::VERSION]; }); file_put_contents(storage_path('app/private/investmoz-v2/portal-audit/revision-persistence-qa-20261011.json'), json_encode($proof, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)); echo json_encode(['result' => 'passed', 'target' => $identity, 'linked_support_requests' => 1, 'read_only' => true, 'active_writes' => 0]).PHP_EOL;