<?php
$lane=getenv('PILOT_LANE');$root=getenv('PILOT_TARGET_ROOT');
$expected=$lane==='B'?'/tmp/zhct-http-store-mysql.dQTTBP':'/tmp/zhct-dm-poc-20260928.fcpiiN/store';
if(!in_array($lane,['B','C'],true)||$root!==$expected||is_link($root)){http_response_code(503);exit;}
$path=parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH);
if($path==='/__poc_boundary'){require $root.'/public/index.php';return;}
$allowed=['lists','create','update','detail','changeStatus','delete'];
if(strpos($path,'/api/consumeLimit/')!==0||!in_array(substr($path,18),$allowed,true)||$_SERVER['REQUEST_METHOD']!=='POST'){http_response_code(403);exit;}
require $root.'/env.php';
if(!function_exists('json')){function json($data=[],$code=200,array $header=[],$options=[]){return \think\Response::create($data,'json',$code,$header,$options);}}
if(getenv('POC_EXTERNAL_STUBS')!=='1'){http_response_code(503);exit;}
require $root.'/external_stubs.php';define('APP_PATH',$root.'/application/');require $root.'/thinkphp/base.php';
require __DIR__.'/SqlCoverageRecorder.php';
$observer=new SqlCoverageRecorder(__DIR__.'/events-'.$lane.'.jsonl',$root,'PILOT_CONSUME_LIMIT_'.strtoupper(substr($path,18)));
\think\App::initCommon();\think\Request::instance()->pathinfo();
$database=require $root.'/application/database.php';$database['debug']=true;$database['sql_explain']=false;
\think\Config::set($database,'database');\think\Db::clear();\think\Db::listen([$observer,'observe']);register_shutdown_function([$observer,'finish']);
\think\App::run()->send();
