Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(hcc): decouple readiness from initial fleet reconciliation

Alfredo Lopez88533a284798
diff --git a/Makefile b/Makefile
index 664e38ecc..ca0e77f5a 100644
--- a/Makefile
+++ b/Makefile
@@ -849,6 +849,11 @@ test-e2e-hcc-communicationchannel-watch-recovery: ## Run isolated minikube HCC w
@echo "Running HCC CommunicationChannel watch-recovery gate..."
E2E_HCC_WATCH_FAULT_INJECTION=1 KUBECONTEXT=$(E2E_KUBECONTEXT) bash scripts/e2e/e2e-hcc-communicationchannel-watch-recovery.sh
+.PHONY: test-e2e-hcc-readiness-bootstrap
+test-e2e-hcc-readiness-bootstrap: ## Prove HCC readiness while its initial Host fleet pass remains active
+ @echo "Running HCC initial-fleet readiness gate..."
+ E2E_HCC_READINESS_FAULT_INJECTION=1 KUBECONTEXT=$(E2E_KUBECONTEXT) bash scripts/e2e/e2e-hcc-readiness-bootstrap.sh
+
.PHONY: test-e2e-stateless-multinode
test-e2e-stateless-multinode: ## Run stateless multi-node lane (opt-in: STATELESS_MULTINODE_GATE=1; needs >=2 schedulable nodes; exit 3 = cross-node UNVERIFIED)
@echo "Running stateless multi-node lane..."
@@ -941,4 +946,3 @@ run-platform-security-gates: ## Execute the revised platform security gate runne
help: ## Show this help
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-24s\033[0m %s\n", $$1, $$2}'
-
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index 2e04d1e84..e5333af94 100644
--- a/host-context-controller/package-lock.json
+++ b/host-context-controller/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-host-context-controller",
- "version": "0.1.158",
+ "version": "0.1.159",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.158",
+ "version": "0.1.159",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@clerum/image-policy": "file:../packages/image-policy",
diff --git a/host-context-controller/package.json b/host-context-controller/package.json
index 32eca539e..221dc92d7 100644
--- a/host-context-controller/package.json
+++ b/host-context-controller/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-host-context-controller",
- "version": "0.1.158",
+ "version": "0.1.159",
"description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API",
"main": "dist/main.js",
"engines": {
diff --git a/host-context-controller/src/k8sClient.test.ts b/host-context-controller/src/k8sClient.test.ts
index 375a37333..76ecbe85f 100644
--- a/host-context-controller/src/k8sClient.test.ts
+++ b/host-context-controller/src/k8sClient.test.ts
@@ -1,7 +1,9 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import * as http from 'http'
import { HostFleetReconcileError } from './hostReconciler'
import { HostK8sRequestTimeoutError } from './k8s/hostK8sApiClient'
import { McpServerWatcher, listAllCommunicationChannels, listAllHosts } from './k8sClient'
+import { ContextMapperServer } from './server'
import type { HostCRD } from './types'
function deferred<T = void>(): {
@@ -18,6 +20,32 @@ function deferred<T = void>(): {
return { promise, resolve, reject }
}
+async function requestReadyOverHttp(server: ContextMapperServer): Promise<{
+ statusCode: number | undefined
+ body: string
+}> {
+ const listener = (server as unknown as { server: http.Server | null }).server
+ const address = listener?.address()
+ if (!address || typeof address === 'string') {
+ throw new Error('HCC readiness listener did not bind a TCP port')
+ }
+
+ return new Promise((resolve, reject) => {
+ const request = http.get(
+ { host: '127.0.0.1', port: address.port, path: '/ready' },
+ response => {
+ let body = ''
+ response.setEncoding('utf8')
+ response.on('data', chunk => {
+ body += chunk
+ })
+ response.on('end', () => resolve({ statusCode: response.statusCode, body }))
+ }
+ )
+ request.once('error', reject)
+ })
+}
+
const mocks = vi.hoisted(() => {
const listNamespacedCustomObject = vi.fn()
const ensureDefaultPolicies = vi.fn().mockResolvedValue(undefined)
@@ -252,6 +280,69 @@ describe('McpServerWatcher startup', () => {
expect(mocks.sfsFullReconcile).toHaveBeenCalledWith([])
})
+ it('completes safe bootstrap while the initial Host fleet reconciliation continues in background', async () => {
+ const initialFleet = deferred()
+ mocks.hostFullReconcile.mockImplementationOnce(() => initialFleet.promise)
+ mocks.listNamespacedCustomObject.mockImplementation(async ({ plural }: { plural: string }) => {
+ if (plural === 'communicationchannels') {
+ return { metadata: { resourceVersion: 'safe-bootstrap-rv' }, items: [] }
+ }
+ return { items: [] }
+ })
+ const watcher = new McpServerWatcher()
+ const startMcpServerWatch = vi
+ .spyOn(watcher as any, 'startMcpServerWatch')
+ .mockResolvedValue(undefined)
+ const startContextWatch = vi
+ .spyOn(watcher as any, 'startContextWatch')
+ .mockResolvedValue(undefined)
+ const startSharedFileSystemWatch = vi
+ .spyOn(watcher as any, 'startSharedFileSystemWatch')
+ .mockResolvedValue(undefined)
+ const startGlobalFileSystemWatch = vi
+ .spyOn(watcher as any, 'startGlobalFileSystemWatch')
+ .mockResolvedValue(undefined)
+
+ const server = new ContextMapperServer(watcher, 0)
+ await server.start()
+ const bootstrap = watcher.start()
+
+ try {
+ await vi.waitFor(() => expect(mocks.hostFullReconcile).toHaveBeenCalledOnce())
+
+ await expect(bootstrap).resolves.toBeUndefined()
+ server.setReady(true)
+ const ready = await requestReadyOverHttp(server)
+
+ expect(ready.statusCode).toBe(200)
+ expect(JSON.parse(ready.body)).toEqual({ status: 'ready', ready: true })
+ expect(startMcpServerWatch).toHaveBeenCalledOnce()
+ expect(startContextWatch).toHaveBeenCalledOnce()
+ expect(startSharedFileSystemWatch).toHaveBeenCalledOnce()
+ expect(startGlobalFileSystemWatch).toHaveBeenCalledOnce()
+ expect(watcher.isCommunicationChannelCacheSynced()).toBe(true)
+ } finally {
+ initialFleet.resolve(undefined)
+ await bootstrap.catch(() => undefined)
+ await server.stop()
+ watcher.stop()
+ }
+ })
+
+ it('rejects safe bootstrap when the McpServer watch cannot be established', async () => {
+ const watcher = new McpServerWatcher()
+ vi.spyOn(watcher as any, 'startMcpServerWatch').mockRejectedValue(
+ new Error('watch unavailable')
+ )
+ vi.spyOn(watcher as any, 'startContextWatch').mockResolvedValue(undefined)
+ vi.spyOn(watcher as any, 'startSharedFileSystemWatch').mockResolvedValue(undefined)
+ vi.spyOn(watcher as any, 'startGlobalFileSystemWatch').mockResolvedValue(undefined)
+ vi.spyOn(watcher as any, 'startCommunicationChannelWatch').mockResolvedValue(undefined)
+
+ await expect(watcher.start()).rejects.toThrow('watch unavailable')
+ watcher.stop()
+ })
+
it('applies the request deadline wrapper to the finite Host inventory LIST', async () => {
mocks.listNamespacedCustomObject.mockImplementation(async ({ plural }: { plural: string }) => {
if (plural === 'hosts') return { items: [] }
@@ -1704,8 +1795,11 @@ describe('McpServerWatcher CommunicationChannel cache recovery', () => {
expect(mocks.hostReconcileHosts).not.toHaveBeenCalled()
expect(maxActivePasses).toBe(1)
- initialPass.resolve(undefined)
+ // Startup now resolves after safe bootstrap; the serialized fleet tail
+ // keeps running independently and must still drain the queued lifecycle pass.
await start
+ initialPass.resolve(undefined)
+ await vi.waitFor(() => expect(mocks.hostReconcileHosts).toHaveBeenCalledOnce())
expect(mocks.hostFullReconcile).toHaveBeenCalledOnce()
expect(mocks.hostReconcileHosts).toHaveBeenCalledOnce()
diff --git a/host-context-controller/src/k8sClient.ts b/host-context-controller/src/k8sClient.ts
index e850c29ae..f579a74c6 100644
--- a/host-context-controller/src/k8sClient.ts
+++ b/host-context-controller/src/k8sClient.ts
@@ -19,15 +19,10 @@ import { GfsReconciler } from './gfsReconciler'
import { ControlApiGfsSeedClient } from './gfsSeedClient'
import {
HostFleetReconcileError,
- HostReconciler,
type HostReconcileSource,
+ HostReconciler,
type ResolvedSfsMount,
} from './hostReconciler'
-import {
- hostDeleteCleanupTotal,
- hostFleetRequestsTotal,
- hostWatchRecoverySeconds,
-} from './metrics'
import {
type InfrastructureTelemetryReporter,
createInfrastructureTelemetryReporter,
@@ -35,6 +30,7 @@ import {
import { K8sGfsApi } from './k8s/gfsK8sApi'
import { makeHostK8sApiClient } from './k8s/hostK8sApiClient'
import { pvcName as sfsPvcName } from './k8s/sharedFileSystemFactory'
+import { hostDeleteCleanupTotal, hostFleetRequestsTotal, hostWatchRecoverySeconds } from './metrics'
import { NetworkPolicyReconciler } from './networkPolicyReconciler'
import { McpServerReconciler } from './reconciler'
import { SharedFileSystemReconciler } from './sharedFileSystemReconciler'
@@ -1752,7 +1748,12 @@ export class McpServerWatcher implements McpServerProvider {
this.ccLifecycleGeneration === 0
? this.beginCommunicationChannelLifecycleTransition()
: this.ccLifecycleGeneration
- await this.requestHostFleetReconcile(
+ // Bootstrap owns cache/watch continuity and the safe CC lifecycle boundary;
+ // full Host convergence can then proceed independently. Waiting for every
+ // Host to settle here made the HCC readiness probe proportional to fleet
+ // size, even though urgent Host watch events retain their own per-Host
+ // serialization and the fleet request carries its established retry path.
+ void this.requestHostFleetReconcile(
'initial Host reconciliation',
initialLifecycleGeneration,
'full'
diff --git a/scripts/e2e/e2e-hcc-readiness-bootstrap.sh b/scripts/e2e/e2e-hcc-readiness-bootstrap.sh
new file mode 100644
index 000000000..339f226fd
--- /dev/null
+++ b/scripts/e2e/e2e-hcc-readiness-bootstrap.sh
@@ -0,0 +1,304 @@
+#!/usr/bin/env bash
+# Proves that HCC exposes its real readiness and discovery endpoints while the
+# initial Host fleet reconciliation is still demonstrably in progress.
+#
+# The gate temporarily routes HCC's control-api token issuance to an isolated
+# in-cluster HTTP blocker, removes one HCC-owned Host bootstrap Secret, and
+# restarts HCC. The blocker holds the resulting token request open, providing a
+# deterministic boundary around the initial fleet pass without production test
+# hooks or timing a large synthetic fleet.
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+# shellcheck source=scripts/e2e/e2e-lib.sh
+source "${SCRIPT_DIR}/e2e-lib.sh"
+
+[ -n "$E2E_KUBECONTEXT" ] || {
+ echo "KUBECONTEXT or E2E_K8S_CONTEXT must select an explicit branch-scoped minikube context." >&2
+ exit 1
+}
+is_branch_scoped_e2e_context "$E2E_KUBECONTEXT" || {
+ echo "Refusing HCC readiness fault injection on non-branch context '${E2E_KUBECONTEXT}'." >&2
+ exit 1
+}
+require_safe_kube_context
+[ "${E2E_HCC_READINESS_FAULT_INJECTION:-0}" = 1 ] || {
+ echo "Set E2E_HCC_READINESS_FAULT_INJECTION=1 to acknowledge temporary HCC fault injection." >&2
+ exit 1
+}
+command -v jq >/dev/null 2>&1 || {
+ echo "jq is required" >&2
+ exit 1
+}
+
+HCC_NS="${HCC_NS:-control-plane}"
+HCC_DEPLOY="${HCC_DEPLOY:-host-context-controller}"
+HOST_NS="${MCP_HOST_NS:-mcp-host}"
+RUN_ID="$(date +%s)-$$"
+BLOCKER_NAME="$(truncate_rfc1123 "e2e-hcc-readiness-blocker-${RUN_ID}")"
+START_MARKER='Running initial Host reconciliation'
+COMPLETE_MARKER='Completed Host reconciliation after initial Host reconciliation'
+FAIL_MARKER='Host reconciliation after initial Host reconciliation failed'
+ORIGINAL_CONTROL_API_BASE_URL=""
+ORIGINAL_REPLICAS=""
+HOST_REF=""
+RUNTIME_SECRET=""
+HCC_MUTATED=0
+BLOCKER_CREATED=0
+
+die() {
+ fail "$*"
+ exit 1
+}
+
+wait_until() {
+ local timeout=$1 description=$2
+ shift 2
+ local elapsed=0
+ while [ "$elapsed" -lt "$timeout" ]; do
+ "$@" && return 0
+ sleep 1
+ elapsed=$((elapsed + 1))
+ done
+ echo "Timed out after ${timeout}s waiting for ${description}" >&2
+ return 1
+}
+
+running_hcc_pod() {
+ kctl get pods -n "$HCC_NS" -l "app=${HCC_DEPLOY}" \
+ --field-selector=status.phase=Running \
+ -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.deletionTimestamp}{"\n"}{end}' \
+ 2>/dev/null |
+ awk -F '\t' '$1 != "" && $2 == "" { print $1; exit }'
+}
+
+hcc_log_contains() {
+ local pod=$1 marker=$2
+ kctl logs "pod/${pod}" -n "$HCC_NS" -c host-context-controller 2>/dev/null |
+ grep -Fq "$marker"
+}
+
+blocker_holds_token_request() {
+ kctl logs "deployment/${BLOCKER_NAME}" -n "$HCC_NS" 2>/dev/null |
+ grep -Fq 'holding POST /api/v1/auth/mcp-host/'
+}
+
+secret_restored() {
+ kctl get secret "$RUNTIME_SECRET" -n "$HOST_NS" >/dev/null 2>&1
+}
+
+cleanup() {
+ local status=$? cleanup_failed=0
+ set +e
+
+ if [ "$HCC_MUTATED" = 1 ] && [ -n "$ORIGINAL_CONTROL_API_BASE_URL" ]; then
+ kctl set env deployment/"$HCC_DEPLOY" -n "$HCC_NS" \
+ "CONTROL_API_BASE_URL=${ORIGINAL_CONTROL_API_BASE_URL}" >/dev/null 2>&1 ||
+ cleanup_failed=1
+ kctl scale deployment "$HCC_DEPLOY" -n "$HCC_NS" \
+ --replicas="${ORIGINAL_REPLICAS:-1}" >/dev/null 2>&1 ||
+ cleanup_failed=1
+ kctl rollout status deployment "$HCC_DEPLOY" -n "$HCC_NS" --timeout=180s >/dev/null 2>&1 ||
+ cleanup_failed=1
+ if [ -n "$RUNTIME_SECRET" ]; then
+ wait_until 180 "HCC to restore ${RUNTIME_SECRET}" secret_restored >/dev/null 2>&1 ||
+ cleanup_failed=1
+ fi
+ fi
+
+ if [ "$BLOCKER_CREATED" = 1 ]; then
+ kctl delete service "$BLOCKER_NAME" -n "$HCC_NS" \
+ --ignore-not-found --wait=true --timeout=60s >/dev/null 2>&1 ||
+ cleanup_failed=1
+ kctl delete deployment "$BLOCKER_NAME" -n "$HCC_NS" \
+ --ignore-not-found --wait=true --timeout=60s >/dev/null 2>&1 ||
+ cleanup_failed=1
+ fi
+
+ if [ "$cleanup_failed" -ne 0 ]; then
+ echo "HCC readiness gate cleanup failed on context ${E2E_KUBECONTEXT}." >&2
+ echo "Verify deployment/${HCC_DEPLOY}, secret/${RUNTIME_SECRET:-unknown}, and ${BLOCKER_NAME}." >&2
+ exit 1
+ fi
+ exit "$status"
+}
+trap cleanup EXIT
+
+header "HCC readiness during initial Host fleet reconciliation"
+
+repo_root="$(git -C "${SCRIPT_DIR}/../.." rev-parse --show-toplevel)"
+[ -z "$(git -C "$repo_root" status --porcelain --untracked-files=normal)" ] ||
+ die "worktree has uncommitted changes; commit and pre-gate sync before runtime proof"
+expected_worktree_id="$(printf '%s' "$repo_root" | shasum | awk '{print $1}')"
+expected_head="$(git -C "$repo_root" rev-parse HEAD)"
+actual_worktree_id="$(kctl get configmap clerum-pre-gate-sync-state -n "$HCC_NS" \
+ -o jsonpath='{.data.worktreeId}' 2>/dev/null || true)"
+actual_head="$(kctl get configmap clerum-pre-gate-sync-state -n "$HCC_NS" \
+ -o jsonpath='{.data.gitHead}' 2>/dev/null || true)"
+[ "$actual_worktree_id" = "$expected_worktree_id" ] ||
+ die "cluster ownership marker does not match this worktree"
+[ "$actual_head" = "$expected_head" ] ||
+ die "cluster HEAD marker ${actual_head:-missing} does not match ${expected_head}"
+ok "branch-scoped cluster ownership matches this clean worktree and HEAD"
+
+kctl get nodes -o json |
+ jq -e 'any(.items[]; .metadata.labels["minikube.k8s.io/name"] != null)' >/dev/null ||
+ die "target context is not a minikube cluster"
+
+ORIGINAL_REPLICAS="$(kctl get deployment "$HCC_DEPLOY" -n "$HCC_NS" \
+ -o jsonpath='{.spec.replicas}')"
+[ "$ORIGINAL_REPLICAS" = 1 ] ||
+ die "expected exactly one HCC replica, found ${ORIGINAL_REPLICAS:-unknown}"
+ORIGINAL_CONTROL_API_BASE_URL="$(kctl get deployment "$HCC_DEPLOY" -n "$HCC_NS" \
+ -o jsonpath='{.spec.template.spec.containers[?(@.name=="host-context-controller")].env[?(@.name=="CONTROL_API_BASE_URL")].value}')"
+[ -n "$ORIGINAL_CONTROL_API_BASE_URL" ] ||
+ die "HCC CONTROL_API_BASE_URL is missing"
+
+HOST_REF="${E2E_HCC_READY_HOST_REF:-$(kctl get hosts -n "$HOST_NS" -o json |
+ jq -r '.items | sort_by(.metadata.name) | .[0].metadata.name // empty')}"
+[ -n "$HOST_REF" ] || die "no Host exists in ${HOST_NS}"
+RUNTIME_SECRET="host-${HOST_REF}-mcp-host-runtime-tokens"
+ok "selected existing Host ${HOST_REF} as the real initial-fleet work item"
+
+BLOCKER_CREATED=1
+kctl apply -f - >/dev/null <<EOF
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: ${BLOCKER_NAME}
+ namespace: ${HCC_NS}
+ labels:
+ app: control-api
+ e2e.clerum.io/hcc-readiness: "${RUN_ID}"
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ e2e.clerum.io/hcc-readiness: "${RUN_ID}"
+ template:
+ metadata:
+ labels:
+ app: control-api
+ e2e.clerum.io/hcc-readiness: "${RUN_ID}"
+ spec:
+ automountServiceAccountToken: false
+ terminationGracePeriodSeconds: 1
+ containers:
+ - name: blocker
+ image: $(kctl get deployment "$HCC_DEPLOY" -n "$HCC_NS" -o jsonpath='{.spec.template.spec.containers[?(@.name=="host-context-controller")].image}')
+ imagePullPolicy: IfNotPresent
+ command: [node, -e]
+ args:
+ - >-
+ require('http').createServer((request) => {
+ console.log('holding ' + request.method + ' ' + request.url);
+ request.resume();
+ }).listen(8090, '0.0.0.0');
+ readinessProbe:
+ tcpSocket: {port: 8090}
+ periodSeconds: 1
+ resources:
+ requests: {cpu: 5m, memory: 16Mi}
+ limits: {cpu: 50m, memory: 48Mi}
+ securityContext:
+ allowPrivilegeEscalation: false
+ capabilities: {drop: [ALL]}
+ readOnlyRootFilesystem: true
+ runAsNonRoot: true
+ runAsUser: 1000
+ runAsGroup: 1000
+ seccompProfile: {type: RuntimeDefault}
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: ${BLOCKER_NAME}
+ namespace: ${HCC_NS}
+ labels:
+ e2e.clerum.io/hcc-readiness: "${RUN_ID}"
+spec:
+ selector:
+ e2e.clerum.io/hcc-readiness: "${RUN_ID}"
+ ports:
+ - name: http
+ port: 8090
+ targetPort: 8090
+EOF
+kctl rollout status deployment "$BLOCKER_NAME" -n "$HCC_NS" --timeout=90s >/dev/null ||
+ die "isolated token-issuance blocker did not become ready"
+ok "isolated in-cluster blocker is ready"
+
+HCC_MUTATED=1
+kctl scale deployment "$HCC_DEPLOY" -n "$HCC_NS" --replicas=0 >/dev/null
+kctl wait pod -n "$HCC_NS" -l "app=${HCC_DEPLOY}" --for=delete --timeout=120s >/dev/null ||
+ die "existing HCC pod did not stop"
+kctl delete secret "$RUNTIME_SECRET" -n "$HOST_NS" --ignore-not-found >/dev/null
+kctl set env deployment/"$HCC_DEPLOY" -n "$HCC_NS" \
+ "CONTROL_API_BASE_URL=http://${BLOCKER_NAME}.${HCC_NS}.svc.cluster.local:8090" >/dev/null
+kctl scale deployment "$HCC_DEPLOY" -n "$HCC_NS" --replicas=1 >/dev/null
+
+new_hcc_pod=""
+capture_running_hcc() {
+ new_hcc_pod="$(running_hcc_pod)"
+ [ -n "$new_hcc_pod" ]
+}
+wait_until 120 "replacement HCC pod to enter Running" capture_running_hcc ||
+ die "replacement HCC pod did not start"
+wait_until 60 "initial Host reconciliation to start" \
+ hcc_log_contains "$new_hcc_pod" "$START_MARKER" ||
+ die "HCC never started the initial Host reconciliation"
+wait_until 60 "the selected Host token request to reach the blocker" blocker_holds_token_request ||
+ die "initial Host reconciliation never reached the deterministic blocker"
+hcc_log_contains "$new_hcc_pod" "$FAIL_MARKER" &&
+ die "initial Host reconciliation failed before the readiness assertion"
+hcc_log_contains "$new_hcc_pod" "$COMPLETE_MARKER" &&
+ die "initial Host reconciliation completed before the readiness assertion"
+ok "initial Host fleet reconciliation is demonstrably active and blocked"
+
+probe_script="$(cat <<'NODE'
+const http = require('http');
+function get(path) {
+ return new Promise((resolve, reject) => {
+ const request = http.get({host: '127.0.0.1', port: 8081, path}, response => {
+ let body = '';
+ response.setEncoding('utf8');
+ response.on('data', chunk => { body += chunk; });
+ response.on('end', () => resolve({status: response.statusCode, body}));
+ });
+ request.setTimeout(5000, () => request.destroy(new Error('timeout')));
+ request.once('error', reject);
+ });
+}
+(async () => {
+ const ready = await get('/ready');
+ const readyBody = JSON.parse(ready.body);
+ if (ready.status !== 200 || readyBody.status !== 'ready' || readyBody.ready !== true) {
+ throw new Error('unexpected readiness response: ' + ready.status + ' ' + ready.body);
+ }
+ const discovery = await get('/api/v1/mcpservers');
+ if (discovery.status !== 200) {
+ throw new Error('unexpected discovery response: ' + discovery.status);
+ }
+ const discoveryBody = JSON.parse(discovery.body);
+ if (!Array.isArray(discoveryBody.servers) || discoveryBody.contextRef !== '*') {
+ throw new Error('discovery response does not match the live API contract');
+ }
+ console.log(JSON.stringify({readyStatus: ready.status, discoveryStatus: discovery.status,
+ discoveredServers: discoveryBody.servers.length}));
+})().catch(error => { console.error(error.message); process.exit(1); });
+NODE
+)"
+probe_result="$(kctl exec "pod/${new_hcc_pod}" -n "$HCC_NS" -c host-context-controller -- \
+ node -e "$probe_script")" ||
+ die "real HCC readiness/discovery HTTP probe failed while the fleet pass was active"
+echo "$probe_result" | jq -e \
+ '.readyStatus == 200 and .discoveryStatus == 200 and (.discoveredServers | type == "number")' \
+ >/dev/null ||
+ die "HCC HTTP probe returned an invalid result: ${probe_result}"
+hcc_log_contains "$new_hcc_pod" "$COMPLETE_MARKER" &&
+ die "initial Host reconciliation completed before the HTTP assertions finished"
+ok "/ready returned 200 while the initial Host fleet pass remained active"
+ok "/api/v1/mcpservers returned a valid live discovery response during that same pass"
+
+header "HCC readiness bootstrap gate passed"
+echo "$probe_result"