@ship.zone/runner 2.1.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 (200) hide show
  1. package/.smartconfig.json +118 -3
  2. package/changelog.md +101 -0
  3. package/dist_rust/runnerworkspace_linux_amd64_musl +0 -0
  4. package/dist_rust/runnerworkspace_linux_amd64_musl.third-party-notices.json +679 -0
  5. package/dist_rust/runnerworkspace_linux_amd64_musl.third-party-notices.txt +15719 -0
  6. package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +5 -5
  7. package/dist_rust/runnerworkspace_linux_arm64_musl +0 -0
  8. package/dist_rust/runnerworkspace_linux_arm64_musl.third-party-notices.json +679 -0
  9. package/dist_rust/runnerworkspace_linux_arm64_musl.third-party-notices.txt +15719 -0
  10. package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +5 -5
  11. package/dist_ts/00_commitinfo_data.d.ts +8 -0
  12. package/dist_ts/00_commitinfo_data.js +9 -0
  13. package/dist_ts/api-client.d.ts +47 -0
  14. package/dist_ts/api-client.js +600 -0
  15. package/dist_ts/artifact-manager.d.ts +11 -0
  16. package/dist_ts/artifact-manager.js +140 -0
  17. package/dist_ts/attempt-state.d.ts +18 -0
  18. package/dist_ts/attempt-state.js +151 -0
  19. package/dist_ts/cache-manager.d.ts +13 -0
  20. package/dist_ts/cache-manager.js +300 -0
  21. package/dist_ts/cli-entry.d.ts +2 -0
  22. package/dist_ts/cli-entry.js +18 -0
  23. package/dist_ts/cli.d.ts +14 -0
  24. package/dist_ts/cli.js +243 -0
  25. package/dist_ts/config.d.ts +8 -0
  26. package/dist_ts/config.js +495 -0
  27. package/dist_ts/egress-proxy.d.ts +99 -0
  28. package/dist_ts/egress-proxy.js +607 -0
  29. package/dist_ts/errors.d.ts +41 -0
  30. package/dist_ts/errors.js +90 -0
  31. package/dist_ts/filesystem.d.ts +73 -0
  32. package/dist_ts/filesystem.js +207 -0
  33. package/dist_ts/index.d.ts +20 -0
  34. package/dist_ts/index.js +21 -0
  35. package/dist_ts/interfaces.d.ts +685 -0
  36. package/dist_ts/interfaces.js +3 -0
  37. package/dist_ts/log-sender.d.ts +26 -0
  38. package/dist_ts/log-sender.js +124 -0
  39. package/dist_ts/microvm-executor.d.ts +90 -0
  40. package/dist_ts/microvm-executor.js +1045 -0
  41. package/dist_ts/node-version.d.ts +11 -0
  42. package/dist_ts/node-version.js +43 -0
  43. package/dist_ts/npm-grants.d.ts +9 -0
  44. package/dist_ts/npm-grants.js +44 -0
  45. package/dist_ts/oci-registry.d.ts +73 -0
  46. package/dist_ts/oci-registry.js +508 -0
  47. package/dist_ts/plugins.d.ts +23 -0
  48. package/dist_ts/plugins.js +27 -0
  49. package/dist_ts/protocol-validator.d.ts +39 -0
  50. package/dist_ts/protocol-validator.js +488 -0
  51. package/dist_ts/redactor.d.ts +78 -0
  52. package/dist_ts/redactor.js +235 -0
  53. package/dist_ts/registration-state.d.ts +16 -0
  54. package/dist_ts/registration-state.js +171 -0
  55. package/dist_ts/runner.d.ts +65 -0
  56. package/dist_ts/runner.js +912 -0
  57. package/dist_ts/source-workspace.d.ts +10 -0
  58. package/dist_ts/source-workspace.js +125 -0
  59. package/dist_ts/spec-version.d.ts +11 -0
  60. package/dist_ts/spec-version.js +41 -0
  61. package/dist_ts/staging-scavenger.d.ts +7 -0
  62. package/dist_ts/staging-scavenger.js +63 -0
  63. package/dist_ts/state-owner.d.ts +74 -0
  64. package/dist_ts/state-owner.js +291 -0
  65. package/dist_ts/transfer-archive.d.ts +78 -0
  66. package/dist_ts/transfer-archive.js +1619 -0
  67. package/dist_ts/validation.d.ts +11 -0
  68. package/dist_ts/validation.js +79 -0
  69. package/dist_ts/vsock-protocol.d.ts +130 -0
  70. package/dist_ts/vsock-protocol.js +336 -0
  71. package/dist_ts/wire-schema.d.ts +10 -0
  72. package/dist_ts/wire-schema.js +114 -0
  73. package/native-notices/crates/bitflags-2.13.1/license-apache +201 -0
  74. package/native-notices/crates/bitflags-2.13.1/license-mit +25 -0
  75. package/native-notices/crates/cc-1.8.0/license-apache +201 -0
  76. package/native-notices/crates/cc-1.8.0/license-mit +25 -0
  77. package/native-notices/crates/cfg-if-1.0.4/license-apache +201 -0
  78. package/native-notices/crates/cfg-if-1.0.4/license-mit +25 -0
  79. package/native-notices/crates/cfg_aliases-0.2.2/license +9 -0
  80. package/native-notices/crates/cfg_aliases-0.2.2/notices.md +26 -0
  81. package/native-notices/crates/find-msvc-tools-0.1.14/license-apache +201 -0
  82. package/native-notices/crates/find-msvc-tools-0.1.14/license-mit +25 -0
  83. package/native-notices/crates/itoa-1.0.18/license-apache +176 -0
  84. package/native-notices/crates/itoa-1.0.18/license-mit +23 -0
  85. package/native-notices/crates/libc-0.2.189/license-apache +176 -0
  86. package/native-notices/crates/libc-0.2.189/license-mit +25 -0
  87. package/native-notices/crates/memchr-2.8.3/copying +3 -0
  88. package/native-notices/crates/memchr-2.8.3/license-mit +21 -0
  89. package/native-notices/crates/memchr-2.8.3/unlicense +24 -0
  90. package/native-notices/crates/nix-0.30.1/license +21 -0
  91. package/native-notices/crates/proc-macro2-1.0.107/license-apache +176 -0
  92. package/native-notices/crates/proc-macro2-1.0.107/license-mit +23 -0
  93. package/native-notices/crates/quote-1.0.47/license-apache +176 -0
  94. package/native-notices/crates/quote-1.0.47/license-mit +23 -0
  95. package/native-notices/crates/serde-1.0.229/license-apache +176 -0
  96. package/native-notices/crates/serde-1.0.229/license-mit +23 -0
  97. package/native-notices/crates/serde_core-1.0.229/license-apache +176 -0
  98. package/native-notices/crates/serde_core-1.0.229/license-mit +23 -0
  99. package/native-notices/crates/serde_derive-1.0.229/license-apache +176 -0
  100. package/native-notices/crates/serde_derive-1.0.229/license-mit +23 -0
  101. package/native-notices/crates/serde_json-1.0.151/license-apache +176 -0
  102. package/native-notices/crates/serde_json-1.0.151/license-mit +23 -0
  103. package/native-notices/crates/shlex-2.0.1/license-apache +13 -0
  104. package/native-notices/crates/shlex-2.0.1/license-mit +21 -0
  105. package/native-notices/crates/syn-3.0.3/license-apache +176 -0
  106. package/native-notices/crates/syn-3.0.3/license-mit +23 -0
  107. package/native-notices/crates/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/license-apache +201 -0
  108. package/native-notices/crates/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/license-mit +25 -0
  109. package/native-notices/crates/tikv-jemallocator-0.7.0/license-apache +201 -0
  110. package/native-notices/crates/tikv-jemallocator-0.7.0/license-mit +25 -0
  111. package/native-notices/crates/unicode-ident-1.0.24/license-apache +176 -0
  112. package/native-notices/crates/unicode-ident-1.0.24/license-mit +23 -0
  113. package/native-notices/crates/unicode-ident-1.0.24/license-unicode +39 -0
  114. package/native-notices/crates/zmij-1.0.23/license-mit +23 -0
  115. package/native-notices/manifest.json +763 -0
  116. package/native-notices/native/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/jemalloc-5.3.1/jemalloc-copying +27 -0
  117. package/native-notices/readme.md +46 -0
  118. package/native-notices/runtime/gcc/gpl-3.0.txt +674 -0
  119. package/native-notices/runtime/gcc/runtime-library-exception-3.1.txt +73 -0
  120. package/native-notices/runtime/libunwind-22.1.2/license.txt +311 -0
  121. package/native-notices/runtime/musl-1.2.5/copyright +193 -0
  122. package/native-notices/rust/compiler-builtins-license.txt +275 -0
  123. package/native-notices/rust/copyright-library.html +8266 -0
  124. package/native-notices/rust/crates/addr2line-0.25.1/license-apache +201 -0
  125. package/native-notices/rust/crates/addr2line-0.25.1/license-mit +25 -0
  126. package/native-notices/rust/crates/adler2-2.0.1/license-0bsd +12 -0
  127. package/native-notices/rust/crates/adler2-2.0.1/license-apache +201 -0
  128. package/native-notices/rust/crates/adler2-2.0.1/license-mit +23 -0
  129. package/native-notices/rust/crates/memchr-2.7.6/copying +3 -0
  130. package/native-notices/rust/crates/memchr-2.7.6/license-mit +21 -0
  131. package/native-notices/rust/crates/memchr-2.7.6/unlicense +24 -0
  132. package/native-notices/rust/crates/miniz_oxide-0.8.9/license +25 -0
  133. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-apache.md +177 -0
  134. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-mit.md +24 -0
  135. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-zlib.md +14 -0
  136. package/native-notices/rust/crates/object-0.37.3/license-apache +201 -0
  137. package/native-notices/rust/crates/object-0.37.3/license-mit +25 -0
  138. package/native-notices/rust/licenses/apache-2.0.txt +73 -0
  139. package/native-notices/rust/licenses/bsd-2-clause.txt +9 -0
  140. package/native-notices/rust/licenses/cc-by-sa-4.0.txt +427 -0
  141. package/native-notices/rust/licenses/gcc-exception-3.1.txt +30 -0
  142. package/native-notices/rust/licenses/gpl-2.0-only.txt +133 -0
  143. package/native-notices/rust/licenses/gpl-3.0-or-later.txt +202 -0
  144. package/native-notices/rust/licenses/isc.txt +7 -0
  145. package/native-notices/rust/licenses/llvm-exception.txt +15 -0
  146. package/native-notices/rust/licenses/mit.txt +9 -0
  147. package/native-notices/rust/licenses/ncsa.txt +29 -0
  148. package/native-notices/rust/licenses/ofl-1.1.txt +43 -0
  149. package/native-notices/rust/licenses/unicode-3.0.txt +39 -0
  150. package/package.json +31 -26
  151. package/readme.md +157 -95
  152. package/rust/.cargo/config.toml +1 -1
  153. package/rust/Cargo.lock +1 -0
  154. package/rust/Cargo.toml +3 -2
  155. package/rust/src/cpio.rs +147 -0
  156. package/rust/src/extfs.rs +747 -0
  157. package/rust/src/guest.rs +2411 -0
  158. package/rust/src/lib.rs +197 -1
  159. package/rust/src/main.rs +7 -2
  160. package/rust/src/oci_tar.rs +842 -0
  161. package/rust-toolchain.toml +4 -0
  162. package/ts/00_commitinfo_data.ts +2 -2
  163. package/ts/api-client.ts +29 -8
  164. package/ts/artifact-manager.ts +9 -7
  165. package/ts/attempt-state.ts +75 -84
  166. package/ts/cache-manager.ts +22 -28
  167. package/ts/cli-entry.ts +17 -0
  168. package/ts/cli.ts +86 -53
  169. package/ts/config.ts +146 -62
  170. package/ts/egress-proxy.ts +649 -0
  171. package/ts/errors.ts +19 -0
  172. package/ts/filesystem.ts +316 -0
  173. package/ts/index.ts +20 -15
  174. package/ts/interfaces.ts +105 -23
  175. package/ts/log-sender.ts +4 -4
  176. package/ts/microvm-executor.ts +1265 -0
  177. package/ts/node-version.ts +49 -0
  178. package/ts/npm-grants.ts +49 -0
  179. package/ts/oci-registry.ts +649 -0
  180. package/ts/plugins.ts +25 -3
  181. package/ts/protocol-validator.ts +34 -30
  182. package/ts/redactor.ts +2 -2
  183. package/ts/registration-state.ts +82 -90
  184. package/ts/runner.ts +81 -34
  185. package/ts/source-workspace.ts +11 -8
  186. package/ts/spec-version.ts +2 -2
  187. package/ts/staging-scavenger.ts +37 -26
  188. package/ts/state-owner.ts +353 -0
  189. package/ts/transfer-archive.ts +214 -243
  190. package/ts/validation.ts +1 -1
  191. package/ts/vsock-protocol.ts +437 -0
  192. package/ts/wire-schema.ts +3 -3
  193. package/deno.json +0 -56
  194. package/deno.lock +0 -1495
  195. package/dist_npm/mod.d.ts +0 -967
  196. package/dist_npm/mod.js +0 -10058
  197. package/mod.ts +0 -8
  198. package/musl-copyright.md +0 -81
  199. package/third-party-licenses.md +0 -187
  200. package/ts/oci-executor.ts +0 -3137
