Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(hcc): require isCurrent on binding-policy reconcile (fail-closed) [R4-F]
Alfredo Lopez000dd2242a6d
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex c117752cd..9bcfc9c0f 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.222",+ "version": "0.1.223","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.222",+ "version": "0.1.223","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 5c14474c8..42fe8f398 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.222",+ "version": "0.1.223","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/bindingPolicyReconciler.test.ts b/host-context-controller/src/bindingPolicyReconciler.test.tsindex 64cffe433..48d6fe191 100644--- a/host-context-controller/src/bindingPolicyReconciler.test.ts+++ b/host-context-controller/src/bindingPolicyReconciler.test.ts@@ -48,7 +48,9 @@ describe('BindingPolicyReconciler', () => {const singleBinding: BindingDef[] = [{ from: 'redis-mcp', to: 'redis', port: 6379 }]it('creates egress + ingress policies for a binding', async () => {- await reconciler.reconcileBindings('my-recipe', singleBinding, 'redis-mcp')+ await reconciler.reconcileBindings('my-recipe', singleBinding, 'redis-mcp', 'redis-mcp', {+ isCurrent: () => true,+ })// 2 calls: 1 egress + 1 ingressexpect(mockApi.createNamespacedNetworkPolicy).toHaveBeenCalledTimes(2)@@ -83,7 +85,9 @@ describe('BindingPolicyReconciler', () => {})it('applies binding-allow labels to all policies', async () => {- await reconciler.reconcileBindings('my-recipe', singleBinding, 'redis-mcp')+ await reconciler.reconcileBindings('my-recipe', singleBinding, 'redis-mcp', 'redis-mcp', {+ isCurrent: () => true,+ })for (const call of mockApi.createNamespacedNetworkPolicy.mock.calls) {const labels = (call[0] as { body: { metadata: { labels: Record<string, string> } } }).body@@ -97,7 +101,9 @@ describe('BindingPolicyReconciler', () => {it('handles 409 conflict with create-or-replace pattern', async () => {mockApi.createNamespacedNetworkPolicy.mockRejectedValue({ code: 409 })- await reconciler.reconcileBindings('my-recipe', singleBinding, 'redis-mcp')+ await reconciler.reconcileBindings('my-recipe', singleBinding, 'redis-mcp', 'redis-mcp', {+ isCurrent: () => true,+ })expect(mockApi.readNamespacedNetworkPolicy).toHaveBeenCalled()expect(mockApi.replaceNamespacedNetworkPolicy).toHaveBeenCalled()@@ -201,7 +207,9 @@ describe('BindingPolicyReconciler', () => {})it('uses _from for ingress rules (K8s client ObjectSerializer maps _from → from)', async () => {- await reconciler.reconcileBindings('my-recipe', singleBinding, 'redis-mcp')+ await reconciler.reconcileBindings('my-recipe', singleBinding, 'redis-mcp', 'redis-mcp', {+ isCurrent: () => true,+ })const calls = mockApi.createNamespacedNetworkPolicy.mock.callsconst ingressCall = calls.find(@@ -218,7 +226,9 @@ describe('BindingPolicyReconciler', () => {})it('uses correct pod selectors and namespace-aware placement', async () => {- await reconciler.reconcileBindings('my-recipe', singleBinding, 'redis-mcp')+ await reconciler.reconcileBindings('my-recipe', singleBinding, 'redis-mcp', 'redis-mcp', {+ isCurrent: () => true,+ })const calls = mockApi.createNamespacedNetworkPolicy.mock.callsconst egressCall = calls.find(@@ -288,7 +298,8 @@ describe('BindingPolicyReconciler', () => {'my-recipe',singleBinding,'redis-mcp',- 'my-recipe-redis-mcp'+ 'my-recipe-redis-mcp',+ { isCurrent: () => true })const calls = mockApi.createNamespacedNetworkPolicy.mock.callsdiff --git a/host-context-controller/src/bindingPolicyReconciler.ts b/host-context-controller/src/bindingPolicyReconciler.tsindex 0f081e64f..0281e69f6 100644--- a/host-context-controller/src/bindingPolicyReconciler.ts+++ b/host-context-controller/src/bindingPolicyReconciler.ts@@ -38,7 +38,11 @@ export interface BindingDef {}export interface BindingPolicyReconcileOptions {- isCurrent?: () => boolean+ // Required (fail-closed): every caller must supply the authority predicate so+ // a retired reconcile pass cannot keep mutating binding NetworkPolicies. There+ // is no assume-current default — an omitted predicate is a compile error, not+ // a silent fail-open (the old `?? (() => true)`) nor a silent no-op.+ isCurrent: () => boolean}export interface BindingPolicyCleanupOptions {@@ -69,9 +73,9 @@ export class BindingPolicyReconciler {bindings: BindingDef[],mcpWorkloadName: string,mcpServerName = mcpWorkloadName,- options: BindingPolicyReconcileOptions = {}+ options: BindingPolicyReconcileOptions): Promise<void> {- const isCurrent = options.isCurrent ?? (() => true)+ const isCurrent = options.isCurrentif (!isCurrent()) returnconsole.log(`[BindingNP] Reconciling ${bindings.length} binding(s) for recipe "${recipeName}"`)