Files
Investidor-V2/outputs/investmoz-audit-current-20261012/option-B7-business-final-QA.php
T
nala ba1c0340ea
tests / ci (push) Canceled after 0s
oportunidades 8
2026-10-14 08:25:30 +02:00

23 lines
5.0 KiB
PHP

<?php
ini_set('zend.exception_ignore_args','1');putenv('STABILITY_QA_MODE=consumers');
$b7Root=dirname(__DIR__,2);$b7QA=$b7Root.'/storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742';$app=require$b7QA.'/tools/portal-stability-runtime.php';$db=Illuminate\Support\Facades\DB::connection();
$t=(array)$db->selectOne('SELECT current_database() AS database,inet_server_port() AS port');if($t!==['database'=>'stability_consumers_20261011_084534_test','port'=>55441])throw new RuntimeException('QA only');$db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY');
try{
$pre=json_decode(file_get_contents(__DIR__.'/option-B7-business-preflight.json'),true);$state=json_decode(file_get_contents(__DIR__.'/option-B7-business-progress.json'),true);$id=$state['id'];
$proof=['at'=>gmdate('c'),'target'=>$t,'SQL_read_only'=>true,'active_writes'=>0,'browser_observed'=>false,'preserved_tables'=>[]];
foreach($pre['protected_tables']as$table=>$expected){$q=$db->table($table);$q=match($table){'existing_businesses'=>$q->where('id','<>',$id),'business_workflow_transitions'=>$q->where('existing_business_id','<>',$id),'existing_business_revisions'=>$q->where('business_id','<>',$id),'tasks'=>$q->where(fn($s)=>$s->whereNull('existing_business_id')->orWhere('existing_business_id','<>',$id)),'outbox_events'=>$q->where('aggregate_id','<>',$id),default=>$q};$rows=$q->get();$bytes=$rows->map(fn($r)=>json_encode($r,JSON_THROW_ON_ERROR))->all();sort($bytes,SORT_STRING);if($rows->count()!==$expected['count']||!hash_equals($expected['sha256'],hash('sha256',implode("\n",$bytes))))throw new RuntimeException('Unexpected table change: '.$table);$proof['preserved_tables'][]=$table;}
$business=App\Models\ExistingBusiness::findOrFail($id);if($business->status!=='published'||$business->version_no!==16||$business->owner_user_id!==21)throw new RuntimeException('Final listing state differs');
$transitions=$db->table('business_workflow_transitions')->where('existing_business_id',$id)->orderBy('created_at')->get();if($transitions->count()!==11||$transitions->where('to_status','published')->count()!==1)throw new RuntimeException('Transitions duplicated');
$revisions=$db->table('existing_business_revisions')->where('business_id',$id)->orderBy('version_no')->get();if($revisions->count()!==16||$revisions->pluck('version_no')->unique()->count()!==16)throw new RuntimeException('Revision duplicated');
foreach($revisions as$r){$plain=Illuminate\Support\Facades\Crypt::decryptString($r->snapshot);if(!hash_equals($r->sha256,hash('sha256',$plain)))throw new RuntimeException('Revision checksum changed');}
$actors=[];foreach(['approval_l2'=>24,'approved'=>22,'published'=>25]as$status=>$actor){$transition=$transitions->where('to_status',$status)->sole();if((int)$transition->actor_id!==$actor)throw new RuntimeException('Independent actor mismatch');$actors[$status]=$actor;}
$tasks=$db->table('tasks')->where('existing_business_id',$id)->count();$outbox=$db->table('outbox_events')->where('aggregate_id',$id)->count();if($tasks!==2||$outbox!==2)throw new RuntimeException('Correction/submission effects duplicated');
if(config('portal.notifications_enabled')||config('existing-business.compatibility_shadow'))throw new RuntimeException('External side effects enabled');
$p=$business->payload;if($p['declared_holder']!=='Titular fictício independente QA B7'||$p['mandate_reference']!=='MANDATO-QA-B7: declaração de simulação sem efeito legal'||!str_contains($p['disclosure_scope'],'Somente título público'))throw new RuntimeException('Mandate or disclosure lost');
$proof['business']=['id'=>$id,'status'=>$business->status,'version'=>16,'owner'=>21,'independent_actors'=>$actors,'transitions'=>11,'single_publication'=>true,'revisions'=>16,'all_revision_hashes_and_cipher_recovered'=>true,'draft_field_corrections_same_id'=>true,'private_mandate_and_disclosure_recovered'=>true,'legal_verification_inconclusive_not_certified'=>true,'submission_tasks'=>2,'submission_outbox'=>2,'counts_reflect_two_distinct_submissions_after_correction_not_replayed_publication'=>true];
$manager=null;foreach(json_decode(file_get_contents(__DIR__.'/QA-credential-correspondence.json'),true)['candidates']as$c)if($c['source_file']==='i0-qa-actor-private.json')$manager=App\Models\User::findOrFail($c['user_id']);
$actual=array_map(fn($rows)=>array_sum(array_column($rows,'count')),app(App\Services\DeclaredOriginStatistics::class)->forManager($manager));if($actual!==['interests'=>17,'desk'=>1,'businesses'=>3])throw new RuntimeException('Unexpected denominators');
$proof['current_statistic_denominators']=$actual;$proof['denominator_change_reason']='One own existing-business listing submitted/published; no new interest or desk request, and no sum as unique people.';
$proof['result']='passed';$dest=__DIR__.'/option-B7-business-final-QA.json';if(is_file($dest))throw new RuntimeException('Preserve proof');file_put_contents($dest,json_encode($proof,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR));echo json_encode($proof,JSON_UNESCAPED_UNICODE).PHP_EOL;
}finally{$db->rollBack();}