country_code = $countryCode;') && $hostWrite !== '' && str_contains($hostWrite, 'CloudAgentSettingsService::invalidateForNetworkSelectorChange(') && !str_contains($hostWrite, '->request('), 'Host writes must persist country_code and invalidate stale selector readiness without contacting the Agent.'); $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($controller, "preg_match('/^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/D', \$network)") && str_contains($controller, 'Agent network_selectors') && str_contains($client, "'host-network': h.default_network || 'public'") && str_contains($template, 'value="public"') && str_contains($template, 'Agent 网络选择器 key') && str_contains($template, '不能填写 bridge:br0'), 'Host network input must use the stable public Agent selector instead of a raw bridge name.'); $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') && str_contains($client, "const body = { name: byId('host-name').value.trim(), enabled: byId('host-enabled').checked, country_code: byId('host-country-code').value, region: byId('host-region').value.trim(), default_network: byId('host-network').value.trim() }"), '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";