package/readme.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # @ship.zone/runner
2
2
 
3
- `@ship.zone/runner` is the outbound-only OCI execution agent for ship.zone CI/CD. It implements the
4
- runner protocol of `@ship.zone/ci-spec` (2.0.0) for the `oci` execution profile, validates leases
5
- and compiled jobs against the published schemas, and runs one fenced attempt at a time on a local
6
- Docker or Podman engine.
3
+ `@ship.zone/runner` is the outbound-only Firecracker microVM execution agent for ship.zone CI/CD.
4
+ It implements the runner protocol of `@ship.zone/ci-spec` (2.0.0) with `microvm` isolation for
5
+ `oci`, `vm`, and dedicated-builder `oci-image` execution profiles, validates leases and compiled
6
+ jobs against the published schemas, and runs one fenced attempt at a time inside a dedicated
7
+ Firecracker microVM managed via `@push.rocks/smartvm`.
8
+
9
+ No host Docker or Podman daemon is required or supported. Jobs still choose any digest-pinned
10
+ Linux Docker/OCI image; the runner pulls and verifies the image layers directly via OCI
11
+ Distribution v2, builds a deterministic read-only ext2 rootfs image, and boots a fresh Firecracker
12
+ microVM with that image attached read-only (`/dev/vda`) and the static Rust `runnerworkspace` guest
13
+ agent as PID 1 (`/init`). Dedicated builder runners (`--profile builder`) execute `oci-image`
14
+ builds via BuildKit (`buildctl`) inside a dedicated Firecracker microVM and record the produced
15
+ image digest with the coordinator.
7
16
 
