Repository: stateful/vscode-runme
Pull request #1412 (2024-06-06 22:33:07)

Rename "Runme Server" to "Kernel Server"
Make its role more clear.

sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=stateful_vscode-runme&pullRequest=1412) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [3 New issues](https://sonarcloud.io/project/issues?id=stateful_vscode-runme&pullRequest=1412&resolved=false&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=stateful_vscode-runme&pullRequest=1412&resolutions=WONTFIX)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=stateful_vscode-runme&pullRequest=1412&resolved=false&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [84.2% Coverage on New Code](https://sonarcloud.io/component_measures?id=stateful_vscode-runme&pullRequest=1412&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=stateful_vscode-runme&pullRequest=1412&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=stateful_vscode-runme&pullRequest=1412)



Patch:
diff --git a/package.json b/package.json
index 91b41007..ac8bbef7 100644
--- a/package.json
+++ b/package.json
@@ -589,18 +589,18 @@
           "runme.server.customAddress": {
             "type": "string",
             "scope": "window",
-            "markdownDescription": "Custom runme server address. This address will be used instead of launching the server at start. Use this only if you know what you are doing!"
+            "markdownDescription": "Custom kernel server address. This address will be used instead of launching the server at start. Use this only if you know what you are doing!"
           },
           "runme.server.binaryPath": {
             "type": "string",
             "scope": "window",
-            "markdownDescription": "Runme server path to binary. (It requires the GRPC interface enabled)"
+            "markdownDescription": "Kernel server path to binary. (It requires the GRPC interface enabled)"
           },
           "runme.server.enableLogger": {
             "type": "boolean",
             "scope": "machine",
             "default": false,
-            "markdownDescription": "Enable Runme server logs. (It requires the GRPC interface enabled)"
+            "markdownDescription": "Enable Kernel server logs. (It requires the GRPC interface enabled)"
           },
           "runme.server.tlsDir": {
             "type": "string",
diff --git a/src/extension/extension.ts b/src/extension/extension.ts
index 9c155176..69c92171 100644
--- a/src/extension/extension.ts
+++ b/src/extension/extension.ts
@@ -20,8 +20,8 @@ import {
 import { WebViews } from '../constants'
 
 import { Kernel } from './kernel'
-import RunmeServer from './server/runmeServer'
-import RunmeServerError from './server/runmeServerError'
+import KernelServer from './server/kernelServer'
+import KernelServerError from './server/kernelServerError'
 import {
   ToggleTerminalProvider,
   BackgroundTaskProvider,
@@ -86,7 +86,7 @@ export class RunmeExtension {
     const grpcRunner = kernel.hasExperimentEnabled('grpcRunner')
     const aiLogs = kernel.hasExperimentEnabled('aiLogs')
 
-    const server = new RunmeServer(
+    const server = new KernelServer(
       context.extensionUri,
       {
         retryOnFailure: true,
@@ -120,18 +120,18 @@ export class RunmeExtension {
     )
 
     /**
-     * Start the Runme server
+     * Start the Kernel server
      */
     try {
       await server.launch()
     } catch (e) {
       // Unrecoverable error happened
-      if (e instanceof RunmeServerError) {
+      if (e instanceof KernelServerError) {
         TelemetryReporter.sendTelemetryErrorEvent('extension.server', { data: e.message })
-        if (server.transportType === RunmeServer.transportTypeDefault) {
+        if (server.transportType === KernelServer.transportTypeDefault) {
           return window
             .showErrorMessage(
-              `Failed to start Runme server (reason: ${e.message}).` +
+              `Failed to start Kernel server (reason: ${e.message}).` +
                 ' Consider switching from TCP to Unix Domain Socket in Settings.',
               'Open Settings',
             )
@@ -143,7 +143,7 @@ export class RunmeExtension {
             })
         }
         return window
-          .showErrorMessage(`Failed to start Runme server. Reason: ${e.message}`)
+          .showErrorMessage(`Failed to start Kernel server. Reason: ${e.message}`)
           .then((action) => {
             if (!action) {
               return
@@ -152,7 +152,7 @@ export class RunmeExtension {
       }
       TelemetryReporter.sendTelemetryErrorEvent('extension.server', { data: (e as Error).message })
       return window.showErrorMessage(
-        'Failed to start Runme server, please try to reload the window. ' +
+        'Failed to start Kernel server, please try to reload the window. ' +
           `Reason: ${(e as any).message}`,
       )
     }
diff --git a/src/extension/provider/codelens.ts b/src/extension/provider/codelens.ts
index 0bcc6a0a..8c6f9ced 100644
--- a/src/extension/provider/codelens.ts
+++ b/src/extension/provider/codelens.ts
@@ -29,7 +29,7 @@ import { Serializer } from '../../types'
 import { getCodeLensEnabled, getCodeLensPasteIntoTerminalNewline } from '../../utils/configuration'
 import { RunmeExtension } from '../extension'
 import type { SurveyWinCodeLensRun } from '../survey'
-import IServer from '../server/runmeServer'
+import IServer from '../server/kernelServer'
 
 import { RunmeTaskProvider } from './runmeTask'
 
diff --git a/src/extension/provider/runmeTask.ts b/src/extension/provider/runmeTask.ts
index cb5501ea..817787a3 100644
--- a/src/extension/provider/runmeTask.ts
+++ b/src/extension/provider/runmeTask.ts
@@ -36,7 +36,7 @@ import type { IRunner, RunProgramExecution, RunProgramOptions } from '../runner'
 import { IRunnerEnvironment } from '../runner/environment'
 import { getCellCwd, getCellProgram, getNotebookSkipPromptEnvSetting } from '../executors/utils'
 import { Kernel } from '../kernel'
-import RunmeServer from '../server/runmeServer'
+import KernelServer from '../server/kernelServer'
 import { ProjectServiceClient, initProjectClient, type ReadyPromise } from '../grpc/client'
 import { LoadEventFoundTask, LoadRequest, LoadResponse } from '../grpc/projectTypes'
 import { RunmeIdentity } from '../grpc/serializerTypes'
@@ -78,7 +78,7 @@ export class RunmeTaskProvider implements TaskProvider {
     private treeView: RunmeLauncherProvider,
     private serializer: SerializerBase,
     private kernel: Kernel,
-    private server: RunmeServer,
+    private server: KernelServer,
     private runner?: IRunner,
   ) {
     this.serverReadyListener = this.server.onTransportReady(({ transport }) =>
diff --git a/src/extension/runner/client.ts b/src/extension/runner/client.ts
index 91340290..82707839 100644
--- a/src/extension/runner/client.ts
+++ b/src/extension/runner/client.ts
@@ -21,7 +21,7 @@ import {
 } from '../grpc/runner/types'
 import { UpdateSessionRequest, UpdateSessionResponse } from '../grpc/runner/v2alpha1'
 import { IRunnerServiceClient, getRunnerServiceClient } from '../grpc/client'
-import { IServer } from '../server/runmeServer'
+import { IServer } from '../server/kernelServer'
 
 import { IRunnerReady } from '.'
 
diff --git a/src/extension/runner/index.ts b/src/extension/runner/index.ts
index 710d5b3e..158d65e6 100644
--- a/src/extension/runner/index.ts
+++ b/src/extension/runner/index.ts
@@ -26,7 +26,7 @@ import { ExecuteDuplex } from '../grpc/runner/types'
 import { progconf } from '../grpc/runner/v2alpha1'
 import { IRunnerServiceClient, RpcError } from '../grpc/client'
 import { getSystemShellPath } from '../executors/utils'
-import { IServer } from '../server/runmeServer'
+import { IServer } from '../server/kernelServer'
 import { convertEnvList } from '../utils'
 import { getEnvWorkspaceFileOrder } from '../../utils/configuration'
 import getLogger from '../logger'
diff --git a/src/extension/serializer.ts b/src/extension/serializer.ts
index e2f85dc4..839f4dcf 100644
--- a/src/extension/serializer.ts
+++ b/src/extension/serializer.ts
@@ -51,7 +51,7 @@ import { initParserClient, ParserServiceClient, type ReadyPromise } from './grpc
 import Languages from './languages'
 import { PLATFORM_OS } from './constants'
 import { initWasm } from './utils'
-import { IServer } from './server/runmeServer'
+import { IServer } from './server/kernelServer'
 import { Kernel } from './kernel'
 import { getCellById } from './cell'
 import { IProcessInfoState } from './terminal/terminalState'
diff --git a/src/extension/server/runmeServer.ts b/src/extension/server/kernelServer.ts
similarity index 91%
rename from src/extension/server/runmeServer.ts
rename to src/extension/server/kernelServer.ts
index 726da800..6c307dd0 100644
--- a/src/extension/server/runmeServer.ts
+++ b/src/extension/server/kernelServer.ts
@@ -23,7 +23,7 @@ import {
 import { isPortAvailable } from '../utils'
 import { HealthClient } from '../grpc/client'
 
-import RunmeServerError from './runmeServerError'
+import KernelServerError from './kernelServerError'
 
 export interface IServerConfig {
   assignPortDynamically?: boolean
@@ -36,7 +36,7 @@ export interface IServerConfig {
   aiLogs?: boolean
 }
 
-const log = getLogger('RunmeServer')
+const log = getLogger('KernelServer')
 
 export interface IServer extends Disposable {
   transportType: ServerTransportType
@@ -51,7 +51,7 @@ export interface IServer extends Disposable {
   transport(): Promise<GrpcTransport>
 }
 
-class RunmeServer implements IServer {
+class KernelServer implements IServer {
   #port: number
   #socketId?: string
   #process: ChildProcessWithoutNullStreams | undefined
@@ -86,7 +86,7 @@ class RunmeServer implements IServer {
   ) {
     this.transportType = getServerConfigurationValue<ServerTransportType>(
       'transportType',
-      RunmeServer.transportTypeDefault,
+      KernelServer.transportTypeDefault,
     )
     this.#port = getPortNumber()
     this.#loggingEnabled = enableServerLogs()
@@ -141,7 +141,7 @@ class RunmeServer implements IServer {
       return customAddress
     }
 
-    if (this.transportType === RunmeServer.transportTypeDefault) {
+    if (this.transportType === KernelServer.transportTypeDefault) {
       const host = `${SERVER_ADDRESS}:${this.#port}`
       return host
     }
@@ -168,7 +168,7 @@ class RunmeServer implements IServer {
 
       return { certPEM, privKeyPEM }
     } catch (e: any) {
-      throw new RunmeServerError('Unable to read TLS files', e)
+      throw new KernelServerError('Unable to read TLS files', e)
     }
   }
 
@@ -181,7 +181,7 @@ class RunmeServer implements IServer {
       return ChannelCredentials.createInsecure()
     }
 
-    const { certPEM, privKeyPEM } = await RunmeServer.getTLS(this.getTLSDir())
+    const { certPEM, privKeyPEM } = await KernelServer.getTLS(this.getTLSDir())
 
     return ChannelCredentials.createSsl(certPEM, privKeyPEM, certPEM)
   }
@@ -220,7 +220,7 @@ class RunmeServer implements IServer {
     )
 
     if (!binaryExists || !isFile) {
-      throw new RunmeServerError('Cannot find server binary file')
+      throw new KernelServerError('Cannot find server binary file')
     }
 
     this.#port = getPortNumber()
@@ -293,7 +293,7 @@ class RunmeServer implements IServer {
               }
             }
           } catch (err: any) {
-            reject(new RunmeServerError(`Server failed, reason: ${(err as Error).message}`))
+            reject(new KernelServerError(`Server failed, reason: ${(err as Error).message}`))
           }
         }
 
@@ -329,7 +329,7 @@ class RunmeServer implements IServer {
     }
 
     const intervalSecs = ((iter * INTERVAL) / 1000).toFixed(1)
-    throw new RunmeServerError(`Server did not accept connections after ${intervalSecs}s`)
+    throw new KernelServerError(`Server did not accept connections after ${intervalSecs}s`)
   }
 
   /**
@@ -353,10 +353,10 @@ class RunmeServer implements IServer {
       addr = await this.start()
     } catch (e) {
       if (this.#retryOnFailure && this.#maxNumberOfIntents > intent) {
-        console.error(`Failed to start runme server, retrying. Error: ${(e as Error).message}`)
+        console.error(`Failed to start kernel server, retrying. Error: ${(e as Error).message}`)
         return this.launch(intent + 1)
       }
-      throw new RunmeServerError(`Cannot start server. Error: ${(e as Error).message}`)
+      throw new KernelServerError(`Cannot start server. Error: ${(e as Error).message}`)
     }
 
     await this.connect()
@@ -398,4 +398,4 @@ class RunmeServer implements IServer {
   }
 }
 
-export default RunmeServer
+export default KernelServer
diff --git a/src/extension/server/runmeServerError.ts b/src/extension/server/kernelServerError.ts
similarity index 56%
rename from src/extension/server/runmeServerError.ts
rename to src/extension/server/kernelServerError.ts
index 6aac696c..e9456dbc 100644
--- a/src/extension/server/runmeServerError.ts
+++ b/src/extension/server/kernelServerError.ts
@@ -1,11 +1,11 @@
-class RunmeServerError extends Error {
+class KernelServerError extends Error {
   constructor(message: string, err?: Error) {
     if (err) {
       message += `\nCaused by: ${err?.message}`
     }
     super(message)
-    this.name = 'RunmeServerError'
+    this.name = 'KernelServerError'
   }
 }
 
-export default RunmeServerError
+export default KernelServerError


Test patch:
diff --git a/tests/extension/commands/index.test.ts b/tests/extension/commands/index.test.ts
index ace0bcb0..616c4d15 100644
--- a/tests/extension/commands/index.test.ts
+++ b/tests/extension/commands/index.test.ts
@@ -66,7 +66,7 @@ vi.mock('../../../src/extension/provider/cli', () => ({
   },
 }))
 
-vi.mock('../../../src/extension/server/runmeServer.ts', () => ({
+vi.mock('../../../src/extension/server/kernelServer.ts', () => ({
   default: class {},
 }))
 
diff --git a/tests/extension/extension.test.ts b/tests/extension/extension.test.ts
index 0bd23e35..48e86ef7 100644
--- a/tests/extension/extension.test.ts
+++ b/tests/extension/extension.test.ts
@@ -5,7 +5,7 @@ import { HealthCheckResponse_ServingStatus } from '@buf/grpc_grpc.community_timo
 
 import { RunmeExtension } from '../../src/extension/extension'
 import { bootFile } from '../../src/extension/utils'
-import RunmeServer from '../../src/extension/server/runmeServer'
+import KernelServer from '../../src/extension/server/kernelServer'
 import { testCertPEM, testPrivKeyPEM } from '../testTLSCert'
 
 vi.mock('vscode')
@@ -80,7 +80,7 @@ test('initializes all providers', async () => {
   } as any)
   const dummyFilePath = Uri.file('/foo/bar')
   vi.mocked(Uri.joinPath).mockReturnValue(dummyFilePath)
-  RunmeServer['getTLS'] = vi
+  KernelServer['getTLS'] = vi
     .fn()
     .mockResolvedValue({ privKeyPEM: testPrivKeyPEM, certPEM: testCertPEM })
   const context: any = {
diff --git a/tests/extension/runner/runner.test.ts b/tests/extension/runner/runner.test.ts
index 9367b8a6..75943521 100644
--- a/tests/extension/runner/runner.test.ts
+++ b/tests/extension/runner/runner.test.ts
@@ -131,7 +131,7 @@ vi.mock('@buf/stateful_runme.community_timostamm-protobuf-ts/runme/runner/v1/run
   },
 }))
 
-class MockedRunmeServer {
+class MockedKernelServer {
   _onTransportReady = new EventEmitter<{ transport: GrpcTransport }>()
   _onClose = new EventEmitter<{ code: number | null }>()
 
@@ -789,7 +789,7 @@ function getMockedDuplex(session: GrpcRunnerProgramSession): MockedDuplexClientS
 }
 
 function createGrpcRunner(initialize = true) {
-  const server = new MockedRunmeServer()
+  const server = new MockedKernelServer()
   const runner = new GrpcRunner(server as any)
 
   if (initialize) {
@@ -800,7 +800,7 @@ function createGrpcRunner(initialize = true) {
 }
 
 function createGrpcRunnerClient(initialize = true) {
-  const server = new MockedRunmeServer()
+  const server = new MockedKernelServer()
   const client = new GrpcRunnerClient(server as any)
 
   if (initialize) {
diff --git a/tests/extension/server/runmeServer.test.ts b/tests/extension/server/kernelServer.test.ts
similarity index 93%
rename from tests/extension/server/runmeServer.test.ts
rename to tests/extension/server/kernelServer.test.ts
index 9b14748d..f790c920 100644
--- a/tests/extension/server/runmeServer.test.ts
+++ b/tests/extension/server/kernelServer.test.ts
@@ -9,8 +9,8 @@ import { HealthCheckResponse_ServingStatus } from '@buf/grpc_grpc.community_timo
 // eslint-disable-next-line import/order
 import { isPortAvailable } from '../../../src/extension/utils'
 
-import Server, { IServerConfig } from '../../../src/extension/server/runmeServer'
-import RunmeServerError from '../../../src/extension/server/runmeServerError'
+import Server, { IServerConfig } from '../../../src/extension/server/kernelServer'
+import KernelServerError from '../../../src/extension/server/kernelServerError'
 import { testCertPEM, testPrivKeyPEM } from '../../testTLSCert'
 
 const healthCheck = vi.fn()
@@ -85,7 +85,7 @@ suite('health check', () => {
   })
 })
 
-suite('Runme server spawn process', () => {
+suite('Kernel server spawn process', () => {
   const configValues: Record<string, any> = {
     binaryPath: 'bin/runme',
   }
@@ -166,7 +166,7 @@ suite('Runme server spawn process', () => {
     })
 
     const serverLaunchSpy = vi.spyOn(server, 'launch')
-    await expect(server.launch()).rejects.toBeInstanceOf(RunmeServerError)
+    await expect(server.launch()).rejects.toBeInstanceOf(KernelServerError)
     expect(serverLaunchSpy).toBeCalledTimes(3)
   })
 
@@ -185,13 +185,13 @@ suite('Runme server spawn process', () => {
 
     vi.mocked(isPortAvailable).mockResolvedValueOnce(false)
     const port = server['_port']()
-    await expect(server.launch()).rejects.toBeInstanceOf(RunmeServerError)
+    await expect(server.launch()).rejects.toBeInstanceOf(KernelServerError)
 
     expect(server['_port']()).toStrictEqual(port + 1)
   })
 })
 
-suite('Runme server accept connections', () => {
+suite('Kernel server accept connections', () => {
   let server: Server
   beforeEach(() => {
     server = createServer({
@@ -216,7 +216,7 @@ suite('Runme server accept connections', () => {
     ;(server as any).isRunning = vi.fn().mockResolvedValue(false)
 
     await expect(server.launch()).rejects.toThrowErrorMatchingInlineSnapshot(
-      `[RunmeServerError: Server did not accept connections after 0.2s]`,
+      `[KernelServerError: Server did not accept connections after 0.2s]`,
     )
   })
 })