shadow -> enforced'), 'Runbook no longer documents the ordered rollout state machine.'); $assert(str_contains($runbook, 'Shadow mode creates the real pool') && str_contains($runbook, 'immutable ledger') && str_contains($runbook, '`traffic_pool_exhausted` network') && str_contains($runbook, 'Enforced mode is irreversible'), 'Shadow/enforced side-effect boundaries are incomplete.'); foreach ([ 'no_network_lines', 'line_frozen_identity_mismatch', 'pool_attention', 'projection_invalid', 'missing_entitlements', 'missing_pools', 'period_identity_mismatch', 'instance_not_ready', 'legacy_network_unsettled', 'usage_unsettled', 'cursor_missing', 'cursor_attention', 'traffic_sample_stale', 'traffic_scan_failures', 'policy_unsettled', 'traffic_restriction_present', 'network_job_unsettled', ] as $blocker) { $assert(str_contains($runbook, '`' . $blocker . '`'), 'Runbook is missing readiness blocker: ' . $blocker); } $assert(str_contains($runbook, 'ready = true') && str_contains($runbook, 'can_enforce = true') && str_contains($runbook, 'blockers = []'), 'Runbook no longer requires the complete enforcement gate.'); $assert(str_contains($runbook, '`pool_attention` and `cursor_attention` are different') && str_contains($runbook, 'they are not') && str_contains($runbook, 'cleared automatically') && str_contains($runbook, 'local, audited break-glass CLI') && !str_contains($runbook, 'no production UI, API or CLI resolver'), 'Runbook no longer requires explicit version-bound attention resolution.'); $inspectAt = strpos($runbook, 'cloudTrafficPoolAttention inspect --pool-id=N'); $repairAt = strpos($runbook, 'Repair the real counter or projection cause'); $freshInspectAt = strpos($runbook, 'Run `inspect` again'); $resolveAt = strpos($runbook, 'cloudTrafficPoolAttention resolve'); $inspectResolutionAt = strpos($runbook, 'cloudTrafficPoolAttention inspect-resolution'); $assert($inspectAt !== false && $repairAt !== false && $freshInspectAt !== false && $resolveAt !== false && $inspectResolutionAt !== false && $inspectAt < $repairAt && $repairAt < $freshInspectAt && $freshInspectAt < $resolveAt && $resolveAt < $inspectResolutionAt && str_contains($runbook, '--expected-version=V') && str_contains($runbook, '--resolution-key=UUID') && str_contains($runbook, '--apply') && str_contains($runbook, '--confirm=RESOLVE_TRAFFIC_POOL:N:V:UUID'), 'Runbook lost the inspect-repair-resolve break-glass sequence.'); $assert(str_contains($runbook, 'If stdout, SSH or the command response is lost, do not repeat `resolve`') && str_contains($runbook, '`committed=true`') && str_contains($runbook, '`committed=false`') && str_contains($runbook, 'exact command with the same UUID') && preg_match('/Never use one UUID for a different\s+pool/', $runbook) === 1 && str_contains($runbook, 'external incident/change ID') && str_contains($runbook, 'resolving attention may make the projection trustworthy'), 'Runbook lost response reconciliation, audit or network-impact rules.'); $assert(str_contains($runbook, 'retain the original `operation_id`') && str_contains($runbook, 'Never:') && str_contains($runbook, 'replay `network_suspend` or `network_resume`') && str_contains($runbook, 'Preserve the immutable ledger') && str_contains($runbook, 'derived projections forward') && str_contains($runbook, 'Do not stop lifecycle as a way to pause enforcement') && str_contains($runbook, 'stop `virt-cloud-worker.service`') && str_contains($runbook, '`virt-cloud-policy-worker@N.service`') && str_contains($runbook, 'Keep') && str_contains($runbook, '`virt-cloud-lifecycle.service`') && str_contains($runbook, '`virt-cloud-recovery-worker.service`') && preg_match('/restore the\s+workers only after/', $runbook) === 1, 'Runbook lost unknown-effect or forward-repair safety rules.'); $assert(str_contains($runbook, 'there is no HTTP or UI') && !preg_match('/traffic[-_\/a-z]*attention|attention[-_\/a-z]*traffic/i', $routes . "\n" . $mainRoutes) && !str_contains($adminTrafficJs, 'resolveAttention') && !str_contains($adminTrafficJs, 'cloudTrafficPoolAttention') && !str_contains($adminResourcesView, 'attention/resolve'), 'A second HTTP/UI attention resolver was exposed beside the local CLI.'); $controllerIterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $root . '/web/app/Controllers', FilesystemIterator::SKIP_DOTS ) ); foreach ($controllerIterator as $controllerFile) { if (!$controllerFile->isFile() || strtolower($controllerFile->getExtension()) !== 'php') { continue; } $controllerSource = file_get_contents($controllerFile->getPathname()); $assert(is_string($controllerSource) && !str_contains( $controllerSource, 'CloudTrafficPoolAccounting::resolveAttention(' ), 'HTTP controller exposes the local-only attention resolver: ' . $controllerFile->getFilename()); } foreach ([ 'external incident/change ID', 'executing host', 'SSH/sudo operator', 'reason, pool ID', 'pool version and UUIDv4', ] as $auditEvidence) { $assert(str_contains($runbook, $auditEvidence), 'Runbook lost attention audit evidence: ' . $auditEvidence); } foreach ([ '| `disabled`, no durable reference |', '| `shadow`, no durable reference |', '| `shadow`, durable period/pool reference |', '| `enforced` | No rollback;', '| Network operation has unknown effect |', ] as $matrixRow) { $assert(str_contains($runbook, $matrixRow), 'Runbook rollback matrix is incomplete: ' . $matrixRow); } foreach ([ 'cloudLifecycle', 'cloudWorker', '--policy-only', '--recovery-only', ] as $command) { $assert(str_contains($runbook, $command) && str_contains($xcat, $command), 'Runbook command does not match XCat: ' . $command); } $assert(str_contains($xcat, 'cloudTrafficPoolAttention inspect --pool-id=N') && str_contains($xcat, 'cloudTrafficPoolAttention inspect-resolution --resolution-key=UUID') && str_contains($xcat, 'cloudTrafficPoolAttention resolve --pool-id=N'), 'Runbook attention commands are not all exposed by XCat help.'); $assert(str_contains($contract, 'TRAFFIC_POOL_ROLLOUT.md') && str_contains($deployment, 'TRAFFIC_POOL_ROLLOUT.md'), 'Traffic-pool contract or deployment guide does not link the runbook.'); $assert(str_contains($agents, 'strict FEFO') && str_contains($agents, 'unused bytes') && str_contains($agents, 'unlimited periods never join a finite pool') && str_contains($agents, 'Legacy unpooled periods keep') && str_contains($agents, 'every active finite instance'), 'Repository instructions contradict the shared traffic-pool contract.'); $assert(str_contains($pruning, '严格 FEFO') && str_contains($pruning, '权益到期只作废自身未用额度') && str_contains($pruning, '无限流量账期不贡献也不消费有限流量池') && str_contains($pruning, '全部活动有限流量实例') && str_contains($pruning, '旧的未入池账期仍按实例独立额度处理'), 'Retained feature boundaries contradict the shared traffic-pool contract.'); echo "Cloud traffic-pool rollout runbook contract passed.\n";