Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
Merge remote-tracking branch 'origin/dev' into fix/gfs-desktop
Miguelon Peluchon6205fbc93dfe
diff --cc host-context-controller/src/mcpServerSafety.tsindex 000000000,7f8d8438d..5b15bda16mode 000000,100644..100644--- a/host-context-controller/src/mcpServerSafety.ts+++ b/host-context-controller/src/mcpServerSafety.ts@@@ -1,0 -1,91 +1,93 @@@+ import type { McpServerCRD } from './types'+ import { getErrorCode } from './utils'++ const NETWORK_READY_ANNOTATION = 'clerum.io/network-ready'++ /**+ * This acknowledgement is written by HCC after it has applied a server's+ * NetworkPolicies so WRC can admit its workload. It is not user intent and it+ * cannot change any NetworkPolicy decision. Treating that write as desired+ * state makes HCC invalidate its own authoritative revocation pass under a+ * large startup fleet, coupling /ready to additive runtime convergence again.+ */-function desiredAnnotations(annotations: Record<string, string> | undefined): Record<string, string> {++function desiredAnnotations(++ annotations: Record<string, string> | undefined++): Record<string, string> {+ if (!annotations?.[NETWORK_READY_ANNOTATION]) return annotations ?? {}+ const { [NETWORK_READY_ANNOTATION]: _networkReady, ...remaining } = annotations+ return remaining+ }++ /**+ * Kubernetes represents objects such as labels and annotations as maps, whose+ * wire key order is not meaningful or stable across LIST and WATCH payloads.+ * Preserve array order (it is semantic) while sorting object keys so a+ * status-only event cannot masquerade as a desired-state revision.+ */+ function stableJson(value: unknown): string {+ if (Array.isArray(value)) return `[${value.map(stableJson).join(',')}]`+ if (value && typeof value === 'object') {+ const record = value as Record<string, unknown>+ return `{${Object.keys(record)+ .sort()+ .map(key => `${JSON.stringify(key)}:${stableJson(record[key])}`)+ .join(',')}}`+ }+ return JSON.stringify(value) ?? 'undefined'+ }++ export function sameMcpServerDesiredRevision(+ expected: McpServerCRD,+ current: McpServerCRD+ ): boolean {+ if (expected.name !== current.name || expected.namespace !== current.namespace) return false+ if (expected.uid && current.uid && expected.uid !== current.uid) return false+ if (+ expected.generation !== undefined &&+ current.generation !== undefined &&+ expected.generation !== current.generation+ ) {+ return false+ }++ return (+ stableJson(expected.spec) === stableJson(current.spec) &&+ stableJson(desiredAnnotations(expected.annotations)) ===+ stableJson(desiredAnnotations(current.annotations)) &&+ stableJson(expected.labels ?? {}) === stableJson(current.labels ?? {})+ )+ }++ export function isMcpServerStatusOnlyUpdate(+ previous: McpServerCRD,+ current: McpServerCRD+ ): boolean {+ return (+ previous.uid === current.uid &&+ previous.generation === current.generation &&+ sameMcpServerDesiredRevision(previous, current)+ )+ }++ export interface AuthoritativeMcpServerAbsenceCheck {+ inventoryAuthoritative: () => boolean+ resolveCurrent: () => McpServerCRD | undefined+ readCurrent: () => Promise<unknown>+ }++ export async function confirmAuthoritativeMcpServerAbsence({+ inventoryAuthoritative,+ resolveCurrent,+ readCurrent,+ }: AuthoritativeMcpServerAbsenceCheck): Promise<boolean> {+ if (!inventoryAuthoritative() || resolveCurrent()) return false++ try {+ await readCurrent()+ return false+ } catch (error: unknown) {+ if (getErrorCode(error) !== 404) throw error+ }++ return inventoryAuthoritative() && !resolveCurrent()+ }diff --cc host-context-controller/src/networkPolicyReconciler.test.tsindex 8f3d3f3e1,047ccd88e..463bc546f--- a/host-context-controller/src/networkPolicyReconciler.test.ts+++ b/host-context-controller/src/networkPolicyReconciler.test.ts@@@ -355,6 -759,82 +759,86 @@@ describe('NetworkPolicyReconciler', ()// ─── L2: Context-Based Policies ────────────────────────────────────describe('L2 — reconcileContext', () => {+ it('refuses to adopt a foreign policy that collides with a live Context policy name', async () => {+ const server: McpServerCRD = {+ name: 'mongo',+ namespace: 'mcp-server',+ spec: {+ contextRef: 'dev',+ image: 'mongo:latest',+ transport: { type: 'streamableHttp', port: 3000 },+ },+ }+ const rec = makeReconciler(mockApi, new Map([[server.name, server]]))+ const context: ContextCRD = {+ name: 'dev',+ namespace: 'mcp-server',+ spec: { contextId: 'dev', mcpServers: [server.name] },+ }+ mockApi.createNamespacedNetworkPolicy.mockRejectedValueOnce(+ Object.assign(new Error('already exists'), { code: 409 })+ )+ mockApi.readNamespacedNetworkPolicy.mockResolvedValueOnce({+ metadata: {+ name: 'ctx-dev-mongo',+ namespace: 'mcp-server',+ uid: 'foreign-uid',+ resourceVersion: '7',+ labels: {+ 'clerum.io/managed-by': 'foreign-controller',+ 'clerum.io/policy-type': 'context-allow',+ 'clerum.io/context': 'dev',+ 'clerum.io/mcpserver': 'mongo',+ },+ },+ })+- await expect(rec.reconcileContext(context, { isCurrent: () => true })).rejects.toThrow(/ownership/i)++ await expect(rec.reconcileContext(context, { isCurrent: () => true })).rejects.toThrow(++ /ownership/i++ )+ expect(mockApi.replaceNamespacedNetworkPolicy).not.toHaveBeenCalled()+ })++ it('refuses to replace an HCC Context policy owned by a different Context/server pair', async () => {+ const server: McpServerCRD = {+ name: 'b-c',+ namespace: 'mcp-server',+ spec: {+ contextRef: 'a',+ image: 'mongo:latest',+ transport: { type: 'streamableHttp', port: 3000 },+ },+ }+ const rec = makeReconciler(mockApi, new Map([[server.name, server]]))+ const context: ContextCRD = {+ name: 'a',+ namespace: 'mcp-server',+ spec: { contextId: 'a', mcpServers: ['b-c'] },+ }+ mockApi.createNamespacedNetworkPolicy.mockRejectedValueOnce(+ Object.assign(new Error('already exists'), { code: 409 })+ )+ mockApi.readNamespacedNetworkPolicy.mockResolvedValueOnce({+ metadata: {+ name: 'ctx-a-b-c',+ namespace: 'mcp-server',+ uid: 'other-hcc-owner-uid',+ resourceVersion: '7',+ labels: {+ 'clerum.io/managed-by': 'host-context-controller',+ 'clerum.io/policy-type': 'context-allow',+ 'clerum.io/context': 'a-b',+ 'clerum.io/mcpserver': 'c',+ },+ },+ })+- await expect(rec.reconcileContext(context, { isCurrent: () => true })).rejects.toThrow(/ownership/i)++ await expect(rec.reconcileContext(context, { isCurrent: () => true })).rejects.toThrow(++ /ownership/i++ )+ expect(mockApi.replaceNamespacedNetworkPolicy).not.toHaveBeenCalled()+ })+it('creates context-allow ingress policy per server in mcp-server namespace', async () => {const cache = new Map<string, McpServerCRD>()cache.set('mongo', {@@@ -566,6 -1292,118 +1296,122 @@@// ─── L3: External Egress ───────────────────────────────────────────describe('L3 — reconcileExternalEgress', () => {+ it('removes a deterministic safety policy created after its desired-state fence is lost', async () => {+ const server: McpServerCRD = {+ name: 'race-server',+ namespace: 'mcp-server',+ spec: {+ contextRef: 'default',+ image: 'race:latest',+ transport: { type: 'streamableHttp', port: 3000 },+ egressBindings: [{ cidr: '104.18.0.0/16', port: 443 }],+ },+ }+ const createStarted = deferred()+ const releaseCreate = deferred()+ let current = true+ mockApi.createNamespacedNetworkPolicy.mockImplementationOnce(async () => {+ createStarted.resolve(undefined)+ await releaseCreate.promise+ return {+ metadata: {+ name: 'ext-egress-race-server-104-18-0-0-16-443',+ namespace: server.namespace,+ uid: 'created-race-policy',+ resourceVersion: '7',+ },+ }+ })++ const safety = (reconciler as any).reconcileExternalEgressSafety(+ server,+ [{ metadata: { name: 'ext-egress-race-server-stale' } }],+ () => current+ ) as Promise<boolean>++ await createStarted.promise+ current = false+ releaseCreate.resolve(undefined)++ expect(await safety).toBe(false)+ const created = mockApi.createNamespacedNetworkPolicy.mock.calls[0][0].body+ expect(mockApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledWith(+ expect.objectContaining({+ name: created.metadata.name,+ namespace: server.namespace,+ body: { preconditions: { uid: 'created-race-policy', resourceVersion: '7' } },+ })+ )+ })++ it('refuses to adopt a foreign policy that collides with an external-egress name', async () => {+ const server: McpServerCRD = {+ name: 'openai-mcp',+ namespace: 'mcp-server',+ spec: {+ contextRef: 'dev',+ image: 'openai:latest',+ transport: { type: 'streamableHttp', port: 3000 },+ egressBindings: [{ cidr: '104.18.0.0/16', port: 443 }],+ },+ }+ mockApi.createNamespacedNetworkPolicy.mockRejectedValueOnce(+ Object.assign(new Error('already exists'), { code: 409 })+ )+ mockApi.readNamespacedNetworkPolicy.mockResolvedValueOnce({+ metadata: {+ name: 'ext-egress-openai-mcp-104-18-0-0-16-443',+ namespace: 'mcp-server',+ uid: 'foreign-uid',+ resourceVersion: '7',+ labels: {+ 'clerum.io/managed-by': 'foreign-controller',+ 'clerum.io/policy-type': 'external-egress',+ 'clerum.io/mcpserver': server.name,+ },+ },+ })+- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(/ownership/i)++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/ownership/i)+ expect(mockApi.replaceNamespacedNetworkPolicy).not.toHaveBeenCalled()+ })++ it('refuses to replace an HCC external-egress policy owned by a different server', async () => {+ const server: McpServerCRD = {+ name: 'openai-mcp',+ namespace: 'mcp-server',+ spec: {+ contextRef: 'dev',+ image: 'openai:latest',+ transport: { type: 'streamableHttp', port: 3000 },+ egressBindings: [{ cidr: '104.18.0.0/16', port: 443 }],+ },+ }+ mockApi.createNamespacedNetworkPolicy.mockRejectedValueOnce(+ Object.assign(new Error('already exists'), { code: 409 })+ )+ mockApi.readNamespacedNetworkPolicy.mockResolvedValueOnce({+ metadata: {+ name: 'ext-egress-openai-mcp-104-18-0-0-16-443',+ namespace: 'mcp-server',+ uid: 'other-hcc-owner-uid',+ resourceVersion: '7',+ labels: {+ 'clerum.io/managed-by': 'host-context-controller',+ 'clerum.io/policy-type': 'external-egress',+ 'clerum.io/mcpserver': 'different-server',+ },+ },+ })+- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(/ownership/i)++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/ownership/i)+ expect(mockApi.replaceNamespacedNetworkPolicy).not.toHaveBeenCalled()+ })+it('creates egress policy for CIDR binding', async () => {const server: McpServerCRD = {name: 'openai-mcp',@@@ -677,15 -1549,202 +1557,208 @@@},}- await expect(reconciler.reconcileExternalEgress(server)).rejects.toThrow('status read denied')-- expect(mockApi.createNamespacedNetworkPolicy).toHaveBeenCalledTimes(1)- expect(mockCustomApi.patchNamespacedCustomObjectStatus).not.toHaveBeenCalled()- })+ await reconciler.reconcileExternalEgress(server, { isCurrent: () => true })- it('creates explicit public-web egress with private and special-use ranges excluded', async () => {- const server: McpServerCRD = {- name: 'search-mcp',+ const patch = mockCustomApi.patchNamespacedCustomObjectStatus.mock.calls[0][0].body+ expect(patch.slice(0, 3)).toEqual([+ { op: 'test', path: '/metadata/uid', value: 'openai-mcp-uid' },+ { op: 'test', path: '/metadata/generation', value: 7 },+ { op: 'test', path: '/metadata/resourceVersion', value: 'status-rv-17' },+ ])+ expect(patch).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ path: '/status/conditions',+ value: expect.arrayContaining([+ expect.objectContaining({+ type: 'RuntimeReady',+ reason: 'DeploymentAvailable',+ }),+ expect.objectContaining({+ type: 'ExternalEgressReady',+ status: 'True',+ observedGeneration: 7,+ }),+ ]),+ }),+ ])+ )+ })++ it('fences every identity field read from status when synthetic input omits them', async () => {+ mockCustomApi.getNamespacedCustomObjectStatus.mockResolvedValueOnce({+ metadata: {+ uid: 'openai-mcp-uid',+ generation: 7,+ resourceVersion: 'status-rv-17',+ },+ status: {},+ })+ const server: McpServerCRD = {+ name: 'openai-mcp',+ namespace: 'mcp-server',+ spec: {+ contextRef: 'dev',+ image: 'openai:latest',+ transport: { type: 'streamableHttp', url: 'http://openai:3000', port: 3000 },+ egressBindings: [{ dns: 'api.openai.com', port: 443 }],+ },+ }++ await reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ const patch = mockCustomApi.patchNamespacedCustomObjectStatus.mock.calls[0][0].body+ expect(patch.slice(0, 3)).toEqual([+ { op: 'test', path: '/metadata/uid', value: 'openai-mcp-uid' },+ { op: 'test', path: '/metadata/generation', value: 7 },+ { op: 'test', path: '/metadata/resourceVersion', value: 'status-rv-17' },+ ])+ })++ it.each([+ {+ name: 'UID',+ currentMetadata: {+ uid: 'replacement-uid',+ generation: 7,+ resourceVersion: 'status-rv-18',+ },+ },+ {+ name: 'generation',+ currentMetadata: {+ uid: 'openai-mcp-uid',+ generation: 8,+ resourceVersion: 'status-rv-18',+ },+ },+ ])(+ 'rejects a stale $name before patching external egress status',+ async ({ currentMetadata }) => {+ mockCustomApi.getNamespacedCustomObjectStatus.mockResolvedValueOnce({+ metadata: currentMetadata,+ status: {},+ })+ const server: McpServerCRD = {+ name: 'openai-mcp',+ namespace: 'mcp-server',+ uid: 'openai-mcp-uid',+ generation: 7,+ spec: {+ contextRef: 'dev',+ image: 'openai:latest',+ transport: { type: 'streamableHttp', url: 'http://openai:3000', port: 3000 },+ egressBindings: [{ dns: 'api.openai.com', port: 443 }],+ },+ }+- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(/stale McpServer/i)++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/stale McpServer/i)++ expect(mockCustomApi.patchNamespacedCustomObjectStatus).not.toHaveBeenCalled()+ }+ )++ it('fails closed when a same-generation status writer wins the resourceVersion race', async () => {+ const conflict = Object.assign(new Error('JSON patch test failed'), { code: 409 })+ mockCustomApi.getNamespacedCustomObjectStatus.mockResolvedValueOnce({+ metadata: {+ uid: 'openai-mcp-uid',+ generation: 7,+ resourceVersion: 'status-rv-17',+ },+ status: {+ conditions: [+ {+ type: 'RuntimeReady',+ status: 'True',+ reason: 'DeploymentAvailable',+ lastTransitionTime: '2026-07-29T00:00:00.000Z',+ },+ ],+ },+ })+ mockCustomApi.patchNamespacedCustomObjectStatus.mockRejectedValueOnce(conflict)+ const server: McpServerCRD = {+ name: 'openai-mcp',+ namespace: 'mcp-server',+ uid: 'openai-mcp-uid',+ generation: 7,+ spec: {+ contextRef: 'dev',+ image: 'openai:latest',+ transport: { type: 'streamableHttp', url: 'http://openai:3000', port: 3000 },+ egressBindings: [{ dns: 'api.openai.com', port: 443 }],+ },+ }+- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toBe(conflict)++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toBe(conflict)++ expect(mockCustomApi.patchNamespacedCustomObjectStatus).toHaveBeenCalledWith(+ expect.objectContaining({+ body: expect.arrayContaining([+ {+ op: 'test',+ path: '/metadata/resourceVersion',+ value: 'status-rv-17',+ },+ ]),+ })+ )+ })++ it('fails closed when ExternalEgressReady status cannot be written', async () => {+ const statusError = new Error('status update denied')+ mockCustomApi.patchNamespacedCustomObjectStatus.mockRejectedValueOnce(statusError)+ const server: McpServerCRD = {+ name: 'openai-mcp',+ namespace: 'mcp-server',+ generation: 7,+ spec: {+ contextRef: 'dev',+ image: 'openai:latest',+ transport: { type: 'streamableHttp', url: 'http://openai:3000', port: 3000 },+ egressBindings: [{ dns: 'api.openai.com', port: 443 }],+ },+ }+- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(- 'status update denied'- )++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow('status update denied')++ expect(mockApi.createNamespacedNetworkPolicy).toHaveBeenCalledTimes(1)+ expect(mockCustomApi.patchNamespacedCustomObjectStatus).toHaveBeenCalled()+ })++ it('fails closed when ExternalEgressReady status cannot be read', async () => {+ const statusError = new Error('status read denied')+ mockCustomApi.getNamespacedCustomObjectStatus.mockRejectedValueOnce(statusError)+ const server: McpServerCRD = {+ name: 'openai-mcp',+ namespace: 'mcp-server',+ generation: 7,+ spec: {+ contextRef: 'dev',+ image: 'openai:latest',+ transport: { type: 'streamableHttp', url: 'http://openai:3000', port: 3000 },+ egressBindings: [{ dns: 'api.openai.com', port: 443 }],+ },+ }+- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow('status read denied')++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow('status read denied')++ expect(mockApi.createNamespacedNetworkPolicy).toHaveBeenCalledTimes(1)+ expect(mockCustomApi.patchNamespacedCustomObjectStatus).not.toHaveBeenCalled()+ })++ it('creates explicit public-web egress with private and special-use ranges excluded', async () => {+ const server: McpServerCRD = {+ name: 'search-mcp',namespace: 'mcp-server',spec: {contextRef: 'dev',@@@ -737,9 -1796,9 +1810,9 @@@},}- await expect(reconciler.reconcileExternalEgress(server)).rejects.toThrow(- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(-- /public-web external egress bindings/-- )++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/public-web external egress bindings/)expect(mockApi.createNamespacedNetworkPolicy).not.toHaveBeenCalled()})@@@ -755,9 -1814,9 +1828,9 @@@},}- await expect(reconciler.reconcileExternalEgress(server)).rejects.toThrow(- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(-- /public-web external egress bindings/-- )++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/public-web external egress bindings/)expect(mockApi.createNamespacedNetworkPolicy).not.toHaveBeenCalled()})@@@ -1219,9 -2278,9 +2292,9 @@@},}- await expect(reconciler.reconcileExternalEgress(server)).rejects.toThrow(- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(-- /External egress reconciliation failed/-- )++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/External egress reconciliation failed/)}expect(mockApi.createNamespacedNetworkPolicy).not.toHaveBeenCalled()@@@ -1240,9 -2299,9 +2313,9 @@@},}- await expect(reconciler.reconcileExternalEgress(server)).rejects.toThrow(- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(-- /resolved disallowed address/-- )++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/resolved disallowed address/)expect(mockApi.createNamespacedNetworkPolicy).not.toHaveBeenCalled()expect(mockCustomApi.patchNamespacedCustomObjectStatus).toHaveBeenCalledWith(@@@ -1275,9 -2334,9 +2348,9 @@@},}- await expect(reconciler.reconcileExternalEgress(server)).rejects.toThrow(- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(-- /private, internal, metadata/-- )++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/private, internal, metadata/)expect(dns.resolve4).not.toHaveBeenCalled()expect(mockApi.createNamespacedNetworkPolicy).not.toHaveBeenCalled()@@@ -1296,9 -2355,9 +2369,9 @@@},}- await expect(reconciler.reconcileExternalEgress(server)).rejects.toThrow(- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(-- /resolved disallowed address/-- )++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/resolved disallowed address/)expect(mockApi.createNamespacedNetworkPolicy).not.toHaveBeenCalled()})@@@ -1351,7 -2412,7 +2426,9 @@@},}- await expect(reconciler.reconcileExternalEgress(server)).rejects.toThrow('delete denied')- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow('delete denied')++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow('delete denied')})it('deletes stale policies and fails when DNS resolution for that binding fails', async () => {@@@ -1374,17 -2435,21 +2451,23 @@@},}- await expect(reconciler.reconcileExternalEgress(server)).rejects.toThrow(/dns timeout/)- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(/dns timeout/)++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/dns timeout/)expect(mockApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledTimes(2)- expect(mockApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledWith({- name: 'ext-egress-openai-mcp-api.openai.com-443',- namespace: 'mcp-server',- })- expect(mockApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledWith({- name: 'ext-egress-openai-mcp-old-example-com-443',- namespace: 'mcp-server',- })+ expect(mockApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledWith(+ expect.objectContaining({+ name: 'ext-egress-openai-mcp-api.openai.com-443',+ namespace: 'mcp-server',+ })+ )+ expect(mockApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledWith(+ expect.objectContaining({+ name: 'ext-egress-openai-mcp-old-example-com-443',+ namespace: 'mcp-server',+ })+ )expect(mockCustomApi.patchNamespacedCustomObjectStatus).toHaveBeenCalledWith(expect.objectContaining({body: expect.arrayContaining([@@@ -1415,9 -2480,9 +2498,9 @@@},}- await expect(reconciler.reconcileExternalEgress(server)).rejects.toThrow(- await expect(reconciler.reconcileExternalEgress(server, { isCurrent: () => true })).rejects.toThrow(-- /must declare dns or cidr/-- )++ await expect(++ reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ ).rejects.toThrow(/must declare dns or cidr/)expect(mockApi.createNamespacedNetworkPolicy).not.toHaveBeenCalled()expect(mockApi.deleteNamespacedNetworkPolicy).not.toHaveBeenCalled()})@@@ -1590,5 -5243,467 +5261,474 @@@reconciler.cleanupExternalEgress('openai-mcp', 'mcp-server')).resolves.toBeUndefined()})++ it('does not report a revocation when the policy was already absent', async () => {+ const error = Object.assign(new Error('not found'), { code: 404 })+ const onDeleted = vi.fn()+ mockApi.listNamespacedNetworkPolicy.mockResolvedValue({+ items: [{ metadata: { name: 'ext-egress-openai-mcp-old-api-443' } }],+ })+ mockApi.deleteNamespacedNetworkPolicy.mockRejectedValueOnce(error)++ await reconciler.cleanupExternalEgress(+ 'openai-mcp',+ 'mcp-server',+ undefined,+ undefined,+ onDeleted+ )++ expect(onDeleted).not.toHaveBeenCalled()+ })+ })++ describe('scoped delta certification vs. a stuck safety inventory', () => {+ const ambiguousReservedPolicy: k8s.V1NetworkPolicy = {+ metadata: { name: 'ctx-reserved-context-server', labels: {} },+ spec: { podSelector: {}, policyTypes: ['Ingress'] },+ }+ const deltaContext: ContextCRD = {+ name: 'default',+ namespace: 'mcp-server',+ spec: { contextId: 'default', mcpServers: [] },+ }++ function stickSafetyInventory(): void {+ // Only the namespace-wide safety inventory sees the foreign policy. The+ // label-scoped LISTs the delta lane uses stay clean, which is exactly why+ // the delta cannot vouch for the namespace.+ mockApi.listNamespacedNetworkPolicy.mockImplementation(+ async ({ namespace, labelSelector }: { namespace?: string; labelSelector?: string }) => ({+ items: !labelSelector && namespace === 'mcp-server' ? [ambiguousReservedPolicy] : [],+ })+ )+ }++ it('refuses to certify a scoped delta while the safety pass is stuck on its inventory', async () => {+ stickSafetyInventory()+ const onAuthoritativeRevocationComplete = vi.fn()++ await expect(+ reconciler.fullReconcile([], [], {+ ensureDefaults: false,+ contextInventoryAuthoritative: () => true,+ serverInventoryAuthoritative: () => true,+ onAuthoritativeRevocationComplete,+ })+ ).rejects.toThrow(/Ambiguous NetworkPolicy ownership/)+ expect(onAuthoritativeRevocationComplete).not.toHaveBeenCalled()++ // The delta's own revocation still completes — its label-scoped LISTs are+ // clean. What it may not do is vouch for the namespace-wide inventory,+ // which the readiness lane checks separately.+ expect(await reconciler.reconcileContext(deltaContext, { isCurrent: () => true })).toBe(true)+ expect(reconciler.hasCertifiedSafetyInventory()).toBe(false)+ })++ it('certifies a scoped delta again once a later safety pass completes', async () => {+ stickSafetyInventory()+ await expect(+ reconciler.fullReconcile([], [], {+ ensureDefaults: false,+ contextInventoryAuthoritative: () => true,+ serverInventoryAuthoritative: () => true,+ onAuthoritativeRevocationComplete: vi.fn(),+ })+ ).rejects.toThrow(/Ambiguous NetworkPolicy ownership/)++ mockApi.listNamespacedNetworkPolicy.mockResolvedValue({ items: [] })+ const onAuthoritativeRevocationComplete = vi.fn()+ await reconciler.fullReconcile([], [], {+ ensureDefaults: false,+ contextInventoryAuthoritative: () => true,+ serverInventoryAuthoritative: () => true,+ onAuthoritativeRevocationComplete,+ })++ expect(onAuthoritativeRevocationComplete).toHaveBeenCalledOnce()+ expect(await reconciler.reconcileContext(deltaContext, { isCurrent: () => true })).toBe(true)+ expect(reconciler.hasCertifiedSafetyInventory()).toBe(true)+ })++ it('does not certify the safety inventory until an authoritative pass has run', async () => {+ // Fail-closed default: before any authoritative safety pass certifies, the+ // namespace-wide inventory is NOT certified, even though the scoped delta's+ // own label-scoped revocation completes (returns true). A delta cannot+ // vouch for the namespace-wide inventory it never enumerated.+ expect(await reconciler.reconcileContext(deltaContext, { isCurrent: () => true })).toBe(true)+ expect(reconciler.hasCertifiedSafetyInventory()).toBe(false)+ })+ })++ describe('lost delete fence during stale-allow revocation', () => {+ const staleContext: ContextCRD = {+ name: 'default',+ namespace: 'mcp-server',+ spec: { contextId: 'default', mcpServers: [] },+ }+ const stalePolicy: k8s.V1NetworkPolicy = {+ metadata: {+ name: 'ctx-default-alpha',+ namespace: 'mcp-server',+ labels: {+ 'clerum.io/managed-by': 'host-context-controller',+ 'clerum.io/policy-type': 'context-allow',+ 'clerum.io/context': 'default',+ 'clerum.io/mcpserver': 'alpha',+ },+ },+ spec: { podSelector: {}, policyTypes: ['Ingress'] },+ }+ const lostFence = Object.assign(new Error('the UID in the precondition does not match'), {+ code: 409,+ })++ function listOnlyTheStalePolicy(): void {+ mockApi.listNamespacedNetworkPolicy.mockImplementation(+ async ({ namespace }: { namespace?: string }) => ({+ items: namespace === 'mcp-server' ? [stalePolicy] : [],+ })+ )+ }++ it('refuses to certify a scoped delta instead of throwing the lost fence', async () => {+ listOnlyTheStalePolicy()+ mockApi.deleteNamespacedNetworkPolicy.mockRejectedValueOnce(lostFence)++ // 409 is what Kubernetes returns when the uid/resourceVersion+ // preconditions no longer match: the object live under that name is not+ // the one this pass classified. Nothing was revoked, so the delta must+ // decline to certify — and it must not blow up the caller, which would+ // only force a spurious full re-convergence.+ // The scoped delta lane reads this boolean and withholds the certificate,+ // so it is the one caller allowed to take the lost fence as an outcome+ // rather than a throw.- expect(await reconciler.reconcileContext(staleContext, { honorsLostFence: true, isCurrent: () => true })).toBe(false)++ expect(++ await reconciler.reconcileContext(staleContext, {++ honorsLostFence: true,++ isCurrent: () => true,++ })++ ).toBe(false)+ expect(mockApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledWith(+ expect.objectContaining({ name: 'ctx-default-alpha', namespace: 'mcp-server' })+ )+ })++ it('withdraws certification when an additive revocation loses the fence after certifying', async () => {+ // The additive phase re-runs reconcileContext, which carries a second+ // revocation lane over a fresh LIST. Losing the fence there happens after+ // the pass already certified, and the outcome recorder is first-wins — so+ // the duration sample stays 'completed', which is right, but the safety+ // fence must still degrade. It is an assertion about live allows, and it+ // may only ever move toward unsafe.+ const additiveContext: ContextCRD = {+ name: 'additive',+ namespace: 'mcp-server',+ spec: { contextId: 'additive', mcpServers: [] },+ }+ const additiveStalePolicy: k8s.V1NetworkPolicy = {+ metadata: {+ name: 'ctx-additive-alpha',+ namespace: 'mcp-server',+ labels: {+ 'clerum.io/managed-by': 'host-context-controller',+ 'clerum.io/policy-type': 'context-allow',+ 'clerum.io/context': 'additive',+ 'clerum.io/mcpserver': 'alpha',+ },+ },+ spec: { podSelector: {}, policyTypes: ['Ingress'] },+ }+ // Self-synchronising: the stale policy only becomes visible once the pass+ // has already certified, so the safety phase is clean by construction and+ // only the additive re-LIST finds work.+ let certified = false+ mockApi.listNamespacedNetworkPolicy.mockImplementation(+ async ({ namespace }: { namespace?: string }) => ({+ items: certified && namespace === 'mcp-server' ? [additiveStalePolicy] : [],+ })+ )+ mockApi.deleteNamespacedNetworkPolicy.mockRejectedValue(lostFence)+ const onAuthoritativeRevocationComplete = vi.fn(() => {+ certified = true+ })++ await expect(+ reconciler.fullReconcile([additiveContext], [], {+ ensureDefaults: false,+ contextInventoryAuthoritative: () => true,+ serverInventoryAuthoritative: () => true,+ onAuthoritativeRevocationComplete,+ })+ ).rejects.toThrow()++ expect(onAuthoritativeRevocationComplete).toHaveBeenCalledOnce()+ expect(reconciler.hasCertifiedSafetyInventory()).toBe(false)+ })++ it('marks the inventory uncertified the moment the authoritative pass loses the fence', async () => {+ // The doom must be visible mid-pass, not only after the unwind. A lost+ // fence is the one doom cause that does not bump a watch generation, so+ // it is the only one where the whole certification machinery stays green+ // while the pass is already condemned. A scoped delta interleaving in+ // that window would certify readiness over a stale allow.+ //+ // Two contexts, each with its own stale policy: the first loses the fence+ // and the second's delete gives an observation point while the pass is+ // condemned but still unwinding.+ const secondContext: ContextCRD = {+ name: 'second',+ namespace: 'mcp-server',+ spec: { contextId: 'second', mcpServers: [] },+ }+ const secondStalePolicy: k8s.V1NetworkPolicy = {+ metadata: {+ name: 'ctx-second-beta',+ namespace: 'mcp-server',+ labels: {+ 'clerum.io/managed-by': 'host-context-controller',+ 'clerum.io/policy-type': 'context-allow',+ 'clerum.io/context': 'second',+ 'clerum.io/mcpserver': 'beta',+ },+ },+ spec: { podSelector: {}, policyTypes: ['Ingress'] },+ }+ mockApi.listNamespacedNetworkPolicy.mockImplementation(+ async ({ namespace }: { namespace?: string }) => ({+ items: namespace === 'mcp-server' ? [stalePolicy, secondStalePolicy] : [],+ })+ )+ let certifiedDuringUnwind: boolean | undefined+ mockApi.deleteNamespacedNetworkPolicy.mockImplementation(async () => {+ if (+ certifiedDuringUnwind === undefined &&+ mockApi.deleteNamespacedNetworkPolicy.mock.calls.length > 1+ ) {+ certifiedDuringUnwind = reconciler.hasCertifiedSafetyInventory()+ return {}+ }+ throw lostFence+ })++ await expect(+ reconciler.fullReconcile([staleContext, secondContext], [], {+ ensureDefaults: false,+ contextInventoryAuthoritative: () => true,+ serverInventoryAuthoritative: () => true,+ onAuthoritativeRevocationComplete: vi.fn(),+ })+ ).rejects.toThrow()++ expect(certifiedDuringUnwind).toBe(false)+ })++ it('fails the additive phase when it loses the delete fence', async () => {+ listOnlyTheStalePolicy()+ // Safety phase revokes cleanly and certifies; the additive phase then+ // races another writer and loses the fence. The additive caller discards+ // reconcileContext's boolean, so swallowing the 409 there would record+ // the pass as a success, disarm the convergence retry, and leave a stale+ // allow live with no NetworkPolicy resync to recover it.+ mockApi.deleteNamespacedNetworkPolicy+ .mockResolvedValueOnce({})+ .mockRejectedValueOnce(lostFence)+ const onAuthoritativeRevocationComplete = vi.fn()++ await expect(+ reconciler.fullReconcile([staleContext], [], {+ ensureDefaults: false,+ contextInventoryAuthoritative: () => true,+ serverInventoryAuthoritative: () => true,+ onAuthoritativeRevocationComplete,+ })+ ).rejects.toThrow()++ expect(onAuthoritativeRevocationComplete).toHaveBeenCalledOnce()+ })++ it('refuses to certify the safety pass instead of throwing the lost fence', async () => {+ listOnlyTheStalePolicy()+ mockApi.deleteNamespacedNetworkPolicy.mockRejectedValueOnce(lostFence)+ const onAuthoritativeRevocationComplete = vi.fn()++ await expect(+ reconciler.fullReconcile([staleContext], [], {+ ensureDefaults: false,+ contextInventoryAuthoritative: () => true,+ serverInventoryAuthoritative: () => true,+ onAuthoritativeRevocationComplete,+ })+ ).rejects.toThrow(/Desired NetworkPolicy inventory changed/)++ expect(onAuthoritativeRevocationComplete).not.toHaveBeenCalled()+ })++ it('still fails loud when the delete fails for any other reason', async () => {+ listOnlyTheStalePolicy()+ const forbidden = Object.assign(new Error('forbidden'), { code: 403 })+ mockApi.deleteNamespacedNetworkPolicy.mockRejectedValueOnce(forbidden)+- await expect(reconciler.reconcileContext(staleContext, { isCurrent: () => true })).rejects.toBe(forbidden)++ await expect(++ reconciler.reconcileContext(staleContext, { isCurrent: () => true })++ ).rejects.toBe(forbidden)+ })++ it('still certifies when the stale policy was already gone', async () => {+ listOnlyTheStalePolicy()+ mockApi.deleteNamespacedNetworkPolicy.mockRejectedValueOnce(+ Object.assign(new Error('not found'), { code: 404 })+ )++ expect(await reconciler.reconcileContext(staleContext, { isCurrent: () => true })).toBe(true)+ })+ })++ describe('same-name conflict creating a safety external-egress policy', () => {+ const server: McpServerCRD = {+ name: 'renamed-server',+ namespace: 'mcp-server',+ spec: {+ contextRef: 'default',+ image: 'renamed:latest',+ transport: { type: 'streamableHttp', port: 3000 },+ egressBindings: [{ cidr: '104.18.0.0/16', port: 443 }],+ },+ }+ const desiredName = 'ext-egress-renamed-server-104-18-0-0-16-443'+ const stalePredecessor: k8s.V1NetworkPolicy = {+ metadata: {+ name: 'ext-egress-renamed-server-stale',+ namespace: 'mcp-server',+ uid: 'stale-uid',+ resourceVersion: '3',+ },+ }++ function reconcileExternalEgressSafety(): Promise<boolean> {+ return (+ reconciler as unknown as {+ reconcileExternalEgressSafety: (+ server: McpServerCRD,+ existingPolicies: k8s.V1NetworkPolicy[],+ isCurrent: () => boolean+ ) => Promise<boolean>+ }+ ).reconcileExternalEgressSafety(server, [stalePredecessor], () => true)+ }++ it('converges an HCC-owned same-name policy instead of aborting the pass', async () => {+ mockApi.createNamespacedNetworkPolicy.mockRejectedValueOnce(+ Object.assign(new Error('already exists'), { code: 409 })+ )+ mockApi.readNamespacedNetworkPolicy.mockResolvedValueOnce({+ metadata: {+ name: desiredName,+ namespace: server.namespace,+ uid: 'own-uid',+ resourceVersion: '7',+ labels: {+ 'clerum.io/managed-by': 'host-context-controller',+ 'clerum.io/policy-type': 'external-egress',+ 'clerum.io/mcpserver': server.name,+ },+ },+ })++ // This is the only creation route that bypasses applyNetworkPolicy. A+ // same-name object HCC already owns is an idempotent re-run, not a+ // reason to fail the pass and hold readiness down.+ expect(await reconcileExternalEgressSafety()).toBe(true)+ expect(mockApi.replaceNamespacedNetworkPolicy).toHaveBeenCalledWith(+ expect.objectContaining({ name: desiredName, namespace: server.namespace })+ )+ })++ it('still fails closed when the same-name policy is foreign', async () => {+ mockApi.createNamespacedNetworkPolicy.mockRejectedValueOnce(+ Object.assign(new Error('already exists'), { code: 409 })+ )+ mockApi.readNamespacedNetworkPolicy.mockResolvedValueOnce({+ metadata: {+ name: desiredName,+ namespace: server.namespace,+ uid: 'foreign-uid',+ resourceVersion: '7',+ labels: {+ 'clerum.io/managed-by': 'foreign-controller',+ 'clerum.io/policy-type': 'external-egress',+ 'clerum.io/mcpserver': server.name,+ },+ },+ })++ await expect(reconcileExternalEgressSafety()).rejects.toThrow(/ownership/i)+ expect(mockApi.replaceNamespacedNetworkPolicy).not.toHaveBeenCalled()+ })++ it('still fails loud when the create fails for any other reason', async () => {+ const forbidden = Object.assign(new Error('forbidden'), { code: 403 })+ mockApi.createNamespacedNetworkPolicy.mockRejectedValueOnce(forbidden)++ await expect(reconcileExternalEgressSafety()).rejects.toBe(forbidden)+ })+ })++ describe('safety-pass duration on the uncertified return path', () => {+ it('samples a failed outcome when the pass returns without certifying', async () => {+ const onAuthoritativeRevocationComplete = vi.fn()++ // Losing inventory authority ends the pass without an exception and+ // without certifying. Operators alert on "the pass never completed", so+ // this path has to produce a `failed` sample — absence is not a signal.+ await expect(+ reconciler.fullReconcile([], [], {+ ensureDefaults: false,+ contextInventoryAuthoritative: () => false,+ serverInventoryAuthoritative: () => true,+ onAuthoritativeRevocationComplete,+ })+ ).resolves.toBeUndefined()++ expect(onAuthoritativeRevocationComplete).not.toHaveBeenCalled()+ expect(networkPolicySafetyPassDurationSeconds.observe).toHaveBeenCalledWith(+ { outcome: 'failed' },+ expect.any(Number)+ )+ expect(networkPolicySafetyPassDurationSeconds.observe).toHaveBeenCalledTimes(1)+ })++ it('keeps the completed sample when a certified pass fails an additive effect afterwards', async () => {+ const context: ContextCRD = {+ name: 'default',+ namespace: 'mcp-server',+ spec: { contextId: 'default', mcpServers: [] },+ }+ const additiveFailure = new Error('additive list unavailable')+ let certified = false+ const onAuthoritativeRevocationComplete = vi.fn(() => {+ certified = true+ })+ mockApi.listNamespacedNetworkPolicy.mockImplementation(async () => {+ if (certified) throw additiveFailure+ return { items: [] }+ })++ await expect(+ reconciler.fullReconcile([context], [], {+ ensureDefaults: false,+ contextInventoryAuthoritative: () => true,+ serverInventoryAuthoritative: () => true,+ onAuthoritativeRevocationComplete,+ })+ ).rejects.toThrow(/additive Context NetworkPolicy reconciliations failed/)++ expect(onAuthoritativeRevocationComplete).toHaveBeenCalledOnce()+ expect(networkPolicySafetyPassDurationSeconds.observe).toHaveBeenCalledWith(+ { outcome: 'completed' },+ expect.any(Number)+ )+ expect(networkPolicySafetyPassDurationSeconds.observe).toHaveBeenCalledTimes(1)+ })})})diff --cc tests/e2e/integration/network-policies.test.tsindex aba9302b2,07925e9db..73e9eddce--- a/tests/e2e/integration/network-policies.test.ts+++ b/tests/e2e/integration/network-policies.test.ts@@@ -141,8 -179,32 +179,32 @@@ function testConnectivity}describe('NetworkPolicy Enforcement (Calico)', () => {+ beforeAll(() => {+ clusterReachable = probeClusterReachable()+ if (clusterReachable) return++ const msg =+ '[network-policies] kubernetes cluster not reachable (kubectl get ns default failed)'+ if (REQUIRE_CLUSTER) {+ throw new Error(+ `${msg}. Refusing to skip: E2E_REQUIRE_CLUSTER/CI is set, and a silent skip here ` ++ 'would report success while asserting nothing about NetworkPolicy enforcement. ' ++ 'Bring up the cluster (e.g. `make minikube-setup`) or unset the flag.'+ )+ }+ if (SKIP_IF_UNREACHABLE) {+ console.log(`${msg} — tests will be skipped (E2E_SKIP_IF_CLUSTER_UNREACHABLE=1)`)+ return+ }+ throw new Error(+ `${msg}. This E2E suite requires a minikube cluster with Calico CNI and all services ` ++ 'deployed. Run `make minikube-setup` first, or set E2E_SKIP_IF_CLUSTER_UNREACHABLE=1 to skip.'+ )+ })+// ─── Prerequisite Check ──────────────────────────────────────────────- it('Calico CNI is active', () => {- it('Calico CNI is active', (ctx) => {++ it('Calico CNI is active', ctx => {+ if (!clusterReachable) ctx.skip()const pods = execFileSync('kubectl',['get', 'pods', '-n', 'kube-system', '-l', 'k8s-app=calico-node', '--no-headers'],@@@ -151,7 -213,8 +213,8 @@@expect(pods).toContain('Running')})- it('deny-all policies exist in secured namespaces', () => {- it('deny-all policies exist in secured namespaces', (ctx) => {++ it('deny-all policies exist in secured namespaces', ctx => {+ if (!clusterReachable) ctx.skip()const namespaces = ['mcp-host', 'mcp-server', 'rpc-proxy', 'sandbox-recipes']for (const ns of namespaces) {let nps: string@@@ -184,7 -247,8 +247,8 @@@// ─── POSITIVE TESTS (Allowed Traffic) ────────────────────────────────describe('Allowed traffic (positive)', () => {- it('control-api → registry-api:8085 (cross-namespace, registry access)', () => {- it('control-api → registry-api:8085 (cross-namespace, registry access)', (ctx) => {++ it('control-api → registry-api:8085 (cross-namespace, registry access)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('control-plane','control-api',@@@ -193,7 -257,8 +257,8 @@@expect(result.reachable).toBe(true)})- it('control-ui → control-api:8090 (UI backend path)', () => {- it('control-ui → control-api:8090 (UI backend path)', (ctx) => {++ it('control-ui → control-api:8090 (UI backend path)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('control-plane','control-ui',@@@ -202,7 -267,8 +267,8 @@@expect(result.reachable).toBe(true)})- it('external-rest-api → profile-control-funnel:8080 (internal control path)', () => {- it('external-rest-api → profile-control-funnel:8080 (internal control path)', (ctx) => {++ it('external-rest-api → profile-control-funnel:8080 (internal control path)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('profiles','external-rest-api',@@@ -211,12 -277,14 +277,14 @@@expect(result.reachable).toBe(true)})- it('rpc-proxy → mcp-host:8080 (message relay)', () => {- it('rpc-proxy → mcp-host:8080 (message relay)', (ctx) => {++ it('rpc-proxy → mcp-host:8080 (message relay)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('rpc-proxy', 'rpc-proxy', getMcpHostRuntimeUrl())expect(result.reachable).toBe(true)})- it('mcp-host can reach the HCC gateway readiness endpoint', () => {- it('mcp-host can reach the HCC gateway readiness endpoint', (ctx) => {++ it('mcp-host can reach the HCC gateway readiness endpoint', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('mcp-host',getMcpHostRuntimeName(),@@@ -230,7 -298,8 +298,8 @@@// ─── NEGATIVE TESTS (Blocked by Design) ──────────────────────────────describe('Blocked traffic (negative — deny-all enforced)', () => {- it('mcp-host → rpc-proxy:8094 (reverse direction blocked)', () => {- it('mcp-host → rpc-proxy:8094 (reverse direction blocked)', (ctx) => {++ it('mcp-host → rpc-proxy:8094 (reverse direction blocked)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('mcp-host',getMcpHostRuntimeName(),@@@ -240,7 -309,8 +309,8 @@@expect(result.error).toContain('timeout')})- it('mcp-host → control-api:8090 (no direct access to control-plane)', () => {- it('mcp-host → control-api:8090 (no direct access to control-plane)', (ctx) => {++ it('mcp-host → control-api:8090 (no direct access to control-plane)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('mcp-host',getMcpHostRuntimeName(),@@@ -250,7 -320,8 +320,8 @@@expect(result.error).toContain('timeout')})- it('channel-reader → workflow approval gateway:8092 (must go through mcp-host)', () => {- it('channel-reader → workflow approval gateway:8092 (must go through mcp-host)', (ctx) => {++ it('channel-reader → workflow approval gateway:8092 (must go through mcp-host)', ctx => {+ if (!clusterReachable) ctx.skip()const podName = getChannelReaderPodName()if (!podName) {console.warn('SKIPPED: no running channel-reader pod in channels')@@@ -266,7 -337,8 +337,8 @@@expect(result.error).toContain('timeout')})- it('mcp-host → registry-api:8085 (no direct registry access)', () => {- it('mcp-host → registry-api:8085 (no direct registry access)', (ctx) => {++ it('mcp-host → registry-api:8085 (no direct registry access)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('mcp-host',getMcpHostRuntimeName(),@@@ -276,7 -348,8 +348,8 @@@expect(result.error).toContain('timeout')})- it('control-api → rpc-proxy:8094 (no direct control-plane hop)', () => {- it('control-api → rpc-proxy:8094 (no direct control-plane hop)', (ctx) => {++ it('control-api → rpc-proxy:8094 (no direct control-plane hop)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('control-plane','control-api',@@@ -286,7 -359,8 +359,8 @@@expect(result.error).toContain('timeout')})- it('external-rest-api → rpc-proxy:8094 (desktop app reaches rpc-proxy directly, not via backend)', () => {- it('external-rest-api → rpc-proxy:8094 (desktop app reaches rpc-proxy directly, not via backend)', (ctx) => {++ it('external-rest-api → rpc-proxy:8094 (desktop app reaches rpc-proxy directly, not via backend)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('profiles','external-rest-api',@@@ -296,19 -370,22 +370,22 @@@expect(result.error).toContain('timeout')})- it('control-api → mcp-host:8080 directly (must go through rpc-proxy)', () => {- it('control-api → mcp-host:8080 directly (must go through rpc-proxy)', (ctx) => {++ it('control-api → mcp-host:8080 directly (must go through rpc-proxy)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('control-plane', 'control-api', getMcpHostRuntimeUrl())expect(result.reachable).toBe(false)expect(result.error).toContain('timeout')})- it('external-rest-api → mcp-host:8080 directly (must go through rpc-proxy)', () => {- it('external-rest-api → mcp-host:8080 directly (must go through rpc-proxy)', (ctx) => {++ it('external-rest-api → mcp-host:8080 directly (must go through rpc-proxy)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('profiles', 'external-rest-api', getMcpHostRuntimeUrl())expect(result.reachable).toBe(false)expect(result.error).toContain('timeout')})- it('mcp-proxy → external-rest-api:3000 (no reverse path)', () => {- it('mcp-proxy → external-rest-api:3000 (no reverse path)', (ctx) => {++ it('mcp-proxy → external-rest-api:3000 (no reverse path)', ctx => {+ if (!clusterReachable) ctx.skip()const result = testConnectivity('mcp-server','mcp-proxy',@@@ -348,7 -425,8 +425,8 @@@}}- it('sandbox-recipes → control-api:8090 (isolated sandbox)', () => {- it('sandbox-recipes → control-api:8090 (isolated sandbox)', (ctx) => {++ it('sandbox-recipes → control-api:8090 (isolated sandbox)', ctx => {+ if (!clusterReachable) ctx.skip()const podName = findExecPod('sandbox-recipes', 'app=db')if (!podName) {console.warn('SKIPPED: no running db pod in sandbox-recipes')@@@ -364,7 -442,8 +442,8 @@@expect(result.error).toContain('timeout')})- it('sandbox-recipes → rpc-proxy:8094 (isolated sandbox)', () => {- it('sandbox-recipes → rpc-proxy:8094 (isolated sandbox)', (ctx) => {++ it('sandbox-recipes → rpc-proxy:8094 (isolated sandbox)', ctx => {+ if (!clusterReachable) ctx.skip()const podName = findExecPod('sandbox-recipes', 'app=db')if (!podName) {console.warn('SKIPPED: no running db pod in sandbox-recipes')diff --cc tests/e2e/package-lock.jsonindex 558c31760,558c31760..5ace9758b--- a/tests/e2e/package-lock.json+++ b/tests/e2e/package-lock.json@@@ -1,12 -1,12 +1,12 @@@{"name": "clerum-e2e-tests",-- "version": "0.1.66",++ "version": "0.1.67","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-e2e-tests",-- "version": "0.1.66",++ "version": "0.1.67","devDependencies": {"@types/jsonwebtoken": "^9.0.10","@types/node": "^22.0.0",diff --cc tests/e2e/package.jsonindex 19145d619,19145d619..6770e4a49--- a/tests/e2e/package.json+++ b/tests/e2e/package.json@@@ -1,6 -1,6 +1,6 @@@{"name": "clerum-e2e-tests",-- "version": "0.1.66",++ "version": "0.1.67","private": true,"type": "module","scripts": {