Files
Investidor-V2/outputs/investmoz-audit-current-20261012/option-B3-preflight.php
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

31 lines
2.6 KiB
PHP

<?php
ini_set('zend.exception_ignore_args', '1');
putenv('STABILITY_QA_MODE=consumers');
$b3Root = dirname(__DIR__, 2);
$b3QA = $b3Root.'/storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742';
$app = require $b3QA.'/tools/portal-stability-runtime.php';
$db = Illuminate\Support\Facades\DB::connection();
$target = (array) $db->selectOne('SELECT current_database() AS database, inet_server_port() AS port');
if ($target !== ['database'=>'stability_consumers_20261011_084534_test', 'port'=>55441]) throw new RuntimeException('QA isolation required');
$db->beginTransaction(); $db->statement('SET TRANSACTION READ ONLY');
try {
if (config('portal.notifications_enabled') || config('suitecrm.enabled') || config('investmoz_ai.enabled')) throw new RuntimeException('External integrations must remain off');
$o = App\Models\Opportunity::findOrFail(30);
if ($o->owner_user_id !== 21 || $o->opportunity_category !== 'investment_project' || $o->workflow_context['working_state'] !== 'published') throw new RuntimeException('Synthetic project changed');
$v = app(App\Services\OpportunityManagement::class)->values($o)['canonical'];
$schema = json_decode(file_get_contents($b3QA.'/resources/data/investmoz-opportunity-modular.schema.json'), true, 512, JSON_THROW_ON_ERROR);
$tables = [];
foreach (['opportunity_locations','opportunity_documents','opportunity_images','desk_cases','desk_requests','desk_documents','investor_journeys','journey_steps','simulation_form_drafts','tasks','documents','memberships','organizations'] as $name) {
$rows = $db->table($name)->get(); $bytes = $rows->map(fn($r)=>json_encode($r, JSON_THROW_ON_ERROR))->all(); sort($bytes, SORT_STRING);
$tables[$name] = ['count'=>$rows->count(), 'sha256'=>hash('sha256', implode("\n", $bytes))];
}
$proof = ['at'=>gmdate('c'), 'target'=>$target, 'SQL_read_only'=>true, 'active_writes'=>0,
'scope_sha256'=>hash_file('sha256', $b3Root.'/docs/investmoz/v2/auditoria-portal/ambito-B-aceitacao-QA.md'),
'external_integrations_off'=>true, 'project_id'=>30, 'licenses'=>$v['licenses'],
'gates'=>array_keys($o->workflow_context['reviews']), 'license_schema'=>$schema['$defs']['licenseCreate'],
'protected_tables'=>$tables];
$dest=__DIR__.'/option-B3-preflight.json'; if(is_file($dest)) throw new RuntimeException('Preserve recorded preflight');
file_put_contents($dest, json_encode($proof, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR));
echo json_encode(array_diff_key($proof, ['protected_tables'=>true]), JSON_UNESCAPED_UNICODE).PHP_EOL;
} finally { $db->rollBack(); }