"""Run production garage filtering and vehicle-fit rules against unsafe inputs.""" from policy_harness import ROOT, body, run p = ROOT/'addons/core/Scripts/Game/ERR/10_AI/ERR_GarageVehicles.c' rules = '\n'.join(body(p, s) for s in ('static bool Garage(', 'static bool Envelope(')) rules = rules.replace('vector ', 'Vec ').replace('ERR_ForceRules.', 'ERR_ForceRules::') run(r''' #include #include #include #include #include #include struct string : std::string { using std::string::string; void ToLower(){std::transform(begin(),end(),begin(),[](unsigned char c){return std::tolower(c);});} bool EndsWith(const std::string& suffix){return size()>=suffix.size() && compare(size()-suffix.size(),suffix.size(),suffix)==0;} }; struct Vec {float v[3];float operator[](int i)const{return v[i];}}; namespace ERR_ForceRules {bool FiniteVector(Vec v){return std::isfinite(v[0])&&std::isfinite(v[1])&&std::isfinite(v[2]);}} ''' + rules + r''' int main(){ assert(Garage("{GUID}Prefabs/Structures/Houses/Garage/Garage_E_01/Garage_E_01.et")); assert(Garage("Prefabs/Structures/Houses/Village/HouseAddon_Garage_E_01/HouseAddon_Garage_E_01.et")); assert(!Garage("Prefabs/Structures/Houses/Garage/Garage_E_01/Dst/Garage_E_01_Ruin.et")); assert(!Garage("Prefabs/Structures/Houses/Garage/Garage_E_01/Furniture/Garage_E_01_furniture_01.et")); assert(!Garage("Prefabs/Structures/BuildingParts/Doors/Door_Garage_E_01_A_LEFT_EXT_COV_B.et")); assert(!Garage("Prefabs/Structures/Military/Houses/GarageMilitary_E_01/GarageMilitary_E_01.et")); assert(Envelope({{-1,-0.2,-2.3}},{{1,1.8,2.3}})); assert(!Envelope({{-1.06f,0,-2}},{{1,1.8,2}})); assert(!Envelope({{-1,0,-2.5}},{{1,1.8,2}})); assert(!Envelope({{-1,0,-2}},{{1,2.1,2}})); assert(!Envelope({{-1,-0.4,-2}},{{1,1.8,2}})); assert(!Envelope({{1,0,2}},{{-1,1.8,-2}})); assert(!Envelope({{NAN,0,-2}},{{1,1.8,2}})); assert(!Envelope({{-1,0,-2}},{{1,INFINITY,2}})); } ''') print('PASS: native garage families only; rubble/furniture/military garages rejected; oversized and invalid vehicle bounds rejected')