scheduleTemplateBackfillAfterStorage(', $transactionEnd === false ? 0 : $transactionEnd ); $assert($transactionEnd !== false && $storageHook !== false && $storageHook > $transactionEnd, 'Storage completion schedules template backfill before its transaction commits.'); $assert(str_contains($agent, "scheduleTemplateBackfill(\$hostId, \$actor, 'agent_ready')"), 'A successful Agent readiness test does not trigger host backfill.'); $assert(str_contains($service, "->where('is_default', 1)") && str_contains($service, "private const TEMPLATE_STATES = ['active', 'degraded', 'error']") && str_contains($service, 'CloudAgentSettingsService::enabledHostIds()') && str_contains($service, 'CloudTemplateReplicaCoordinator::isExactReplica('), 'Host backfill is not constrained to ready hosts and current generations.'); $assert(str_contains($service, 'foreach ($plan[\'pending\'] as $templateId)') && str_contains($service, '} catch (\\Throwable $error) {'), 'One template failure can abort the remaining ready-host backfill plan.'); echo "Template ready-host backfill contracts passed.\n";