@ship.zone/runner 3.0.0 → 4.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 (79) hide show
  1. package/.smartconfig.json +19 -1
  2. package/changelog.md +43 -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.js +39 -11
  15. package/dist_ts/config.js +70 -20
  16. package/dist_ts/egress-proxy.d.ts +99 -0
  17. package/dist_ts/egress-proxy.js +607 -0
  18. package/dist_ts/errors.js +1 -1
  19. package/dist_ts/filesystem.js +1 -1
  20. package/dist_ts/index.d.ts +5 -1
  21. package/dist_ts/index.js +6 -2
  22. package/dist_ts/interfaces.d.ts +93 -22
  23. package/dist_ts/interfaces.js +1 -1
  24. package/dist_ts/log-sender.js +1 -1
  25. package/dist_ts/microvm-executor.d.ts +90 -0
  26. package/dist_ts/microvm-executor.js +1045 -0
  27. package/dist_ts/node-version.d.ts +11 -0
  28. package/dist_ts/node-version.js +43 -0
  29. package/dist_ts/npm-grants.d.ts +9 -0
  30. package/dist_ts/npm-grants.js +44 -0
  31. package/dist_ts/oci-registry.d.ts +73 -0
  32. package/dist_ts/oci-registry.js +508 -0
  33. package/dist_ts/plugins.d.ts +6 -2
  34. package/dist_ts/plugins.js +7 -3
  35. package/dist_ts/protocol-validator.d.ts +3 -3
  36. package/dist_ts/protocol-validator.js +26 -21
  37. package/dist_ts/redactor.js +1 -1
  38. package/dist_ts/registration-state.js +1 -1
  39. package/dist_ts/runner.d.ts +6 -5
  40. package/dist_ts/runner.js +48 -18
  41. package/dist_ts/source-workspace.js +1 -1
  42. package/dist_ts/spec-version.js +1 -1
  43. package/dist_ts/staging-scavenger.js +1 -1
  44. package/dist_ts/state-owner.js +4 -2
  45. package/dist_ts/transfer-archive.js +1 -1
  46. package/dist_ts/validation.js +1 -1
  47. package/dist_ts/vsock-protocol.d.ts +130 -0
  48. package/dist_ts/vsock-protocol.js +336 -0
  49. package/dist_ts/wire-schema.js +1 -1
  50. package/package.json +9 -6
  51. package/readme.md +72 -61
  52. package/rust/Cargo.lock +1 -0
  53. package/rust/Cargo.toml +2 -1
  54. package/rust/src/cpio.rs +147 -0
  55. package/rust/src/extfs.rs +747 -0
  56. package/rust/src/guest.rs +2411 -0
  57. package/rust/src/lib.rs +41 -0
  58. package/rust/src/main.rs +6 -1
  59. package/rust/src/oci_tar.rs +842 -0
  60. package/ts/00_commitinfo_data.ts +2 -2
  61. package/ts/api-client.ts +19 -1
  62. package/ts/cli-entry.ts +15 -2
  63. package/ts/cli.ts +33 -11
  64. package/ts/config.ts +96 -23
  65. package/ts/egress-proxy.ts +649 -0
  66. package/ts/index.ts +5 -1
  67. package/ts/interfaces.ts +103 -21
  68. package/ts/microvm-executor.ts +1265 -0
  69. package/ts/node-version.ts +49 -0
  70. package/ts/npm-grants.ts +49 -0
  71. package/ts/oci-registry.ts +649 -0
  72. package/ts/plugins.ts +6 -2
  73. package/ts/protocol-validator.ts +29 -25
  74. package/ts/runner.ts +51 -17
  75. package/ts/state-owner.ts +8 -1
  76. package/ts/vsock-protocol.ts +437 -0
  77. package/dist_ts/oci-executor.d.ts +0 -155
  78. package/dist_ts/oci-executor.js +0 -2238
  79. package/ts/oci-executor.ts +0 -2989
package/ts/interfaces.ts CHANGED
@@ -3,12 +3,12 @@ import { commitinfo } from './00_commitinfo_data.js';
3
3
  export const runnerVersion: string = commitinfo.version;
4
4
 
5
5
  export type TExecutionProfile = 'oci' | 'oci-image' | 'vm';
6
+ export type TRunnerRole = 'workload' | 'builder';
6
7
  export type TIsolation = 'container' | 'microvm';
7
8
  export type TRunnerFeature = 'source.tar-gz' | 'artifacts' | 'caches';
8
9
  export type TLeaseFeature = 'image-pull-grants' | 'candidate-bindings' | 'npm-read-grants';
9
10
  export type TNetworkMode = 'none' | 'egress';
10
11
  export type TSourceFormat = 'tar.gz';
11
- export type TOciRuntime = 'docker' | 'podman';
12
12
  export type TArtifactPermission = 'none' | 'write';
13
13
  export type TCachePermission = 'none' | 'read' | 'read-write';
14
14
  export type TImagePermission = 'none' | 'push';
@@ -192,13 +192,11 @@ export interface IJobLease {
192
192
  }
193
193
 