8
17
  The control plane owns workflow compilation, scheduling, authorization, secrets policy, and
9
18
  canonical run state. This package owns runner registration, lease handling, isolated execution,
@@ -19,30 +28,31 @@ Requests directly.
19
28
 
20
29
  ## Security Model
21
30
 
22
- - Only local Unix-socket Docker and Podman endpoints are accepted. Remote contexts and connections
23
- are rejected before capabilities are advertised.
24
- - Job images must be Linux images pinned by an exact SHA-256 digest. The image OS, architecture, and
25
- digest are checked before lease acceptance.
26
- - Every compiled step runs in a fresh container as a numeric non-root user with a read-only root,
27
- all capabilities dropped, `no-new-privileges`, private IPC, and CPU, memory, PID, shared-memory
28
- (`/dev/shm`), time, and writable-storage limits. The job's `resources` are these ceilings; omitted
29
- values take the runner defaults, and every value is bounded by the maximum the runner advertises.
30
- - The only network mode is `none`: every step container runs in a new network namespace whose only
31
- interface is its own loopback, so nothing leaves the sandbox and loopback ports never collide with
32
- another attempt. The runner exposes no service on that loopback. `egress` allowlists are not
33
- enforced by this runner, are never advertised, and cannot be configured.
34
- - Job containers receive no host paths, runtime sockets, devices, host namespaces, or arbitrary OCI
35
- arguments. Their only persistent writable mount is `/workspace`.
36
- - The shared workspace is an attempt-specific `nodev,nosuid` tmpfs with hard byte and entry
37
- ceilings. Imported executable files may run directly from it. A trusted static Rust helper imports
38
- source/cache staging, measures the workspace around every step, and exports only declared
39
- artifact/cache paths.
40
- - Helper containers use the exact job image only as an inert root filesystem. They override the
41
- entrypoint with the packaged static helper, have no network, and receive only the narrowly scoped
42
- `CHOWN` and `DAC_OVERRIDE` capabilities required for private staging ownership. Job containers do
43
- not receive those capabilities.
44
- - Step containers receive exactly the compiled step environment plus job secrets. Secret values are
45
- passed through the runtime environment rather than OCI command arguments.
31
+ - Every attempt runs inside its own jailed Firecracker microVM (`/dev/kvm`) managed via
32
+ `@push.rocks/smartvm` (`smartvm-helper`). No host Docker or Podman daemon is used or accepted.
33
+ - Job images must be Linux images pinned by an exact SHA-256 digest (or resolved from a
34
+ coordinator-supplied candidate binding). The runner pulls and verifies every manifest, config, and
35
+ layer digest directly via OCI Distribution v2, matching pull grants strictly by literal registry
36
+ and repository with redirect refusal and attempt-private caching for grant-backed images.
37
+ - In `oci` profile, every compiled step runs inside the microVM pivoted into the read-only OCI
38
+ rootfs (`/dev/vda`) as a numeric non-root user with all capabilities dropped, `no-new-privileges`,
39
+ private namespaces, and bounded vCPU, memory, PID, shared-memory (`/dev/shm`), time, and
40
+ writable-storage limits. In `vm` profile, steps run inside the microVM over an ephemeral writable
41
+ overlayfs above the read-only OCI rootfs and are torn down between steps via cgroup v2 kill.
42
+ - Dedicated builder runners (`--profile builder`) advertise only `oci-image` (never `oci` or `vm`),
43
+ run BuildKit inside a fresh Firecracker microVM with source-policy digest pinning, scoped `0400`
44
+ secrets and push credentials, attestations disabled, and digest-only push before calling
45
+ `PUT /jobs/{jobId}/attempts/{attemptId}/image`.
46
+ - By default the network mode is `none` (Firecracker microVM with no external connectivity). When
47
+ `--allow-egress` is enabled, the runner advertises `['none', 'egress']` and enforces `egress`
48
+ allowlists on the host via `EgressProxy` (DNS `A`/`AAAA`-only allowlist, private/link-local/
49
+ non-global/IPv4-mapped and custom CIDR blocking, TTL bindings, TLS SNI on 443, HTTP `Host` on 80).
50
+ - MicroVMs receive no host paths, runtime sockets, devices, or host namespaces. Their only
51
+ persistent writable workspace is `/workspace`, imported/exported by the static Rust
52
+ `runnerworkspace` guest PID 1 agent over vsock.
53
+ - `.npmrc` credentials from `npmGrants` are mounted read-only inside the guest and exposed via
54
+ `NPM_CONFIG_USERCONFIG`; every secret value and npm grant token is added to the attempt's
55
+ redaction set.
46
56
  - The attempt's redaction set holds every secret value, every npm grant token, and each line of a
