Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(hcc): apply cheap low-risk Zach88 round-2 nits (#447)
Alfredo Lopezc1597988d404
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex 9f10b8432..f406d893c 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.239",+ "version": "0.1.240","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.239",+ "version": "0.1.240","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.jsonindex 37be548c1..f98cd3935 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.239",+ "version": "0.1.240","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.tsindex fd624ce4e..a065444c1 100644--- a/host-context-controller/src/k8sClient.test.ts+++ b/host-context-controller/src/k8sClient.test.ts@@ -109,14 +109,31 @@ async function requestMetricsOverHttp(server: ContextMapperServer): Promise<{// Label order is not part of the Prometheus contract. Match each label// independently so a scrape-path pin cannot pass on registry.get() and fail-// on the text GKE actually keys.+// on the text GKE actually keys. Require the pair to end at ',' or '}' so a+// value cannot match as a prefix of a longer sibling (result="certified"+// must not hit result="certified-extra").+function promLabelPairPresent(labelPart: string, key: string, value: string): boolean {+ const needle = `${key}="${value}"`+ let from = 0+ while (from < labelPart.length) {+ const at = labelPart.indexOf(needle, from)+ if (at < 0) return false+ const after = labelPart[at + needle.length]+ if (after === ',' || after === '}' || after === undefined) return true+ from = at + 1+ }+ return false+}+function readPromTextMetric(text: string, name: string, labels: Record<string, string>): number {for (const line of text.split('\n')) {if (!line.startsWith(`${name}{`)) continueconst close = line.indexOf('}')if (close < 0) continueconst labelPart = line.slice(name.length, close + 1)- if (!Object.entries(labels).every(([key, value]) => labelPart.includes(`${key}="${value}"`))) {+ if (+ !Object.entries(labels).every(([key, value]) => promLabelPairPresent(labelPart, key, value))+ ) {continue}const value = Number(line.slice(close + 1).trim())@@ -125,6 +142,21 @@ function readPromTextMetric(text: string, name: string, labels: Record<string, sreturn 0}+describe('readPromTextMetric', () => {+ it('does not treat a label value as a prefix of another', () => {+ const text = [+ 'clerum_hcc_initial_convergence_pass_results_total{lane="NetworkPolicy",result="certified-extra"} 9',+ 'clerum_hcc_initial_convergence_pass_results_total{lane="NetworkPolicy",result="certified"} 3',+ ].join('\n')+ expect(+ readPromTextMetric(text, 'clerum_hcc_initial_convergence_pass_results_total', {+ lane: 'NetworkPolicy',+ result: 'certified',+ })+ ).toBe(3)+ })+})+function stubAuthoritativeInventoryWatch(watcher: McpServerWatcher,kind: 'McpServer' | 'Context',diff --git a/scripts/e2e/e2e-hcc-np-convergence-ladder.sh b/scripts/e2e/e2e-hcc-np-convergence-ladder.shindex 7d1a1acb2..e6363965c 100755--- a/scripts/e2e/e2e-hcc-np-convergence-ladder.sh+++ b/scripts/e2e/e2e-hcc-np-convergence-ladder.sh@@ -39,6 +39,14 @@ source "${SCRIPT_DIR}/_lib/hcc-ready-series.sh"# e2e-lib log() writes stdout. This probe captures helper output as pod names,# so progress lines must not leak into those substitutions.log() { echo -e "${CYAN}[E2E]${NC} $*" >&2; }+# Shared ready_status hardcodes loopback:8081. Keep /ready on the same+# HCC_PROBE_* pair as /metrics so an override cannot split the two probes.+ready_status() {+ local pod=$1+ kctl exec "pod/$pod" -n "$HCC_NS" -c host-context-controller -- \+ wget -T 10 -t 1 -qO- "http://${HCC_PROBE_HOST}:${HCC_PROBE_PORT}/ready" >/dev/null 2>&1 &&+ echo 200 || echo 503+}OWNED_MINIKUBE_PROFILE="clerum-fix-447-hcc-certification-watchdog-45626152"VACUOUS_EXIT=3@@ -109,11 +117,6 @@ die() {exit 1}-hcc_ready_now() {- local pod- pod="$(running_hcc_pod)" && [ -n "$pod" ] && [ "$(ready_status "$pod")" = 200 ]-}-hcc_pod_uid() {local pod=$1kctl get pod "$pod" -n "$HCC_NS" -o jsonpath='{.metadata.uid}'@@ -189,9 +192,9 @@ assert_convergence_metrics_closure() {fail "INCONCLUSIVE: no deferred-unsynced pass on ${pod} — /metrics closure is vacuous for #447"return 1fi- [ "${swallowed:-0}" = "$deferred" ] &&- ok "wire /metrics: swallowed{unsynced}=${swallowed} == deferred-unsynced=${deferred}" ||- fail "wire /metrics: swallowed{unsynced}=${swallowed} != deferred-unsynced=${deferred}"+ [ "${swallowed:-0}" -ge 1 ] &&+ ok "wire /metrics: swallowed{unsynced}=${swallowed}" ||+ fail "wire /metrics: swallowed{unsynced}=${swallowed} after deferred-unsynced>=1"[ "${retries:-0}" -ge 1 ] &&ok "wire /metrics: retries_total=${retries} (armed; not attributed to the 5s timer alone)" ||fail "wire /metrics: retries_total=${retries} after a deferred-unsynced pass"@@ -235,7 +238,7 @@ write_evidence_artifact() {cleanup() {local status=$? cleanup_failed=0 restore_ok=1- trap - EXIT+ trap - EXIT INT TERMset +eif [ "$ROLLOUT_TRIGGERED" = 1 ]; thenkctl rollout status deployment "$HCC_DEPLOY" -n "$HCC_NS" --timeout=240s >/dev/null 2>&1 || restore_ok=0@@ -333,7 +336,7 @@ wait_ready_after_observation() {return 1}-trap cleanup EXIT+trap cleanup EXIT INT TERMacquire_hcc_watch_gate_lock