Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
chore: restore dev formatting drift
Josuée88187c677b6
diff --git a/control-ui/components/__tests__/GovernedTraceSurface.test.tsx b/control-ui/components/__tests__/GovernedTraceSurface.test.tsxindex 1a984cab3..97b8e7025 100644--- a/control-ui/components/__tests__/GovernedTraceSurface.test.tsx+++ b/control-ui/components/__tests__/GovernedTraceSurface.test.tsx@@ -1,11 +1,11 @@import { afterEach, describe, expect, it, vi } from 'vitest'import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'import {- type InfrastructureCostScopeCatalog,getGovernedTraceEvents,getInfrastructureCostScopes,getInfrastructureTraceCosts,isTraceCostsUnavailable,+ type InfrastructureCostScopeCatalog,} from '@lib/governedTrace'import { GovernedTraceSurface } from '../GovernedTraceSurface'diff --git a/control-ui/e2e/host-stateless-channel-rejection.spec.ts b/control-ui/e2e/host-stateless-channel-rejection.spec.tsindex 3467625f3..ecf8655fe 100644--- a/control-ui/e2e/host-stateless-channel-rejection.spec.ts+++ b/control-ui/e2e/host-stateless-channel-rejection.spec.ts@@ -39,8 +39,8 @@* 4. E2E_KUBECONTEXT (or CONTEXT) — an allowed kubectl context (clerum-test /* clerum-codex-* / gke_<project>_<zone>_<cluster>). Passed to every kubectl call.*/-import { type Page, expect, test } from '@playwright/test'import { execFileSync } from 'node:child_process'+import { type Page, expect, test } from '@playwright/test'const BASE_UI = process.env.CONTROL_UI_URL || 'http://localhost:3000'const ADMIN_USER = process.env.ADMIN_USER || 'admin'@@ -132,8 +132,7 @@ test.describe('operator sees the stateless × CommunicationChannel hard-rejectiotest.beforeAll(() => {// Fail loud on missing prerequisites rather than skipping silently.if (!HOST) throw new Error('E2E_STATELESS_HOST must name a dedicated stateless Host.')- if (!KUBECONTEXT)- throw new Error('E2E_KUBECONTEXT (or CONTEXT) must be set to an allowed context.')+ if (!KUBECONTEXT) throw new Error('E2E_KUBECONTEXT (or CONTEXT) must be set to an allowed context.')const host = getHostJson()// Guard: the target must actually be a stateless Host, or the whole scenario is invalid.const statelessRaw = kubectl([@@ -174,9 +173,7 @@ test.describe('operator sees the stateless × CommunicationChannel hard-rejectio'HCC did not hard-reject the stateless Host after the CommunicationChannel was applied ' +'(requires the Addendum-6 executor fix deployed).',})- .toMatch(- /"effectiveMode":"stateful".*"rejected":true|"rejected":true.*"effectiveMode":"stateful"/- )+ .toMatch(/"effectiveMode":"stateful".*"rejected":true|"rejected":true.*"effectiveMode":"stateful"/)const rejectionMessage = getHostJson().rejectionMessageexpect(rejectionMessage, 'StatelessEnableRejected condition must carry a message').toBeTruthy()@@ -202,9 +199,9 @@ test.describe('operator sees the stateless × CommunicationChannel hard-rejectio// (1) the warning banner container carries the reason verbatimawait expect(rejectionBanner).toContainText(rejectionMessage as string, { timeout: 20_000 })// (2) the lifecycle chip is a second visibility surface — assert it deliberately- await expect(page.locator('.cu-chip', { hasText: rejectionMessage as string })).toBeVisible({- timeout: 20_000,- })+ await expect(+ page.locator('.cu-chip', { hasText: rejectionMessage as string })+ ).toBeVisible({ timeout: 20_000 })// Disassociation recovery: remove the channel; HCC clears the rejection.// Strict delete (not the best-effort cleanup helper) so a real failure herediff --git a/desktop-app/test/e2e-playwright/stateless-wake.test.ts b/desktop-app/test/e2e-playwright/stateless-wake.test.tsindex d94b0c954..dddb6c05e 100644--- a/desktop-app/test/e2e-playwright/stateless-wake.test.ts+++ b/desktop-app/test/e2e-playwright/stateless-wake.test.ts@@ -774,7 +774,9 @@ async function expectAssistantMarkerRendered(// usable model list (ModelSelector returns null until data loads and renders a// non-interactive chip only when degraded), so a visible interactive picker with// selectable options is itself the proof.-async function exerciseVisibleModelPicker(appPage: import('@playwright/test').Page): Promise<void> {+async function exerciseVisibleModelPicker(+ appPage: import('@playwright/test').Page+): Promise<void> {const trigger = appPage.getByRole('button', { name: /^Model — / })await expect(trigger,@@ -881,12 +883,13 @@ test('Scenario 4 — concurrent session/model/message on a COLD wake, then two-c// exercise of the coordinator dedup (the Desktop mirror of bash Test 6). The// prewarm's status is the cold/warm oracle; the UI waking-state affordance is NOT// used for the mode because a transparent sub-hold-deadline wake never renders it.- const [prewarmDuringColdWake, sessionsDuringColdWake, modelsDuringColdWake] = await Promise.all([- probeStatelessPrewarm(appPage),- readStatelessSessionIds(appPage),- probeStatelessHostModels(appPage),- sendButton.click(),- ])+ const [prewarmDuringColdWake, sessionsDuringColdWake, modelsDuringColdWake] =+ await Promise.all([+ probeStatelessPrewarm(appPage),+ readStatelessSessionIds(appPage),+ probeStatelessHostModels(appPage),+ sendButton.click(),+ ])expect(sessionsDuringColdWake.error,`[stateless-wake] concurrent listSessions during the COLD wake must not 403/fail — ${sessionsDuringColdWake.error}`diff --git a/desktop-app/test/rpcTokenManager.test.ts b/desktop-app/test/rpcTokenManager.test.tsindex 7e603ad3c..4126151c4 100644--- a/desktop-app/test/rpcTokenManager.test.ts+++ b/desktop-app/test/rpcTokenManager.test.ts@@ -1,115 +1,113 @@-import { describe, expect, it, vi } from 'vitest'-import type { AuthClient } from '../src/authClient.js'-import { RpcTokenManager } from '../src/rpcTokenManager.js'--vi.mock('../src/config.js', () => ({- config: { requestTimeoutMs: 5000, externalRestApiBaseUrl: 'http://localhost:8091' },-}))-vi.mock('../src/httpClient.js', () => ({+import { describe, it, expect, vi } from "vitest";++vi.mock("../src/config.js", () => ({+ config: { requestTimeoutMs: 5000, externalRestApiBaseUrl: "http://localhost:8091" },+}));+vi.mock("../src/httpClient.js", () => ({requestJson: vi.fn(),- ApiError: class extends Error {- status = 0- bodyText = ''- },-}))+ ApiError: class extends Error { status = 0; bodyText = ""; },+}));++import { RpcTokenManager } from "../src/rpcTokenManager.js";+import type { AuthClient } from "../src/authClient.js";// ── Helpers ───────────────────────────────────────────────────────────────────-function makeAuthClient(token = 'rpc-token-123', expiresInSeconds = 60) {+function makeAuthClient(token = "rpc-token-123", expiresInSeconds = 60) {return {issueRpcToken: vi.fn().mockResolvedValue({token,- teamId: 'team-1',- scopes: ['host:message:invoke'],- hostRefs: ['chatllm'],+ teamId: "team-1",+ scopes: ["host:message:invoke"],+ hostRefs: ["chatllm"],expiresInSeconds,}),- } as unknown as AuthClient+ } as unknown as AuthClient;}// ── Tests ─────────────────────────────────────────────────────────────────────-describe('RpcTokenManager — initial state', () => {- it('returns null expiresAtMs before any token is fetched', () => {- const manager = new RpcTokenManager(makeAuthClient())- const meta = manager.getMetadata()+describe("RpcTokenManager — initial state", () => {+ it("returns null expiresAtMs before any token is fetched", () => {+ const manager = new RpcTokenManager(makeAuthClient());+ const meta = manager.getMetadata();- expect(meta.expiresAtMs).toBeNull()- expect(meta.scopes).toEqual([])- expect(meta.hostRefs).toEqual([])- })-})+ expect(meta.expiresAtMs).toBeNull();+ expect(meta.scopes).toEqual([]);+ expect(meta.hostRefs).toEqual([]);+ });+});-describe('RpcTokenManager — clear()', () => {- it('resets cache so next getOrIssue() fetches fresh', async () => {- const authClient = makeAuthClient()- const manager = new RpcTokenManager(authClient)+describe("RpcTokenManager — clear()", () => {+ it("resets cache so next getOrIssue() fetches fresh", async () => {+ const authClient = makeAuthClient();+ const manager = new RpcTokenManager(authClient);// Prime cache- await manager.getOrIssue('sess-token', ['host:message:invoke'])- expect(authClient.issueRpcToken).toHaveBeenCalledOnce()+ await manager.getOrIssue("sess-token", ["host:message:invoke"]);+ expect(authClient.issueRpcToken).toHaveBeenCalledOnce();// After clear(), a second getOrIssue() should re-fetch- manager.clear()- await manager.getOrIssue('sess-token', ['host:message:invoke'])- expect(authClient.issueRpcToken).toHaveBeenCalledTimes(2)- })-})--describe('RpcTokenManager — getOrIssue()', () => {- it('fetches a new token when cache is empty', async () => {- const authClient = makeAuthClient('rpc-fresh-token')- const manager = new RpcTokenManager(authClient)-- const result = await manager.getOrIssue('sess-token', ['host:message:invoke'])- expect(result.token).toBe('rpc-fresh-token')- expect(authClient.issueRpcToken).toHaveBeenCalledOnce()- })-- it('reuses cached token on second call when not expired', async () => {- const authClient = makeAuthClient('rpc-cached-token', 60)- const manager = new RpcTokenManager(authClient)-- const first = await manager.getOrIssue('sess-token', ['host:message:invoke'])- const second = await manager.getOrIssue('sess-token', ['host:message:invoke'])-- expect(first.token).toBe(second.token)+ manager.clear();+ await manager.getOrIssue("sess-token", ["host:message:invoke"]);+ expect(authClient.issueRpcToken).toHaveBeenCalledTimes(2);+ });+});++describe("RpcTokenManager — getOrIssue()", () => {+ it("fetches a new token when cache is empty", async () => {+ const authClient = makeAuthClient("rpc-fresh-token");+ const manager = new RpcTokenManager(authClient);++ const result = await manager.getOrIssue("sess-token", ["host:message:invoke"]);+ expect(result.token).toBe("rpc-fresh-token");+ expect(authClient.issueRpcToken).toHaveBeenCalledOnce();+ });++ it("reuses cached token on second call when not expired", async () => {+ const authClient = makeAuthClient("rpc-cached-token", 60);+ const manager = new RpcTokenManager(authClient);++ const first = await manager.getOrIssue("sess-token", ["host:message:invoke"]);+ const second = await manager.getOrIssue("sess-token", ["host:message:invoke"]);++ expect(first.token).toBe(second.token);// Should only have fetched once (cache hit)- expect(authClient.issueRpcToken).toHaveBeenCalledOnce()- })+ expect(authClient.issueRpcToken).toHaveBeenCalledOnce();+ });- it('re-fetches when token is expired (expiresInSeconds = 0)', async () => {- const authClient = makeAuthClient('rpc-expired', 0)- const manager = new RpcTokenManager(authClient)+ it("re-fetches when token is expired (expiresInSeconds = 0)", async () => {+ const authClient = makeAuthClient("rpc-expired", 0);+ const manager = new RpcTokenManager(authClient);// First call populates cache with 0s TTL (expired immediately)- await manager.getOrIssue('sess-token', ['host:message:invoke'])+ await manager.getOrIssue("sess-token", ["host:message:invoke"]);// Override to return fresh tokenvi.mocked(authClient.issueRpcToken).mockResolvedValueOnce({- token: 'rpc-fresh-2',- accessScope: 'team',- teamId: 'team-1',- scopes: ['host:message:invoke'],- hostRefs: ['chatllm'],+ token: "rpc-fresh-2",+ accessScope: "team",+ teamId: "team-1",+ scopes: ["host:message:invoke"],+ hostRefs: ["chatllm"],expiresInSeconds: 60,- })+ });- const result = await manager.getOrIssue('sess-token', ['host:message:invoke'])- expect(result.token).toBe('rpc-fresh-2')- expect(authClient.issueRpcToken).toHaveBeenCalledTimes(2)- })+ const result = await manager.getOrIssue("sess-token", ["host:message:invoke"]);+ expect(result.token).toBe("rpc-fresh-2");+ expect(authClient.issueRpcToken).toHaveBeenCalledTimes(2);+ });- it('returns metadata reflecting cached token after first fetch', async () => {- const manager = new RpcTokenManager(makeAuthClient('tok', 120))- await manager.getOrIssue('sess', ['host:message:invoke'])+ it("returns metadata reflecting cached token after first fetch", async () => {+ const manager = new RpcTokenManager(makeAuthClient("tok", 120));+ await manager.getOrIssue("sess", ["host:message:invoke"]);- const meta = manager.getMetadata()- expect(meta.expiresAtMs).toBeGreaterThan(Date.now())- expect(meta.scopes).toContain('host:message:invoke')- expect(meta.hostRefs).toContain('chatllm')- })-})+ const meta = manager.getMetadata();+ expect(meta.expiresAtMs).toBeGreaterThan(Date.now());+ expect(meta.scopes).toContain("host:message:invoke");+ expect(meta.hostRefs).toContain("chatllm");+ });+});// ── Subset-scope reuse: INTENTIONAL, pinned on purpose ────────────────────────//@@ -125,35 +123,35 @@ describe('RpcTokenManager — getOrIssue()', () => {// undocumented side effect: if someone later makes stream open a wake-capable// route, or narrows this cache to exact-scope keying, one of these two// assertions turns red and forces the decision to be made explicitly.-describe('RpcTokenManager — subset scope reuse', () => {- it('serves a narrower request from the cached superset token, which still carries host:wake:write', async () => {+describe("RpcTokenManager — subset scope reuse", () => {+ it("serves a narrower request from the cached superset token, which still carries host:wake:write", async () => {const authClient = {issueRpcToken: vi.fn().mockResolvedValue({- token: 'rpc-token-superset',- accessScope: 'team',- teamId: 'team-1',- scopes: ['host:activity:read', 'host:task:read', 'host:wake:write'],- hostRefs: ['chatllm'],+ token: "rpc-token-superset",+ accessScope: "team",+ teamId: "team-1",+ scopes: ["host:activity:read", "host:task:read", "host:wake:write"],+ hostRefs: ["chatllm"],expiresInSeconds: 60,}),- } as unknown as AuthClient- const manager = new RpcTokenManager(authClient)+ } as unknown as AuthClient;+ const manager = new RpcTokenManager(authClient);// Broad issuance (e.g. a finite operation that legitimately needs wake).await manager.getOrIssue(- 'sess-token',- ['host:activity:read', 'host:task:read', 'host:wake:write'],- ['chatllm']- )- expect(authClient.issueRpcToken).toHaveBeenCalledOnce()+ "sess-token",+ ["host:activity:read", "host:task:read", "host:wake:write"],+ ["chatllm"]+ );+ expect(authClient.issueRpcToken).toHaveBeenCalledOnce();// Narrower request (e.g. an observability read) — served from cache.- const reused = await manager.getOrIssue('sess-token', ['host:activity:read'], ['chatllm'])+ const reused = await manager.getOrIssue("sess-token", ["host:activity:read"], ["chatllm"]);// 1. Exactly ONE issuance: the subset did not trigger a second round trip.- expect(authClient.issueRpcToken).toHaveBeenCalledOnce()+ expect(authClient.issueRpcToken).toHaveBeenCalledOnce();// 2. The DELIVERED token is the cached superset — it still carries wake.- expect(reused.token).toBe('rpc-token-superset')- expect(reused.scopes).toContain('host:wake:write')- })-})+ expect(reused.token).toBe("rpc-token-superset");+ expect(reused.scopes).toContain("host:wake:write");+ });+});diff --git a/host-context-controller/src/hostReconciler.test.ts b/host-context-controller/src/hostReconciler.test.tsindex 495a4bc38..c6d258c89 100644--- a/host-context-controller/src/hostReconciler.test.ts+++ b/host-context-controller/src/hostReconciler.test.ts@@ -10,11 +10,7 @@ import {createMockNetworkingApi,createMockRbacApi,} from '../test/__fixtures__/testMocks'-import {- HostFleetReconcileError,- HostReconciler,- destructiveCleanupAllowed,-} from './hostReconciler'+import { HostFleetReconcileError, HostReconciler, destructiveCleanupAllowed } from './hostReconciler'import { HostK8sRequestTimeoutError } from './k8s/hostK8sApiClient'import { registry } from './metrics'import { HostCRD } from './types'@@ -359,20 +355,14 @@ describe('HostReconciler fleet failure isolation', () => {metadata: {name: 'orphan-a',namespace: 'mcp-host',- labels: {- 'clerum.io/managed-by': 'host-context-controller',- 'clerum.io/host': 'orphan-a',- },+ labels: { 'clerum.io/managed-by': 'host-context-controller', 'clerum.io/host': 'orphan-a' },},} as k8s.V1Deployment,{metadata: {name: 'orphan-b',namespace: 'mcp-host',- labels: {- 'clerum.io/managed-by': 'host-context-controller',- 'clerum.io/host': 'orphan-b',- },+ labels: { 'clerum.io/managed-by': 'host-context-controller', 'clerum.io/host': 'orphan-b' },},} as k8s.V1Deployment,])@@ -427,12 +417,7 @@ describe('HostReconciler bounded fleet workers', () => {rbacApi: asRbacApi(createMockRbacApi()),})// Isolate reconcile concurrency from the cleanup phase.- vi.spyOn(- reconciler as unknown as {- collectHostCleanupFailures(...args: unknown[]): Promise<unknown[]>- },- 'collectHostCleanupFailures'- ).mockResolvedValue([])+ vi.spyOn(reconciler as unknown as { collectHostCleanupFailures(...args: unknown[]): Promise<unknown[]> }, 'collectHostCleanupFailures').mockResolvedValue([])let active = 0let maxActive = 0const gates: Array<() => void> = []@@ -465,12 +450,7 @@ describe('HostReconciler bounded fleet workers', () => {networkingApi: asNetworkingApi(createMockNetworkingApi()),rbacApi: asRbacApi(createMockRbacApi()),})- vi.spyOn(- reconciler as unknown as {- collectHostCleanupFailures(...args: unknown[]): Promise<unknown[]>- },- 'collectHostCleanupFailures'- ).mockResolvedValue([])+ vi.spyOn(reconciler as unknown as { collectHostCleanupFailures(...args: unknown[]): Promise<unknown[]> }, 'collectHostCleanupFailures').mockResolvedValue([])let active = 0let maxActive = 0const gates = new Map<string, () => void>()diff --git a/host-context-controller/src/hostReconciler.ts b/host-context-controller/src/hostReconciler.tsindex 5bf92cfa6..c9251dece 100644--- a/host-context-controller/src/hostReconciler.ts+++ b/host-context-controller/src/hostReconciler.ts@@ -21,13 +21,6 @@ import {} from './k8s/sharedFileSystemFactory'import { hccLogger } from './logger'import { issueMcpHostRuntimeTokens } from './mcpHostRuntimeTokenIssuerClient'-import {- hostCleanupDeferredTotal,- hostDeleteCleanupTotal,- hostReconcileDurationSeconds,- hostReconcileInFlight,- hostReconcileQueueWaitSeconds,-} from './metrics'import {MCP_HOST_GFS_TOKEN_SECRET_KEY,MCP_HOST_RUNTIME_TOKEN_SECRET_ACCESS_KEY,@@ -59,6 +52,13 @@ import {preserveServiceAssignedFields,replaceWithConflictRetry,} from './utils'+import {+ hostCleanupDeferredTotal,+ hostDeleteCleanupTotal,+ hostReconcileDurationSeconds,+ hostReconcileInFlight,+ hostReconcileQueueWaitSeconds,+} from './metrics'export type { EffectiveHostLifecycle } from './statelessLifecycle.types'@@ -3978,8 +3978,7 @@ export class HostReconciler {if (!authorityValid()) {const current = this.hostWatchAuthority()- const reason =- !capturedAuthority.known || !current.known ? 'authority_unknown' : 'generation_changed'+ const reason = !capturedAuthority.known || !current.known ? 'authority_unknown' : 'generation_changed'hostCleanupDeferredTotal.inc({ reason })console.warn(`[HostReconciler] Deferring orphan cleanup: ${reason}`)return failures@@ -4139,10 +4138,7 @@ export class HostReconciler {try {const list = await this.coreApi.listNamespacedSecret({namespace: channelsNs,- labelSelector: [- `${MANAGED_BY_LABEL}=${MANAGED_BY_VALUE}`,- 'clerum.io/component=channel-reader',- ].join(','),+ labelSelector: [`${MANAGED_BY_LABEL}=${MANAGED_BY_VALUE}`, 'clerum.io/component=channel-reader'].join(','),})for (const sec of list.items ?? []) {const labels = sec.metadata?.labels@@ -4271,6 +4267,7 @@ export class HostReconciler {})return (response.items || []).filter(item => item.metadata?.labels?.[HOST_LABEL])}+}function canonicalStringify(obj: Record<string, unknown>): string {diff --git a/host-context-controller/src/k8sClient.test.ts b/host-context-controller/src/k8sClient.test.tsindex 375a37333..c4f573f0e 100644--- a/host-context-controller/src/k8sClient.test.ts+++ b/host-context-controller/src/k8sClient.test.ts@@ -2399,10 +2399,9 @@ describe('McpServerWatcher Host periodic resync serialization', () => {order.push(`watch:${host.name}:${host.generation}`)})await (watcher as any).startHostWatch('test-host-rv')- if (!hostWatchCallback)- throw new Error('Host watch callback was not installed')- // Cache already synced: the full pass blocks purely on the mocked- // fullReconcile and does not drive recovery, isolating admission behavior.+ if (!hostWatchCallback) throw new Error('Host watch callback was not installed')+ // Cache already synced: the full pass blocks purely on the mocked+ // fullReconcile and does not drive recovery, isolating admission behavior.;(watcher as any).hostCacheSynced = trueconst full = (watcher as any).requestHostFleetReconcile(@@ -2476,7 +2475,11 @@ describe('McpServerWatcher Host periodic resync serialization', () => {spec: { host: 'same-host' },})- expect(order).toEqual(['reconcile:same-host:1', 'reconcile:same-host:2', 'delete:same-host'])+ expect(order).toEqual([+ 'reconcile:same-host:1',+ 'reconcile:same-host:2',+ 'delete:same-host',+ ])expect((watcher as any).hosts.has('same-host')).toBe(false)watcher.stop()})@@ -2968,10 +2971,7 @@ describe('McpServerWatcher Host watch generation', () => {spec: { host: 'retry-host', lifecycle: { stateless: true } },})expect(reconcile).toHaveBeenCalledOnce()- expect(reconcile).toHaveBeenCalledWith(- expect.objectContaining({ uid: 'retry-host-uid' }),- 'urgent'- )+ expect(reconcile).toHaveBeenCalledWith(expect.objectContaining({ uid: 'retry-host-uid' }), 'urgent')expect((watcher as any).hostWatchRetryTimers.size).toBe(1)expect((watcher as any).latestHostWatchEventRevisions.size).toBe(1)@@ -3230,7 +3230,11 @@ describe('McpServerWatcher Host watch generation', () => {expect(reconcileDelete).toHaveBeenCalledWith('gone-host', 'mcp-host', expect.anything()))// A Host still present in the fresh snapshot is never deleted.- expect(reconcileDelete).not.toHaveBeenCalledWith('live-host', 'mcp-host', expect.anything())+ expect(reconcileDelete).not.toHaveBeenCalledWith(+ 'live-host',+ 'mcp-host',+ expect.anything()+ )watcher.stop()})@@ -3318,12 +3322,7 @@ describe('McpServerWatcher Host watch generation', () => {it('suppresses a watch event whose identity (uid) differs from the cached Host (#827 item 2)', () => {const watcher = new McpServerWatcher()- ;(watcher as any).hosts.set('x', {- name: 'x',- namespace: 'mcp-host',- uid: 'uid-B',- generation: 3,- })+ ;(watcher as any).hosts.set('x', { name: 'x', namespace: 'mcp-host', uid: 'uid-B', generation: 3 });(watcher as any).latestHostWatchEventRevisions.set('x', 7)// A stale MODIFIED carrying the OLD identity must not act on the recreated one.expect(@@ -3381,7 +3380,10 @@ describe('McpServerWatcher Host watch generation', () => {new Map([['waker', 'u1']]) // NOT recreated (same uid))await vi.waitFor(() =>- expect(reconcile).toHaveBeenCalledWith(expect.objectContaining({ name: 'waker' }), 'urgent')+ expect(reconcile).toHaveBeenCalledWith(+ expect.objectContaining({ name: 'waker' }),+ 'urgent'+ ))watcher.stop()})@@ -3403,15 +3405,7 @@ describe('McpServerWatcher Host watch generation', () => {spec: { host: 'steady' },});(watcher as any).enqueueRecoveredUrgentHosts(- [- {- name: 'steady',- namespace: 'mcp-host',- uid: 'u1',- generation: 4,- spec: { host: 'steady' },- },- ],+ [{ name: 'steady', namespace: 'mcp-host', uid: 'u1', generation: 4, spec: { host: 'steady' } }],new Set(['steady']),new Map([['steady', 4]]),new Map([['steady', 'u1']])diff --git a/host-context-controller/src/k8sClient.ts b/host-context-controller/src/k8sClient.tsindex ea754b7b5..e850c29ae 100644--- a/host-context-controller/src/k8sClient.ts+++ b/host-context-controller/src/k8sClient.ts@@ -19,10 +19,15 @@ import { GfsReconciler } from './gfsReconciler'import { ControlApiGfsSeedClient } from './gfsSeedClient'import {HostFleetReconcileError,- type HostReconcileSource,HostReconciler,+ type HostReconcileSource,type ResolvedSfsMount,} from './hostReconciler'+import {+ hostDeleteCleanupTotal,+ hostFleetRequestsTotal,+ hostWatchRecoverySeconds,+} from './metrics'import {type InfrastructureTelemetryReporter,createInfrastructureTelemetryReporter,@@ -30,7 +35,6 @@ 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'diff --git a/host-context-controller/src/metrics.ts b/host-context-controller/src/metrics.tsindex 75b8cc5f0..4de90228e 100644--- a/host-context-controller/src/metrics.ts+++ b/host-context-controller/src/metrics.ts@@ -47,7 +47,9 @@ function gauge(options: {* (15s), and wake (45s) budgets, plus longer diagnostic tails. Shared by every* HCC reconcile/recovery latency histogram.*/-const RECONCILE_LATENCY_BUCKETS = [0.05, 0.1, 0.25, 0.5, 1, 2, 5, 15, 45, 120] as const+const RECONCILE_LATENCY_BUCKETS = [+ 0.05, 0.1, 0.25, 0.5, 1, 2, 5, 15, 45, 120,+] as const/** Idempotent Histogram helper mirroring counter()/gauge(). */function histogram(options: {diff --git a/host-context-controller/test/hostReconciler.heartbeat.test.ts b/host-context-controller/test/hostReconciler.heartbeat.test.tsindex 4e6593024..6d9918a16 100644--- a/host-context-controller/test/hostReconciler.heartbeat.test.ts+++ b/host-context-controller/test/hostReconciler.heartbeat.test.ts@@ -439,8 +439,7 @@ describe('HostReconciler.publishSuspendBlockedReason', () => {lifecycle: {state: 'active',wakeHandledGeneration: 0,- reason:- '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',+ reason: '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',},},})@@ -453,8 +452,7 @@ describe('HostReconciler.publishSuspendBlockedReason', () => {freshHostRead({state: 'active',wakeHandledGeneration: 0,- reason:- '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',+ reason: '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',}))diff --git a/host-context-controller/test/hostReconciler.lifecycle.test.ts b/host-context-controller/test/hostReconciler.lifecycle.test.tsindex d624bf4e2..3bd808b44 100644--- a/host-context-controller/test/hostReconciler.lifecycle.test.ts+++ b/host-context-controller/test/hostReconciler.lifecycle.test.ts@@ -793,8 +793,7 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {expect(writes[1].lifecycle).toEqual({state: 'active',wakeHandledGeneration: 5,- reason:- '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',+ reason: '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',})expect(rejectedCondition(writes[1])).toMatchObject({status: 'True',@@ -873,8 +872,7 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {expect(writes[1].lifecycle).toEqual({state: 'active',wakeHandledGeneration: 6,- reason:- '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',+ reason: '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',})})@@ -990,9 +988,7 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {)const writes = lifecycleStatusWrites(customApi)expect(writes).toHaveLength(2)- expect(writes[1].lifecycle?.reason).toBe(- '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle'- )+ expect(writes[1].lifecycle?.reason).toBe('1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle')})it('does not repeat bootstrap provisioning when channel ingress already existed in spec', async () => {@@ -1392,8 +1388,7 @@ describe('HostReconciler stateless lifecycle — kill-switches', () => {expect(writes[0].lifecycle).toEqual({state: 'active',wakeHandledGeneration: 3,- reason:- '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',+ reason: '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',})expect(rejectedCondition(writes[0]).status).toBe('True')})@@ -1607,8 +1602,7 @@ describe('HostReconciler stateless lifecycle — AP-1 fresh-read status writer',expect(writes.at(-1)?.lifecycle).toEqual({state: 'active',wakeHandledGeneration: 3,- reason:- '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',+ reason: '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',})})@@ -1636,8 +1630,7 @@ describe('HostReconciler stateless lifecycle — AP-1 fresh-read status writer',expect(writes.at(-1)?.lifecycle).toEqual({state: 'active',wakeHandledGeneration: 2,- reason:- '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',+ reason: '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',})})@@ -1663,8 +1656,7 @@ describe('HostReconciler stateless lifecycle — AP-1 fresh-read status writer',expect(writes.at(-1)?.lifecycle).toEqual({state: 'suspended',wakeHandledGeneration: 5,- reason:- '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',+ reason: '1 CommunicationChannel(s) reference this Host; disassociate them to enable the requested stateless lifecycle',})})diff --git a/rpc-proxy/src/__tests__/wake-route-coverage.test.ts b/rpc-proxy/src/__tests__/wake-route-coverage.test.tsindex b7289c749..eed0e33ba 100644--- a/rpc-proxy/src/__tests__/wake-route-coverage.test.ts+++ b/rpc-proxy/src/__tests__/wake-route-coverage.test.ts@@ -78,11 +78,7 @@ function makeApp() {return app}-function mockFetchResponse(- status: number,- body: string,- headers?: Record<string, string>-): Response {+function mockFetchResponse(status: number, body: string, headers?: Record<string, string>): Response {return {ok: status >= 200 && status < 300,status,@@ -107,10 +103,7 @@ const originalFetch = globalThis.fetchbeforeEach(() => {vi.clearAllMocks()serviceMock.resolveHostConnectionForUser.mockResolvedValue({ ...HOST_CONNECTION })- controlApiMock.requestHostWakeFromControlApi.mockResolvedValue({- kind: 'active',- wakeGeneration: null,- })+ controlApiMock.requestHostWakeFromControlApi.mockResolvedValue({ kind: 'active', wakeGeneration: null })})afterEach(() => {@@ -124,9 +117,7 @@ describe('§11.4 wake coverage — GET /rpc/hosts/:hostRef/models', () => {.fn().mockRejectedValueOnce(hostDownError()).mockResolvedValueOnce(- mockFetchResponse(200, JSON.stringify({ models: [] }), {- 'content-type': 'application/json',- })+ mockFetchResponse(200, JSON.stringify({ models: [] }), { 'content-type': 'application/json' }))globalThis.fetch = fetchMock as unknown as typeof fetch@@ -199,11 +190,13 @@ describe('§11.4 wake coverage — context-breakdown honors the draining fence',it('a plain upstream 404 is NOT treated as a wake trigger (passes through)', async () => {authTokenMock.verifyRpcToken.mockReturnValue(claims(['host:session:read', 'host:wake:write']))- globalThis.fetch = vi.fn().mockResolvedValue(- mockFetchResponse(404, JSON.stringify({ error: 'session not found' }), {- 'content-type': 'application/json',- })- ) as unknown as typeof fetch+ globalThis.fetch = vi+ .fn()+ .mockResolvedValue(+ mockFetchResponse(404, JSON.stringify({ error: 'session not found' }), {+ 'content-type': 'application/json',+ })+ ) as unknown as typeof fetchconst res = await request(makeApp()).get('/rpc/hosts/chatllm/sessions/chatllm/missing/context-breakdown')@@ -334,7 +327,9 @@ describe('§11.4 wake coverage — approvals deny', () => {// wake-capable token never touches the wake plane when the host is up.describe('§13.4 row 3 — task result forwards normally on an active host', () => {it('an active host forwards the task result and never touches the wake plane', async () => {- authTokenMock.verifyRpcToken.mockReturnValue(claims(['host:message:invoke', 'host:wake:write']))+ authTokenMock.verifyRpcToken.mockReturnValue(+ claims(['host:message:invoke', 'host:wake:write'])+ )serviceMock.forwardTaskResultFromHost.mockResolvedValue({status: 'completed',response: 'done',diff --git a/rpc-proxy/src/services/__tests__/probeHostHealth.test.ts b/rpc-proxy/src/services/__tests__/probeHostHealth.test.tsindex 7efd0f186..07b34521b 100644--- a/rpc-proxy/src/services/__tests__/probeHostHealth.test.ts+++ b/rpc-proxy/src/services/__tests__/probeHostHealth.test.ts@@ -1,7 +1,5 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import type { ResolvedServerConnection } from '../../types.js'-// vi.mock is hoisted above imports, so the static import resolves the mock.-import { probeHostReadyViaHealth } from '../wakeAndHold.js'// The wake-and-hold readiness probe must use mcp-host's UNAUTHENTICATED// /v1/runtime/health endpoint (Issue #791 §11.3), which comes up before MCP@@ -15,6 +13,9 @@ const restMock = vi.hoisted(() => ({vi.mock('../mcpHostRestService.js', () => restMock)+// vi.mock is hoisted above imports, so the static import resolves the mock.+import { probeHostReadyViaHealth } from '../wakeAndHold.js'+const HOST: ResolvedServerConnection = {name: 'chatllm',url: 'http://chatllm.mcp-host.svc.cluster.local:8080',diff --git a/rpc-proxy/src/services/__tests__/wakeCoordinator.principal.test.ts b/rpc-proxy/src/services/__tests__/wakeCoordinator.principal.test.tsindex 03329a2be..3ad2db1d7 100644--- a/rpc-proxy/src/services/__tests__/wakeCoordinator.principal.test.ts+++ b/rpc-proxy/src/services/__tests__/wakeCoordinator.principal.test.ts@@ -91,11 +91,7 @@ afterEach(() => {describe('wakeCoordinationKey', () => {it('excludes jti/exp/role/scopes and is stable across token rotation for one principal', () => {const a = makeClaims({ jti: 'j1', expMs: Date.now() + 1_000_000, scopes: ['host:wake:write'] })- const b = makeClaims({- jti: 'j2',- expMs: Date.now() + 9_000_000,- scopes: ['host:session:read'],- })+ const b = makeClaims({ jti: 'j2', expMs: Date.now() + 9_000_000, scopes: ['host:session:read'] })expect(wakeCoordinationKey(a, 'chatllm')).toBe(wakeCoordinationKey(b, 'chatllm'))})diff --git a/rpc-proxy/src/services/wakeAndHold.ts b/rpc-proxy/src/services/wakeAndHold.tsindex a8b769594..a60c3a9d1 100644--- a/rpc-proxy/src/services/wakeAndHold.ts+++ b/rpc-proxy/src/services/wakeAndHold.ts@@ -217,12 +217,7 @@ export class WakeAndHoldCoordinator {const activeEntry = entryreturn await new Promise<WakeHoldOutcome>(resolve => {const id = ++this.waiterSeq- const waiter: Waiter = {- id,- resolve,- timer: null as unknown as NodeJS.Timeout,- settled: false,- }+ const waiter: Waiter = { id, resolve, timer: null as unknown as NodeJS.Timeout, settled: false }waiter.timer = setTimeout(() => {if (waiter.settled) returnwaiter.settled = true