make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); App\Shared\Testing\TestingDatabaseGuard::assertSafe();$p=json_decode(file_get_contents($file),true,512,JSON_THROW_ON_ERROR); $db=Illuminate\Support\Facades\DB::connection();$i=$db->selectOne("SELECT current_setting('cluster_name') AS name");if($i->name!=='sgf_modular_regression_'.getenv('SGF_ISOLATED_REGRESSION_RUN'))throw new RuntimeException('Wrong QA cluster'); $db->select("SELECT set_config('application_name',?,false)",[$p['application']]);$db->statement("SET lock_timeout='8s'"); $actor=App\Models\User::findOrFail($p['actor']);auth()->guard()->setUser($actor);app(App\Shared\Context\CompanyContext::class)->selectFor($actor->id,$p['scope']['tenant_id'],$p['scope']['company_id'],$p['scope']['unit_id']); config(['workshop_stock.synthetic_sources.'.implode(':',$p['scope'])=>$p['binding']]); try{$service=app(App\Modules\Workshop\WorkshopStock::class);$action=$p['action']??'confirm';$result=$action==='confirm'?$service->confirm($p['proposal'],'Synthetic independent concurrent confirmation.',(bool)($p['received_in_warehouse']??false)):$service->close($p['proposal'],$action,(int)$p['state_version'],$p['source_hash'],$p['reason']);$out=['status'=>200,'result'=>$result];} catch(Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $e){$out=['status'=>$e->getStatusCode()];} file_put_contents($file.'.result',json_encode($out,JSON_THROW_ON_ERROR));