47
57
  value containing a line terminator (CR LF, LF, or CR), leaving out members shorter than 8 UTF-8
48
58
  bytes; a short line of a multi-line value stays unmasked when printed on its own. Every member is
@@ -55,35 +65,53 @@ Requests directly.
55
65
 
56
66
  ## Requirements
57
67
 
58
- - Deno 2
59
- - pnpm 11
60
- - Docker or Podman on Linux
61
- - A rootless runtime by default
68
+ - Linux on x64 or arm64 with `/dev/kvm`
69
+ - `smartvm-helper` (`@push.rocks/smartvm`) with Firecracker v1.17+ and a pinned Linux `vmlinux` kernel
70
+ - For the npm package: Node.js 26.1 or later; the staging capacity check reads the filesystem
71
+ fragment size, `statfs` `frsize`, which Node.js provides from 26.1 on. The executables embed
72
+ Node.js 26.11.1.
73
+ - pnpm 12
62
74
  - Rust and configured cross-compilers when building the packaged helpers from source
63
75
 
64
76
  ## Install
65
77
 
66
- Add the published source package to a Deno project:
78
+ Install the `ship-zone-runner` executable on a Linux host:
67
79
 
68
80
  ```sh
69
- deno add npm:@ship.zone/runner
81
+ curl -fsSL https://code.foss.global/ship.zone/runner/releases/download/latest/install.sh | sudo bash
70
82
  ```
71
83
 
72
- Then import the package through the generated import-map name. The npm export resolves to the
73
- prebuilt Deno JavaScript bundle and its rolled-up TypeScript declarations:
84
+ The installer is an asset of every release from 3.0.0 on. It downloads the executable of the newest
85
+ release for the host's architecture (`ship-zone-runner-linux-x64` or `ship-zone-runner-linux-arm64`)
86
+ with its third-party notices, verifies them against the release's `SHA256SUMS.txt`, and runs the
87
+ executable with `--version` before it changes anything. It installs to
88
+ `/opt/ship-zone-runner/ship-zone-runner` and links `/usr/local/bin/ship-zone-runner`. Pass
89
+ `--version vX.Y.Z` for a given release, `--install-dir <dir>` for another directory, or `--dry-run`
90
+ to check the release assets without changing anything:
74
91
 
75
- ```ts
76
- import { ShipRunner } from '@ship.zone/runner';
92
+ ```sh
93
+ curl -fsSL https://code.foss.global/ship.zone/runner/releases/download/latest/install.sh | sudo bash -s -- --version vX.Y.Z
77
94
  ```
78
95
 
79
- Without an import-map entry, use the npm package directly:
96
+ Running it again updates the executable. The installer never touches the runner's configuration
97
+ or state: the runner keeps reading `./runner.config.json` and `./.runner-state` relative to its
98
+ working directory (or the paths `--config`, `SHIP_RUNNER_CONFIG` and `stateDirectory` name). If a
99
+ systemd service named `ship-zone-runner` is running, the installer stops it for the update and
100
+ restarts it with the new version; it does not create a service. Each executable embeds the static workspace
101
+ helper of its architecture, which the runner copies into its private state as described below.
102
+
103
+ Or add the package to a Node.js project:
104
+
105
+ ```sh
106
+ pnpm add @ship.zone/runner
107
+ ```
80
108
 
81
109
  ```ts
