Skip to content

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

TypeScript

fix(hcc): apply cheap zach88 review nits

Alfredo Lopez21453c2815ec
diff --git a/deploy/scripts/apply-inter-service-tokens.sh b/deploy/scripts/apply-inter-service-tokens.sh
index cdab1ec1c..0b4a18fce 100755
--- a/deploy/scripts/apply-inter-service-tokens.sh
+++ b/deploy/scripts/apply-inter-service-tokens.sh
@@ -311,7 +311,11 @@ kctl -n channels patch secret workflow-approval-request-reader-credentials --typ
# Roll the consumers so they pick up the fresh tokens on first deploy. Safe
# no-ops if the Deployments do not yet exist. HCC is Recreate + replicas:1
# and reloads HMAC only at process start, so skip that extra rollout when the
-# in-memory HCC key is unchanged (image/spec applies still roll HCC themselves).
+# HCC key this run writes equals the key already in the Secret (image/spec
+# applies still roll HCC themselves). This is not "the running pod env matches
+# the Secret": an out-of-band kubectl patch of the HCC key, then a re-run that
+# preserve-or-generates from the Secret, will skip. Heal that with
+# FORCE_CONSUMER_RESTART=true.
for pair in "control-plane:control-api" \
"control-plane:workflow-recipes" \
"control-plane:host-context-controller" \
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index 228cc22ad..98f09c301 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.234",
+ "version": "0.1.235",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.234",
+ "version": "0.1.235",
"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 bc1e9d0e4..7fc86e36c 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.234",
+ "version": "0.1.235",
"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/k8sClient.ts b/host-context-controller/src/k8sClient.ts
index 9d16b4d91..cd2475957 100644
--- a/host-context-controller/src/k8sClient.ts
+++ b/host-context-controller/src/k8sClient.ts
@@ -62,6 +62,7 @@ import {
initialConvergenceRetriesTotal,
} from './metrics'
import { NetworkPolicyReconciler, sameContextDesiredRevision } from './networkPolicyReconciler'
+import type { ReadinessInventoryDetail } from './readinessGate'
import { McpServerReconciler } from './reconciler'
import { SharedFileSystemReconciler } from './sharedFileSystemReconciler'
import {
@@ -1013,15 +1014,7 @@ export class McpServerWatcher implements McpServerProvider {
* by preserving replicas and disabling stateless suspension until recovery.
* SFS/GFS retain their established eventual-resync contract.
*/
- getReadinessInventoryDetail(): {
- stopped: boolean
- mcpServerCacheSynced: boolean
- contextCacheSynced: boolean
- hostCacheSynced: boolean
- safetyInventoryCertified: boolean
- contextRevisionAligned: boolean
- serverRevisionAligned: boolean
- } {
+ getReadinessInventoryDetail(): ReadinessInventoryDetail {
return {
stopped: this.stopped,
mcpServerCacheSynced: this.mcpServerCacheSynced,
diff --git a/host-context-controller/src/server.test.ts b/host-context-controller/src/server.test.ts
index f9934a6c7..5d6909eba 100644
--- a/host-context-controller/src/server.test.ts
+++ b/host-context-controller/src/server.test.ts
@@ -655,6 +655,48 @@ describe('ContextMapperServer desktop status authority', () => {
message: 'Host inventory is not authoritative',
})
})
+
+ it('fails desktop closed when the Host authority check throws', async () => {
+ const authorityError = new Error('host authority unavailable')
+ const errorLog = vi.spyOn(console, 'error').mockImplementation(() => undefined)
+ server = new ContextMapperServer(
+ new FakeProvider(),
+ 0,
+ runningReconciler,
+ hasDesktopFn,
+ () => true,
+ () => {
+ throw authorityError
+ }
+ )
+ server.setReady(true)
+
+ const desktop = await invoke(server, '/api/v1/desktop/host-a')
+ expect(desktop.statusCode).toBe(503)
+ expect(JSON.parse(desktop.body)).toEqual({
+ error: 'Service Unavailable',
+ message: 'Host inventory is not authoritative',
+ })
+ const hostErrors = errorLog.mock.calls
+ .map(args => {
+ try {
+ return JSON.parse(String(args[0])) as {
+ msg?: string
+ err?: { name?: string; message?: string }
+ }
+ } catch {
+ return null
+ }
+ })
+ .filter((entry): entry is { msg: string; err?: { name?: string; message?: string } } =>
+ Boolean(entry && entry.msg === 'host authority check failed')
+ )
+ expect(hostErrors).toHaveLength(1)
+ expect(hostErrors[0].err).toEqual({
+ name: authorityError.name,
+ message: authorityError.message,
+ })
+ })
})
describe('ContextMapperServer /ready reasons', () => {
@@ -772,7 +814,7 @@ describe('ContextMapperServer /ready reasons', () => {
})
})
- it('emits closed reasons through the same resolvers main.ts uses', async () => {
+ it('emits closed reasons through the main.ts resolve*Fn wiring', async () => {
let detail = authoritativeDetail()
const watcher = {
isReadinessInventoryAuthoritative: () =>
diff --git a/host-context-controller/src/server.ts b/host-context-controller/src/server.ts
index 791c59427..515c2fb2d 100644
--- a/host-context-controller/src/server.ts
+++ b/host-context-controller/src/server.ts
@@ -141,7 +141,7 @@ export class ContextMapperServer {
try {
return this.hostAuthoritativeFn()
} catch (err) {
- console.error('[Server] Host authority check failed:', err)
+ readinessLog.error('host authority check failed', { err })
return false
}
}
diff --git a/scripts/tests/test-inter-service-tokens.sh b/scripts/tests/test-inter-service-tokens.sh
index bd2f8c187..590294d6f 100755
--- a/scripts/tests/test-inter-service-tokens.sh
+++ b/scripts/tests/test-inter-service-tokens.sh
@@ -172,6 +172,23 @@ fi
assert_other_consumers_restarted "$unchanged_rollout"
assert_no_secret_material
+# Dominant CI redeploy path: no INTERNAL_CONTROL_JWT_HCC_HMAC_SECRET override.
+# Both resolve_token and HCC_HMAC_BEFORE read KUBE_SECRET_HCC.
+preserve_rollout="$TMP/rollout-preserve-or-generate.log"
+KUBE_SECRET_HCC="$HCC_OLD" KUBE_SECRET_WRC="$WRC_OLD" \
+ run_hcc_apply "$preserve_rollout" env \
+ -u INTERNAL_CONTROL_JWT_HCC_HMAC_SECRET \
+ -u INTERNAL_CONTROL_JWT_WRC_HMAC_SECRET \
+ CONTROL_API_MEMBER_REGISTRATION_HMAC_SECRET=test-member-registration-hmac
+grep -q 'Skipping rollout of control-plane/host-context-controller: hcc-hmac unchanged' "$TMP/stderr"
+if grep -q 'host-context-controller' "$preserve_rollout"; then
+ echo "preserve-or-generate HCC HMAC must not restart host-context-controller" >&2
+ cat "$preserve_rollout" >&2
+ exit 1
+fi
+assert_other_consumers_restarted "$preserve_rollout"
+assert_no_secret_material
+
changed_rollout="$TMP/rollout-changed.log"
KUBE_SECRET_HCC="$HCC_OLD" KUBE_SECRET_WRC="$WRC_OLD" \
run_hcc_apply "$changed_rollout" env \