Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(egress): close the two coverage gaps the #513 review found
Alfredo Lopez0249da4910be
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex c76d3e955..677db12b5 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.285",+ "version": "0.1.286","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.285",+ "version": "0.1.286","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.jsonindex 31e93dd0b..2bc819451 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.285",+ "version": "0.1.286","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/networkPolicyReconciler.egressClassification.test.ts b/host-context-controller/src/networkPolicyReconciler.egressClassification.test.tsindex acf547644..43b240ade 100644--- a/host-context-controller/src/networkPolicyReconciler.egressClassification.test.ts+++ b/host-context-controller/src/networkPolicyReconciler.egressClassification.test.ts@@ -198,9 +198,15 @@ describe('#513: a non-DNS exception inside the resolve block is not a DNS condit*/function statusConditions(): Condition[] {type Op = { op?: string; path?: string; value?: unknown }+ // `mock.calls` is `any[][]`, so the parameter is typed as the loose array it+ // actually is and the argument shape is asserted inside. Annotating it as a+ // fixed-length tuple does not typecheck under `tsc --noEmit` (which, unlike+ // `tsconfig.build.json`, includes test files): an `any[]` may have fewer+ // elements than a 1-tuple requires.return mockCustomApi.patchNamespacedCustomObjectStatus.mock.calls.flatMap(- (call: [{ body?: Op[] }]) =>- (call[0]?.body ?? []).flatMap((op): Condition[] => {+ (call: unknown[]): Condition[] => {+ const body = (call[0] as { body?: Op[] } | undefined)?.body ?? []+ return body.flatMap((op): Condition[] => {if (op.path === '/status/conditions') return (op.value ?? []) as Condition[]if (op.path === '/status') {return (((op.value ?? {}) as { conditions?: Condition[] }).conditions ??@@ -208,6 +214,7 @@ describe('#513: a non-DNS exception inside the resolve block is not a DNS condit}return []})+ })}@@ -270,6 +277,33 @@ describe('#513: a non-DNS exception inside the resolve block is not a DNS conditexpect(egress.at(-1)?.reason).toBe('ExternalEgressRejected')})+ it('T5 keeps freezing the lapsed window on a real transient resolver code', async () => {+ // The gate has two exemptions and this pins the one the other tests do not+ // touch. Deleting `kind !== 'transient'` from the condition turns every+ // transient failure into a rethrow — fail-static (D4) collapses, and an+ // outage at the resolver would take the accumulated /32s with it.+ //+ // The only other coverage of this branch lives in+ // `networkPolicyReconciler.egressFailStatic.test.ts`, and it arrives via the+ // bounded-timeout wrapper's synthetic ETIMEDOUT rather than an answer the+ // resolver actually gave. ESERVFAIL is that answer.+ await seedAccumulatedPolicy({ lapsed: true })+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)+ resolve4Mock.mockRejectedValueOnce(+ Object.assign(new Error('queryA ESERVFAIL api.example.com'), { code: 'ESERVFAIL' })+ )++ // Freezing means the reconcile completes: no rethrow, no prune, no delete.+ await reconciler.reconcileExternalEgress(server, { isCurrent: () => true })++ expect(mockApi.deleteNamespacedNetworkPolicy).not.toHaveBeenCalled()+ expect(warn.mock.calls.flat().join('\n')).not.toContain('permanent DNS failure')+ warn.mockRestore()++ const egress = statusConditions().filter(c => c.type === 'ExternalEgressReady')+ expect(egress.at(-1)?.reason).not.toBe('ExternalEgressReconcileFailed')+ })+it("T4 treats EBADNAME as the operator's malformed name, not as a controller fault", async () => {// EBADNAME is a POSITIVE verdict about the name: c-ares refused to send the// query at all. It is reachable from user input — the CRD pattern fordiff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.jsonindex 523c9265d..aba5d2c98 100644--- a/workflow-recipes/package-lock.json+++ b/workflow-recipes/package-lock.json@@ -1,12 +1,12 @@{"name": "workload-recipes-controller",- "version": "0.1.323",+ "version": "0.1.324","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "workload-recipes-controller",- "version": "0.1.323",+ "version": "0.1.324","license": "SEE LICENSE IN LICENSE","dependencies": {"@aws-sdk/client-s3": "^3.1009.0",diff --git a/workflow-recipes/package.json b/workflow-recipes/package.jsonindex b26da66da..62ddd2793 100644--- a/workflow-recipes/package.json+++ b/workflow-recipes/package.json@@ -1,6 +1,6 @@{"name": "workload-recipes-controller",- "version": "0.1.323",+ "version": "0.1.324","description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface","main": "dist/main.js","engines": {diff --git a/workflow-recipes/src/reconciler/reconciler.test.ts b/workflow-recipes/src/reconciler/reconciler.test.tsindex 07bf7ade4..5ac2d4777 100644--- a/workflow-recipes/src/reconciler/reconciler.test.ts+++ b/workflow-recipes/src/reconciler/reconciler.test.ts@@ -3977,6 +3977,46 @@ describe('WorkflowRecipeReconciler', () => {.find(b => b.metadata?.name === name)}+ it('#513: a throwing lookup fails the recipe without touching the ui egress policy', async () => {+ // The workload lane has the same guard; this is the ui lane, which reaches+ // `resolveExternalEgress` through a different call site+ // (`reconcileUiEgressPolicy`) with its own error routing. `defaultFqdnLookup`+ // now throws rather than dressing an unclassifiable fault as "no A or AAAA+ // records", and that only helps if BOTH call sites land somewhere honest:+ // the terminal `failed` phase carrying the real code, reached before any+ // write or delete, so a live `ui-egress-*` policy is left as it was.+ const kc = new k8s.KubeConfig()+ const rec = new WorkflowRecipeReconciler(kc, undefined, {+ fqdnLookup: async () => {+ throw new Error(+ 'DNS lookup for "api.stripe.com" failed with a non-DNS error (EBADFAMILY): queryA EBADFAMILY',+ { cause: Object.assign(new Error('queryA EBADFAMILY'), { code: 'EBADFAMILY' }) }+ )+ },+ })++ const result = await rec.reconcile(+ uiRecipeWithExternals([{ fqdn: 'api.stripe.com', port: 443 }])+ )++ expect(result.phase).toBe('failed')+ expect(result.message).toContain('EBADFAMILY')+ // Not laundered into the operator-facing no-records wording.+ expect(result.message).not.toContain('no A or AAAA records')++ expect(createdPolicy('ui-egress-test-recipe')).toBeUndefined()+ expect(mockNetworkingApi.replaceNamespacedNetworkPolicy).not.toHaveBeenCalledWith(+ expect.objectContaining({+ body: expect.objectContaining({+ metadata: expect.objectContaining({ name: 'ui-egress-test-recipe' }),+ }),+ })+ )+ expect(mockNetworkingApi.deleteNamespacedNetworkPolicy).not.toHaveBeenCalledWith(+ expect.objectContaining({ name: 'ui-egress-test-recipe' })+ )+ })+it('records the ui lane egress set with the exact enforced cidrs and ports', async () => {const cap = captureEgressRecords()try {