194
194
  /**
195
- * A lease this runner executes: an `oci` job in `container` isolation with a digest-pinned image,
196
- * no image grants or bindings, and no npm grants.
195
+ * A lease this runner executes in Firecracker `microvm` isolation (`oci`, `vm`, or `oci-image`),
196
+ * including optional attempt-scoped image grants, candidate bindings, and npm read grants.
197
197
  */
198
- export interface IOciJobLease extends Omit<IJobLease, 'job' | 'grants' | 'bindings' | 'npmGrants'> {
199
- job: IOciRunnerJob;
200
- grants: [];
201
- bindings: [];
198
+ export interface IOciJobLease extends Omit<IJobLease, 'job'> {
199
+ job: TExecutableRunnerJob;
202
200
  }
203
201
 
204
202
  export interface IJobIdentity {
@@ -278,6 +276,32 @@ export interface IRecoverAttemptRequest {
278
276
  reason: 'runner_restarted';
279
277
  }
280
278
 
279
+ export interface IRecordImageRequest {
280
+ recordRequestId: string;
281
+ identity: IJobIdentity;
282
+ manifestDigest: string;
283
+ mediaType: 'application/vnd.oci.image.manifest.v1+json';
284
+ sizeBytes: number;
285
+ platform: string;
286
+ }
287
+
288
+ export interface IImageRecord {
289
+ registry: string;
290
+ repository: string;
291
+ manifestDigest: string;
292
+ mediaType: 'application/vnd.oci.image.manifest.v1+json';
293
+ sizeBytes: number;
294
+ platform: string;
295
+ createdAt: string;
296
+ }
297
+
298
+ export interface IProducedImageManifest {
299
+ readonly manifestDigest: string;
300
+ readonly mediaType: 'application/vnd.oci.image.manifest.v1+json';
301
+ readonly sizeBytes: number;
302
+ readonly platform: string;
303
+ }
304
+
281
305
  export interface ITransferRecord {
282
306
  name: string;
283
307
  format: 'tar.gz';
@@ -456,13 +480,31 @@ export interface IImageBuildRunnerJob extends ICompiledRunnerJobBase {
456
480
  /** Every compiled job shape the published runner job schema admits. */
457
481
  export type TCompiledRunnerJob = IContainerRunnerJob | IVmRunnerJob | IImageBuildRunnerJob;
458
482
 
459
- /** An `oci` job this runner executes: container isolation, no network, a digest-pinned image. */
483
+ /** An `oci` job this runner executes in Firecracker `microvm` isolation. */
460
484
  export interface IOciRunnerJob extends IContainerRunnerJob {
461
- requirements: IJobRequirements & { executionProfile: 'oci'; isolation: 'container' };
462
- network: INoNetwork;
463
- execution: IOciExecution & { image: string };
485
+ requirements: IJobRequirements & { executionProfile: 'oci'; isolation: 'microvm' };
486
+ }
487
+
488
+ /** A `vm` job this runner executes in Firecracker `microvm` isolation. */
489
+ export interface IVmExecutableRunnerJob extends IVmRunnerJob {
490
+ requirements: IJobRequirements & { executionProfile: 'vm'; isolation: 'microvm'; platform: string };
491
+ }
492
+
493
+ /** An `oci-image` job this runner executes in a dedicated builder Firecracker microVM. */
494
+ export interface IImageBuildExecutableRunnerJob extends IImageBuildRunnerJob {
495
+ requirements: IJobRequirements & {
496
+ executionProfile: 'oci-image';
497
+ isolation: 'microvm';
498
+ platform: string;
499
+ };
464
500
  }
465
501
 
502
+ /** Every compiled job shape this Firecracker runner can execute across workload and builder roles. */
503
+ export type TExecutableRunnerJob =
504
+ | IOciRunnerJob
505
+ | IVmExecutableRunnerJob
506
+ | IImageBuildExecutableRunnerJob;
507
+
466
508
  export interface ITransferMetadata {
467
509
  sha256: string;
468
510
  sizeBytes: number;
@@ -519,10 +561,33 @@ export type TOciArchitecture = 'amd64' | 'arm64';
519
561
  export type TOciHelperTarget = 'linux_amd64' | 'linux_arm64';
520
562
 
521
563
  export interface IOciExecutorConfig {
522
- runtime: TOciRuntime;
523
- runtimePath: string;
564
+ /**
565
+ * Dedicated runner role per `@ship.zone/ci-spec`:
566
+ * - `'workload'`: executes `oci` and `vm` jobs (never `oci-image`).
567
+ * - `'builder'`: executes `oci-image` container builds exclusively (never `oci` or `vm`).
568
+ */
569
+ runnerProfile: TRunnerRole;
570
+ /** Pinned Linux vmlinux kernel path for Firecracker microVMs. */
571
+ kernelPath: string;
572
+ /** Pinned ext2 guest rootfs containing rootless BuildKit (`buildkitd` + `buildctl`) for `builder` runners. */
573
+ builderRootfsPath?: string;
574
+ /** Optional override for the `buildctl` binary path inside the builder guest. */
575
+ buildctlPath?: string;
576
+ /** Optional smartvm-helper Unix socket path (defaults to `/run/smartvm/helper.sock`). */
577
+ smartvmSocketPath?: string;
578
+ /** Optional smartvm-bridge runtime directory for vsock relay sockets. */
579
+ smartvmRuntimeDir?: string;
580
+ /** Optional explicit path to the smartvm-bridge binary. */
581
+ smartvmBridgePath?: string;
582
+ /** Kernel boot arguments passed to Firecracker. */
583
+ bootArgs: string;
584
+ /** Maximum extracted OCI rootfs image bytes accepted during image materialization. */
585
+ maximumRootfsBytes: number;
586
+ /** Guest memory headroom reserved for the guest kernel and init agent on top of step memory. */
587
+ guestMemoryOverheadBytes: number;
588
+ /** Extra internal CIDRs blocked by the host egress proxy (e.g. coordinator network ranges). */
589
+ egressBlockedCidrs: string[];
524
590
  workspaceHelperPath?: string;
525
- requireRootless: boolean;
526
591
  allowedNetworks: TNetworkMode[];
527
592
  containerUser: string;
528
593
  defaultTimeoutMs: number;
@@ -583,16 +648,24 @@ export interface IExecutionContext {
583
648
  onLog: (stream: 'stdout' | 'stderr', data: string) => Promise<void>;
584
649
  }
585
650
 
651
+ export interface IMicroVmShapeInfo {
652
+ readonly id: string;
653
+ readonly vcpus: number;
654
+ readonly memMib: number;
655
+ }
656
+
586
657
  export interface IOciRuntimeFacts {
587
- readonly runtime: TOciRuntime;
658
+ readonly engine: 'firecracker';
659
+ readonly firecrackerVersion: string;
588
660
  readonly endpoint: string;
589
- readonly rootless: boolean;
590
661
  readonly os: 'linux';
591
662
  readonly architecture: TOciArchitecture;
592
663
  readonly helperTarget: TOciHelperTarget;
593
664
  readonly helperPath: string;
594
665
  readonly helperSha256: string;
595
- readonly workspaceBlockSize: number;
666
+ readonly initrdPath: string;
667
+ readonly kernelPath: string;
668
+ readonly shapes: readonly IMicroVmShapeInfo[];
596
669
  }
597
670
 
598
671
  export interface IPrepareOciLeaseContext {
@@ -607,6 +680,11 @@ export interface IPreparedOciLease {
607
680
  readonly attemptId: string;
608
681
  readonly image: string;
609
682
  readonly imageArchitecture: TOciArchitecture;
683
+ readonly rootfsPath?: string;
684
+ readonly imageDigest?: string;
685
+ readonly shapeId?: string;
686
+ readonly defaultEnv?: Record<string, string>;
687
+ readonly defaultWorkingDir?: string;
610
688
  cleanup(): Promise<void>;
611
689
  }
612
690
 
@@ -636,6 +714,7 @@ export interface IRuntimeWorkspaceExporter {
636
714
  export interface IExecutionResult {
637
715
  exitCode: number | null;
638
716
  stopReason?: TExecutionStopReason;
717
+ producedImage?: IProducedImageManifest;
639
718
  workspace?: IRuntimeWorkspaceExporter;
640
719
  }
641
720
 
@@ -655,7 +734,7 @@ export interface IPreparedWorkspace {
655
734
 
656
735
  export interface ISourcePrepareContext {
657
736
  identity: IJobIdentity;
658
- job: Pick<IOciRunnerJob, 'source' | 'permissions' | 'requirements'>;
737
+ job: Pick<TExecutableRunnerJob, 'source' | 'permissions' | 'requirements'>;
659
738
  signal: AbortSignal;
660
739
  }
661
740
 
@@ -679,7 +758,7 @@ export interface ISecretRedactionSet {
679
758
 
680
759
  export interface IArtifactUploadContext {
681
760
  workspace: IRuntimeWorkspaceExporter;
682
- job: Pick<IOciRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
761
+ job: Pick<IOciRunnerJob | IVmExecutableRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
683
762
  status: TJobCompletionStatus;
684
763
  redactionSet: ISecretRedactionSet;
685
764
  identity: IJobIdentity;
@@ -693,14 +772,17 @@ export interface IArtifactManager {
693
772
  export interface ICacheRestoreContext {
694
773
  workspacePath: string;
695
774
  workspaceEntryCount: number;
696
- job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements' | 'source'>;
775
+ job: Pick<
776
+ IOciRunnerJob | IVmExecutableRunnerJob,
777
+ 'caches' | 'permissions' | 'requirements' | 'source'
778
+ >;
697
779
  identity: IJobIdentity;
698
780
  signal: AbortSignal;
699
781
  }
700
782
 
701
783
  export interface ICacheSaveContext {
702
784
  workspace: IRuntimeWorkspaceExporter;
703
- job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements'>;
785
+ job: Pick<IOciRunnerJob | IVmExecutableRunnerJob, 'caches' | 'permissions' | 'requirements'>;
704
786
  status: TJobCompletionStatus;
705
787
  redactionSet: ISecretRedactionSet;
706
788
  identity: IJobIdentity;