dispatch') && str_contains($actionBody, 'CloudAgentDispatchUncertain') && str_contains($actionBody, "'/api/v1/jobs/'"), 'Action endpoint is not wired to the Agent operation/status boundary.'); foreach (['CloudJobService::enqueue', 'CloudEngineClient', 'ssh', 'SSH', 'shell_exec', 'curl_exec'] as $forbidden) { $assert(!str_contains($actionBody, $forbidden), 'Action endpoint still contains a legacy transport/queue reference: ' . $forbidden); } $assert(str_contains($service, 'CloudAgentOperationIdentity::uuidForIdempotencyKey') && str_contains($service, '重试必须同时提供 operation_id 和幂等键') && !str_contains($service, 'idempotencyKeyForOperationId') && str_contains($service, 'CloudAgentVmGateway') && str_contains($service, "'action'") && str_contains($service, "'instance_id' => (string)"), 'Action service lost typed identity, gateway dispatch, or browser DTO projection.'); $assert(str_contains($identity, 'random_bytes(16)') && str_contains($identity, 'uuidForIdempotencyKey') && str_contains($identity, 'validateIdempotencyKey') && !str_contains($identity, 'idempotencyKeyForOperationId'), 'Agent operation identity must use UUIDs and bounded idempotency keys without deriving a key from an opaque operation UUID.'); $assert(str_contains($gateway, "'poweroff' => 'destroy'") && str_contains($gateway, 'isReducedFailure') && str_contains($gateway, 'isDefinitiveReducedRejection') && str_contains($gateway, 'agent_operation_transport_uncertain'), 'Gateway lost the panel-to-Agent power mapping or reduced-error handling.'); $assert(str_contains($repository, 'lockInstanceState') && str_contains($repository, "'instance_busy'") && str_contains($repository, "whereIn('status', ['pending', 'running', 'uncertain'])") && str_contains($repository, 'in_array($request[\'kind\'], self::MUTATING_KINDS, true)'), 'Agent mutations lost the per-instance durable serialization gate.'); $assert(str_contains($actionBody, 'bodyIdempotency !== $headerIdempotency') && str_contains($actionBody, 'bodyOperationId !== $headerOperationId') && str_contains($actionBody, '重试必须同时提供 operation_id 和幂等键') && str_contains($actionBody, 'CloudAgentOperationException'), 'Action endpoint must reject split identity headers and preserve deterministic repository errors.'); $assert(str_contains($runtime, 'POWER_OPERATION_STORAGE_PREFIX') && str_contains($runtime, 'powerOperationStorageKey(vmId, action, vmUuid = \'\')') && str_contains($runtime, 'powerOperationMemory') && str_contains($runtime, "body: { action, idempotency_key: idempotencyKey }") && str_contains($runtime, "headers: { 'Idempotency-Key': idempotencyKey }") && str_contains($runtime, 'allowUncertain: true') && str_contains($runtime, 'reconcile: true') && str_contains($runtime, '${path}/reconcile') && str_contains($runtime, '结果待核对') && str_contains($runtime, 'clearPowerOperationKey'), 'Power UI must persist one bounded idempotency key and surface uncertain Agent results without retrying.'); fwrite(STDOUT, "Cloud Agent action cutover contract passed.\n");