Skip to content

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

TypeScript

test(hcc): derive container fixture defaults from the recorded blob

Alfredo Lopezbc10b8ac666f
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index 2813266c8..e09d87ca2 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.283",
+ "version": "0.1.284",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.283",
+ "version": "0.1.284",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@clerum/codex-catalog-projection": "file:../packages/codex-catalog-projection",
diff --git a/host-context-controller/package.json b/host-context-controller/package.json
index 3f6fff27a..a0eb362b8 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.283",
+ "version": "0.1.284",
"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__/asApiserverDeployment.ts b/host-context-controller/src/__tests__/asApiserverDeployment.ts
index b6074070d..a859308bc 100644
--- a/host-context-controller/src/__tests__/asApiserverDeployment.ts
+++ b/host-context-controller/src/__tests__/asApiserverDeployment.ts
@@ -8,9 +8,15 @@ import type * as k8s from '@kubernetes/client-node'
* a field, refresh this blob so the suite goes red until the comparator or
* builder learns that default (PR G §8).
*
- * Container `imagePullPolicy` is filled after overlay from kube
- * `DefaultImagePullPolicy` (Always for `:latest` / untagged; IfNotPresent
- * otherwise) because recorded containers are replaced by the desired list.
+ * Desired containers replace the recorded list (arrays overlay by clone).
+ * Top-level omitted container defaults are then copied from the recorded
+ * container — one list, not a hand-written twin of
+ * `normalizeContainerDefaults`. `imagePullPolicy` stays content-dependent
+ * (`DefaultImagePullPolicy`: Always for `:latest` / untagged; IfNotPresent
+ * otherwise). Nested defaults (ports, probes, env.fieldRef) only exist when
+ * those child objects are present and stay synthesized. Refresh the recorded
+ * container from a live GET so a new apiserver default turns the suite red
+ * (PR G §8 / #530).
*/
const SERVER_TIME = new Date('2026-04-01T00:00:00.000Z')
const SERVER_UID = '11111111-2222-3333-4444-555555555555'
@@ -70,6 +76,7 @@ export const RECORDED_APPSV1_DEPLOYMENT: k8s.V1Deployment = {
name: 'recorded',
image: 'recorded:1',
imagePullPolicy: 'IfNotPresent',
+ resources: {},
terminationMessagePath: '/dev/termination-log',
terminationMessagePolicy: 'File',
},
@@ -178,17 +185,34 @@ function applyPodSpecDefaults(podSpec: k8s.V1PodSpec | undefined): void {
for (const volume of podSpec.volumes ?? []) applyVolumeDefaults(volume)
}
+const RECORDED_CONTAINER_AUTHORING = new Set(['name', 'image'])
+const RECORDED_CONTAINER_CONTENT_DEPENDENT = new Set(['imagePullPolicy'])
+
+function recordedContainer(): k8s.V1Container {
+ const container = RECORDED_APPSV1_DEPLOYMENT.spec?.template?.spec?.containers?.[0]
+ if (!container) {
+ throw new Error('RECORDED_APPSV1_DEPLOYMENT is missing a recorded container')
+ }
+ return container
+}
+
function applyContainerDefaults(container: k8s.V1Container): void {
- if (container.resources === undefined) container.resources = {}
+ // Top-level omitted keys come from the recorded container so a refreshed
+ // blob (new apiserver default) fills without a parallel if-chain.
+ for (const [key, value] of Object.entries(recordedContainer()) as Array<
+ [keyof k8s.V1Container, unknown]
+ >) {
+ if (RECORDED_CONTAINER_AUTHORING.has(key) || RECORDED_CONTAINER_CONTENT_DEPENDENT.has(key)) {
+ continue
+ }
+ if (value === undefined) continue
+ if (container[key] === undefined) {
+ ;(container as unknown as Record<string, unknown>)[key] = structuredClone(value)
+ }
+ }
if (container.imagePullPolicy === undefined) {
container.imagePullPolicy = defaultImagePullPolicy(container.image)
}
- if (container.terminationMessagePath === undefined) {
- container.terminationMessagePath = '/dev/termination-log'
- }
- if (container.terminationMessagePolicy === undefined) {
- container.terminationMessagePolicy = 'File'
- }
for (const port of container.ports ?? []) {
if (port.protocol === undefined) port.protocol = 'TCP'
}
diff --git a/host-context-controller/src/__tests__/deploymentMatchesDesired.test.ts b/host-context-controller/src/__tests__/deploymentMatchesDesired.test.ts
index f149ac58f..231feb436 100644
--- a/host-context-controller/src/__tests__/deploymentMatchesDesired.test.ts
+++ b/host-context-controller/src/__tests__/deploymentMatchesDesired.test.ts
@@ -17,7 +17,7 @@ import {
normalizeDeploymentForComparison,
preserveDeploymentAnnotations,
} from '../utils'
-import { asApiserverDeployment } from './asApiserverDeployment'
+import { RECORDED_APPSV1_DEPLOYMENT, asApiserverDeployment } from './asApiserverDeployment'
import {
cloneAndMutateLeaf,
collectLeafPaths,
@@ -176,6 +176,45 @@ describe('asApiserverDeployment', () => {
expect(existing.spec?.template?.spec?.restartPolicy).toBe('Always')
})
+ it('FIXTURE-1: top-level container defaults come from the recorded container', () => {
+ const recorded = RECORDED_APPSV1_DEPLOYMENT.spec?.template?.spec?.containers?.[0]
+ expect(recorded).toBeDefined()
+ const desired = sparseDeployment()
+ delete desired.spec!.template.spec!.containers![0].ports
+ const synthesized = asApiserverDeployment(desired).spec?.template?.spec?.containers?.[0]
+ expect(synthesized).toBeDefined()
+
+ const topLevelDefaults = (container: k8s.V1Container) => {
+ const rest: Record<string, unknown> = { ...container }
+ delete rest.name
+ delete rest.image
+ delete rest.imagePullPolicy
+ return rest
+ }
+ expect(topLevelDefaults(synthesized!)).toEqual(topLevelDefaults(recorded!))
+ expect(recorded?.resources).toEqual({})
+ expect(synthesized?.resources).toEqual({})
+ })
+
+ it('FIXTURE-1: recorded container defaults that the lemma strips still strip; IPP does not', () => {
+ const recorded = RECORDED_APPSV1_DEPLOYMENT.spec?.template?.spec?.containers?.[0]
+ expect(recorded).toBeDefined()
+ const desired = sparseDeployment()
+ desired.spec!.template.spec!.containers![0] = {
+ name: 'c',
+ image: 'img:1',
+ imagePullPolicy: recorded!.imagePullPolicy,
+ resources: structuredClone(recorded!.resources),
+ terminationMessagePath: recorded!.terminationMessagePath,
+ terminationMessagePolicy: recorded!.terminationMessagePolicy,
+ }
+ const container = canonicalPodSpec(normalizeDeploymentForComparison(desired))?.containers?.[0]
+ expect(container?.resources).toBeUndefined()
+ expect(container?.terminationMessagePath).toBeUndefined()
+ expect(container?.terminationMessagePolicy).toBeUndefined()
+ expect(container?.imagePullPolicy).toBe('IfNotPresent')
+ })
+
it('FIXTURE-1: fills omitted imagePullPolicy the way apps/v1 defaults it', () => {
const containerOf = (desired: k8s.V1Deployment) =>
asApiserverDeployment(desired).spec?.template?.spec?.containers?.[0]
@@ -204,6 +243,9 @@ type CanonicalPodSpec = {
serviceAccountName?: string
containers?: Array<{
resources?: unknown
+ imagePullPolicy?: string
+ terminationMessagePath?: string
+ terminationMessagePolicy?: string
livenessProbe?: { timeoutSeconds?: number; failureThreshold?: number }
}>
}