actor($request, $write)') && str_contains($controller, '$this->actor($request, true)'), 'Scheduling reads must allow administrators while writes stay super-admin only.'); $assert(str_contains($controller, "'resource_pool_id', 'scheduler_state'") && !str_contains(substr($controller, strpos($controller, 'public function hostScheduling'), strpos($controller, 'public function userIsoSettings') - strpos($controller, 'public function hostScheduling')), 'public_ip'), 'The scheduling allowlist must not accept manual public IP fields.'); $saveStart = strpos($service, 'public static function save'); $saveEnd = strpos($service, 'private static function validateActive', $saveStart); $save = $saveStart === false || $saveEnd === false ? '' : substr($service, $saveStart, $saveEnd - $saveStart); $hostLock = strpos($save, "CloudHost::where('id', \$hostId)->lockForUpdate()"); $membershipLock = strpos($save, 'CloudHostPoolMembershipService::lockedRows'); $policyLock = strpos($save, "CloudHostCapacityPolicy::where('host_id', \$hostId)"); $attachmentLock = strpos($save, 'assertNetworkLine($host, $line)'); $assert($save !== '' && $hostLock !== false && $membershipLock !== false && $policyLock !== false && $attachmentLock !== false && $hostLock < $membershipLock && $membershipLock < $policyLock && $policyLock < $attachmentLock && str_contains($service, '->lockForUpdate()->first();'), 'Scheduling writes must lock host, membership, policy and network guard in order.'); $assert(str_contains($service, 'CloudHostPoolMembershipService::replaceLocked(') && str_contains($service, "'memberships' => \$memberships->map") && str_contains($membershipService, 'CloudHostResourcePoolMembership::where(\'host_id\'') && str_contains($membershipService, 'if ($rows->isEmpty()' . ' && $host->resource_pool_id !== null)') && str_contains($membershipService, 'public const SAFE_PRIORITY = 0;') && str_contains($membershipService, 'public const SAFE_WEIGHT = 100;') && str_contains($membershipService, '$row->delete();') && str_contains($membershipService, '宿主机存在多个启用中的资源池成员关系'), 'Membership authority, legacy backfill or first-release single-row policy is missing.'); $assert(str_contains($service, "\$schedulerState === 'active'") && str_contains($service, 'CloudNetworkLineFeature::enabled()') && str_contains($service, "(string) \$pool->status !== 'active'") && str_contains($service, "(string) \$region->status !== 'active'") && str_contains($service, '$safety >= $configured'), 'Active scheduling must validate the host, pool hierarchy and safety reserves.'); $assert(str_contains($service, 'assertReservationLine($host, $pool, $line)') && str_contains($service, "->whereIn('state', ['held', 'uncertain', 'committed'])") && str_contains($service, '宿主机仍有其他线路的实例或资源预留,不能跨线路更换资源池'), 'Hosts with live reservations must not move their configured network line across sales lines.'); $assert(str_contains($service, 'assertNetworkLine($host, $line)') && str_contains($service, 'CloudHostNetworkAttachment::where(') && str_contains($service, 'CloudPublicIpPool::where(') && str_contains($service, '宿主机已有其他线路的公网网络接入,不能静默跨线路更换资源池'), 'Configured network attachments must prevent silent cross-line relabeling.'); $assert(!str_contains($service, 'CloudHostInventorySyncService') && !str_contains($service, 'syncOne(') && str_contains($service, 'hostUsage(') && str_contains($service, 'capacityDto('), 'Scheduling capacity must come from panel policy and reservation/IP ledgers without inventory sync.'); $assert(str_contains($template, 'data-admin-host-scheduling-drawer') && str_contains($template, 'id="host-panel-capacity"') && str_contains($template, '{if $admin_can_manage|default:false}') && str_contains($template, '不扫描宿主机') && str_contains($template, '公网 IP 由面板地址池配置和账本维护') && !str_contains($template, 'host-capacity-sync') && !str_contains($template, '宿主机盘点'), 'The host drawer must expose panel-owned capacity and IP ledger controls.'); $assert(str_contains($script, 'window.VenixDrawerMotion.openDrawerWithMotion') && str_contains($script, 'window.VenixDrawerMotion.closeDrawerWithMotion') && str_contains($script, '/scheduling') && !str_contains($script, '/capacity-sync'), 'The host drawer must reuse shared motion and the panel scheduling endpoint.'); $assert(preg_match("/venix_asset_version value='([0-9]+)'/", $assets, $match) === 1 && (int) $match[1] >= 2026100313, 'Shared asset version must be bumped for admin.js changes.'); $assert(!file_exists($root . '/public/cloud/admin-host-scheduling.css'), 'Host scheduling must not introduce a standalone CSS file.'); echo "Administrator host scheduling contract checks passed.\n";