12 lines
2.3 KiB
PHP
12 lines
2.3 KiB
PHP
<?php
|
|
use Illuminate\Support\Facades\DB;
|
|
$s=json_decode(file_get_contents(getenv('RECEIPT_COMPOSITION_STATE')),true);$out=$s['root'].'/stock-period-queries.json';if(!($s['stockPeriod']??false)||!is_file($s['root'].'/stock-period-result.json')||is_file($out))throw new LogicException('Completed period regression required');
|
|
require $s['app'].'/vendor/autoload.php';$app=require $s['app'].'/bootstrap/app.php';$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();App\Modules\Purchasing\BudgetAdapter::guard();
|
|
require_once $s['app'].'/packages/inventory-read/bootstrap.php';$profile=json_decode(file_get_contents($s['root'].'/stock-binding.json'),true);$binding=array_values($profile['bindings'])[0];config(['database.connections.period_metrics'=>$profile['connection']]);$source=DB::connection('period_metrics');
|
|
$i=$source->selectOne("SELECT current_database() db,current_user role,current_setting('cluster_name') cluster,current_setting('default_transaction_read_only') read_only");
|
|
if($i->db!=='compras_receipts_test_'.$s['tag']||$i->role!=='stock_receipt_read_'.$s['tag']||$i->cluster!=='sgf_modular_regression_'.$s['env']['SGF_ISOLATED_REGRESSION_RUN']||$i->read_only!=='on')throw new LogicException('Owned read role required');
|
|
$selects=0;DB::listen(function($query)use(&$selects){if($query->connectionName==='period_metrics'&&preg_match('/^select\b/i',$query->sql))$selects++;});$counts=[];$rows=[];
|
|
foreach([25,100]as$size){$selects=0;$result=(new App\Modules\Inventory\StockPeriodReport($source))->read($binding,hash('sha256','isolated-query-observation'),['from'=>'2026-11-01','to'=>'2026-11-03','search'=>'','warehouse_id'=>null,'page'=>1,'per_page'=>$size],null);$counts[$size]=$selects;$rows[$size]=count($result['rows']);}
|
|
if($counts[25]!==$counts[100]||$counts[100]>6||$rows!==[25=>25,100=>100])throw new RuntimeException('Projection query budget or pagination changed');
|
|
file_put_contents($out,json_encode(['passed'=>true,'checks'=>['projection SELECT count is independent of page size25/100 and bounded by6','projection materialises only the requested25/100 report rows'],'select_queries'=>$counts,'returned_rows'=>$rows,'scope'=>'direct projection only; authentication/middleware/physical-source checks excluded','sustained_load'=>false,'deployment_capacity_validated'=>false],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo "2 period query checks passed.\n";
|