82
- import { ShipRunner } from 'npm:@ship.zone/runner';
110
+ import { ShipRunner } from '@ship.zone/runner';
83
111
  ```
84
112
 
85
- For development in this repository, install dependencies and build the npm bundle plus the static
86
- musl-based `linux_amd64` and `linux_arm64` helpers:
113
+ For development in this repository, install dependencies, compile the TypeScript sources to
114
+ `dist_ts/`, and build the static musl-based helper for the host architecture:
87
115
 
88
116
  ```sh
89
117
  pnpm install
@@ -103,13 +131,13 @@ not changed, so package managers may install the source without executable bits.
103
131
  directory is the host access boundary; mode `0755` lets capability-dropped helper containers execute
104
132
  the host-owned read-only bind mount. `IOciRuntimeFacts.helperPath` reports the validated
105
133
  materialized path used by host probes and OCI bind mounts, while `helperSha256` reports its content
106
- digest. A private advisory lock serializes materialization. Existing digest paths are reused only
134
+ digest. Existing digest paths are reused only
107
135
  after their type, single-link status, mode, and digest are revalidated without mutating them; the
108
136
  runner retains a bounded set for rollback, reclaims stale incomplete temporary copies, and rejects
109
137
  excessive recent temporary residue. The sole immediate-recovery exception is a validated temporary
110
138
  name and exact digest destination that still reference the same two-link inode after interruption;
111
- the runner removes the temporary name under the lock, verifies the destination became single-link,
112
- and then reuses it.
139
+ the runner removes the temporary name, verifies the destination became single-link, and then reuses
140
+ it. The advisory `.workspace-helper.lock` file of runner 2.x is no longer used and is removed.
113
141
 
114
142
  Runtime verification creates one private `.runtime-probe-owner_<id>` marker in the helper state.
115
143
  Host tmpfs probes include that owner in their exact directory names, and OCI runtime probe volumes
@@ -117,35 +145,58 @@ carry the same `ship.zone.runner.runtime-probe-owner` label. This lets interrupt
117
145
  cleaned by the same state owner without touching unowned probes or probes from another runner. The
118
146
  runner syncs both the helper-directory entry and a newly created owner marker before using them.
119
147
 
148
+ ## State Directory Ownership
149
+
150
+ One runner owns a state directory at a time; many runners per host are still supported, each with
151
+ its own state directory. Before anything else touches the state directory, the runner starts its
152
+ own static helper as `runnerworkspace own-state <stateDirectory>`, which takes an exclusive kernel
153
+ `flock` on `<stateDirectory>/.runner-owner.lock` (mode `0600`, a single-link regular file owned by
154
+ the runner user). The lock lives exactly as long as that helper process: the helper prints `locked`,
155
+ then waits for end of input on stdin, which the runner closes when it releases the lock or exits, and
156
+ it carries a parent-death signal as a backstop. It ignores `SIGINT`, `SIGTERM`, and `SIGHUP`, so a
157
+ graceful shutdown keeps its ownership until the runner releases it.
158
+
159
+ A second runner on the same state directory is a configuration error: its helper exits at once with
160
+ exit code `3`, and the runner stops with `RunnerStateOwnedElsewhereError` instead of waiting. If the
161
+ helper exits while the runner is still live, ownership is lost and the runner shuts down with
162
+ `RunnerStateOwnershipLostError`.
163
+
164
+ The runner writes the verified helper bytes to a private exclusive mode-`0700` file in the state
165
+ directory, starts it, and removes the file as soon as the lock is held. Within the runner process,
166
+ helper materialization and the runtime probe owner marker run one after another on the owner's
167
+ single in-process chain.
168
+
120
169
  ## Configure And Run
121
170
 
122
171
  Create a private runner configuration:
123
172
 
124
173
  ```sh
125
- deno run --allow-all \
126
- npm:@ship.zone/runner init \
174
+ ship-zone-runner init \
127
175
  --control-plane https://foss.global \
128
- --runtime-path /usr/bin/docker
176
+ --kernel-path /var/lib/ship-zone-runner/vmlinux
129
177
  ```
130
178
 
179
+ Optional flags for `init`:
180
+
181
+ - `--profile workload|builder`: `workload` (default) advertises `['oci', 'vm']`; `builder`
182
+ advertises only `['oci-image']` and requires `--builder-rootfs-path <path>`.
183
+ - `--allow-egress`: enable host-enforced `egress` allowlist proxy and advertise `['none', 'egress']`.
184
+ - `--egress-blocked-cidr <cidr>` (repeatable): block additional destination CIDRs in `egress` mode.
185
+
131
186
  Register with a one-time bootstrap token, then start the daemon:
132
187
 
133
188
  ```sh
134
- SHIP_RUNNER_BOOTSTRAP_TOKEN='<one-time token>' \
135
- deno run --allow-all \
136
- npm:@ship.zone/runner register
137
- deno run --allow-all \
138
- npm:@ship.zone/runner run
189
+ SHIP_RUNNER_BOOTSTRAP_TOKEN='<one-time token>' ship-zone-runner register
190
+ ship-zone-runner run
139
191
  ```
140
192
 
141
- `--allow-all` is required because Deno reserves direct `/dev/shm` access for that mode. The runner
142
- uses `/dev/shm` for fail-closed host tmpfs verification before registration and must already be
143
- trusted with unrestricted subprocess execution for the configured OCI runtime.
193
+ The runner uses `/dev/shm` for fail-closed host tmpfs verification before registration and talks to
194
+ `smartvm-helper` (`@push.rocks/smartvm`) to boot per-attempt Firecracker microVMs.
144
195
 
145
196
  Replace `run` with `once` to claim at most one job or `config` to print the effective configuration
