21 lines
4.3 KiB
PHP
21 lines
4.3 KiB
PHP
<?php
|
|
// Existing canonical materiality service, synthetic snapshots only. Does not create approval decisions in the DB.
|
|
ini_set('zend.exception_ignore_args','1');set_exception_handler(function(Throwable$e){fwrite(STDERR,json_encode(['error_type'=>$e::class,'line'=>$e->getLine(),'values_recorded'=>false]));exit(1);});
|
|
$root=dirname(__DIR__,2);$f=json_decode(file_get_contents(__DIR__.'/business-country-fixture.json'),true,512,JSON_THROW_ON_ERROR);$qa=$f['QA_source'];putenv('STABILITY_QA_MODE=consumers');$app=require $qa.'/tools/portal-stability-runtime.php';$db=Illuminate\Support\Facades\DB::connection();$db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY');$id=(array)$db->selectOne('SELECT current_database() AS database,inet_server_port() AS port');if($id!==$f['target']||(int)$id['port']!==55441)throw new RuntimeException('QA guard');
|
|
$m=app(App\Services\OpportunityReviewMateriality::class);$gates=['brand_license_review','franchise_legal_review','financial_review','confidentiality_clearance'];
|
|
$before=['hash'=>hash('sha256','synthetic_before'),'payload'=>['opportunity_category'=>'franchise','official_title'=>'Franquia sintética QA','business_transaction'=>['franchise_terms'=>['brand'=>'Marca sintética QA','initial_fee'=>1000,'royalties'=>'5% da receita; cenário QA']]],'resources'=>['locations'=>[],'documents'=>[],'images'=>[]]];
|
|
$reviews=[];foreach($gates as$g)$reviews[$g]=['decision'=>'approved','hash'=>hash('sha256','synthetic_decision_'.$g),'actor_id'=>24,'at'=>'2026-10-12T00:00:00+00:00','scope_hash'=>$m->hash($before,$g),'scope_rule'=>$m::VERSION,'evidence_document_ids'=>[]];
|
|
$results=[];foreach(['initial_fee'=>1250,'royalties'=>'6% da receita; cenário QA']as$field=>$value){$after=$before;$after['hash']=hash('sha256','synthetic_after_'.$field);$after['payload']['business_transaction']['franchise_terms'][$field]=$value;$result=$m->reconcile($before,$after,$reviews,$gates);$results[$field]=['reopened'=>$result['reopened'],'retained'=>$result['retained'],'financial_review_reopened'=>in_array('financial_review',$result['reopened'],true)];}
|
|
$editorial=$before;$editorial['hash']=hash('sha256','synthetic_editorial');$editorial['payload']['official_title'].=' — correção ortográfica';$editorialResult=$m->reconcile($before,$editorial,$reviews,$gates);
|
|
$historical=[];if(defined($m::class.'::BEFORE_FRANCHISE_FINANCE_VERSION'))foreach([$m::PREVIOUS_VERSION,$m::BEFORE_FRANCHISE_FINANCE_VERSION]as$rule){
|
|
$old=$reviews;foreach($gates as$g){$old[$g]['scope_hash']=$m->hash($before,$g,[],false,$rule);$old[$g]['scope_rule']=$rule;}
|
|
$unchanged=$m->reconcile($before,$editorial,$old,$gates);$changed=$before;$changed['hash']=hash('sha256','historical_changed');$changed['payload']['business_transaction']['franchise_terms']['initial_fee']=1250;$changed=$m->reconcile($before,$changed,$old,$gates);
|
|
$preserved=$unchanged['reopened']===[];foreach($gates as$g)$preserved=$preserved&&$unchanged['reviews'][$g]['hash']===$old[$g]['hash']&&$unchanged['reviews'][$g]['at']===$old[$g]['at']&&$unchanged['reviews'][$g]['actor_id']===$old[$g]['actor_id'];
|
|
$historical[$rule]=['unchanged_decision_hash_actor_timestamp_preserved'=>$preserved,'initial_fee_reopens_financial_review'=>in_array('financial_review',$changed['reopened'],true)];
|
|
if(!$preserved||!$historical[$rule]['initial_fee_reopens_financial_review'])throw new RuntimeException('Historical scope compatibility failed');
|
|
}
|
|
$mode=$argv[1]??'before';if(!in_array($mode,['before','after'],true))throw new RuntimeException('Unknown mode');$db->rollBack();
|
|
$proof=['at'=>gmdate('c'),'target'=>$id,'source_version'=>$m::VERSION,'cases'=>$results,'editorial_title_reopens'=>$editorialResult['reopened'],'historical_compatibility'=>$historical,'synthetic_snapshots_only'=>true,'real_signed_reviews_or_DB_approvals_created'=>false,'DB_writes'=>0,'active_writes'=>0,'proof_kind'=>'Service regression, not HTTP transition or interface demonstration'];
|
|
$proof['result']=($results['initial_fee']['financial_review_reopened']&&$results['royalties']['financial_review_reopened']&&$editorialResult['reopened']===[])?'passed':'missing_financial_materiality';
|
|
file_put_contents(__DIR__.'/franchise-materiality-'.$mode.'.json',json_encode($proof,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo json_encode($proof);if($mode==='after'&&$proof['result']!=='passed')exit(1);
|