<?php
declare(strict_types=1);
$root=dirname(__DIR__);$checks=[];
$checks['version']=str_contains((string)file_get_contents($root.'/DDB_VERSION.json'),'11.0.11.60');
$checks['phase']=str_contains((string)file_get_contents($root.'/DDB_VERSION.json'),'H11.0-P11.1-R45-P2.2.1');
$p=(string)file_get_contents($root.'/tools/revenue-sql-plan-profile.php');
$checks['display_cursor']=str_contains($p,'DBMS_XPLAN.DISPLAY_CURSOR');
$checks['same_session']=str_contains($p,'Database::connection');
$checks['no_explain_plan']=!str_contains(strtoupper($p),'EXPLAIN PLAN FOR');
$checks['gather_stats']=str_contains($p,'GATHER_PLAN_STATISTICS');
$checks['different_year_guard']=str_contains($p,'must be different');
$a=(string)file_get_contents($root.'/tools/revenue-production-page-acceptance.php');
$checks['acceptance_tool']=str_contains($a,'DDB_REVENUE_PRODUCTION_PAGE_ACCEPTANCE_V1');
$checks['comparison_filter']=str_contains($a,'comparison');
$checks['thresholds']=str_contains($a,'6000')&&str_contains($a,'3000');
$failed=array_keys(array_filter($checks,fn($v)=>!$v));echo json_encode(['schema'=>'R45_P2_2_1_QA','checks'=>$checks,'passed'=>count($checks)-count($failed),'failed'=>$failed],JSON_PRETTY_PRINT).PHP_EOL;exit($failed?1:0);
