file_get_contents($root . '/' . $path); $assert = static function (bool $condition, string $message): void { if (!$condition) { throw new RuntimeException($message); } }; $schema = $read('sql/cloud.sql'); $setup = $read('app/Command/CloudSetup.php'); $routes = $read('config/routes_cloud.php'); $middleware = $read('app/Middleware/CloudApi.php'); $controller = $read( 'app/Controllers/CloudAdminHostNetworkAttachmentController.php' ); $service = $read( 'app/Services/Cloud/CloudHostNetworkAttachmentService.php' ); $agent = $read('app/Services/Cloud/CloudAgentSettingsService.php'); $template = $read('resources/views/venix/admin/hosts/index.tpl'); $client = $read('public/cloud/admin-hosts.js'); $assets = $read('resources/views/venix/layout_assets.tpl'); $assert(str_contains($schema, 'network_selectors_json LONGTEXT NOT NULL') && str_contains($schema, 'config_revision BIGINT UNSIGNED NOT NULL DEFAULT 1') && str_contains($schema, 'verified_agent_revision BIGINT UNSIGNED NOT NULL DEFAULT 0') && str_contains($schema, "verification_state VARCHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'never'") && str_contains($schema, 'UNIQUE KEY cloud_host_network_selector (host_id, network_selector)') && str_contains($schema, 'cloud_network_attachment_verification') && str_contains($setup, "'network_selectors_json'") && str_contains($setup, "'verification_error_code'"), 'Fresh schema/setup lost independent Agent selector evidence.'); $assert(str_contains($routes, '/network-attachments\'') && str_contains($routes, '/network-attachments/discover') && str_contains($routes, '/network-attachments/{attachment_key:[0-9a-f]{32}}/test') && str_contains($middleware, 'network-attachments') && str_contains($controller, 'CloudAccess::manage($actor)') && str_contains($controller, "'Cache-Control', 'private, no-store'") && str_contains($controller, "'expected_revision'"), 'Attachment HTTP routes lost authorization, no-store or CAS boundaries.'); $assert(str_contains($service, 'self::assertAdminRead($actor)') && substr_count($service, 'CloudAccess::manage($actor);') >= 4, 'Attachment service lost read or mutation authorization boundaries.'); $assert(str_contains($agent, "->request('GET', '/v1/capabilities', \$actor)") && str_contains($agent, 'network_selectors_json') && str_contains($agent, 'testedNetworkSelectors(') && str_contains($service, 'CloudAgentSettingsService::probeNetworkSelectors') && str_contains($service, 'CloudAgentSettingsService::testedNetworkSelectors') && str_contains($service, "verification_state = 'verified'") && str_contains($service, 'verified_agent_revision') && str_contains($service, 'agent_network_selector_missing') && !str_contains($service, 'sync_state = \'verified\''), 'Attachment verification no longer uses exact current Agent evidence.'); $assert(str_contains($service, 'CloudHostPoolMembershipService::lockedRows') && str_contains($service, 'assertMembershipLine(') && str_contains($service, 'sameConfiguration(') && str_contains($service, 'expected_revision') && str_contains($service, 'request_key') && str_contains($service, "scheduler_state === 'active'") && str_contains($service, "->where('status', 'active')") && str_contains($service, 'CloudPublicIpPool::where('), 'Attachment writes lost membership, idempotency, CAS or bound-pool guards.'); $assert(str_contains($template, 'id="host-config-network-attachments"') && str_contains($template, 'id="host-network-attachments-drawer"') && str_contains($template, 'id="host-network-attachment-new-selector"') && str_contains($template, 'default_network 仅为兼容默认值') && str_contains($template, '{if !$admin_can_manage|default:false}disabled{/if}') && str_contains($client, "networkAttachments: openHostNetworkAttachments") && str_contains($client, '/network-attachments/discover`, { method: \'POST\', body: {} }') && str_contains($client, '/network-attachments/${encodeURIComponent(attachmentKey)}/test`') && str_contains($client, "{ method: 'PUT', body }") && str_contains($client, "{ method: 'POST', body }") && str_contains($client, 'if (!hostId || !canManage || state.networkAttachmentBusy) return;') && str_contains($client, 'state.networkAttachmentCandidates.includes(selector)') && str_contains($client, 'expected_revision: expectedRevision') && !file_exists($root . '/public/cloud/admin-host-network.css'), 'Network attachment drawer lost exact Agent candidates, CAS writes, read-only guards or shared drawer styling.'); $assert(preg_match("/venix_asset_version value='([0-9]+)'/", $assets, $match) === 1 && (int) $match[1] >= 2026110205, 'Shared browser asset version does not cover the network attachment drawer.'); echo "Administrator host network attachment contracts passed.\n";