<?php
$lane=getenv('FR2_LANE');$root=getenv('FR2_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(!in_array($path,['/api/balance.log/list','/api/balance.log/detail','/api/cashout/list'],true)||$_SERVER['REQUEST_METHOD']!=='GET'){http_response_code(403);exit;}
// PHP built-in server treats dots as static-file routes; emulate the production PATH_INFO rewrite.
$_SERVER['PATH_INFO']=$path;
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';
$sourceRoot=is_dir(__DIR__.'/source/application')&&($_SERVER['HTTP_X_FR2_BASELINE']??'')!=='1'?__DIR__.'/source':$root;
define('APP_PATH',$sourceRoot.'/application/');define('RUNTIME_PATH',__DIR__.'/runtime/');require $root.'/thinkphp/base.php';require __DIR__.'/SqlCoverageRecorder.php';
$observer=new SqlCoverageRecorder(__DIR__.'/events-'.$lane.'.jsonl',$sourceRoot,'PILOT_FINANCE_READ2_'.strtoupper(str_replace(['/','.'],'_',$path)));
\think\App::initCommon();\think\Request::instance()->pathinfo();\think\Log::init(['type'=>'File','path'=>__DIR__.'/runtime/safe-log/','level'=>['no_raw_application_log']]);
\think\Config::set(['type'=>'File','path'=>__DIR__.'/cache/','prefix'=>'FR2_'],'cache');
// Preserve the actual database debug settings; no performance masking override.
$database=require $root.'/application/database.php';\think\Config::set($database,'database');\think\Db::clear();\think\Db::listen([$observer,'observe']);register_shutdown_function([$observer,'finish']);\think\App::run()->send();
