@ship.zone/runner 3.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/.smartconfig.json +19 -1
  2. package/changelog.md +61 -0
  3. package/dist_rust/runnerworkspace_linux_amd64_musl +0 -0
  4. package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +4 -4
  5. package/dist_rust/runnerworkspace_linux_arm64_musl +0 -0
  6. package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +4 -4
  7. package/dist_ts/00_commitinfo_data.js +3 -3
  8. package/dist_ts/api-client.d.ts +2 -1
  9. package/dist_ts/api-client.js +10 -2
  10. package/dist_ts/artifact-manager.js +1 -1
  11. package/dist_ts/attempt-state.js +1 -1
  12. package/dist_ts/cache-manager.js +1 -1
  13. package/dist_ts/cli-entry.js +17 -3
  14. package/dist_ts/cli.d.ts +7 -0
  15. package/dist_ts/cli.js +155 -35
  16. package/dist_ts/config.js +75 -22
  17. package/dist_ts/egress-proxy.d.ts +99 -0
  18. package/dist_ts/egress-proxy.js +607 -0
  19. package/dist_ts/errors.js +1 -1
  20. package/dist_ts/filesystem.js +1 -1
  21. package/dist_ts/index.d.ts +5 -1
  22. package/dist_ts/index.js +6 -2
  23. package/dist_ts/interfaces.d.ts +85 -31
  24. package/dist_ts/interfaces.js +1 -1
  25. package/dist_ts/log-sender.js +1 -1
  26. package/dist_ts/microvm-executor.d.ts +90 -0
  27. package/dist_ts/microvm-executor.js +1078 -0
  28. package/dist_ts/node-version.d.ts +11 -0
  29. package/dist_ts/node-version.js +43 -0
  30. package/dist_ts/npm-grants.d.ts +9 -0
  31. package/dist_ts/npm-grants.js +44 -0
  32. package/dist_ts/oci-registry.d.ts +73 -0
  33. package/dist_ts/oci-registry.js +508 -0
  34. package/dist_ts/plugins.d.ts +6 -2
  35. package/dist_ts/plugins.js +7 -3
  36. package/dist_ts/protocol-validator.d.ts +3 -5
  37. package/dist_ts/protocol-validator.js +27 -51
  38. package/dist_ts/redactor.js +1 -1
  39. package/dist_ts/registration-state.js +1 -1
  40. package/dist_ts/runner.d.ts +5 -5
  41. package/dist_ts/runner.js +47 -22
  42. package/dist_ts/source-workspace.js +1 -1
  43. package/dist_ts/spec-version.js +1 -1
  44. package/dist_ts/staging-scavenger.js +1 -1
  45. package/dist_ts/state-owner.js +4 -2
  46. package/dist_ts/transfer-archive.js +1 -1
  47. package/dist_ts/validation.js +1 -1
  48. package/dist_ts/vsock-protocol.d.ts +130 -0
  49. package/dist_ts/vsock-protocol.js +336 -0
  50. package/dist_ts/wire-schema.js +1 -1
  51. package/package.json +19 -15
  52. package/readme.md +106 -108
  53. package/rust/Cargo.lock +1 -0
  54. package/rust/Cargo.toml +2 -1
  55. package/rust/src/cpio.rs +147 -0
  56. package/rust/src/extfs.rs +747 -0
  57. package/rust/src/guest.rs +2411 -0
  58. package/rust/src/lib.rs +41 -0
  59. package/rust/src/main.rs +6 -1
  60. package/rust/src/oci_tar.rs +842 -0
  61. package/ts/00_commitinfo_data.ts +2 -2
  62. package/ts/api-client.ts +19 -1
  63. package/ts/cli-entry.ts +15 -2
  64. package/ts/cli.ts +172 -40
  65. package/ts/config.ts +100 -25
  66. package/ts/egress-proxy.ts +649 -0
  67. package/ts/index.ts +5 -1
  68. package/ts/interfaces.ts +97 -30
  69. package/ts/microvm-executor.ts +1310 -0
  70. package/ts/node-version.ts +49 -0
  71. package/ts/npm-grants.ts +49 -0
  72. package/ts/oci-registry.ts +649 -0
  73. package/ts/plugins.ts +6 -2
  74. package/ts/protocol-validator.ts +29 -58
  75. package/ts/runner.ts +48 -21
  76. package/ts/state-owner.ts +8 -1
  77. package/ts/vsock-protocol.ts +437 -0
  78. package/dist_ts/oci-executor.d.ts +0 -155
  79. package/dist_ts/oci-executor.js +0 -2238
  80. package/ts/oci-executor.ts +0 -2989
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@ship.zone/runner',
6
- version: '3.0.0',
7
- description: 'The isolated OCI job runner for ship.zone CI/CD'
6
+ version: '5.0.0',
7
+ description: 'The Firecracker microVM OCI job runner for ship.zone CI/CD'
8
8
  }
