country_code = $countryCode;') && $hostWrite !== '' && !str_contains($hostWrite, 'invalidateForNetworkSelectorChange') && !str_contains($hostWrite, '->request('), 'Host writes must persist country_code without making compatibility metadata an Agent readiness authority.'); $assert(str_contains($catalog, "'CN' => ['name' => '中国'") && str_contains($catalog, "'HK' => ['name' => '中国香港'") && str_contains($catalog, "'JP' => ['name' => '日本'") && str_contains($catalog, "'US' => ['name' => '美国'") && str_contains($catalog, "'SG' => ['name' => '新加坡'") && str_contains($catalog, '$code = strtoupper(trim($value));') && !str_contains($catalog, 'safeText'), 'The shared country catalog must normalize complete values without truncation.'); $assert(str_contains($pageController, "assign('cloud_country_options', CloudCountryCatalog::options())") && str_contains($legacyPageController, "assign('cloud_country_options', CloudCountryCatalog::options())") && str_contains($template, '{foreach $cloud_country_options as $country}') && str_contains($template, '{$country.name|escape}') && str_contains($template, '({$country.code|escape})'), 'Host country selector must render the shared readable country catalog.'); $assert(str_contains($template, 'id="host-country-code"') && preg_match('/id="host-region"[^>]*required[^>]*maxlength="64"/', $template) === 1 && str_contains($controller, '具体地区需为 1 至 64 字符'), 'Host editor must require a country and an exact region within the panel limit.'); $assert(str_contains($client, "'host-country-code': h.country_code || ''") && str_contains($client, "country_code: byId('host-country-code').value"), 'Host editor must round-trip country_code through the admin API.'); $assert(str_contains($hostWrite, 'CloudNetworkSelector::isValid($network)') && str_contains($template, 'id="host-network-type"') && str_contains($template, 'value="bridge" selected') && str_contains($template, 'value="network"') && str_contains($template, 'id="host-network-name"') && str_contains($template, 'value="br0"') && str_contains($template, 'id="host-network-warning"') && !str_contains($template, 'Agent 网络选择器 key'), 'Host network input must select an existing bridge or libvirt network with an explicit legacy warning.'); $legacyPublicInputs = [ 'host-public-pool', 'host-gateway', 'host-dns', 'host-reserved', 'host-vm-prefix', ]; foreach ($legacyPublicInputs as $inputId) { $assert(!str_contains($template, 'id="' . $inputId . '"'), 'The main host form still exposes the retired single-pool input: ' . $inputId); } $assert(!str_contains($client, 'function hostPublicNetworkPayload()') && !str_contains($controller, 'normalizeHostPublicNetwork') && str_contains($template, 'id="host-network-pools-drawer"') && !str_contains($hostWrite, 'public_pool_cidr') && !str_contains($hostWrite, 'public_dns_servers'), 'Public pools must use the dedicated panel-owned drawer, separate from host metadata writes.'); $assert(str_contains($template, 'href="/admin/agents"') && str_contains($template, '配置宿主机 Agent API') && !str_contains($template, 'host-private-key') && !str_contains($client, 'private_key') && !str_contains($controller, 'engineHost'), 'Host metadata must not retain old SSH/engine credentials; Agent API settings are managed on their dedicated page.'); echo "Structured cloud host country and region contracts passed.\n";