Skip to content

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

TypeScript

fix(hcc): preserve observed MCP desired state

Alfredo Lopez51d67a02aa4e
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index 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.json
index 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__/reconciler.sanitize.test.ts b/host-context-controller/src/__tests__/reconciler.sanitize.test.ts
index b3d979815..0ef68a1c8 100644
--- a/host-context-controller/src/__tests__/reconciler.sanitize.test.ts
+++ b/host-context-controller/src/__tests__/reconciler.sanitize.test.ts
@@ -122,6 +122,19 @@ describe('CRD Field Injection Prevention (sanitizeCrdSpec)', () => {
const container = capturedContainer(appsApi)
expect(container.imagePullPolicy).toBe('IfNotPresent')
})
+
+ it('does not mutate a watched desired spec while building the sanitized Deployment', async () => {
+ const server = makeServer({
+ imagePullPolicy: 'Always',
+ security: { runAsUser: 0, addCapabilities: ['CHOWN', 'SYS_ADMIN'] },
+ })
+ const originalSpec = structuredClone(server.spec)
+
+ await reconciler.reconcile(server)
+
+ expect(capturedContainer(appsApi).imagePullPolicy).toBe('IfNotPresent')
+ expect(server.spec).toEqual(originalSpec)
+ })
})
// ════════════════════════════════════════════════════════════════════
diff --git a/host-context-controller/src/reconciler.ts b/host-context-controller/src/reconciler.ts
index b54c4069e..eae8da378 100644
--- a/host-context-controller/src/reconciler.ts
+++ b/host-context-controller/src/reconciler.ts
@@ -744,7 +744,13 @@ ${authHeaderLines ? '\n # ── Credential auth headers (envsubst-resolv
}
private buildDeployment(server: McpServerCRD): k8s.V1Deployment {
- // ── Platform hardening: sanitize CRD before building PodSpec ──
+ // ── Platform hardening: sanitize an ephemeral copy before building PodSpec ──
+ // The caller retains this object as the LIST -> WATCH desired-state cache.
+ // Mutating it here makes a later status-only watch event look like a
+ // user-driven spec revision, which invalidates the authoritative policy
+ // revocation marker during startup. Sanitization remains mandatory for the
+ // generated PodSpec, but must never rewrite the observed CRD inventory.
+ server = structuredClone(server)
this.sanitizeCrdSpec(server)
const transportPort = server.spec.transport.port || 3000