package/ts/api-client.ts CHANGED
@@ -15,12 +15,14 @@ import type {
15
15
  ICompleteJobResponse,
16
16
  IDiscoveryResponse,
17
17
  IErrorResponse,
18
+ IImageRecord,
18
19
  IJobHeartbeatRequest,
19
20
  IJobHeartbeatResponse,
20
21
  IJobIdentity,
21
22
  IJobSource,
22
23
  ILogAcknowledgement,
23
24
  ILogChunk,
25
+ IRecordImageRequest,
24
26
  IRecoverAttemptRequest,
25
27
  IRegisterRunnerRequest,
26
28
  IRegisterRunnerResponse,
@@ -59,6 +61,7 @@ export interface IRunnerApiClientOptions {
59
61
 
60
62
  interface IJsonRequestOptions {
61
63
  requestSchema: TWireSchemaName;
64
+ method?: 'POST' | 'PUT';
62
65
  token?: string;
63
66
  signal?: AbortSignal;
64
67
  fenced?: boolean;
@@ -437,6 +440,21 @@ export class RunnerApiClient {
437
440
  );
438
441
  }
439
442
 
443
+ public async recordImage(
444
+ request: IRecordImageRequest,
445
+ signal?: AbortSignal,
446
+ ): Promise<IImageRecord> {
447
+ return validateWireMessage<IImageRecord>(
448
+ 'ImageRecord',
449
+ await this.requestJson(this.jobPath(request.identity, 'image'), request, {
450
+ method: 'PUT',
451
+ requestSchema: 'RecordImageRequest',
452
+ signal,
453
+ fenced: true,
454
+ }),
455
+ );
456
+ }
457
+
440
458
  public async completeJob(
441
459
  request: ICompleteJobRequest,
442
460
  signal?: AbortSignal,
@@ -632,7 +650,7 @@ export class RunnerApiClient {
632
650
  let response: Response;
633
651
  try {
634
652
  response = await this.fetchImplementation(new URL(path, this.baseUrl), {
635
- method: 'POST',
653
+ method: options.method ?? 'POST',
636
654
  headers: {
637
655
  authorization: `Bearer ${token}`,
638
656
  'content-type': 'application/json',
package/ts/cli-entry.ts CHANGED
@@ -1,4 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { runCli } from './cli.js';
2
+ import { assertSupportedNodeVersion } from './node-version.js';
3
3
 
4
- await runCli(process.argv.slice(2));
4
+ // The CLI's modules load only after the Node.js version check, so an unsupported release gets a
5
+ // clear refusal instead of a failure deep inside.
6
+ let supported = false;
7
+ try {
8
+ assertSupportedNodeVersion(process.versions.node);
9
+ supported = true;
10
+ } catch (error) {
11
+ console.error(error instanceof Error ? error.message : 'Runner failed');
12
+ process.exitCode = 1;
13
+ }
14
+ if (supported) {
15
+ const { runCli } = await import('./cli.js');
16
+ await runCli(process.argv.slice(2));
17
+ }
package/ts/cli.ts CHANGED
@@ -17,7 +17,7 @@ import type {
17
17
  IRunnerConfig,
18
18
  } from './interfaces.js';
19
19
  import { runnerVersion } from './interfaces.js';
20
- import { OciExecutor } from './oci-executor.js';
20
+ import { MicroVmExecutor } from './microvm-executor.js';
21
21
  import { RegistrationStateStore } from './registration-state.js';
22
22
  import { reconcileProtocolLimits, runnerCapabilities, ShipRunner } from './runner.js';
23
23
  import { runnerSpecVersion } from './spec-version.js';
@@ -26,15 +26,35 @@ import { RunnerStateOwner } from './state-owner.js';
26
26
 
27
27
  interface IParsedArguments {
28
28
  command: string;
29
- options: Map<string, string | true>;
29
+ options: Map<string, string[]>;
30
+ flags: Set<string>;
30
31
  }
31
32
 
32
33
  const cliInvocation = 'ship-zone-runner';
33
34
 
34
- const usage = `ship.zone runner ${runnerVersion}
35
+ const BOOLEAN_FLAGS = new Set<string>(['allow-insecure-loopback']);
36
+ const VALUE_OPTIONS = new Set<string>([
37
+ 'config',
38
+ 'control-plane',
39
+ 'name',
40
+ 'labels',
41
+ 'state-directory',
42
+ 'kernel-path',
43
+ 'builder-rootfs-path',
44
+ 'builder-image',
45
+ 'buildctl-path',
46
+ 'smartvm-socket',
47
+ 'smartvm-runtime-dir',
48
+ 'smartvm-bridge-path',
49
+ 'workspace-helper-path',
50
+ 'egress-blocked-cidr',
51
+ ]);
52
+
53
+ const usage = `ship.zone runner ${runnerVersion} (Firecracker microVM · ci-spec ${runnerSpecVersion})
35
54
 
36
55
  Usage:
37
- ${cliInvocation} init --control-plane <url> [--config <path>] [--name <name>]
56
+ ${cliInvocation} enroll --control-plane <url> [--config <path>] [--name <name>] [--labels <a,b>] [--kernel-path <path>] [--builder-rootfs-path <path> | --builder-image <ref@sha256:...>] [--smartvm-socket <path>]
57
+ ${cliInvocation} init --control-plane <url> [--config <path>] [--name <name>] [--labels <a,b>] [--kernel-path <path>] [--builder-rootfs-path <path> | --builder-image <ref@sha256:...>] [--smartvm-socket <path>]
38
58
  ${cliInvocation} register [--config <path>]
39
59
  ${cliInvocation} run [--config <path>]
40
60
  ${cliInvocation} once [--config <path>]
@@ -45,36 +65,88 @@ Bootstrap credentials must be supplied through SHIP_RUNNER_BOOTSTRAP_TOKEN or th
45
65
  0600 config file. Secret values are intentionally not accepted as command arguments.
46
66
  `;
47
67
 
48
- const parseArguments = (arguments_: string[]): IParsedArguments => {
68
+ export const parseArguments = (arguments_: string[]): IParsedArguments => {
49
69
  const normalizedArguments = arguments_[0] === '--' ? arguments_.slice(1) : arguments_;
50
70
  const [command = 'help', ...rest] = normalizedArguments;
51
- const options = new Map<string, string | true>();
71
+ const options = new Map<string, string[]>();
72
+ const flags = new Set<string>();
73
+
52
74
  for (let index = 0; index < rest.length; index++) {
53
75
  const entry = rest[index];
54
76
  if (!entry.startsWith('--')) throw new ConfigurationError(`Unexpected argument: ${entry}`);
55
- const name = entry.slice(2);
56
- const next = rest[index + 1];
57
- if (!next || next.startsWith('--')) options.set(name, true);
58
- else {
59
- options.set(name, next);
77
+ const eqIndex = entry.indexOf('=');
78
+ const name = eqIndex >= 0 ? entry.slice(2, eqIndex) : entry.slice(2);
79
+ const inlineValue = eqIndex >= 0 ? entry.slice(eqIndex + 1) : undefined;
80
+
81
+ if (BOOLEAN_FLAGS.has(name)) {
82
+ if (inlineValue !== undefined) {
83
+ throw new ConfigurationError(`--${name} does not accept a value`);
84
+ }
85
+ flags.add(name);
86
+ continue;
87
+ }
88
+
89
+ if (!VALUE_OPTIONS.has(name)) {
90
+ if (name === 'profile') {
91
+ throw new ConfigurationError(
92
+ '--profile was removed in 5.0.0; one unified microVM runner executes oci, vm, and oci-image jobs',
93
+ );
94
+ }
95
+ if (name === 'allow-egress' || name === 'allow-network') {
96
+ throw new ConfigurationError(
97
+ `--${name} is not supported yet; Firecracker guest egress transport is not wired`,
98
+ );
99
+ }
100
+ throw new ConfigurationError(`Unknown option: --${name}`);
101
+ }
102
+
103
+ let value: string | undefined;
104
+ if (inlineValue !== undefined) {
105
+ value = inlineValue;
106
+ } else {
107
+ const next = rest[index + 1];
108
+ if (!next || next.startsWith('--')) {
109
+ throw new ConfigurationError(`--${name} requires a value`);
110
+ }
111
+ value = next;
60
112
  index++;
61
113
  }
114
+ if (value.length === 0) {
115
+ throw new ConfigurationError(`--${name} requires a non-empty value`);
116
+ }
117
+ const existing = options.get(name);
118
+ if (existing) existing.push(value);
119
+ else options.set(name, [value]);
62
120
  }
63
- return { command, options };
121
+ return { command, options, flags };
64
122
  };
65
123
 
66
- const stringOption = (
67
- options: Map<string, string | true>,
124
+ const singleOption = (
125
+ options: Map<string, string[]>,
68
126
  name: string,
69
127
  ): string | undefined => {
70
- const value = options.get(name);
71
- if (value === undefined) return undefined;
72
- if (value === true) throw new ConfigurationError(`--${name} requires a value`);
73
- return value;
128
+ const values = options.get(name);
129
+ if (!values || values.length === 0) return undefined;
130
+ if (values.length > 1) {
131
+ throw new ConfigurationError(`--${name} may only be specified once`);
132
+ }
133
+ return values[0];
134
+ };
135
+
136
+ const listOption = (
137
+ options: Map<string, string[]>,
138
+ name: string,
139
+ ): string[] | undefined => {
140
+ const values = options.get(name);
141
+ if (!values || values.length === 0) return undefined;
142
+ return values
143
+ .flatMap((entry) => entry.split(','))
144
+ .map((entry) => entry.trim())
145
+ .filter(Boolean);
74
146
  };
75
147
 
76
- const configPath = (options: Map<string, string | true>): string =>
77
- stringOption(options, 'config') ?? process.env.SHIP_RUNNER_CONFIG ?? './runner.config.json';
148
+ const configPath = (options: Map<string, string[]>): string =>
149
+ singleOption(options, 'config') ?? process.env.SHIP_RUNNER_CONFIG ?? './runner.config.json';
78
150
 
79
151
  const apiFor = (config: IRunnerConfig): RunnerApiClient =>
80
152
  new RunnerApiClient({
@@ -119,38 +191,93 @@ export const registerRunnerDurably = async (options: {
119
191
  return registered;
120
192
  };
121
193
 
122
- const runInit = async (options: Map<string, string | true>): Promise<void> => {
194
+ const buildConfigFromOptions = (
195
+ options: Map<string, string[]>,
196
+ flags: Set<string>,
197
+ ): IRunnerConfig => {
123
198
  const config = defaultRunnerConfig();
124
- config.controlPlaneUrl = stringOption(options, 'control-plane') ?? '';
125
- config.name = stringOption(options, 'name') ?? config.name;
126
- const labels = stringOption(options, 'labels');
127
- if (labels) config.labels = labels.split(',').map((entry) => entry.trim()).filter(Boolean);
128
- const runtimePath = stringOption(options, 'runtime-path');
129
- if (runtimePath) config.oci.runtimePath = runtimePath;
130
- const helperPath = stringOption(options, 'workspace-helper-path');
199
+ config.controlPlaneUrl = singleOption(options, 'control-plane') ?? '';
200
+ config.name = singleOption(options, 'name') ?? config.name;
201
+ const stateDirectory = singleOption(options, 'state-directory');
202
+ if (stateDirectory) config.stateDirectory = stateDirectory;
203
+ const labels = listOption(options, 'labels');
204
+ if (labels) config.labels = labels;
205
+ const kernelPath = singleOption(options, 'kernel-path');
206
+ if (kernelPath) config.oci.kernelPath = kernelPath;
207
+ const builderRootfsPath = singleOption(options, 'builder-rootfs-path');
208
+ if (builderRootfsPath) config.oci.builderRootfsPath = builderRootfsPath;
209
+ const builderImage = singleOption(options, 'builder-image');
210
+ if (builderImage) config.oci.builderImage = builderImage;
211
+ const buildctlPath = singleOption(options, 'buildctl-path');
212
+ if (buildctlPath) config.oci.buildctlPath = buildctlPath;
213
+ const smartvmSocket = singleOption(options, 'smartvm-socket');
214
+ if (smartvmSocket) config.oci.smartvmSocketPath = smartvmSocket;
215
+ const smartvmRuntimeDir = singleOption(options, 'smartvm-runtime-dir');
216
+ if (smartvmRuntimeDir) config.oci.smartvmRuntimeDir = smartvmRuntimeDir;
217
+ const smartvmBridgePath = singleOption(options, 'smartvm-bridge-path');
218
+ if (smartvmBridgePath) config.oci.smartvmBridgePath = smartvmBridgePath;
219
+ const helperPath = singleOption(options, 'workspace-helper-path');
131
220
  if (helperPath) config.oci.workspaceHelperPath = helperPath;
132
- if (options.has('allow-insecure-loopback')) config.allowInsecureLoopback = true;
133
- if (options.has('allow-network')) {
134
- throw new ConfigurationError(
135
- '--allow-network is not supported: this runner does not enforce egress allowlists',
136
- );
137
- }
221
+ if (flags.has('allow-insecure-loopback')) config.allowInsecureLoopback = true;
222
+ const blockedCidrs = listOption(options, 'egress-blocked-cidr');
223
+ if (blockedCidrs) config.oci.egressBlockedCidrs = blockedCidrs;
138
224
  validateRunnerConfig(config);
225
+ return config;
226
+ };
227
+
228
+ const runInit = async (
229
+ options: Map<string, string[]>,
230
+ flags: Set<string>,
231
+ ): Promise<void> => {
232
+ const config = buildConfigFromOptions(options, flags);
139
233
  const path = configPath(options);
140
234
  await saveRunnerConfig(path, config);
141
235
  console.log(`Created ${path}`);
142
236
  };
143
237
 
144
- const runRegister = async (options: Map<string, string | true>): Promise<void> => {
238
+ const runEnroll = async (
239
+ options: Map<string, string[]>,
240
+ flags: Set<string>,
241
+ ): Promise<void> => {
242
+ const bootstrapToken = process.env.SHIP_RUNNER_BOOTSTRAP_TOKEN?.trim();
243
+ if (!bootstrapToken) {
244
+ throw new ConfigurationError('SHIP_RUNNER_BOOTSTRAP_TOKEN is required for enrollment');
245
+ }
246
+ const config = buildConfigFromOptions(options, flags);
247
+ config.bootstrapToken = bootstrapToken;
248
+ const path = configPath(options);
249
+ const stateOwner = await acquireStateOwner(config);
250
+ const executor = new MicroVmExecutor(config, stateOwner);
251
+ try {
252
+ const api = apiFor(config);
253
+ const runtime = await executor.verifyRuntime();
254
+ const discovery = await api.discover();
255
+ const capabilities = runnerCapabilities(config, runtime);
256
+ reconcileProtocolLimits(config, discovery, capabilities);
257
+ const registered = await registerRunnerDurably({
258
+ configPath: path,
259
+ config,
260
+ capabilities,
261
+ api,
262
+ stateStore: new RegistrationStateStore(stateOwner),
263
+ });
264
+ console.log(`Enrolled runner ${registered.runnerId} (${path})`);
265
+ } finally {
266
+ await executor.close().catch(() => {});
267
+ await stateOwner.release();
268
+ }
269
+ };
270
+
271
+ const runRegister = async (options: Map<string, string[]>): Promise<void> => {
145
272
  const path = configPath(options);
146
273
  const config = await loadRunnerConfig(path);
147
274
  if (!config.bootstrapToken) {
148
275
  throw new ConfigurationError('SHIP_RUNNER_BOOTSTRAP_TOKEN is required for registration');
149
276
  }
150
277
  const stateOwner = await acquireStateOwner(config);
278
+ const executor = new MicroVmExecutor(config, stateOwner);
151
279
  try {
152
280
  const api = apiFor(config);
153
- const executor = new OciExecutor(config, stateOwner);
154
281
  const runtime = await executor.verifyRuntime();
155
282
  const discovery = await api.discover();
156
283
  const capabilities = runnerCapabilities(config, runtime);
@@ -164,6 +291,7 @@ const runRegister = async (options: Map<string, string | true>): Promise<void> =
164
291
  });
165
292
  console.log(`Registered runner ${registered.runnerId}`);
166
293
  } finally {
294
+ await executor.close().catch(() => {});
167
295
  await stateOwner.release();
168
296
  }
169
297
  };
@@ -178,7 +306,7 @@ const acquireStateOwner = async (config: IRunnerConfig): Promise<RunnerStateOwne
178
306
  });
179
307
 
180
308
  const runDaemon = async (
181
- options: Map<string, string | true>,
309
+ options: Map<string, string[]>,
182
310
  once: boolean,
183
311
  ): Promise<void> => {
184
312
  const path = configPath(options);
@@ -188,9 +316,9 @@ const runDaemon = async (
188
316
  const shutdownListener = (): void => shutdown.abort('runner_shutdown');
189
317
  const signals = ['SIGINT', 'SIGTERM'] as const;
190
318
  for (const signal of signals) process.on(signal, shutdownListener);
319
+ const executor = new MicroVmExecutor(config, stateOwner);
191
320
  try {
192
321
  const api = apiFor(config);
193
- const executor = new OciExecutor(config, stateOwner);
194
322
  const reportMessage = (message: string): void => console.error(message);
195
323
  const runner = new ShipRunner(config, {
196
324
  stateOwner,
@@ -210,16 +338,20 @@ const runDaemon = async (
210
338
  if (once) console.log(result.claimed ? `Job ${result.status}` : 'No job available');
211
339
  } finally {
212
340
  for (const signal of signals) process.off(signal, shutdownListener);
341
+ await executor.close().catch(() => {});
213
342
  await stateOwner.release();
214
343
  }
215
344
  };
216
345
 
217
346
  export const runCli = async (arguments_: string[]): Promise<void> => {
218
347
  try {
219
- const { command, options } = parseArguments(arguments_);
348
+ const { command, options, flags } = parseArguments(arguments_);
220
349
  switch (command) {
350
+ case 'enroll':
351
+ await runEnroll(options, flags);
352
+ break;
221
353
  case 'init':
222
- await runInit(options);
354
+ await runInit(options, flags);
223
355
  break;
224
356
  case 'register':
225
357
  await runRegister(options);
package/ts/config.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as plugins from './plugins.js';
2
+ import { parseCidr } from './egress-proxy.js';
2
3
  import { ConfigurationError } from './errors.js';
3
4
  import {
4
5
  createNewWriteFlags,
@@ -9,6 +10,7 @@ import {
9
10
  writeAll,
10
11
  } from './filesystem.js';
11
12
  import type { IOciExecutorConfig, IRunnerConfig, IRunnerCredential } from './interfaces.js';
13
+ import { parseDigestPinnedImageReference } from './oci-registry.js';
12
14
  import { isRecord, validateHttpUrl } from './validation.js';
13
15
 
14
16
  const { dirname, isAbsolute, join } = plugins.path;
@@ -30,9 +32,11 @@ const timestampPattern =
30
32
  /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/;
31
33
 
32
34
  const defaultOciConfig: IOciExecutorConfig = {
33
- runtime: 'docker',
34
- runtimePath: '/usr/bin/docker',
35
- requireRootless: true,
35
+ kernelPath: '/var/lib/ship-zone-runner/vmlinux',
36
+ bootArgs: 'console=ttyS0 reboot=k panic=1 pci=off rdinit=/init',
37
+ maximumRootfsBytes: 4 * 1024 * 1024 * 1024,
38
+ guestMemoryOverheadBytes: 128 * 1024 * 1024,
39
+ egressBlockedCidrs: [],
36
40
  allowedNetworks: ['none'],
37
41
  containerUser: '65532:65532',
38
42
  defaultTimeoutMs: 30 * 60 * 1000,
@@ -53,8 +57,8 @@ const defaultOciConfig: IOciExecutorConfig = {
53
57
  export const defaultRunnerConfig = (): IRunnerConfig => ({
54
58
  controlPlaneUrl: '',
55
59
  allowInsecureLoopback: false,
56
- name: `runner-${process.env.HOSTNAME ?? 'local'}`,
57
- labels: ['linux', hostArchitectureLabel(), 'oci'],
60
+ name: `runner-${plugins.os.hostname() || 'local'}`,
61
+ labels: ['linux', hostArchitectureLabel(), 'microvm'],
58
62
  stateDirectory: './.runner-state',
59
63
  transferStagingReserveBytes: 1024 * 1024 * 1024,
60
64
  transferStagingReserveInodes: 10_000,
@@ -182,28 +186,49 @@ const validTimestamp = (value: string): boolean => {
182
186
  };
183
187
 
184
188
  /**
185
- * The OCI executor enforces only the `none` network mode: every step container gets a new network
186
- * namespace with loopback only. `egress` needs a runner-provided resolver and per-attempt
187
- * connection filtering that this executor does not implement, so it can be neither configured nor
188
- * advertised.
189
+ * Network modes enforceable by the Firecracker microVM runner:
190
+ * - `none`: isolated guest namespace with loopback only.
191
+ * Host-enforced `egress` guest transport is not yet wired into Firecracker/smartvm, so
192
+ * advertising `egress` is rejected fail-closed instead of silently running egress jobs offline.
189
193
  */
190
194
  const requireEnforceableNetworks = (networks: readonly string[]): void => {
191
195
  if (networks.length !== 1 || networks[0] !== 'none') {
192
196
  throw new ConfigurationError(
193
- 'oci.allowedNetworks must be ["none"]: this runner does not enforce egress allowlists',
197
+ 'oci.allowedNetworks must be ["none"]; Firecracker guest egress transport is not yet wired',
194
198
  );
195
199
  }
196
200
  };
197
201
 
202
+ const parseBlockedCidrs = (value: unknown, fallback: string[]): string[] => {
203
+ if (value === undefined) return [...fallback];
204
+ if (!Array.isArray(value) || value.length > 64 || value.some((entry) => typeof entry !== 'string')) {
205
+ throw new ConfigurationError('oci.egressBlockedCidrs must be an array of at most 64 CIDR strings');
206
+ }
207
+ for (const cidr of value) {
208
+ try {
209
+ parseCidr(cidr);
210
+ } catch {
211
+ throw new ConfigurationError(`oci.egressBlockedCidrs contains invalid CIDR: ${cidr}`);
212
+ }
213
+ }
214
+ return [...value];
215
+ };
216
+
198
217
  const parseOciConfig = (input: unknown, fallback: IOciExecutorConfig): IOciExecutorConfig => {
199
218
  const value = input === undefined ? {} : input;
200
219
  if (!isRecord(value)) throw new ConfigurationError('oci must be an object');
201
220
  if (Object.hasOwn(value, 'allowMutableImages')) {
202
221
  throw new ConfigurationError('oci.allowMutableImages is not supported by the runner protocol');
203
222
  }
204
- const runtime = value.runtime ?? fallback.runtime;
205
- if (runtime !== 'docker' && runtime !== 'podman') {
206
- throw new ConfigurationError('oci.runtime must be docker or podman');
223
+ if (Object.hasOwn(value, 'runtime') || Object.hasOwn(value, 'runtimePath')) {
224
+ throw new ConfigurationError(
225
+ 'oci.runtime and oci.runtimePath were removed in 4.0.0; this runner uses Firecracker microVMs exclusively',
226
+ );
227
+ }
228
+ if (Object.hasOwn(value, 'runnerProfile')) {
229
+ throw new ConfigurationError(
230
+ 'oci.runnerProfile was removed in 5.0.0; one unified microVM runner executes oci, vm, and oci-image jobs',
231
+ );
207
232
  }
208
233
  const allowedNetworks = stringArray(
209
234
  value.allowedNetworks,
@@ -213,14 +238,30 @@ const parseOciConfig = (input: unknown, fallback: IOciExecutorConfig): IOciExecu
213
238
  );
214
239
  requireEnforceableNetworks(allowedNetworks);
215
240
  return {
216
- runtime,
217
- runtimePath: stringValue(value.runtimePath, fallback.runtimePath, 'oci.runtimePath'),
218
- workspaceHelperPath: optionalString(value.workspaceHelperPath, 'oci.workspaceHelperPath'),
219
- requireRootless: booleanValue(
220
- value.requireRootless,
221
- fallback.requireRootless,
222
- 'oci.requireRootless',
241
+ kernelPath: stringValue(value.kernelPath, fallback.kernelPath, 'oci.kernelPath'),
242
+ builderRootfsPath: optionalString(value.builderRootfsPath, 'oci.builderRootfsPath'),
243
+ builderImage: optionalString(value.builderImage, 'oci.builderImage'),
244
+ buildctlPath: optionalString(value.buildctlPath, 'oci.buildctlPath'),
245
+ smartvmSocketPath: optionalString(value.smartvmSocketPath, 'oci.smartvmSocketPath'),
246
+ smartvmRuntimeDir: optionalString(value.smartvmRuntimeDir, 'oci.smartvmRuntimeDir'),
247
+ smartvmBridgePath: optionalString(value.smartvmBridgePath, 'oci.smartvmBridgePath'),
248
+ bootArgs: stringValue(value.bootArgs, fallback.bootArgs, 'oci.bootArgs', 1024),
249
+ maximumRootfsBytes: integerValue(
250
+ value.maximumRootfsBytes,
251
+ fallback.maximumRootfsBytes,
252
+ 'oci.maximumRootfsBytes',
253
+ 16_777_216,
254
+ 1_099_511_627_776,
223
255
  ),
256
+ guestMemoryOverheadBytes: integerValue(
257
+ value.guestMemoryOverheadBytes,
258
+ fallback.guestMemoryOverheadBytes,
259
+ 'oci.guestMemoryOverheadBytes',
260
+ 16_777_216,
261
+ 1_073_741_824,
262
+ ),
263
+ egressBlockedCidrs: parseBlockedCidrs(value.egressBlockedCidrs, fallback.egressBlockedCidrs),
264
+ workspaceHelperPath: optionalString(value.workspaceHelperPath, 'oci.workspaceHelperPath'),
224
265
  allowedNetworks: allowedNetworks as IOciExecutorConfig['allowedNetworks'],
225
266
  containerUser: stringValue(value.containerUser, fallback.containerUser, 'oci.containerUser'),
226
267
  defaultTimeoutMs: integerValue(
@@ -627,16 +668,50 @@ export const validateRunnerConfig = (config: IRunnerConfig): void => {
627
668
  }
628
669
  numberValue(config.oci.defaultCpus, config.oci.defaultCpus, 'oci.defaultCpus', 0, 1024);
629
670
  numberValue(config.oci.maximumCpus, config.oci.maximumCpus, 'oci.maximumCpus', 0, 1024);
630
- if (config.oci.runtime !== 'docker' && config.oci.runtime !== 'podman') {
631
- throw new ConfigurationError('oci.runtime must be docker or podman');
632
- }
633
671
  requireEnforceableNetworks(config.oci.allowedNetworks);
634
- if (!isAbsolute(config.oci.runtimePath)) {
635
- throw new ConfigurationError('oci.runtimePath must be absolute');
672
+ parseBlockedCidrs(config.oci.egressBlockedCidrs, []);
673
+ if (!isAbsolute(config.oci.kernelPath)) {
674
+ throw new ConfigurationError('oci.kernelPath must be absolute');
675
+ }
676
+ if (config.oci.builderRootfsPath && !isAbsolute(config.oci.builderRootfsPath)) {
677
+ throw new ConfigurationError('oci.builderRootfsPath must be absolute');
678
+ }
679
+ if (config.oci.builderImage) {
680
+ try {
681
+ parseDigestPinnedImageReference(config.oci.builderImage);
682
+ } catch {
683
+ throw new ConfigurationError('oci.builderImage must be a digest-pinned OCI image reference');
684
+ }
685
+ }
686
+ if (config.oci.buildctlPath && !isAbsolute(config.oci.buildctlPath)) {
687
+ throw new ConfigurationError('oci.buildctlPath must be absolute');
688
+ }
689
+ if (config.oci.smartvmSocketPath && !isAbsolute(config.oci.smartvmSocketPath)) {
690
+ throw new ConfigurationError('oci.smartvmSocketPath must be absolute');
691
+ }
692
+ if (config.oci.smartvmRuntimeDir && !isAbsolute(config.oci.smartvmRuntimeDir)) {
693
+ throw new ConfigurationError('oci.smartvmRuntimeDir must be absolute');
694
+ }
695
+ if (config.oci.smartvmBridgePath && !isAbsolute(config.oci.smartvmBridgePath)) {
696
+ throw new ConfigurationError('oci.smartvmBridgePath must be absolute');
636
697
  }
637
698
  if (config.oci.workspaceHelperPath && !isAbsolute(config.oci.workspaceHelperPath)) {
638
699
  throw new ConfigurationError('oci.workspaceHelperPath must be absolute');
639
700
  }
701
+ integerValue(
702
+ config.oci.maximumRootfsBytes,
703
+ config.oci.maximumRootfsBytes,
704
+ 'oci.maximumRootfsBytes',
705
+ 16_777_216,
706
+ 1_099_511_627_776,
707
+ );
708
+ integerValue(
709
+ config.oci.guestMemoryOverheadBytes,
710
+ config.oci.guestMemoryOverheadBytes,
711
+ 'oci.guestMemoryOverheadBytes',
712
+ 16_777_216,
713
+ 1_073_741_824,
714
+ );
640
715
  const user = /^([1-9][0-9]*)(?::([1-9][0-9]*))?$/.exec(config.oci.containerUser);
641
716
  if (!user || [user[1], user[2] ?? user[1]].some((entry) => Number(entry) > 4_294_967_294)) {
642
717
  throw new ConfigurationError('oci.containerUser must be a numeric non-root UID[:GID]');