@ship.zone/runner 1.0.0 → 2.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.
- package/changelog.md +46 -0
- package/deno.json +13 -13
- package/deno.lock +7 -7
- package/dist_npm/mod.d.ts +12 -11
- package/dist_npm/mod.js +75 -55
- package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +3 -3
- package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +3 -3
- package/package.json +2 -2
- package/readme.md +28 -20
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/cli.ts +2 -7
- package/ts/interfaces.ts +6 -0
- package/ts/oci-executor.ts +11 -10
- package/ts/plugins.ts +4 -4
- package/ts/protocol-validator.ts +38 -6
- package/ts/runner.ts +6 -31
- package/ts/spec-version.ts +0 -11
- package/ts/wire-schema.ts +8 -7
package/changelog.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026-09-27 - 2.0.0
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
- speak the @ship.zone/ci-spec 2.0.0 runner protocol (protocol)
|
|
8
|
+
- Replace the deprecated `@foss.global/ci-spec` 1.2.0 with `@ship.zone/ci-spec` 2.0.0; the runner
|
|
9
|
+
implements and sends `spec` 2.0.0 and, under the same-major rule, refuses 1.x coordinators and
|
|
10
|
+
abandons 1.x jobs as `runner_error`.
|
|
11
|
+
- The reserved step environment names are `SHIPZONE_CI_MATRIX_JSON` and `SHIPZONE_CI_INPUTS_JSON`,
|
|
12
|
+
and secret targets and step environment names may not use any other `SHIPZONE_CI_*` name;
|
|
13
|
+
`FOSS_CI_*` names are no longer reserved.
|
|
14
|
+
- The compiled job schema and the OpenAPI components are registered under their 2.0.0 document
|
|
15
|
+
identifiers, `https://ship.zone/spec/ci/schemas/runner-job.schema.json` and
|
|
16
|
+
`https://ship.zone/spec/ci/spec/runner.openapi.json`, the job schema by its `$id` only.
|
|
17
|
+
- Capabilities always carry `resources`, the empty `leaseFeatures` list, and `maximumTimeoutMs`,
|
|
18
|
+
which are plain 2.0.0 capability fields; `capabilitiesForCoordinator`, `compareSpecVersions`,
|
|
19
|
+
and `lowerSpecVersion` are removed from the public API.
|
|
20
|
+
- The runner names its OCI containers and volumes `shipzone-ci-step-*`, `shipzone-ci-helper-*`,
|
|
21
|
+
`shipzone-ci-probe-*`, and `shipzone-ci-volume-*` instead of `foss-ci-*`, and reconciles only
|
|
22
|
+
the new names; operators of an earlier runner remove leftover `foss-ci-*` containers and volumes
|
|
23
|
+
by hand.
|
|
24
|
+
- The conformance map follows the 2.0.0 behavior cases: `capability-fields-negotiated` is gone,
|
|
25
|
+
and the 11 new behaviour cases are coordinator obligations.
|
|
26
|
+
|
|
27
|
+
### Maintenance
|
|
28
|
+
|
|
29
|
+
- exempt the ship.zone scope from the Deno release-age gate (deno)
|
|
30
|
+
- `deno.json` excludes `npm:@ship.zone/*` instead of `npm:@foss.global/*`, which no dependency uses any more.
|
|
31
|
+
|
|
32
|
+
## 2026-09-27 - 1.1.0
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
- speak the @foss.global/ci-spec 1.2.0 runner protocol (protocol)
|
|
37
|
+
- Upgrade `@foss.global/ci-spec` to 1.2.0; the runner implements and sends `spec` 1.2.0, and a 1.1
|
|
38
|
+
or 1.0 coordinator still uses the constructs of its own version.
|
|
39
|
+
- Capabilities advertise an empty `leaseFeatures` list and `maximumTimeoutMs`, the configured
|
|
40
|
+
`oci.maximumTimeoutMs`, when the lower of the coordinator and runner versions is 1.2.0 or later,
|
|
41
|
+
and omit both below it, as `resources` is omitted against a 1.0.0 coordinator.
|
|
42
|
+
- A lease that uses a pull grant, binding, or `npmGrants` outside the advertised `leaseFeatures`,
|
|
43
|
+
or a job whose `timeoutMs` exceeds the advertised `maximumTimeoutMs`, is abandoned as
|
|
44
|
+
`runner_error` before acceptance. Leases with grants, bindings, or npm grants stay refused in
|
|
45
|
+
every session.
|
|
46
|
+
- The redaction set splits values into lines at CR LF, LF, and CR, as 1.2.0 defines; the behavior
|
|
47
|
+
is unchanged and now covered by the line-definition vectors.
|
|
48
|
+
|
|
3
49
|
## 2026-09-27 - 1.0.0
|
|
4
50
|
|
|
5
51
|
### Breaking Changes
|
package/deno.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ship.zone/runner",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"exports": "./mod.ts",
|
|
5
5
|
"nodeModulesDir": "none",
|
|
6
6
|
"minimumDependencyAge": {
|
|
7
7
|
"age": "P1D",
|
|
8
8
|
"exclude": [
|
|
9
|
-
"npm:@foss.global/*",
|
|
10
9
|
"npm:@git.zone/*",
|
|
11
|
-
"npm:@push.rocks/*"
|
|
10
|
+
"npm:@push.rocks/*",
|
|
11
|
+
"npm:@ship.zone/*"
|
|
12
12
|
]
|
|
13
13
|
},
|
|
14
14
|
"tasks": {
|
|
15
15
|
"dev": "deno run --allow-all mod.ts",
|
|
16
|
-
"bundle": "deno bundle --frozen --check --platform=deno --keep-names --external '@
|
|
16
|
+
"bundle": "deno bundle --frozen --check --platform=deno --keep-names --external '@ship.zone/ci-spec' --external '@ship.zone/ci-spec/*' --external 'ajv/*' --declaration --outdir dist_npm mod.ts",
|
|
17
17
|
"test": "deno test --allow-env --allow-net --allow-read --allow-write --allow-run test/",
|
|
18
18
|
"check": "deno check mod.ts test/ scripts/",
|
|
19
19
|
"fmt": "deno fmt",
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"strict": true
|
|
41
41
|
},
|
|
42
42
|
"imports": {
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
43
|
+
"@ship.zone/ci-spec": "npm:@ship.zone/ci-spec@2.0.0",
|
|
44
|
+
"@ship.zone/ci-spec/archive-cases.json": "npm:@ship.zone/ci-spec@2.0.0/archive-cases.json",
|
|
45
|
+
"@ship.zone/ci-spec/digest-cases.json": "npm:@ship.zone/ci-spec@2.0.0/digest-cases.json",
|
|
46
|
+
"@ship.zone/ci-spec/runner-cases.json": "npm:@ship.zone/ci-spec@2.0.0/runner-cases.json",
|
|
47
|
+
"@ship.zone/ci-spec/runner-job.schema.json": "npm:@ship.zone/ci-spec@2.0.0/runner-job.schema.json",
|
|
48
|
+
"@ship.zone/ci-spec/runner-messages.json": "npm:@ship.zone/ci-spec@2.0.0/runner-messages.json",
|
|
49
|
+
"@ship.zone/ci-spec/runner.openapi.json": "npm:@ship.zone/ci-spec@2.0.0/runner.openapi.json",
|
|
50
|
+
"@ship.zone/ci-spec/version-cases.json": "npm:@ship.zone/ci-spec@2.0.0/version-cases.json",
|
|
51
|
+
"@ship.zone/ci-spec/conformance/runner-jobs/": "npm:/@ship.zone/ci-spec@2.0.0/conformance/runner-jobs/",
|
|
52
52
|
"@std/assert": "jsr:@std/assert@^1.0.14",
|
|
53
53
|
"@std/path": "jsr:@std/path@^1.1.2",
|
|
54
54
|
"ajv/dist/2020.js": "npm:ajv@8.20.0/dist/2020.js"
|
package/deno.lock
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"jsr:@std/internal@^1.0.12": "1.0.14",
|
|
6
6
|
"jsr:@std/internal@^1.0.14": "1.0.14",
|
|
7
7
|
"jsr:@std/path@^1.1.2": "1.1.6",
|
|
8
|
-
"npm:@foss.global/ci-spec@1.1.1": "1.1.1",
|
|
9
8
|
"npm:@git.zone/tsrust@^1.15.1": "1.15.1",
|
|
9
|
+
"npm:@ship.zone/ci-spec@2.0.0": "2.0.0",
|
|
10
10
|
"npm:ajv@8.20.0": "8.20.0",
|
|
11
11
|
"npm:ajv@^8.20.0": "8.20.0"
|
|
12
12
|
},
|
|
@@ -103,10 +103,6 @@
|
|
|
103
103
|
],
|
|
104
104
|
"tarball": "https://verdaccio.lossless.digital/@design.estate/dees-element/-/dees-element-3.3.0.tgz"
|
|
105
105
|
},
|
|
106
|
-
"@foss.global/ci-spec@1.1.1": {
|
|
107
|
-
"integrity": "sha512-0ODCGgjXFUk+2zLiPXXmO5oz4jTHqHsTXPp1nRrOpm01TjvYLG/NPrCFyezWqOT+IPADZ7rcJHunOn/1sMIMSw==",
|
|
108
|
-
"tarball": "https://verdaccio.lossless.digital/@foss.global/ci-spec/-/ci-spec-1.1.1.tgz"
|
|
109
|
-
},
|
|
110
106
|
"@git.zone/tsrust@1.15.1": {
|
|
111
107
|
"integrity": "sha512-J7B5IrmIt6mE9T/SHGxzATvYQSpTrn0z2cEeeJtbeQEDxy/2rumra4fS8tjzuWxVHuET5HdlW/rILD9vc6fDLg==",
|
|
112
108
|
"dependencies": [
|
|
@@ -515,6 +511,10 @@
|
|
|
515
511
|
],
|
|
516
512
|
"tarball": "https://verdaccio.lossless.digital/@push.rocks/webstore/-/webstore-2.2.0.tgz"
|
|
517
513
|
},
|
|
514
|
+
"@ship.zone/ci-spec@2.0.0": {
|
|
515
|
+
"integrity": "sha512-W46vBiBCaapX84/CNaFazg5o/ibcVPv8qzRa1I9V952CAE0k2S/LuAsZCDBFSNfjzVWF2M4cHYEenERHqRUVXQ==",
|
|
516
|
+
"tarball": "https://verdaccio.lossless.digital/@ship.zone/ci-spec/-/ci-spec-2.0.0.tgz"
|
|
517
|
+
},
|
|
518
518
|
"@tempfix/lenis@1.3.20": {
|
|
519
519
|
"integrity": "sha512-ypeB0FuHLHOCQXW4d0RQ69txPJJH+1CHcpsZIUdcv2t1vR0IVyQr2vHihtde9UOXhjzqEnUphWon/UcJNsa0YA==",
|
|
520
520
|
"tarball": "https://verdaccio.lossless.digital/@tempfix/lenis/-/lenis-1.3.20.tgz"
|
|
@@ -1748,13 +1748,13 @@
|
|
|
1748
1748
|
"dependencies": [
|
|
1749
1749
|
"jsr:@std/assert@^1.0.14",
|
|
1750
1750
|
"jsr:@std/path@^1.1.2",
|
|
1751
|
-
"npm:@
|
|
1751
|
+
"npm:@ship.zone/ci-spec@2.0.0",
|
|
1752
1752
|
"npm:ajv@8.20.0"
|
|
1753
1753
|
],
|
|
1754
1754
|
"packageJson": {
|
|
1755
1755
|
"dependencies": [
|
|
1756
|
-
"npm:@foss.global/ci-spec@1.1.1",
|
|
1757
1756
|
"npm:@git.zone/tsrust@^1.15.1",
|
|
1757
|
+
"npm:@ship.zone/ci-spec@2.0.0",
|
|
1758
1758
|
"npm:ajv@^8.20.0"
|
|
1759
1759
|
]
|
|
1760
1760
|
}
|
package/dist_npm/mod.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ export declare const runnerVersion: string;
|
|
|
93
93
|
export type TExecutionProfile = 'oci' | 'oci-image' | 'vm';
|
|
94
94
|
export type TIsolation = 'container' | 'microvm';
|
|
95
95
|
export type TRunnerFeature = 'source.tar-gz' | 'artifacts' | 'caches';
|
|
96
|
+
export type TLeaseFeature = 'image-pull-grants' | 'candidate-bindings' | 'npm-read-grants';
|
|
96
97
|
export type TNetworkMode = 'none' | 'egress';
|
|
97
98
|
export type TSourceFormat = 'tar.gz';
|
|
98
99
|
export type TOciRuntime = 'docker' | 'podman';
|
|
@@ -158,7 +159,12 @@ export interface IRunnerCapabilities { executionProfiles: TExecutionProfile[];
|
|
|
158
159
|
networks: TNetworkMode[];
|
|
159
160
|
sourceFormats: TSourceFormat[];
|
|
160
161
|
limits: ITransferLimits;
|
|
162
|
+
/** The largest resource ceilings the runner enforces per attempt. */
|
|
161
163
|
resources?: IResourceLimits;
|
|
164
|
+
/** The lease contents the runner uses. */
|
|
165
|
+
leaseFeatures?: TLeaseFeature[];
|
|
166
|
+
/** The largest job `timeoutMs` the runner executes. */
|
|
167
|
+
maximumTimeoutMs?: number;
|
|
162
168
|
}
|
|
163
169
|
export interface IRegisterRunnerRequest { registrationRequestId: string;
|
|
164
170
|
spec: string;
|
|
@@ -795,7 +801,10 @@ export declare class RunnerProtocolValidator { private readonly implementedSpec;
|
|
|
795
801
|
* the compiled plan digest, internal coherence, and fit against the capability snapshot.
|
|
796
802
|
*/
|
|
797
803
|
validateJob(jobUnknown: unknown): Promise<TCompiledRunnerJob>;
|
|
798
|
-
/**
|
|
804
|
+
/**
|
|
805
|
+
* Validates a lease against the published `JobLease` schema, its job, lease coherence, and the
|
|
806
|
+
* lease features of the capability snapshot.
|
|
807
|
+
*/
|
|
799
808
|
validateJobLease(leaseUnknown: unknown): Promise<IJobLease>;
|
|
800
809
|
/** Validates a lease and narrows it to the `oci` shape this runner executes. */
|
|
801
810
|
validateExecutableLease(leaseUnknown: unknown): Promise<IOciJobLease>;
|
|
@@ -900,14 +909,10 @@ export interface IRunnerDependencies { api: IRunnerCoordinatorClient;
|
|
|
900
909
|
/**
|
|
901
910
|
* The capabilities this runner advertises: the `oci` profile in `container` isolation on the
|
|
902
911
|
* native linux platform of its verified OCI engine, the `none` network mode, the configured
|
|
903
|
-
* transfer limits,
|
|
912
|
+
* transfer limits, the resource ceilings it enforces per attempt, no lease features (it uses no
|
|
913
|
+
* image grants, candidate bindings, or npm read grants), and its configured longest job timeout.
|
|
904
914
|
*/
|
|
905
915
|
export declare const runnerCapabilities: (config: IRunnerConfig, runtime: Pick<IOciRuntimeFacts, "os" | "architecture">) => IRunnerCapabilities;
|
|
906
|
-
/**
|
|
907
|
-
* Restricts capabilities to the constructs defined at the lower of the coordinator and runner
|
|
908
|
-
* specification versions, the version every non-job message may use.
|
|
909
|
-
*/
|
|
910
|
-
export declare const capabilitiesForCoordinator: (capabilities: IRunnerCapabilities, discovery: Pick<IDiscoveryResponse, "spec">) => IRunnerCapabilities;
|
|
911
916
|
export declare const reconcileProtocolLimits: (config: IRunnerConfig, discovery: IDiscoveryResponse, capabilities: IRunnerCapabilities) => void;
|
|
912
917
|
export declare class ShipRunner { private readonly config;
|
|
913
918
|
private readonly dependencies;
|
|
@@ -949,10 +954,6 @@ export declare const runnerSpecVersion: string;
|
|
|
949
954
|
export declare const acceptSpecVersion: (implemented: string, declared: unknown) => TSpecAcceptance;
|
|
950
955
|
/** Returns whether two canonical versions share a major version, the coordinator session rule. */
|
|
951
956
|
export declare const specMajorVersionsMatch: (left: string, right: string) => boolean;
|
|
952
|
-
/** Compares two canonical specification versions numerically. */
|
|
953
|
-
export declare const compareSpecVersions: (left: string, right: string) => number;
|
|
954
|
-
/** The lower of two canonical versions: the version whose constructs a message may use. */
|
|
955
|
-
export declare const lowerSpecVersion: (left: string, right: string) => string;
|
|
956
957
|
export declare const scavengeRunnerStaging: (stateDirectory: string) => Promise<void>;
|
|
957
958
|
/** OpenAPI component schemas of the published runner protocol that this runner validates. */
|
|
958
959
|
export declare const wireSchemaNames: readonly ["AbandonJobRequest", "AcceptJobRequest", "ClaimJobRequest", "ClaimJobResponse", "CompleteJobRequest", "CompleteJobResponse", "DiscoveryResponse", "ErrorResponse", "ImageBinding", "ImageGrant", "ImageRecord", "JobHeartbeatRequest", "JobHeartbeatResponse", "JobLease", "LogAcknowledgement", "LogChunk", "NpmGrant", "RecordImageRequest", "RecoverAttemptRequest", "RegisterRunnerRequest", "RegisterRunnerResponse", "RunnerCapabilities", "RunnerHeartbeatRequest", "RunnerHeartbeatResponse", "StartSessionRequest", "StartSessionResponse", "TransferRecord"];
|
package/dist_npm/mod.js
CHANGED
|
@@ -104,17 +104,17 @@ var init_errors = __esm({
|
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
// ts/plugins.ts
|
|
107
|
-
import { ciSpecStatus, ciSpecVersion, executionProfileIdentifiers, maximumArchivePathMetadataBytes, runnerProtocolBasePath } from "@
|
|
107
|
+
import { ciSpecStatus, ciSpecVersion, executionProfileIdentifiers, maximumArchivePathMetadataBytes, runnerProtocolBasePath } from "@ship.zone/ci-spec";
|
|
108
108
|
import { Ajv2020 } from "ajv/dist/2020.js";
|
|
109
|
-
import runnerJobSchema from "@
|
|
110
|
-
import runnerOpenApi from "@
|
|
109
|
+
import runnerJobSchema from "@ship.zone/ci-spec/runner-job.schema.json" with { type: "json" };
|
|
110
|
+
import runnerOpenApi from "@ship.zone/ci-spec/runner.openapi.json" with { type: "json" };
|
|
111
111
|
var init_plugins = __esm({
|
|
112
112
|
"ts/plugins.ts"() {
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
// ts/spec-version.ts
|
|
117
|
-
var canonicalSpecVersionPattern, parseSpecVersion, requireCanonical, compareParts, runnerSpecVersion, acceptSpecVersion, specMajorVersionsMatch
|
|
117
|
+
var canonicalSpecVersionPattern, parseSpecVersion, requireCanonical, compareParts, runnerSpecVersion, acceptSpecVersion, specMajorVersionsMatch;
|
|
118
118
|
var init_spec_version = __esm({
|
|
119
119
|
"ts/spec-version.ts"() {
|
|
120
120
|
init_errors();
|
|
@@ -155,8 +155,6 @@ var init_spec_version = __esm({
|
|
|
155
155
|
return compareParts(declaredParts, implementedParts) > 0 ? "newer" : "accepted";
|
|
156
156
|
}, "acceptSpecVersion");
|
|
157
157
|
specMajorVersionsMatch = /* @__PURE__ */ __name((left, right) => requireCanonical(left, "Specification version").major === requireCanonical(right, "Specification version").major, "specMajorVersionsMatch");
|
|
158
|
-
compareSpecVersions = /* @__PURE__ */ __name((left, right) => compareParts(requireCanonical(left, "Specification version"), requireCanonical(right, "Specification version")), "compareSpecVersions");
|
|
159
|
-
lowerSpecVersion = /* @__PURE__ */ __name((left, right) => compareSpecVersions(left, right) <= 0 ? left : right, "lowerSpecVersion");
|
|
160
158
|
}
|
|
161
159
|
});
|
|
162
160
|
|
|
@@ -220,7 +218,7 @@ var init_validation = __esm({
|
|
|
220
218
|
});
|
|
221
219
|
|
|
222
220
|
// ts/wire-schema.ts
|
|
223
|
-
var wireSchemaNames, isWireSchemaName, openApiSchemaId,
|
|
221
|
+
var wireSchemaNames, isWireSchemaName, openApiSchemaId, runnerJobSchemaId, rewriteComponentReferences, componentSchemas, ajv, validatorCache, validatorFor, componentValidator, sanitizeErrorText, safeErrorDetails, assertValid, isValidWireMessage, validateWireMessage, validateCompiledJobSchema;
|
|
224
222
|
var init_wire_schema = __esm({
|
|
225
223
|
"ts/wire-schema.ts"() {
|
|
226
224
|
init_errors();
|
|
@@ -256,8 +254,8 @@ var init_wire_schema = __esm({
|
|
|
256
254
|
"TransferRecord"
|
|
257
255
|
];
|
|
258
256
|
isWireSchemaName = /* @__PURE__ */ __name((value) => typeof value === "string" && wireSchemaNames.includes(value), "isWireSchemaName");
|
|
259
|
-
openApiSchemaId = "https://
|
|
260
|
-
|
|
257
|
+
openApiSchemaId = "https://ship.zone/spec/ci/spec/runner.openapi.json";
|
|
258
|
+
runnerJobSchemaId = "https://ship.zone/spec/ci/schemas/runner-job.schema.json";
|
|
261
259
|
rewriteComponentReferences = /* @__PURE__ */ __name((value) => {
|
|
262
260
|
if (Array.isArray(value)) return value.map(rewriteComponentReferences);
|
|
263
261
|
if (!isRecord(value)) return value;
|
|
@@ -285,7 +283,7 @@ var init_wire_schema = __esm({
|
|
|
285
283
|
type: "string",
|
|
286
284
|
validate: isProtocolTimestamp
|
|
287
285
|
});
|
|
288
|
-
ajv.addSchema(runnerJobSchema
|
|
286
|
+
ajv.addSchema(runnerJobSchema);
|
|
289
287
|
ajv.addSchema({
|
|
290
288
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
291
289
|
$id: openApiSchemaId,
|
|
@@ -326,7 +324,7 @@ var init_wire_schema = __esm({
|
|
|
326
324
|
}, "assertValid");
|
|
327
325
|
isValidWireMessage = /* @__PURE__ */ __name((name, value) => componentValidator(name)(value) === true, "isValidWireMessage");
|
|
328
326
|
validateWireMessage = /* @__PURE__ */ __name((name, value) => assertValid(componentValidator(name), value, name), "validateWireMessage");
|
|
329
|
-
validateCompiledJobSchema = /* @__PURE__ */ __name((value) => assertValid(validatorFor(
|
|
327
|
+
validateCompiledJobSchema = /* @__PURE__ */ __name((value) => assertValid(validatorFor(runnerJobSchemaId), value, "Compiled runner job"), "validateCompiledJobSchema");
|
|
330
328
|
}
|
|
331
329
|
});
|
|
332
330
|
|
|
@@ -4960,20 +4958,20 @@ var init_deno = __esm({
|
|
|
4960
4958
|
"deno.json"() {
|
|
4961
4959
|
deno_default = {
|
|
4962
4960
|
name: "@ship.zone/runner",
|
|
4963
|
-
version: "
|
|
4961
|
+
version: "2.0.0",
|
|
4964
4962
|
exports: "./mod.ts",
|
|
4965
4963
|
nodeModulesDir: "none",
|
|
4966
4964
|
minimumDependencyAge: {
|
|
4967
4965
|
age: "P1D",
|
|
4968
4966
|
exclude: [
|
|
4969
|
-
"npm:@foss.global/*",
|
|
4970
4967
|
"npm:@git.zone/*",
|
|
4971
|
-
"npm:@push.rocks/*"
|
|
4968
|
+
"npm:@push.rocks/*",
|
|
4969
|
+
"npm:@ship.zone/*"
|
|
4972
4970
|
]
|
|
4973
4971
|
},
|
|
4974
4972
|
tasks: {
|
|
4975
4973
|
dev: "deno run --allow-all mod.ts",
|
|
4976
|
-
bundle: "deno bundle --frozen --check --platform=deno --keep-names --external '@
|
|
4974
|
+
bundle: "deno bundle --frozen --check --platform=deno --keep-names --external '@ship.zone/ci-spec' --external '@ship.zone/ci-spec/*' --external 'ajv/*' --declaration --outdir dist_npm mod.ts",
|
|
4977
4975
|
test: "deno test --allow-env --allow-net --allow-read --allow-write --allow-run test/",
|
|
4978
4976
|
check: "deno check mod.ts test/ scripts/",
|
|
4979
4977
|
fmt: "deno fmt",
|
|
@@ -5000,15 +4998,15 @@ var init_deno = __esm({
|
|
|
5000
4998
|
strict: true
|
|
5001
4999
|
},
|
|
5002
5000
|
imports: {
|
|
5003
|
-
"@
|
|
5004
|
-
"@
|
|
5005
|
-
"@
|
|
5006
|
-
"@
|
|
5007
|
-
"@
|
|
5008
|
-
"@
|
|
5009
|
-
"@
|
|
5010
|
-
"@
|
|
5011
|
-
"@
|
|
5001
|
+
"@ship.zone/ci-spec": "npm:@ship.zone/ci-spec@2.0.0",
|
|
5002
|
+
"@ship.zone/ci-spec/archive-cases.json": "npm:@ship.zone/ci-spec@2.0.0/archive-cases.json",
|
|
5003
|
+
"@ship.zone/ci-spec/digest-cases.json": "npm:@ship.zone/ci-spec@2.0.0/digest-cases.json",
|
|
5004
|
+
"@ship.zone/ci-spec/runner-cases.json": "npm:@ship.zone/ci-spec@2.0.0/runner-cases.json",
|
|
5005
|
+
"@ship.zone/ci-spec/runner-job.schema.json": "npm:@ship.zone/ci-spec@2.0.0/runner-job.schema.json",
|
|
5006
|
+
"@ship.zone/ci-spec/runner-messages.json": "npm:@ship.zone/ci-spec@2.0.0/runner-messages.json",
|
|
5007
|
+
"@ship.zone/ci-spec/runner.openapi.json": "npm:@ship.zone/ci-spec@2.0.0/runner.openapi.json",
|
|
5008
|
+
"@ship.zone/ci-spec/version-cases.json": "npm:@ship.zone/ci-spec@2.0.0/version-cases.json",
|
|
5009
|
+
"@ship.zone/ci-spec/conformance/runner-jobs/": "npm:/@ship.zone/ci-spec@2.0.0/conformance/runner-jobs/",
|
|
5012
5010
|
"@std/assert": "jsr:@std/assert@^1.0.14",
|
|
5013
5011
|
"@std/path": "jsr:@std/path@^1.1.2",
|
|
5014
5012
|
"ajv/dist/2020.js": "npm:ajv@8.20.0/dist/2020.js"
|
|
@@ -5452,8 +5450,8 @@ var init_oci_executor = __esm({
|
|
|
5452
5450
|
hostTmpfsProbeMaximumAgeMs = 60 * 60 * 1e3;
|
|
5453
5451
|
runtimeProbeVolumeMaximumAgeMs = 60 * 60 * 1e3;
|
|
5454
5452
|
runtimeProbeOwnerIdPattern = /^[a-f0-9]{32}$/;
|
|
5455
|
-
hostTmpfsProbeNamePattern = /^
|
|
5456
|
-
runtimeProbeVolumeNamePattern = /^
|
|
5453
|
+
hostTmpfsProbeNamePattern = /^shipzone-ci-probe-([a-f0-9]{32})-[a-f0-9]{16}$/;
|
|
5454
|
+
runtimeProbeVolumeNamePattern = /^shipzone-ci-volume-[a-f0-9]{32}$/;
|
|
5457
5455
|
workspaceHelperDirectoryName = "workspace-helpers";
|
|
5458
5456
|
workspaceHelperLockName = ".workspace-helper.lock";
|
|
5459
5457
|
runtimeProbeOwnerMarkerPrefix = ".runtime-probe-owner_";
|
|
@@ -5780,7 +5778,7 @@ var init_oci_executor = __esm({
|
|
|
5780
5778
|
}
|
|
5781
5779
|
}, "validateStepCommand");
|
|
5782
5780
|
validateGeneratedName = /* @__PURE__ */ __name((value, kind) => {
|
|
5783
|
-
const pattern = kind === "container" ? /^
|
|
5781
|
+
const pattern = kind === "container" ? /^shipzone-ci-(?:helper|probe|step)-[a-f0-9]{32}$/ : /^shipzone-ci-volume-[a-f0-9]{32}$/;
|
|
5784
5782
|
if (!pattern.test(value)) throw new ProtocolError(`Runner generated an invalid OCI ${kind} name`);
|
|
5785
5783
|
return value;
|
|
5786
5784
|
}, "validateGeneratedName");
|
|
@@ -5950,8 +5948,8 @@ var init_oci_executor = __esm({
|
|
|
5950
5948
|
sessionId: context.sessionId,
|
|
5951
5949
|
lease: context.lease,
|
|
5952
5950
|
step,
|
|
5953
|
-
containerName: `
|
|
5954
|
-
volumeName: `
|
|
5951
|
+
containerName: `shipzone-ci-step-${"0".repeat(32)}`,
|
|
5952
|
+
volumeName: `shipzone-ci-volume-${"0".repeat(32)}`
|
|
5955
5953
|
});
|
|
5956
5954
|
}
|
|
5957
5955
|
}, "validateLeasePolicy");
|
|
@@ -6422,7 +6420,7 @@ var init_oci_executor = __esm({
|
|
|
6422
6420
|
requireSuccess(containers, "Unable to enumerate orphan OCI containers");
|
|
6423
6421
|
for (const line of decode(containers.stdout).split("\n").filter(Boolean)) {
|
|
6424
6422
|
const [name, sessionId] = line.split("|", 2);
|
|
6425
|
-
if (/^
|
|
6423
|
+
if (/^shipzone-ci-(?:helper|probe|step)-[a-f0-9]{32}$/.test(name) && sessionId !== currentSessionId) {
|
|
6426
6424
|
await this.stopAndRemoveContainer(name);
|
|
6427
6425
|
}
|
|
6428
6426
|
}
|
|
@@ -6439,7 +6437,7 @@ var init_oci_executor = __esm({
|
|
|
6439
6437
|
requireSuccess(volumes, "Unable to enumerate orphan OCI volumes");
|
|
6440
6438
|
for (const line of decode(volumes.stdout).split("\n").filter(Boolean)) {
|
|
6441
6439
|
const [name, sessionId] = line.split("|", 2);
|
|
6442
|
-
if (/^
|
|
6440
|
+
if (/^shipzone-ci-volume-[a-f0-9]{32}$/.test(name) && sessionId !== currentSessionId) {
|
|
6443
6441
|
await this.removeVolume(name);
|
|
6444
6442
|
}
|
|
6445
6443
|
}
|
|
@@ -7107,7 +7105,7 @@ var init_oci_executor = __esm({
|
|
|
7107
7105
|
await scavengeHostTmpfsProbes("/dev/shm", {}, runtimeProbeOwnerId);
|
|
7108
7106
|
path = await Deno.makeTempDir({
|
|
7109
7107
|
dir: "/dev/shm",
|
|
7110
|
-
prefix: `
|
|
7108
|
+
prefix: `shipzone-ci-probe-${runtimeProbeOwnerId}-`
|
|
7111
7109
|
});
|
|
7112
7110
|
const before = await this.readFilesystemProbe(helperPath, path);
|
|
7113
7111
|
const first = join3(path, "first");
|
|
@@ -7819,7 +7817,7 @@ var init_oci_executor = __esm({
|
|
|
7819
7817
|
}
|
|
7820
7818
|
}
|
|
7821
7819
|
createResourceName(kind) {
|
|
7822
|
-
const name = `
|
|
7820
|
+
const name = `shipzone-ci-${kind}-${this.randomHex()}`;
|
|
7823
7821
|
return validateGeneratedName(name, kind === "volume" ? "volume" : "container");
|
|
7824
7822
|
}
|
|
7825
7823
|
randomHex() {
|
|
@@ -7840,7 +7838,7 @@ var init_oci_executor = __esm({
|
|
|
7840
7838
|
});
|
|
7841
7839
|
|
|
7842
7840
|
// ts/protocol-validator.ts
|
|
7843
|
-
var sha256Pattern3, reservedEnvironmentNames, npmUserConfigEnvironmentName, maximumCommandArgumentBytes2, maximumCommandBytes2, maximumCombinedEnvironmentEntries, transferLimitNames, assertWellFormedUnicode, canonicalizeJsonInner, canonicalizeJson, toJsonValue, projectCompiledPlan, sha256, computeCompiledPlanDigest, UnsupportedJobError, deepFreeze, createRunnerCapabilitySnapshot, hasSteps, isLinuxPlatform, requireCapabilityFit, requireTransferCoherence, requireCanonicalReservedJson, requireExecutionCoherence, candidateReferences, imageName, requireLeaseCoherence, requireExecutableLease, validateCapabilityFit, RunnerProtocolValidator, validateJobLease;
|
|
7841
|
+
var sha256Pattern3, reservedEnvironmentNames, npmUserConfigEnvironmentName, maximumCommandArgumentBytes2, maximumCommandBytes2, maximumCombinedEnvironmentEntries, transferLimitNames, assertWellFormedUnicode, canonicalizeJsonInner, canonicalizeJson, toJsonValue, projectCompiledPlan, sha256, computeCompiledPlanDigest, UnsupportedJobError, deepFreeze, createRunnerCapabilitySnapshot, hasSteps, isLinuxPlatform, requireCapabilityFit, requireLeaseFeatureFit, requireTransferCoherence, requireCanonicalReservedJson, requireExecutionCoherence, candidateReferences, imageName, requireLeaseCoherence, requireExecutableLease, validateCapabilityFit, RunnerProtocolValidator, validateJobLease;
|
|
7844
7842
|
var init_protocol_validator = __esm({
|
|
7845
7843
|
"ts/protocol-validator.ts"() {
|
|
7846
7844
|
init_errors();
|
|
@@ -7849,8 +7847,8 @@ var init_protocol_validator = __esm({
|
|
|
7849
7847
|
init_wire_schema();
|
|
7850
7848
|
sha256Pattern3 = /^[a-f0-9]{64}$/;
|
|
7851
7849
|
reservedEnvironmentNames = [
|
|
7852
|
-
"
|
|
7853
|
-
"
|
|
7850
|
+
"SHIPZONE_CI_INPUTS_JSON",
|
|
7851
|
+
"SHIPZONE_CI_MATRIX_JSON"
|
|
7854
7852
|
];
|
|
7855
7853
|
npmUserConfigEnvironmentName = "NPM_CONFIG_USERCONFIG";
|
|
7856
7854
|
maximumCommandArgumentBytes2 = 16 * 1024;
|
|
@@ -8035,7 +8033,33 @@ var init_protocol_validator = __esm({
|
|
|
8035
8033
|
}
|
|
8036
8034
|
}
|
|
8037
8035
|
}
|
|
8036
|
+
if (capabilities.maximumTimeoutMs !== void 0 && job.timeoutMs > capabilities.maximumTimeoutMs) {
|
|
8037
|
+
throw new ProtocolError("Job timeoutMs exceeds runner capability");
|
|
8038
|
+
}
|
|
8038
8039
|
}, "requireCapabilityFit");
|
|
8040
|
+
requireLeaseFeatureFit = /* @__PURE__ */ __name((lease, capabilities) => {
|
|
8041
|
+
const advertised = capabilities.leaseFeatures;
|
|
8042
|
+
if (advertised === void 0) return;
|
|
8043
|
+
const used = [
|
|
8044
|
+
[
|
|
8045
|
+
lease.grants.some((grant) => grant.access === "pull"),
|
|
8046
|
+
"image-pull-grants"
|
|
8047
|
+
],
|
|
8048
|
+
[
|
|
8049
|
+
lease.bindings.length > 0,
|
|
8050
|
+
"candidate-bindings"
|
|
8051
|
+
],
|
|
8052
|
+
[
|
|
8053
|
+
lease.npmGrants !== void 0,
|
|
8054
|
+
"npm-read-grants"
|
|
8055
|
+
]
|
|
8056
|
+
];
|
|
8057
|
+
for (const [uses, feature] of used) {
|
|
8058
|
+
if (uses && !advertised.includes(feature)) {
|
|
8059
|
+
throw new ProtocolError(`Lease uses ${feature}, a lease feature this runner does not advertise`);
|
|
8060
|
+
}
|
|
8061
|
+
}
|
|
8062
|
+
}, "requireLeaseFeatureFit");
|
|
8039
8063
|
requireTransferCoherence = /* @__PURE__ */ __name((job) => {
|
|
8040
8064
|
const limits = job.requirements.limits;
|
|
8041
8065
|
if (!job.requirements.features.includes("source.tar-gz")) {
|
|
@@ -8102,8 +8126,8 @@ var init_protocol_validator = __esm({
|
|
|
8102
8126
|
const secretTargets = Object.keys(job.secrets);
|
|
8103
8127
|
const npmRead = job.npmRead !== void 0;
|
|
8104
8128
|
for (const secretName of secretTargets) {
|
|
8105
|
-
if (secretName.startsWith("
|
|
8106
|
-
throw new ProtocolError("Secret targets may not use reserved
|
|
8129
|
+
if (secretName.startsWith("SHIPZONE_CI_")) {
|
|
8130
|
+
throw new ProtocolError("Secret targets may not use reserved SHIPZONE_CI names");
|
|
8107
8131
|
}
|
|
8108
8132
|
if (npmRead && secretName === npmUserConfigEnvironmentName) {
|
|
8109
8133
|
throw new ProtocolError(`Secret targets may not use the reserved ${secretName}`);
|
|
@@ -8126,8 +8150,8 @@ var init_protocol_validator = __esm({
|
|
|
8126
8150
|
for (const step of job.steps) {
|
|
8127
8151
|
const environmentNames = Object.keys(step.environment);
|
|
8128
8152
|
for (const name of environmentNames) {
|
|
8129
|
-
if (name.startsWith("
|
|
8130
|
-
throw new ProtocolError("Step environment uses an unknown reserved
|
|
8153
|
+
if (name.startsWith("SHIPZONE_CI_") && !reservedEnvironmentNames.includes(name)) {
|
|
8154
|
+
throw new ProtocolError("Step environment uses an unknown reserved SHIPZONE_CI name");
|
|
8131
8155
|
}
|
|
8132
8156
|
if (npmRead && name === npmUserConfigEnvironmentName) {
|
|
8133
8157
|
throw new ProtocolError(`Step environment may not define the reserved ${name}`);
|
|
@@ -8286,7 +8310,10 @@ var init_protocol_validator = __esm({
|
|
|
8286
8310
|
requireCapabilityFit(job, this.capabilities);
|
|
8287
8311
|
return job;
|
|
8288
8312
|
}
|
|
8289
|
-
/**
|
|
8313
|
+
/**
|
|
8314
|
+
* Validates a lease against the published `JobLease` schema, its job, lease coherence, and the
|
|
8315
|
+
* lease features of the capability snapshot.
|
|
8316
|
+
*/
|
|
8290
8317
|
async validateJobLease(leaseUnknown) {
|
|
8291
8318
|
if (!isRecord(leaseUnknown)) throw new ProtocolError("Invalid job lease");
|
|
8292
8319
|
const { job: jobUnknown, ...envelope } = leaseUnknown;
|
|
@@ -8296,6 +8323,7 @@ var init_protocol_validator = __esm({
|
|
|
8296
8323
|
job
|
|
8297
8324
|
});
|
|
8298
8325
|
requireLeaseCoherence(lease);
|
|
8326
|
+
requireLeaseFeatureFit(lease, this.capabilities);
|
|
8299
8327
|
return lease;
|
|
8300
8328
|
}
|
|
8301
8329
|
/** Validates a lease and narrows it to the `oci` shape this runner executes. */
|
|
@@ -8566,7 +8594,7 @@ var init_staging_scavenger = __esm({
|
|
|
8566
8594
|
});
|
|
8567
8595
|
|
|
8568
8596
|
// ts/runner.ts
|
|
8569
|
-
var identifierPattern4, genericSystemError, containsControlCharacter, defaultSleep2, identityFor, safeIdentityFromUnknown, isDefinitiveConflict, LeaseGuard,
|
|
8597
|
+
var identifierPattern4, genericSystemError, containsControlCharacter, defaultSleep2, identityFor, safeIdentityFromUnknown, isDefinitiveConflict, LeaseGuard, runnerCapabilities, reconcileProtocolLimits, ShipRunner;
|
|
8570
8598
|
var init_runner = __esm({
|
|
8571
8599
|
"ts/runner.ts"() {
|
|
8572
8600
|
init_attempt_state();
|
|
@@ -8675,7 +8703,6 @@ var init_runner = __esm({
|
|
|
8675
8703
|
if (this.timer !== void 0) clearTimeout(this.timer);
|
|
8676
8704
|
}
|
|
8677
8705
|
};
|
|
8678
|
-
resourceLimitsSpecVersion = "1.1.0";
|
|
8679
8706
|
runnerCapabilities = /* @__PURE__ */ __name((config, runtime) => {
|
|
8680
8707
|
const artifactEnabled = config.maximumArtifacts > 0 && config.maximumArtifactBytes > 0 && config.maximumArtifactExtractedBytes > 0 && config.maximumArtifactEntries > 0;
|
|
8681
8708
|
const cacheEnabled = config.maximumCaches > 0 && config.maximumCacheArchiveBytes > 0 && config.maximumCacheExtractedBytes > 0 && config.maximumCacheEntries > 0;
|
|
@@ -8729,15 +8756,11 @@ var init_runner = __esm({
|
|
|
8729
8756
|
maximumCpus: config.oci.maximumCpus,
|
|
8730
8757
|
maximumPids: config.oci.maximumPids,
|
|
8731
8758
|
maximumSharedMemoryBytes: config.oci.maximumSharedMemoryBytes
|
|
8732
|
-
}
|
|
8759
|
+
},
|
|
8760
|
+
leaseFeatures: [],
|
|
8761
|
+
maximumTimeoutMs: config.oci.maximumTimeoutMs
|
|
8733
8762
|
});
|
|
8734
8763
|
}, "runnerCapabilities");
|
|
8735
|
-
capabilitiesForCoordinator = /* @__PURE__ */ __name((capabilities, discovery) => {
|
|
8736
|
-
const messageSpec = lowerSpecVersion(discovery.spec, runnerSpecVersion);
|
|
8737
|
-
if (compareSpecVersions(messageSpec, resourceLimitsSpecVersion) >= 0) return capabilities;
|
|
8738
|
-
const { resources: _resources, ...withoutResources } = capabilities;
|
|
8739
|
-
return createRunnerCapabilitySnapshot(withoutResources);
|
|
8740
|
-
}, "capabilitiesForCoordinator");
|
|
8741
8764
|
reconcileProtocolLimits = /* @__PURE__ */ __name((config, discovery, capabilities) => {
|
|
8742
8765
|
if (!specMajorVersionsMatch(discovery.spec, runnerSpecVersion)) {
|
|
8743
8766
|
throw new ProtocolError(`Coordinator specification ${discovery.spec} is incompatible with runner specification ${runnerSpecVersion}`);
|
|
@@ -8785,7 +8808,7 @@ var init_runner = __esm({
|
|
|
8785
8808
|
this.dependencies.api.setRunnerToken(this.config.runnerToken);
|
|
8786
8809
|
const runtime = await this.dependencies.executor.verifyRuntime();
|
|
8787
8810
|
const discovery = await this.dependencies.api.discover(options.signal);
|
|
8788
|
-
const capabilities =
|
|
8811
|
+
const capabilities = runnerCapabilities(this.config, runtime);
|
|
8789
8812
|
reconcileProtocolLimits(this.config, discovery, capabilities);
|
|
8790
8813
|
const validator = new RunnerProtocolValidator(capabilities);
|
|
8791
8814
|
const session = await this.dependencies.api.startSession({
|
|
@@ -9859,7 +9882,7 @@ Bootstrap credentials must be supplied through SHIP_RUNNER_BOOTSTRAP_TOKEN or th
|
|
|
9859
9882
|
const executor = new OciExecutor(config);
|
|
9860
9883
|
const runtime = await executor.verifyRuntime();
|
|
9861
9884
|
const discovery = await api.discover();
|
|
9862
|
-
const capabilities =
|
|
9885
|
+
const capabilities = runnerCapabilities(config, runtime);
|
|
9863
9886
|
reconcileProtocolLimits(config, discovery, capabilities);
|
|
9864
9887
|
const registered = await registerRunnerDurably({
|
|
9865
9888
|
configPath: path,
|
|
@@ -10003,8 +10026,6 @@ export {
|
|
|
10003
10026
|
buildOciRunCommand,
|
|
10004
10027
|
calculateWorkspaceVolumeLimits,
|
|
10005
10028
|
canonicalizeJson,
|
|
10006
|
-
capabilitiesForCoordinator,
|
|
10007
|
-
compareSpecVersions,
|
|
10008
10029
|
computeCompiledPlanDigest,
|
|
10009
10030
|
copyOciConfig,
|
|
10010
10031
|
createRunnerCapabilitySnapshot,
|
|
@@ -10012,7 +10033,6 @@ export {
|
|
|
10012
10033
|
isValidWireMessage,
|
|
10013
10034
|
isWireSchemaName,
|
|
10014
10035
|
loadRunnerConfig,
|
|
10015
|
-
lowerSpecVersion,
|
|
10016
10036
|
maskRunnerConfig,
|
|
10017
10037
|
minimumRedactionMemberBytes,
|
|
10018
10038
|
parseRunnerConfig,
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"binarySha256": "d69a00882fd822a2afecf456c38dcf828c164ec7241ce1ecfb0365d94061932b",
|
|
4
4
|
"buildInfo": {
|
|
5
5
|
"projectName": "@ship.zone/runner",
|
|
6
|
-
"projectVersion": "
|
|
7
|
-
"gitCommit": "
|
|
6
|
+
"projectVersion": "2.0.0",
|
|
7
|
+
"gitCommit": "a6f054f5aa45bfe86054b7a266d836d7318c4546",
|
|
8
8
|
"gitDirty": false,
|
|
9
|
-
"builtAt": "2026-09-
|
|
9
|
+
"builtAt": "2026-09-27T19:54:14.422Z",
|
|
10
10
|
"tsrustVersion": "1.15.1",
|
|
11
11
|
"binary": "runnerworkspace",
|
|
12
12
|
"target": "linux_amd64_musl"
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"binarySha256": "7775abaf87eeaaf41bc47607734e704e8c63b99fdcceeb6c692397536ba7b394",
|
|
4
4
|
"buildInfo": {
|
|
5
5
|
"projectName": "@ship.zone/runner",
|
|
6
|
-
"projectVersion": "
|
|
7
|
-
"gitCommit": "
|
|
6
|
+
"projectVersion": "2.0.0",
|
|
7
|
+
"gitCommit": "a6f054f5aa45bfe86054b7a266d836d7318c4546",
|
|
8
8
|
"gitDirty": false,
|
|
9
|
-
"builtAt": "2026-09-
|
|
9
|
+
"builtAt": "2026-09-27T19:54:22.712Z",
|
|
10
10
|
"tsrustVersion": "1.15.1",
|
|
11
11
|
"binary": "runnerworkspace",
|
|
12
12
|
"target": "linux_arm64_musl"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ship.zone/runner",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "The isolated OCI job runner for ship.zone CI/CD",
|
|
5
5
|
"homepage": "https://code.foss.global/ship.zone/runner",
|
|
6
6
|
"bugs": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@
|
|
32
|
+
"@ship.zone/ci-spec": "2.0.0",
|
|
33
33
|
"ajv": "^8.20.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
package/readme.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @ship.zone/runner
|
|
2
2
|
|
|
3
3
|
`@ship.zone/runner` is the outbound-only OCI execution agent for ship.zone CI/CD. It implements the
|
|
4
|
-
runner protocol of `@
|
|
4
|
+
runner protocol of `@ship.zone/ci-spec` (2.0.0) for the `oci` execution profile, validates leases
|
|
5
5
|
and compiled jobs against the published schemas, and runs one fenced attempt at a time on a local
|
|
6
6
|
Docker or Podman engine.
|
|
7
7
|
|
|
@@ -44,13 +44,14 @@ Requests directly.
|
|
|
44
44
|
- Step containers receive exactly the compiled step environment plus job secrets. Secret values are
|
|
45
45
|
passed through the runtime environment rather than OCI command arguments.
|
|
46
46
|
- The attempt's redaction set holds every secret value, every npm grant token, and each line of a
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
value containing a line terminator (CR LF, LF, or CR), leaving out members shorter than 8 UTF-8
|
|
48
|
+
bytes; a short line of a multi-line value stays unmasked when printed on its own. Every member is
|
|
49
|
+
replaced with `***` in log output, per stream and across the attempt's interleaved chunk sequence,
|
|
50
|
+
so no chunk and no concatenation of consecutive chunks contains one. An artifact or cache archive
|
|
51
|
+
whose entry path, link target, or file content contains a member is never published: a required
|
|
52
|
+
artifact or a cache completes the attempt `system_error`, an optional artifact is omitted and
|
|
53
|
+
reported. Redaction matches exact bytes; a job that transforms a value can still disclose it, so
|
|
54
|
+
the coordinator must not grant protected secrets to untrusted jobs.
|
|
54
55
|
|
|
55
56
|
## Requirements
|
|
56
57
|
|
|
@@ -225,21 +226,28 @@ terminates the attempt as `system_error`; output is never silently truncated.
|
|
|
225
226
|
|
|
226
227
|
## Runner Protocol
|
|
227
228
|
|
|
228
|
-
The runner implements the specification version of the `@
|
|
229
|
-
against (its `ciSpecVersion`, currently
|
|
229
|
+
The runner implements the specification version of the `@ship.zone/ci-spec` package it is built
|
|
230
|
+
against (its `ciSpecVersion`, currently 2.0.0), and sends it as `spec` in registration and session
|
|
230
231
|
requests. It refuses a coordinator whose discovery, registration, or session `spec` has another
|
|
231
|
-
major version,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
accepted only when its `spec` has the same
|
|
235
|
-
version; any other job is abandoned as
|
|
232
|
+
major version, so a 2.x runner never talks to a 1.x (`@foss.global/ci-spec`) coordinator, and a
|
|
233
|
+
coordinator answers a runner of another major version with HTTP 409 `spec_incompatible`. Every
|
|
234
|
+
capability the runner advertises is defined in 2.0.0, so it sends the same capability snapshot to
|
|
235
|
+
every coordinator of major version 2. A leased job is accepted only when its `spec` has the same
|
|
236
|
+
major version and is not newer than the implemented version; any other job is abandoned as
|
|
237
|
+
`runner_error`.
|
|
236
238
|
|
|
237
239
|
The runner advertises the `oci` profile, `container` isolation, the native `linux/<arch>` platform
|
|
238
|
-
of its verified OCI engine, the `none` network mode, its transfer limits,
|
|
239
|
-
memory, CPUs, PIDs, and shared memory
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
`
|
|
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`.
|
|
247
|
+
|
|
248
|
+
The reserved step environment names are `SHIPZONE_CI_MATRIX_JSON` and `SHIPZONE_CI_INPUTS_JSON`,
|
|
249
|
+
each carrying canonical RFC 8785 JSON. A job whose step environment defines any other
|
|
250
|
+
`SHIPZONE_CI_*` name, or whose secret targets use any `SHIPZONE_CI_*` name, is rejected.
|
|
243
251
|
|
|
244
252
|
All endpoints are below `/api/runner`. Registration uses the one-time bootstrap bearer token;
|
|
245
253
|
subsequent requests use the renewable runner credential. Every request body is validated against its
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/cli.ts
CHANGED
|
@@ -19,12 +19,7 @@ import type {
|
|
|
19
19
|
import { runnerVersion } from './interfaces.ts';
|
|
20
20
|
import { OciExecutor } from './oci-executor.ts';
|
|
21
21
|
import { RegistrationStateStore } from './registration-state.ts';
|
|
22
|
-
import {
|
|
23
|
-
capabilitiesForCoordinator,
|
|
24
|
-
reconcileProtocolLimits,
|
|
25
|
-
runnerCapabilities,
|
|
26
|
-
ShipRunner,
|
|
27
|
-
} from './runner.ts';
|
|
22
|
+
import { reconcileProtocolLimits, runnerCapabilities, ShipRunner } from './runner.ts';
|
|
28
23
|
import { runnerSpecVersion } from './spec-version.ts';
|
|
29
24
|
import { SourceWorkspaceManager } from './source-workspace.ts';
|
|
30
25
|
|
|
@@ -156,7 +151,7 @@ const runRegister = async (options: Map<string, string | true>): Promise<void> =
|
|
|
156
151
|
const executor = new OciExecutor(config);
|
|
157
152
|
const runtime = await executor.verifyRuntime();
|
|
158
153
|
const discovery = await api.discover();
|
|
159
|
-
const capabilities =
|
|
154
|
+
const capabilities = runnerCapabilities(config, runtime);
|
|
160
155
|
reconcileProtocolLimits(config, discovery, capabilities);
|
|
161
156
|
const registered = await registerRunnerDurably({
|
|
162
157
|
configPath: path,
|
package/ts/interfaces.ts
CHANGED
|
@@ -5,6 +5,7 @@ export const runnerVersion: string = denoConfig.version;
|
|
|
5
5
|
export type TExecutionProfile = 'oci' | 'oci-image' | 'vm';
|
|
6
6
|
export type TIsolation = 'container' | 'microvm';
|
|
7
7
|
export type TRunnerFeature = 'source.tar-gz' | 'artifacts' | 'caches';
|
|
8
|
+
export type TLeaseFeature = 'image-pull-grants' | 'candidate-bindings' | 'npm-read-grants';
|
|
8
9
|
export type TNetworkMode = 'none' | 'egress';
|
|
9
10
|
export type TSourceFormat = 'tar.gz';
|
|
10
11
|
export type TOciRuntime = 'docker' | 'podman';
|
|
@@ -89,7 +90,12 @@ export interface IRunnerCapabilities {
|
|
|
89
90
|
networks: TNetworkMode[];
|
|
90
91
|
sourceFormats: TSourceFormat[];
|
|
91
92
|
limits: ITransferLimits;
|
|
93
|
+
/** The largest resource ceilings the runner enforces per attempt. */
|
|
92
94
|
resources?: IResourceLimits;
|
|
95
|
+
/** The lease contents the runner uses. */
|
|
96
|
+
leaseFeatures?: TLeaseFeature[];
|
|
97
|
+
/** The largest job `timeoutMs` the runner executes. */
|
|
98
|
+
maximumTimeoutMs?: number;
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
export interface IRegisterRunnerRequest {
|
package/ts/oci-executor.ts
CHANGED
|
@@ -56,8 +56,8 @@ const maximumWorkspaceHelperErrorBytes = 512;
|
|
|
56
56
|
const hostTmpfsProbeMaximumAgeMs = 60 * 60 * 1000;
|
|
57
57
|
const runtimeProbeVolumeMaximumAgeMs = 60 * 60 * 1000;
|
|
58
58
|
const runtimeProbeOwnerIdPattern = /^[a-f0-9]{32}$/;
|
|
59
|
-
const hostTmpfsProbeNamePattern = /^
|
|
60
|
-
const runtimeProbeVolumeNamePattern = /^
|
|
59
|
+
const hostTmpfsProbeNamePattern = /^shipzone-ci-probe-([a-f0-9]{32})-[a-f0-9]{16}$/;
|
|
60
|
+
const runtimeProbeVolumeNamePattern = /^shipzone-ci-volume-[a-f0-9]{32}$/;
|
|
61
61
|
const workspaceHelperDirectoryName = 'workspace-helpers';
|
|
62
62
|
const workspaceHelperLockName = '.workspace-helper.lock';
|
|
63
63
|
const runtimeProbeOwnerMarkerPrefix = '.runtime-probe-owner_';
|
|
@@ -573,8 +573,8 @@ const validateStepCommand = (command: string[]): void => {
|
|
|
573
573
|
|
|
574
574
|
const validateGeneratedName = (value: string, kind: 'container' | 'volume'): string => {
|
|
575
575
|
const pattern = kind === 'container'
|
|
576
|
-
? /^
|
|
577
|
-
: /^
|
|
576
|
+
? /^shipzone-ci-(?:helper|probe|step)-[a-f0-9]{32}$/
|
|
577
|
+
: /^shipzone-ci-volume-[a-f0-9]{32}$/;
|
|
578
578
|
if (!pattern.test(value)) throw new ProtocolError(`Runner generated an invalid OCI ${kind} name`);
|
|
579
579
|
return value;
|
|
580
580
|
};
|
|
@@ -839,8 +839,8 @@ const validateLeasePolicy = (
|
|
|
839
839
|
sessionId: context.sessionId,
|
|
840
840
|
lease: context.lease,
|
|
841
841
|
step,
|
|
842
|
-
containerName: `
|
|
843
|
-
volumeName: `
|
|
842
|
+
containerName: `shipzone-ci-step-${'0'.repeat(32)}`,
|
|
843
|
+
volumeName: `shipzone-ci-volume-${'0'.repeat(32)}`,
|
|
844
844
|
});
|
|
845
845
|
}
|
|
846
846
|
};
|
|
@@ -1387,7 +1387,8 @@ export class OciExecutor implements IJobExecutor {
|
|
|
1387
1387
|
for (const line of decode(containers.stdout).split('\n').filter(Boolean)) {
|
|
1388
1388
|
const [name, sessionId] = line.split('|', 2);
|
|
1389
1389
|
if (
|
|
1390
|
-
/^
|
|
1390
|
+
/^shipzone-ci-(?:helper|probe|step)-[a-f0-9]{32}$/.test(name) &&
|
|
1391
|
+
sessionId !== currentSessionId
|
|
1391
1392
|
) {
|
|
1392
1393
|
await this.stopAndRemoveContainer(name);
|
|
1393
1394
|
}
|
|
@@ -1405,7 +1406,7 @@ export class OciExecutor implements IJobExecutor {
|
|
|
1405
1406
|
requireSuccess(volumes, 'Unable to enumerate orphan OCI volumes');
|
|
1406
1407
|
for (const line of decode(volumes.stdout).split('\n').filter(Boolean)) {
|
|
1407
1408
|
const [name, sessionId] = line.split('|', 2);
|
|
1408
|
-
if (/^
|
|
1409
|
+
if (/^shipzone-ci-volume-[a-f0-9]{32}$/.test(name) && sessionId !== currentSessionId) {
|
|
1409
1410
|
await this.removeVolume(name);
|
|
1410
1411
|
}
|
|
1411
1412
|
}
|
|
@@ -2315,7 +2316,7 @@ export class OciExecutor implements IJobExecutor {
|
|
|
2315
2316
|
await scavengeHostTmpfsProbes('/dev/shm', {}, runtimeProbeOwnerId);
|
|
2316
2317
|
path = await Deno.makeTempDir({
|
|
2317
2318
|
dir: '/dev/shm',
|
|
2318
|
-
prefix: `
|
|
2319
|
+
prefix: `shipzone-ci-probe-${runtimeProbeOwnerId}-`,
|
|
2319
2320
|
});
|
|
2320
2321
|
const before = await this.readFilesystemProbe(helperPath, path);
|
|
2321
2322
|
const first = join(path, 'first');
|
|
@@ -3117,7 +3118,7 @@ export class OciExecutor implements IJobExecutor {
|
|
|
3117
3118
|
}
|
|
3118
3119
|
|
|
3119
3120
|
private createResourceName(kind: 'helper' | 'probe' | 'step' | 'volume'): string {
|
|
3120
|
-
const name = `
|
|
3121
|
+
const name = `shipzone-ci-${kind}-${this.randomHex()}`;
|
|
3121
3122
|
return validateGeneratedName(name, kind === 'volume' ? 'volume' : 'container');
|
|
3122
3123
|
}
|
|
3123
3124
|
|
package/ts/plugins.ts
CHANGED
|
@@ -4,16 +4,16 @@ export {
|
|
|
4
4
|
executionProfileIdentifiers,
|
|
5
5
|
maximumArchivePathMetadataBytes,
|
|
6
6
|
runnerProtocolBasePath,
|
|
7
|
-
} from '@
|
|
7
|
+
} from '@ship.zone/ci-spec';
|
|
8
8
|
|
|
9
9
|
export const loadCiSpecArchiveCases = async (): Promise<unknown> =>
|
|
10
|
-
(await import('@
|
|
10
|
+
(await import('@ship.zone/ci-spec/archive-cases.json', { with: { type: 'json' } })).default;
|
|
11
11
|
|
|
12
12
|
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
13
13
|
export { Ajv2020 };
|
|
14
14
|
|
|
15
|
-
import runnerJobSchema from '@
|
|
15
|
+
import runnerJobSchema from '@ship.zone/ci-spec/runner-job.schema.json' with { type: 'json' };
|
|
16
16
|
export { runnerJobSchema };
|
|
17
17
|
|
|
18
|
-
import runnerOpenApi from '@
|
|
18
|
+
import runnerOpenApi from '@ship.zone/ci-spec/runner.openapi.json' with { type: 'json' };
|
|
19
19
|
export { runnerOpenApi };
|
package/ts/protocol-validator.ts
CHANGED
|
@@ -10,13 +10,14 @@ import type {
|
|
|
10
10
|
TImageReference,
|
|
11
11
|
TJsonObject,
|
|
12
12
|
TJsonValue,
|
|
13
|
+
TLeaseFeature,
|
|
13
14
|
} from './interfaces.ts';
|
|
14
15
|
import { acceptSpecVersion, runnerSpecVersion } from './spec-version.ts';
|
|
15
16
|
import { isRecord } from './validation.ts';
|
|
16
17
|
import { validateCompiledJobSchema, validateWireMessage } from './wire-schema.ts';
|
|
17
18
|
|
|
18
19
|
const sha256Pattern = /^[a-f0-9]{64}$/;
|
|
19
|
-
const reservedEnvironmentNames = ['
|
|
20
|
+
const reservedEnvironmentNames = ['SHIPZONE_CI_INPUTS_JSON', 'SHIPZONE_CI_MATRIX_JSON'] as const;
|
|
20
21
|
const npmUserConfigEnvironmentName = 'NPM_CONFIG_USERCONFIG';
|
|
21
22
|
const maximumCommandArgumentBytes = 16 * 1024;
|
|
22
23
|
const maximumCommandBytes = 128 * 1024;
|
|
@@ -214,6 +215,33 @@ const requireCapabilityFit = (
|
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
}
|
|
218
|
+
if (
|
|
219
|
+
capabilities.maximumTimeoutMs !== undefined && job.timeoutMs > capabilities.maximumTimeoutMs
|
|
220
|
+
) {
|
|
221
|
+
throw new ProtocolError('Job timeoutMs exceeds runner capability');
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Checks that a lease uses only the lease features of the capability snapshot: a pull grant
|
|
227
|
+
* requires `image-pull-grants`, a binding `candidate-bindings`, and `npmGrants`
|
|
228
|
+
* `npm-read-grants`. A snapshot without `leaseFeatures` imposes no such condition.
|
|
229
|
+
*/
|
|
230
|
+
const requireLeaseFeatureFit = (lease: IJobLease, capabilities: IRunnerCapabilities): void => {
|
|
231
|
+
const advertised = capabilities.leaseFeatures;
|
|
232
|
+
if (advertised === undefined) return;
|
|
233
|
+
const used: Array<[boolean, TLeaseFeature]> = [
|
|
234
|
+
[lease.grants.some((grant) => grant.access === 'pull'), 'image-pull-grants'],
|
|
235
|
+
[lease.bindings.length > 0, 'candidate-bindings'],
|
|
236
|
+
[lease.npmGrants !== undefined, 'npm-read-grants'],
|
|
237
|
+
];
|
|
238
|
+
for (const [uses, feature] of used) {
|
|
239
|
+
if (uses && !advertised.includes(feature)) {
|
|
240
|
+
throw new ProtocolError(
|
|
241
|
+
`Lease uses ${feature}, a lease feature this runner does not advertise`,
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
217
245
|
};
|
|
218
246
|
|
|
219
247
|
const requireTransferCoherence = (job: TCompiledRunnerJob): void => {
|
|
@@ -303,8 +331,8 @@ const requireExecutionCoherence = (job: TCompiledRunnerJob): void => {
|
|
|
303
331
|
const secretTargets = Object.keys(job.secrets);
|
|
304
332
|
const npmRead = job.npmRead !== undefined;
|
|
305
333
|
for (const secretName of secretTargets) {
|
|
306
|
-
if (secretName.startsWith('
|
|
307
|
-
throw new ProtocolError('Secret targets may not use reserved
|
|
334
|
+
if (secretName.startsWith('SHIPZONE_CI_')) {
|
|
335
|
+
throw new ProtocolError('Secret targets may not use reserved SHIPZONE_CI names');
|
|
308
336
|
}
|
|
309
337
|
if (npmRead && secretName === npmUserConfigEnvironmentName) {
|
|
310
338
|
throw new ProtocolError(`Secret targets may not use the reserved ${secretName}`);
|
|
@@ -329,11 +357,11 @@ const requireExecutionCoherence = (job: TCompiledRunnerJob): void => {
|
|
|
329
357
|
const environmentNames = Object.keys(step.environment);
|
|
330
358
|
for (const name of environmentNames) {
|
|
331
359
|
if (
|
|
332
|
-
name.startsWith('
|
|
360
|
+
name.startsWith('SHIPZONE_CI_') && !reservedEnvironmentNames.includes(
|
|
333
361
|
name as (typeof reservedEnvironmentNames)[number],
|
|
334
362
|
)
|
|
335
363
|
) {
|
|
336
|
-
throw new ProtocolError('Step environment uses an unknown reserved
|
|
364
|
+
throw new ProtocolError('Step environment uses an unknown reserved SHIPZONE_CI name');
|
|
337
365
|
}
|
|
338
366
|
if (npmRead && name === npmUserConfigEnvironmentName) {
|
|
339
367
|
throw new ProtocolError(`Step environment may not define the reserved ${name}`);
|
|
@@ -517,13 +545,17 @@ export class RunnerProtocolValidator {
|
|
|
517
545
|
return job;
|
|
518
546
|
}
|
|
519
547
|
|
|
520
|
-
/**
|
|
548
|
+
/**
|
|
549
|
+
* Validates a lease against the published `JobLease` schema, its job, lease coherence, and the
|
|
550
|
+
* lease features of the capability snapshot.
|
|
551
|
+
*/
|
|
521
552
|
public async validateJobLease(leaseUnknown: unknown): Promise<IJobLease> {
|
|
522
553
|
if (!isRecord(leaseUnknown)) throw new ProtocolError('Invalid job lease');
|
|
523
554
|
const { job: jobUnknown, ...envelope } = leaseUnknown;
|
|
524
555
|
const job = await this.validateJob(jobUnknown);
|
|
525
556
|
const lease = validateWireMessage<IJobLease>('JobLease', { ...envelope, job });
|
|
526
557
|
requireLeaseCoherence(lease);
|
|
558
|
+
requireLeaseFeatureFit(lease, this.capabilities);
|
|
527
559
|
return lease;
|
|
528
560
|
}
|
|
529
561
|
|
package/ts/runner.ts
CHANGED
|
@@ -45,12 +45,7 @@ import { runnerVersion } from './interfaces.ts';
|
|
|
45
45
|
import { LogSender } from './log-sender.ts';
|
|
46
46
|
import { createRunnerCapabilitySnapshot, RunnerProtocolValidator } from './protocol-validator.ts';
|
|
47
47
|
import { SecretRedactionSet } from './redactor.ts';
|
|
48
|
-
import {
|
|
49
|
-
compareSpecVersions,
|
|
50
|
-
lowerSpecVersion,
|
|
51
|
-
runnerSpecVersion,
|
|
52
|
-
specMajorVersionsMatch,
|
|
53
|
-
} from './spec-version.ts';
|
|
48
|
+
import { runnerSpecVersion, specMajorVersionsMatch } from './spec-version.ts';
|
|
54
49
|
import { scavengeRunnerStaging } from './staging-scavenger.ts';
|
|
55
50
|
|
|
56
51
|
export interface IRunnerCoordinatorClient {
|
|
@@ -209,16 +204,11 @@ class LeaseGuard {
|
|
|
209
204
|
}
|
|
210
205
|
}
|
|
211
206
|
|
|
212
|
-
/**
|
|
213
|
-
* The first specification version that defines the optional capability `resources`. This is a
|
|
214
|
-
* fixed fact of the specification history, not the version this runner implements.
|
|
215
|
-
*/
|
|
216
|
-
const resourceLimitsSpecVersion = '1.1.0';
|
|
217
|
-
|
|
218
207
|
/**
|
|
219
208
|
* The capabilities this runner advertises: the `oci` profile in `container` isolation on the
|
|
220
209
|
* native linux platform of its verified OCI engine, the `none` network mode, the configured
|
|
221
|
-
* transfer limits,
|
|
210
|
+
* transfer limits, the resource ceilings it enforces per attempt, no lease features (it uses no
|
|
211
|
+
* image grants, candidate bindings, or npm read grants), and its configured longest job timeout.
|
|
222
212
|
*/
|
|
223
213
|
export const runnerCapabilities = (
|
|
224
214
|
config: IRunnerConfig,
|
|
@@ -263,23 +253,11 @@ export const runnerCapabilities = (
|
|
|
263
253
|
maximumPids: config.oci.maximumPids,
|
|
264
254
|
maximumSharedMemoryBytes: config.oci.maximumSharedMemoryBytes,
|
|
265
255
|
},
|
|
256
|
+
leaseFeatures: [],
|
|
257
|
+
maximumTimeoutMs: config.oci.maximumTimeoutMs,
|
|
266
258
|
});
|
|
267
259
|
};
|
|
268
260
|
|
|
269
|
-
/**
|
|
270
|
-
* Restricts capabilities to the constructs defined at the lower of the coordinator and runner
|
|
271
|
-
* specification versions, the version every non-job message may use.
|
|
272
|
-
*/
|
|
273
|
-
export const capabilitiesForCoordinator = (
|
|
274
|
-
capabilities: IRunnerCapabilities,
|
|
275
|
-
discovery: Pick<IDiscoveryResponse, 'spec'>,
|
|
276
|
-
): IRunnerCapabilities => {
|
|
277
|
-
const messageSpec = lowerSpecVersion(discovery.spec, runnerSpecVersion);
|
|
278
|
-
if (compareSpecVersions(messageSpec, resourceLimitsSpecVersion) >= 0) return capabilities;
|
|
279
|
-
const { resources: _resources, ...withoutResources } = capabilities;
|
|
280
|
-
return createRunnerCapabilitySnapshot(withoutResources);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
261
|
export const reconcileProtocolLimits = (
|
|
284
262
|
config: IRunnerConfig,
|
|
285
263
|
discovery: IDiscoveryResponse,
|
|
@@ -344,10 +322,7 @@ export class ShipRunner {
|
|
|
344
322
|
|
|
345
323
|
const runtime = await this.dependencies.executor.verifyRuntime();
|
|
346
324
|
const discovery = await this.dependencies.api.discover(options.signal);
|
|
347
|
-
const capabilities =
|
|
348
|
-
runnerCapabilities(this.config, runtime),
|
|
349
|
-
discovery,
|
|
350
|
-
);
|
|
325
|
+
const capabilities = runnerCapabilities(this.config, runtime);
|
|
351
326
|
reconcileProtocolLimits(this.config, discovery, capabilities);
|
|
352
327
|
const validator = new RunnerProtocolValidator(capabilities);
|
|
353
328
|
const session = await this.dependencies.api.startSession({
|
package/ts/spec-version.ts
CHANGED
|
@@ -53,14 +53,3 @@ export const acceptSpecVersion = (implemented: string, declared: unknown): TSpec
|
|
|
53
53
|
export const specMajorVersionsMatch = (left: string, right: string): boolean =>
|
|
54
54
|
requireCanonical(left, 'Specification version').major ===
|
|
55
55
|
requireCanonical(right, 'Specification version').major;
|
|
56
|
-
|
|
57
|
-
/** Compares two canonical specification versions numerically. */
|
|
58
|
-
export const compareSpecVersions = (left: string, right: string): number =>
|
|
59
|
-
compareParts(
|
|
60
|
-
requireCanonical(left, 'Specification version'),
|
|
61
|
-
requireCanonical(right, 'Specification version'),
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
/** The lower of two canonical versions: the version whose constructs a message may use. */
|
|
65
|
-
export const lowerSpecVersion = (left: string, right: string): string =>
|
|
66
|
-
compareSpecVersions(left, right) <= 0 ? left : right;
|
package/ts/wire-schema.ts
CHANGED
|
@@ -39,12 +39,13 @@ export const isWireSchemaName = (value: unknown): value is TWireSchemaName =>
|
|
|
39
39
|
typeof value === 'string' && (wireSchemaNames as readonly string[]).includes(value);
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* The
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* The document identifiers of the runner protocol (Document Identifiers): the compiled job schema
|
|
43
|
+
* carries its identifier as `$id`, and the OpenAPI components are registered under the
|
|
44
|
+
* description's identifier, against which its `../schemas/runner-job.schema.json` references
|
|
45
|
+
* resolve to that `$id`.
|
|
45
46
|
*/
|
|
46
|
-
const openApiSchemaId = 'https://
|
|
47
|
-
const
|
|
47
|
+
const openApiSchemaId = 'https://ship.zone/spec/ci/spec/runner.openapi.json';
|
|
48
|
+
const runnerJobSchemaId = 'https://ship.zone/spec/ci/schemas/runner-job.schema.json';
|
|
48
49
|
|
|
49
50
|
const rewriteComponentReferences = (value: unknown): unknown => {
|
|
50
51
|
if (Array.isArray(value)) return value.map(rewriteComponentReferences);
|
|
@@ -73,7 +74,7 @@ const componentSchemas = (): unknown => {
|
|
|
73
74
|
|
|
74
75
|
const ajv = new plugins.Ajv2020({ allErrors: true, strict: true });
|
|
75
76
|
ajv.addFormat('date-time', { type: 'string', validate: isProtocolTimestamp });
|
|
76
|
-
ajv.addSchema(plugins.runnerJobSchema
|
|
77
|
+
ajv.addSchema(plugins.runnerJobSchema);
|
|
77
78
|
ajv.addSchema({
|
|
78
79
|
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
79
80
|
$id: openApiSchemaId,
|
|
@@ -134,4 +135,4 @@ export const validateWireMessage = <T>(name: TWireSchemaName, value: unknown): T
|
|
|
134
135
|
|
|
135
136
|
/** Validates a compiled runner job against the published runner job schema. */
|
|
136
137
|
export const validateCompiledJobSchema = <T>(value: unknown): T =>
|
|
137
|
-
assertValid<T>(validatorFor(
|
|
138
|
+
assertValid<T>(validatorFor(runnerJobSchemaId), value, 'Compiled runner job');
|