146
- with credentials masked. Within this repository, `deno task dev -- <command>` is the equivalent
147
- development invocation. `SHIP_RUNNER_CONFIG` selects a config path; the default is
148
- `./runner.config.json`.
197
+ with credentials masked. Within this repository, `pnpm build` followed by
198
+ `node dist_ts/cli-entry.js <command>` is the equivalent development invocation.
199
+ `SHIP_RUNNER_CONFIG` selects a config path; the default is `./runner.config.json`.
149
200
 
150
201
  `init` writes the config with mode `0600`. Registration verifies the runtime and protocol discovery
151
202
  document before advertising capabilities, durably journals the exact registration request without
@@ -156,10 +207,10 @@ credential becomes active.
156
207
 
157
208
  The default policy includes:
158
209
 
159
- - rootless Docker at `/usr/bin/docker`;
160
- - labels for Linux, the current architecture, and OCI;
161
- - network `none` only;
162
- - job user `65532:65532`;
210
+ - Firecracker microVM isolation via `@push.rocks/smartvm` (`workload` profile: `oci` and `vm`);
211
+ - labels for Linux, the current architecture, and microVM;
212
+ - network `none` only (add `--allow-egress` to enable host-enforced `egress`);
213
+ - job user `65532:65532` (for `oci` steps);
163
214
  - a 4 GiB maximum logical workspace and 100,000 entries;
164
215
  - bounded source, artifact, cache, log, environment, and staging limits;
165
216
  - a 1 GiB free-space and 10,000-inode staging reserve.
@@ -193,10 +244,11 @@ An attempt-scoped inert holder container keeps Docker's local-driver tmpfs mount
193
244
  and helper containers come and go. It runs no image-provided command and is removed with the
194
245
  workspace.
195
246
 
196
- On restart, a new session first removes stale labeled containers and volumes locally, scavenges only
197
- the runner's known host-staging directories and journal temporary files, then reads the secret-free
198
- journal and calls the recovery endpoint to revoke and reconcile the interrupted attempt. Work is
199
- never resumed, and a coordinator outage cannot retain prior staging.
247
+ On restart, the runner first scavenges only its known host-staging directories, journal temporary
248
+ files, and stale private copies of the state owner helper, right after it owns the state directory
249
+ and before it verifies the runtime. A new session then removes stale labeled containers and volumes
250
+ locally, reads the secret-free journal, and calls the recovery endpoint to revoke and reconcile the
251
+ interrupted attempt. Work is never resumed, and a coordinator outage cannot retain prior staging.
200
252
 
201
253
  ## Job Timeout
202
254
 
@@ -236,14 +288,15 @@ every coordinator of major version 2. A leased job is accepted only when its `sp
236
288
  major version and is not newer than the implemented version; any other job is abandoned as
237
289
  `runner_error`.
238
290
 
239
- The runner advertises the `oci` profile, `container` isolation, the native `linux/<arch>` platform
240
- of its verified OCI engine, the `none` network mode, its transfer limits, `resources` maxima for
241
- memory, CPUs, PIDs, and shared memory, an empty `leaseFeatures` list because it uses no image pull
242
- grants, candidate bindings, or npm read grants, and `maximumTimeoutMs`, its configured
243
- `oci.maximumTimeoutMs`. It refuses, by abandoning the lease as `runner_error` before acceptance,
244
- every lease it cannot execute as specified: the `vm` and `oci-image` profiles, `microvm` isolation,
245
- `egress` networks, candidate images with `bindings`, image `grants`, jobs with `npmRead` and their
246
- `npmGrants`, and jobs whose `timeoutMs` exceeds `oci.maximumTimeoutMs`.
291
+ The runner advertises `microvm` isolation, its native `linux/<arch>` platform, `executionProfiles`
292
+ of `['oci', 'vm']` for a `workload` runner or `['oci-image']` for a dedicated `builder` runner,
293
+ `networks` of `['none']` (or `['none', 'egress']` when `--allow-egress` is enabled), its transfer
294
+ limits, `resources` maxima for memory, CPUs, PIDs, and shared memory,
295
+ `leaseFeatures: ['image-pull-grants', 'candidate-bindings', 'npm-read-grants']`, and
296
+ `maximumTimeoutMs`, its configured `oci.maximumTimeoutMs`. It refuses, by abandoning the lease as
297
+ `runner_error` before acceptance, any lease outside its advertised capabilities (for example
298
+ `container` isolation, non-Linux platforms, mismatched execution profile, or `timeoutMs` exceeding
299
+ `oci.maximumTimeoutMs`).
247
300
 
248
301
  The reserved step environment names are `SHIPZONE_CI_MATRIX_JSON` and `SHIPZONE_CI_INPUTS_JSON`,
249
302
  each carrying canonical RFC 8785 JSON. A job whose step environment defines any other
@@ -269,6 +322,7 @@ published OpenAPI component before it is sent, and every response before it is u
269
322
  | Source | `GET sources/{sha256}` | Immutable attempt-bound digest |
270
323
  | Artifact | `PUT jobs/{jobId}/attempts/{attemptId}/artifacts/{name}` | `transferRequestId` and metadata |
271
324
  | Cache | `GET/PUT jobs/{jobId}/attempts/{attemptId}/caches/{name}` | Fenced declaration and transfer ID |
325
+ | Record image | `PUT jobs/{jobId}/attempts/{attemptId}/image` | Fenced produced OCI image digest |
272
326
 
273
327
  Transient retry statuses are 429, 502, 503, and 504. Exact retries reuse the same request ID and
274
328
  canonical body. Request, response, archive, extracted-data, entry, and stream sizes are bounded.
@@ -286,7 +340,8 @@ import {
286
340
  ArtifactManager,
287
341
  CacheManager,
288
342
  defaultRunnerConfig,
289
- OciExecutor,
343
+ EgressProxy,
344
+ MicroVmExecutor,
290
345
  RunnerApiClient,
291
346
  ShipRunner,
292
347
  SourceWorkspaceManager,
@@ -294,37 +349,44 @@ import {
294
349
  ```
