Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(hcc): assert guardrails-revision annotation on the mcp-host pod template
Andy Pavia4cffc405ca06
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex d340287bc..c1bd6fa81 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.171",+ "version": "0.1.172","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.171",+ "version": "0.1.172","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 e0bf3e74e..705941267 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.171",+ "version": "0.1.172","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/__tests__/hostReconciler.mounts.test.ts b/host-context-controller/src/__tests__/hostReconciler.mounts.test.tsindex 8200f6c2e..3a1d353b8 100644--- a/host-context-controller/src/__tests__/hostReconciler.mounts.test.ts+++ b/host-context-controller/src/__tests__/hostReconciler.mounts.test.ts@@ -5,6 +5,7 @@ import { config as hccConfig } from '../config'import { HostReconciler, type ResolvedSfsMount } from '../hostReconciler'import { issueMcpHostRuntimeTokens } from '../mcpHostRuntimeTokenIssuerClient'import type { HostCRD } from '../types'+import { canonicalStringify } from '../utils'vi.mock('../mcpHostRuntimeTokenIssuerClient', () => ({issueMcpHostRuntimeTokens: vi.fn().mockResolvedValue({@@ -990,6 +991,47 @@ describe('HostReconciler.buildDeployment — SharedFileSystem mounts', () => {})})+ it('omits the guardrails-revision annotation when the host has no guardrails', () => {+ const reconciler = new HostReconciler(makeStubKc())+ const dep = reconciler.buildDeployment(makeHost())+ expect(dep.spec!.template!.metadata!.annotations ?? {}).not.toHaveProperty(+ 'clerum.io/guardrails-revision'+ )+ })++ it('stamps sha256(canonicalStringify(guardrails)) on the pod template when guardrails are set', () => {+ const reconciler = new HostReconciler(makeStubKc())+ const guardrails: HostCRD['spec']['guardrails'] = {+ hooks: { preCall: [{ id: 'h1', digest: 'sha256:abc' }] },+ }+ const host: HostCRD = { ...makeHost(), spec: { ...makeHost().spec, guardrails } }+ const dep = reconciler.buildDeployment(host)+ const expected = createHash('sha256')+ .update(canonicalStringify(guardrails as unknown as Record<string, unknown>))+ .digest('hex')+ expect(dep.spec!.template!.metadata!.annotations?.['clerum.io/guardrails-revision']).toBe(+ expected+ )+ })++ it('changes the guardrails-revision on a guardrails change and is stable otherwise', () => {+ const reconciler = new HostReconciler(makeStubKc())+ const revFor = (guardrails: HostCRD['spec']['guardrails']): string | undefined => {+ const host: HostCRD = { ...makeHost(), spec: { ...makeHost().spec, guardrails } }+ return reconciler.buildDeployment(host).spec!.template!.metadata!.annotations?.[+ 'clerum.io/guardrails-revision'+ ]+ }+ const a = revFor({ hooks: { preCall: [{ id: 'h1', digest: 'sha256:abc' }] } })+ const aAgain = revFor({ hooks: { preCall: [{ id: 'h1', digest: 'sha256:abc' }] } })+ const b = revFor({ hooks: { preCall: [{ id: 'h2', digest: 'sha256:def' }] } })+ // Same guardrails → same hash: no spurious rolls.+ expect(a).toBe(aAgain)+ // Changed guardrails → new hash → the pod template flips → rolling restart.+ expect(a).not.toBe(b)+ expect(a).toMatch(/^[0-9a-f]{64}$/)+ })+it('keeps liveness separate from runtime-auth readiness', () => {const reconciler = new HostReconciler(makeStubKc())const dep = reconciler.buildDeployment(makeHost())