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

30 lines
3.7 KiB
PHP

<?php
ini_set('zend.exception_ignore_args','1');putenv('STABILITY_QA_MODE=consumers');
$b4Root=dirname(__DIR__,2);$app=require $b4Root.'/storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742/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 only');
$db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY');
try{
$pre=json_decode(file_get_contents(__DIR__.'/option-B4-preflight.json'),true,512,JSON_THROW_ON_ERROR);$preserved=[];
$newTasks=$db->table('tasks')->where('created_at','>=',$pre['at'])->get(['id','external_id','source_system','due_at']);
foreach($newTasks as$t)if($t->source_system!=='opportunity-workflow'||!str_starts_with($t->external_id,'portal-opportunity:30:')||$t->due_at!==null)throw new RuntimeException('Unexpected task or deadline');
foreach($pre['protected_tables']as$name=>$before){$q=$db->table($name);if($name==='tasks')$q->whereNotIn('id',$newTasks->pluck('id'));$rows=$q->get();$bytes=$rows->map(fn($r)=>json_encode($r,JSON_THROW_ON_ERROR))->all();sort($bytes,SORT_STRING);$preserved[$name]=$rows->count()===$before['count']&&hash('sha256',implode("\n",$bytes))===$before['sha256'];}
if(in_array(false,$preserved,true))throw new RuntimeException('Protected data changed');
$o=App\Models\Opportunity::findOrFail(30);$ctx=$o->workflow_context;$cond=$ctx['conditions']['826fa774-2aab-40d7-ab57-80eefc87c748'];
if($ctx['working_state']!=='published'||$ctx['publication']['visibility']!=='internal'||$cond['status']==='open'||($cond['resolution']['actor_id']??null)!==24)throw new RuntimeException('Final state/condition mismatch');
$prior=json_decode(file_get_contents(__DIR__.'/option-B4-condition-read.json'),true,512,JSON_THROW_ON_ERROR)['condition']['resolution_history'];
if(Illuminate\Support\Arr::sortRecursive($cond['resolution_history'])!==Illuminate\Support\Arr::sortRecursive($prior))throw new RuntimeException('Old condition history changed');
$actor=App\Models\User::findOrFail(21);Illuminate\Support\Facades\Auth::setUser($actor);request()->setUserResolver(fn()=>$actor);
$contracts=[];
foreach([30,31,32,33,34,35,54,56]as$id){$record=App\Models\Opportunity::findOrFail($id);if($record->owner_user_id!==21)throw new RuntimeException('Own fixtures only');
try{$snapshot=app(App\Services\OpportunityCanonicalContract::class)->validateSubmission($record);$contracts[]=['id'=>$id,'category'=>$record->opportunity_category,'compatible'=>true,'snapshot_hash'=>$snapshot['hash']];}
catch(Illuminate\Validation\ValidationException $e){$contracts[]=['id'=>$id,'category'=>$record->opportunity_category,'compatible'=>false,'error_fields'=>array_keys($e->errors())];}
}
$p=['at'=>gmdate('c'),'target'=>$target,'SQL_read_only'=>true,'active_writes'=>0,'protected_tables_preserved'=>$preserved,
'prior_tasks_preserved'=>$pre['protected_tables']['tasks']['count'],'new_tasks'=>$newTasks->count(),'new_tasks_only_project30_without_due_dates'=>true,
'coeditor_membership_roles_and_pair_unchanged'=>true,'condition_history_preserved'=>true,'condition_reverified_internally_by'=>24,
'state'=>'published','visibility'=>'internal','contracts_read_only_compatibility'=>$contracts,
'compatibility_is_not_new_workflow_or_visual_proof'=>true,'browser_observed'=>false,'A_B_C37_not_repeated'=>true];
$dest=__DIR__.'/option-B4-final-QA.json';if(is_file($dest))throw new RuntimeException('Preserve proof');file_put_contents($dest,json_encode($p,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo json_encode($p).PHP_EOL;
}finally{$db->rollBack();}