295
350
 
296
351
  The CLI is the supported complete assembly. Embedded callers must preserve the same runtime
297
- verification, discovery, lifecycle, fencing, cleanup, and credential-persistence ordering.
352
+ verification, discovery, lifecycle, fencing, cleanup, and credential-persistence ordering, and must
353
+ own the state directory first:
354
+
355
+ ```ts
356
+ import { MicroVmExecutor, RunnerStateOwner, ShipRunner } from '@ship.zone/runner';
357
+
358
+ const stateOwner = await RunnerStateOwner.acquire({ stateDirectory: config.stateDirectory });
359
+ try {
360
+ const executor = new MicroVmExecutor(config, stateOwner);
361
+ // new ShipRunner(config, { stateOwner, executor, ... }).run(...)
362
+ } finally {
363
+ await stateOwner.release();
364
+ }
365
+ ```
298
366
 
299
367
  ## Verification
300
368
 
301
369
  ```sh
302
- deno task fmt --check
303
- deno task lint
304
- deno task check
305
- pnpm test
306
370
  pnpm build
371
+ pnpm exec tsbuild check 'test/**/*'
372
+ pnpm test
307
373
  pnpm pack --dry-run
308
374
  ```
309
375
 
310
- The real Docker integration is opt-in and requires a locally available digest-pinned Linux image:
311
-
312
- ```sh
313
- SHIP_RUNNER_OCI_TEST=1 \
314
- SHIP_RUNNER_OCI_IMAGE='alpine@sha256:<digest>' \
315
- deno test --allow-all test/oci-executor.test.ts
316
- ```
317
-
318
- It verifies direct execution of an imported workspace file, shared multi-step state, helper
319
- ownership, selected export, hardlink rejection, inode exhaustion, and container/volume cleanup
320
- against the real runtime.
376
+ `pnpm test` builds first: the tests take real state ownership with the host helper in `dist_rust/`,
377
+ run the TypeScript unit/E2E suites (`test/test.*.node.ts`, including Firecracker microVM, OCI
378
+ registry, egress allowlist proxy, and dedicated `oci-image` builder tests), and run `cargo test`
379
+ for the static Rust `runnerworkspace` helper and guest PID 1 agent.
321
380
 
322
381
  ## License and Legal Information
323
382
 
324
383
  This repository contains open-source code licensed under the MIT License. A copy of the license can
325
- be found in the [repository license file](./license.md). Dependency notices for the npm bundle and
326
- the packaged static helper binaries are in [third-party-licenses.md](./third-party-licenses.md),
327
- with the complete applicable musl inventory in [musl-copyright.md](./musl-copyright.md).
384
+ be found in the [repository license file](./license.md). The third-party notices of the packaged
385
+ static helpers (Rust crates, jemalloc, the Rust standard library, musl and the other runtime
386
+ libraries) are generated into [native-notices/](./native-notices/readme.md), and every helper in
387
+ `dist_rust/` carries the notices of its target beside it. Every release executable comes with its
388
+ own `<executable>.third-party-notices.txt` and `.json`, which cover Node.js, the bundled JavaScript
389
+ dependencies and the embedded helper.
328
390
 
329
391
  **Please note:** The MIT License does not grant permission to use the trade names, trademarks,
330
392
  service marks, or product names of the project, except as required for reasonable and customary use
@@ -2,4 +2,4 @@
2
2
  linker = "aarch64-linux-gnu-gcc"
3
3
 
4
4
  [target.aarch64-unknown-linux-musl]
5
- linker = "aarch64-linux-gnu-gcc"
5
+ linker = "aarch64-linux-musl-gcc"
package/rust/Cargo.lock CHANGED
@@ -88,6 +88,7 @@ dependencies = [
88
88
  name = "runnerworkspace"
89
89
  version = "0.1.0"
90
90
  dependencies = [
91
+ "libc",
91
92
  "nix",
92
93
  "serde",
93
94
  "serde_json",
package/rust/Cargo.toml CHANGED
@@ -6,9 +6,10 @@ license = "MIT"
6
6
  publish = false
7
7
 
8
8
  [dependencies]
9
- nix = { version = "0.30.1", default-features = false, features = ["fs", "signal"] }
9
+ libc = "0.2.189"
10
+ nix = { version = "0.30.1", default-features = false, features = ["fs", "process", "signal", "user"] }
10
11
  serde = { version = "1.0.229", features = ["derive"] }
11
- serde_json = "1.0.149"
12
+ serde_json = { version = "1.0.149" }
12
13
 
13
14
  [target.'cfg(not(target_env = "msvc"))'.dependencies]
14
15
  tikv-jemallocator = { version = "0.7.0", features = ["background_threads"] }
@@ -0,0 +1,147 @@
1
+ use crate::Error;
2
+ use std::fs::{self, OpenOptions};
3
+ use std::io::{self, Write};
4
+ use std::os::unix::fs::OpenOptionsExt;
5
+ use std::path::Path;
6
+
7
+ const NEWC_MAGIC: &[u8; 6] = b"070701";
8
+ const MAXIMUM_INITRD_BINARY_BYTES: u64 = 64 * 1024 * 1024;
9
+
10
+ fn align4(len: usize) -> usize {
11
+ (4 - (len % 4)) % 4
12
+ }
13
+
14
+ fn write_newc_entry<W: Write>(
15
+ writer: &mut W,
16
+ ino: u32,
17
+ mode: u32,
18
+ nlink: u32,
19
+ name: &str,
20
+ data: &[u8],
21
+ ) -> io::Result<()> {
22
+ let name_bytes = name.as_bytes();
23
+ let namesize = name_bytes.len() + 1;
24
+ let filesize = data.len();
25
+ let header = format!(
26
+ "{}{:08x}{:08x}{:08x}{:08x}{:08x}{:08x}{:08x}{:08x}{:08x}{:08x}{:08x}{:08x}{:08x}",
27
+ std::str::from_utf8(NEWC_MAGIC).unwrap_or("070701"),
28
+ ino,
29
+ mode,
30
+ 0u32, // uid
31
+ 0u32, // gid
32
+ nlink,
33
+ 0u32, // mtime (deterministic)
34
+ filesize as u32,
35
+ 0u32, // devmajor
36
+ 0u32, // devminor
37
+ 0u32, // rdevmajor
38
+ 0u32, // rdevminor
39
+ namesize as u32,
40
+ 0u32, // check
41
+ );
42
+ writer.write_all(header.as_bytes())?;
43
+ writer.write_all(name_bytes)?;
44
+ writer.write_all(&[0u8])?;
45
+ let header_pad = align4(110 + namesize);
46
+ if header_pad > 0 {
47
+ writer.write_all(&[0u8; 4][..header_pad])?;
48
+ }
49
+ if !data.is_empty() {
50
+ writer.write_all(data)?;
51
+ let data_pad = align4(filesize);
52
+ if data_pad > 0 {
53
+ writer.write_all(&[0u8; 4][..data_pad])?;
54
+ }
55
+ }
56
+ Ok(())
57
+ }
58
+
59
+ /// Builds a deterministic Linux `newc` CPIO initramfs containing `/init` (the static guest binary)
60
+ /// and the minimal mountpoint directories required during Firecracker guest boot.
61
+ pub fn build_initrd(binary_path: &Path, output_path: &Path) -> Result<u64, Error> {
62
+ if !binary_path.is_absolute() || !output_path.is_absolute() {
63
+ return Err(Error::new("initrd paths must be absolute"));
64
+ }
65
+ let metadata = fs::symlink_metadata(binary_path)
66
+ .map_err(|_| Error::new("unable to inspect guest binary for initrd"))?;
67
+ if !metadata.file_type().is_file() {
68
+ return Err(Error::new("guest binary must be a regular file"));
69
+ }
70
+ if metadata.len() == 0 || metadata.len() > MAXIMUM_INITRD_BINARY_BYTES {
71
+ return Err(Error::new("guest binary size is out of bounds"));
72
+ }
73
+ let binary_bytes =
74
+ fs::read(binary_path).map_err(|_| Error::new("unable to read guest binary for initrd"))?;
75
+
76
+ let mut buffer = Vec::with_capacity(binary_bytes.len() + 4096);
77
+ let dirs = [
78
+ "dev",
79
+ "proc",
80
+ "sys",
81
+ "tmp",
82
+ "workspace",
83
+ "oci-rootfs",
84
+ "run",
85
+ "mnt",
86
+ ];
87
+ let mut ino: u32 = 1;
88
+ for dir in dirs {
89
+ write_newc_entry(&mut buffer, ino, 0o040755, 2, dir, &[])
90
+ .map_err(|_| Error::new("unable to write initrd directory entry"))?;
91
+ ino += 1;
92
+ }
93
+ write_newc_entry(&mut buffer, ino, 0o100755, 1, "init", &binary_bytes)
94
+ .map_err(|_| Error::new("unable to write initrd /init entry"))?;
95
+ write_newc_entry(&mut buffer, 0, 0, 1, "TRAILER!!!", &[])
96
+ .map_err(|_| Error::new("unable to write initrd trailer"))?;
97
+
98
+ // Pad to 512-byte boundary for clean initrd loading.
99
+ let rem = buffer.len() % 512;
100
+ if rem != 0 {
101
+ buffer.resize(buffer.len() + (512 - rem), 0);
102
+ }
103
+
104
+ let mut out = OpenOptions::new()
105
+ .write(true)
106
+ .create(true)
107
+ .truncate(true)
108
+ .mode(0o600)
109
+ .open(output_path)
110
+ .map_err(|_| Error::new("unable to create initrd output file"))?;
111
+ out.write_all(&buffer)
112
+ .map_err(|_| Error::new("unable to write initrd output file"))?;
113
+ out.sync_all()
114
+ .map_err(|_| Error::new("unable to sync initrd output file"))?;
115
+ Ok(buffer.len() as u64)
116
+ }
117
+
118
+ #[cfg(test)]
119
+ mod tests {
120
+ use super::*;
121
+
122
+ #[test]
123
+ fn builds_deterministic_newc_initrd() {
124
+ let dir = std::env::temp_dir().join(format!(
125
+ "runnerworkspace-cpio-test-{}",
126
+ std::process::id()
127
+ ));
128
+ let _ = fs::remove_dir_all(&dir);
129
+ fs::create_dir_all(&dir).unwrap();
130
+ let bin = dir.join("fake-init");
131
+ let out1 = dir.join("initrd1.cpio");
132
+ let out2 = dir.join("initrd2.cpio");
133
+ fs::write(&bin, b"#!/bin/sh\necho hi\n").unwrap();
134
+
135
+ let size1 = build_initrd(&bin, &out1).unwrap();
136
+ let size2 = build_initrd(&bin, &out2).unwrap();
137
+ assert_eq!(size1, size2);
138
+ let bytes1 = fs::read(&out1).unwrap();
139
+ let bytes2 = fs::read(&out2).unwrap();
140
+ assert_eq!(bytes1, bytes2);
141
+ assert!(bytes1.starts_with(b"070701"));
142
+ assert!(bytes1.windows(10).any(|w| w == b"TRAILER!!!"));
143
+ assert_eq!(bytes1.len() % 512, 0);
144
+
145
+ let _ = fs::remove_dir_all(&dir);
146
+ }
147
+ }