@ship.zone/runner 0.2.4 → 1.1.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 +74 -0
- package/deno.json +18 -4
- package/deno.lock +143 -224
- package/dist_npm/mod.d.ts +297 -39
- package/dist_npm/mod.js +941 -628
- package/dist_rust/runnerworkspace_linux_amd64_musl +0 -0
- package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +14 -0
- package/dist_rust/runnerworkspace_linux_arm64_musl +0 -0
- package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +14 -0
- package/package.json +3 -3
- package/readme.md +65 -18
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/api-client.ts +85 -304
- package/ts/artifact-manager.ts +9 -3
- package/ts/cache-manager.ts +3 -2
- package/ts/cli.ts +16 -6
- package/ts/config.ts +50 -16
- package/ts/errors.ts +11 -0
- package/ts/index.ts +2 -0
- package/ts/interfaces.ts +196 -32
- package/ts/log-sender.ts +18 -9
- package/ts/oci-executor.ts +48 -22
- package/ts/plugins.ts +5 -1
- package/ts/protocol-validator.ts +261 -224
- package/ts/redactor.ts +229 -20
- package/ts/registration-state.ts +12 -45
- package/ts/runner.ts +116 -22
- package/ts/spec-version.ts +66 -0
- package/ts/transfer-archive.ts +25 -3
- package/ts/validation.ts +20 -0
- package/ts/wire-schema.ts +137 -0
package/dist_npm/mod.js
CHANGED
|
@@ -11,7 +11,7 @@ var __export = (target, all) => {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// ts/errors.ts
|
|
14
|
-
var RunnerError, ResourceCleanupError, ConfigurationError, CoordinatorError, AuthenticationError, LeaseLostError, ProtocolError;
|
|
14
|
+
var RunnerError, ResourceCleanupError, ConfigurationError, CoordinatorError, AuthenticationError, LeaseLostError, ProtocolError, SecretDisclosureError;
|
|
15
15
|
var init_errors = __esm({
|
|
16
16
|
"ts/errors.ts"() {
|
|
17
17
|
RunnerError = class extends Error {
|
|
@@ -91,20 +91,77 @@ var init_errors = __esm({
|
|
|
91
91
|
this.name = "ProtocolError";
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
+
SecretDisclosureError = class extends RunnerError {
|
|
95
|
+
static {
|
|
96
|
+
__name(this, "SecretDisclosureError");
|
|
97
|
+
}
|
|
98
|
+
constructor(message = "Archive contains a redacted secret value and was not published") {
|
|
99
|
+
super(message);
|
|
100
|
+
this.name = "SecretDisclosureError";
|
|
101
|
+
}
|
|
102
|
+
};
|
|
94
103
|
}
|
|
95
104
|
});
|
|
96
105
|
|
|
97
106
|
// ts/plugins.ts
|
|
98
|
-
import { ciSpecStatus, maximumArchivePathMetadataBytes, runnerProtocolBasePath
|
|
107
|
+
import { ciSpecStatus, ciSpecVersion, executionProfileIdentifiers, maximumArchivePathMetadataBytes, runnerProtocolBasePath } from "@foss.global/ci-spec";
|
|
99
108
|
import { Ajv2020 } from "ajv/dist/2020.js";
|
|
100
109
|
import runnerJobSchema from "@foss.global/ci-spec/runner-job.schema.json" with { type: "json" };
|
|
110
|
+
import runnerOpenApi from "@foss.global/ci-spec/runner.openapi.json" with { type: "json" };
|
|
101
111
|
var init_plugins = __esm({
|
|
102
112
|
"ts/plugins.ts"() {
|
|
103
113
|
}
|
|
104
114
|
});
|
|
105
115
|
|
|
116
|
+
// ts/spec-version.ts
|
|
117
|
+
var canonicalSpecVersionPattern, parseSpecVersion, requireCanonical, compareParts, runnerSpecVersion, acceptSpecVersion, specMajorVersionsMatch, compareSpecVersions, lowerSpecVersion;
|
|
118
|
+
var init_spec_version = __esm({
|
|
119
|
+
"ts/spec-version.ts"() {
|
|
120
|
+
init_errors();
|
|
121
|
+
init_plugins();
|
|
122
|
+
canonicalSpecVersionPattern = /^(0|[1-9][0-9]{0,14})\.(0|[1-9][0-9]{0,14})\.(0|[1-9][0-9]{0,14})$/;
|
|
123
|
+
parseSpecVersion = /* @__PURE__ */ __name((value) => {
|
|
124
|
+
if (typeof value !== "string") return void 0;
|
|
125
|
+
const match = canonicalSpecVersionPattern.exec(value);
|
|
126
|
+
if (!match) return void 0;
|
|
127
|
+
return {
|
|
128
|
+
major: BigInt(match[1]),
|
|
129
|
+
minor: BigInt(match[2]),
|
|
130
|
+
patch: BigInt(match[3])
|
|
131
|
+
};
|
|
132
|
+
}, "parseSpecVersion");
|
|
133
|
+
requireCanonical = /* @__PURE__ */ __name((value, field2) => {
|
|
134
|
+
const parts = parseSpecVersion(value);
|
|
135
|
+
if (!parts) throw new ProtocolError(`${field2} is not a canonical specification version`);
|
|
136
|
+
return parts;
|
|
137
|
+
}, "requireCanonical");
|
|
138
|
+
compareParts = /* @__PURE__ */ __name((left, right) => {
|
|
139
|
+
for (const key of [
|
|
140
|
+
"major",
|
|
141
|
+
"minor",
|
|
142
|
+
"patch"
|
|
143
|
+
]) {
|
|
144
|
+
if (left[key] !== right[key]) return left[key] < right[key] ? -1 : 1;
|
|
145
|
+
}
|
|
146
|
+
return 0;
|
|
147
|
+
}, "compareParts");
|
|
148
|
+
runnerSpecVersion = ciSpecVersion;
|
|
149
|
+
requireCanonical(runnerSpecVersion, "The implemented specification version");
|
|
150
|
+
acceptSpecVersion = /* @__PURE__ */ __name((implemented, declared) => {
|
|
151
|
+
const implementedParts = requireCanonical(implemented, "The implemented specification version");
|
|
152
|
+
const declaredParts = parseSpecVersion(declared);
|
|
153
|
+
if (!declaredParts) return "malformed";
|
|
154
|
+
if (declaredParts.major !== implementedParts.major) return "major-mismatch";
|
|
155
|
+
return compareParts(declaredParts, implementedParts) > 0 ? "newer" : "accepted";
|
|
156
|
+
}, "acceptSpecVersion");
|
|
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
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
106
163
|
// ts/validation.ts
|
|
107
|
-
var isRecord, validateIdentifier, validateEnvironmentName, validateHttpUrl, utf8Length;
|
|
164
|
+
var isRecord, validateIdentifier, validateEnvironmentName, validateHttpUrl, utf8Length, protocolTimestampPattern, isProtocolTimestamp;
|
|
108
165
|
var init_validation = __esm({
|
|
109
166
|
"ts/validation.ts"() {
|
|
110
167
|
init_errors();
|
|
@@ -145,16 +202,143 @@ var init_validation = __esm({
|
|
|
145
202
|
throw new ConfigurationError(`${field2} must use HTTPS`);
|
|
146
203
|
}, "validateHttpUrl");
|
|
147
204
|
utf8Length = /* @__PURE__ */ __name((value) => new TextEncoder().encode(value).byteLength, "utf8Length");
|
|
205
|
+
protocolTimestampPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/;
|
|
206
|
+
isProtocolTimestamp = /* @__PURE__ */ __name((value) => {
|
|
207
|
+
const match = protocolTimestampPattern.exec(value);
|
|
208
|
+
if (!match || !Number.isFinite(Date.parse(value))) return false;
|
|
209
|
+
const year = Number(match[1]);
|
|
210
|
+
const month = Number(match[2]);
|
|
211
|
+
const day = Number(match[3]);
|
|
212
|
+
const hour = Number(match[4]);
|
|
213
|
+
const minute = Number(match[5]);
|
|
214
|
+
const second = Number(match[6]);
|
|
215
|
+
const offsetHour = match[7] === void 0 ? 0 : Number(match[7]);
|
|
216
|
+
const offsetMinute = match[8] === void 0 ? 0 : Number(match[8]);
|
|
217
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= new Date(Date.UTC(year, month, 0)).getUTCDate() && hour <= 23 && minute <= 59 && second <= 59 && offsetHour <= 23 && offsetMinute <= 59;
|
|
218
|
+
}, "isProtocolTimestamp");
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// ts/wire-schema.ts
|
|
223
|
+
var wireSchemaNames, isWireSchemaName, openApiSchemaId, runnerJobSchemaKey, rewriteComponentReferences, componentSchemas, ajv, validatorCache, validatorFor, componentValidator, sanitizeErrorText, safeErrorDetails, assertValid, isValidWireMessage, validateWireMessage, validateCompiledJobSchema;
|
|
224
|
+
var init_wire_schema = __esm({
|
|
225
|
+
"ts/wire-schema.ts"() {
|
|
226
|
+
init_errors();
|
|
227
|
+
init_plugins();
|
|
228
|
+
init_validation();
|
|
229
|
+
wireSchemaNames = [
|
|
230
|
+
"AbandonJobRequest",
|
|
231
|
+
"AcceptJobRequest",
|
|
232
|
+
"ClaimJobRequest",
|
|
233
|
+
"ClaimJobResponse",
|
|
234
|
+
"CompleteJobRequest",
|
|
235
|
+
"CompleteJobResponse",
|
|
236
|
+
"DiscoveryResponse",
|
|
237
|
+
"ErrorResponse",
|
|
238
|
+
"ImageBinding",
|
|
239
|
+
"ImageGrant",
|
|
240
|
+
"ImageRecord",
|
|
241
|
+
"JobHeartbeatRequest",
|
|
242
|
+
"JobHeartbeatResponse",
|
|
243
|
+
"JobLease",
|
|
244
|
+
"LogAcknowledgement",
|
|
245
|
+
"LogChunk",
|
|
246
|
+
"NpmGrant",
|
|
247
|
+
"RecordImageRequest",
|
|
248
|
+
"RecoverAttemptRequest",
|
|
249
|
+
"RegisterRunnerRequest",
|
|
250
|
+
"RegisterRunnerResponse",
|
|
251
|
+
"RunnerCapabilities",
|
|
252
|
+
"RunnerHeartbeatRequest",
|
|
253
|
+
"RunnerHeartbeatResponse",
|
|
254
|
+
"StartSessionRequest",
|
|
255
|
+
"StartSessionResponse",
|
|
256
|
+
"TransferRecord"
|
|
257
|
+
];
|
|
258
|
+
isWireSchemaName = /* @__PURE__ */ __name((value) => typeof value === "string" && wireSchemaNames.includes(value), "isWireSchemaName");
|
|
259
|
+
openApiSchemaId = "https://foss.global/spec/runner.openapi.json";
|
|
260
|
+
runnerJobSchemaKey = "https://foss.global/schemas/runner-job.schema.json";
|
|
261
|
+
rewriteComponentReferences = /* @__PURE__ */ __name((value) => {
|
|
262
|
+
if (Array.isArray(value)) return value.map(rewriteComponentReferences);
|
|
263
|
+
if (!isRecord(value)) return value;
|
|
264
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
|
|
265
|
+
key,
|
|
266
|
+
key === "$ref" && typeof entry === "string" ? entry.replace("#/components/schemas/", "#/$defs/") : rewriteComponentReferences(entry)
|
|
267
|
+
]));
|
|
268
|
+
}, "rewriteComponentReferences");
|
|
269
|
+
componentSchemas = /* @__PURE__ */ __name(() => {
|
|
270
|
+
const document = runnerOpenApi;
|
|
271
|
+
if (!isRecord(document) || !isRecord(document.components)) {
|
|
272
|
+
throw new ProtocolError("The published runner OpenAPI document has no components");
|
|
273
|
+
}
|
|
274
|
+
const schemas = document.components.schemas;
|
|
275
|
+
if (!isRecord(schemas)) {
|
|
276
|
+
throw new ProtocolError("The published runner OpenAPI document has no component schemas");
|
|
277
|
+
}
|
|
278
|
+
return rewriteComponentReferences(schemas);
|
|
279
|
+
}, "componentSchemas");
|
|
280
|
+
ajv = new Ajv2020({
|
|
281
|
+
allErrors: true,
|
|
282
|
+
strict: true
|
|
283
|
+
});
|
|
284
|
+
ajv.addFormat("date-time", {
|
|
285
|
+
type: "string",
|
|
286
|
+
validate: isProtocolTimestamp
|
|
287
|
+
});
|
|
288
|
+
ajv.addSchema(runnerJobSchema, runnerJobSchemaKey);
|
|
289
|
+
ajv.addSchema({
|
|
290
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
291
|
+
$id: openApiSchemaId,
|
|
292
|
+
$defs: componentSchemas()
|
|
293
|
+
});
|
|
294
|
+
validatorCache = /* @__PURE__ */ new Map();
|
|
295
|
+
validatorFor = /* @__PURE__ */ __name((reference) => {
|
|
296
|
+
const cached = validatorCache.get(reference);
|
|
297
|
+
if (cached) return cached;
|
|
298
|
+
const validate = ajv.getSchema(reference);
|
|
299
|
+
if (!validate) throw new ProtocolError(`The published schema ${reference} is unavailable`);
|
|
300
|
+
validatorCache.set(reference, validate);
|
|
301
|
+
return validate;
|
|
302
|
+
}, "validatorFor");
|
|
303
|
+
componentValidator = /* @__PURE__ */ __name((name) => validatorFor(`${openApiSchemaId}#/$defs/${name}`), "componentValidator");
|
|
304
|
+
sanitizeErrorText = /* @__PURE__ */ __name((value) => [
|
|
305
|
+
...value
|
|
306
|
+
].map((character) => {
|
|
307
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
308
|
+
return codePoint < 32 || codePoint === 127 ? "?" : character;
|
|
309
|
+
}).join(""), "sanitizeErrorText");
|
|
310
|
+
safeErrorDetails = /* @__PURE__ */ __name((validate) => {
|
|
311
|
+
const validationErrors = validate.errors;
|
|
312
|
+
const errors = Array.isArray(validationErrors) ? validationErrors.slice(0, 8) : [];
|
|
313
|
+
return errors.map((errorUnknown) => {
|
|
314
|
+
const error = isRecord(errorUnknown) ? errorUnknown : {};
|
|
315
|
+
const instancePath = typeof error.instancePath === "string" ? error.instancePath : "/";
|
|
316
|
+
const message = typeof error.message === "string" ? error.message : "is invalid";
|
|
317
|
+
return `${sanitizeErrorText(instancePath).slice(0, 160)} ${sanitizeErrorText(message).slice(0, 160)}`;
|
|
318
|
+
}).join("; ").slice(0, 1024);
|
|
319
|
+
}, "safeErrorDetails");
|
|
320
|
+
assertValid = /* @__PURE__ */ __name((validate, value, label) => {
|
|
321
|
+
if (!validate(value)) {
|
|
322
|
+
const details = safeErrorDetails(validate);
|
|
323
|
+
throw new ProtocolError(`${label} failed schema validation${details ? `: ${details}` : ""}`);
|
|
324
|
+
}
|
|
325
|
+
return value;
|
|
326
|
+
}, "assertValid");
|
|
327
|
+
isValidWireMessage = /* @__PURE__ */ __name((name, value) => componentValidator(name)(value) === true, "isValidWireMessage");
|
|
328
|
+
validateWireMessage = /* @__PURE__ */ __name((name, value) => assertValid(componentValidator(name), value, name), "validateWireMessage");
|
|
329
|
+
validateCompiledJobSchema = /* @__PURE__ */ __name((value) => assertValid(validatorFor(runnerJobSchemaKey), value, "Compiled runner job"), "validateCompiledJobSchema");
|
|
148
330
|
}
|
|
149
331
|
});
|
|
150
332
|
|
|
151
333
|
// ts/api-client.ts
|
|
152
|
-
var retryableStatuses, maximumAttempts, identifierPattern, sha256Pattern,
|
|
334
|
+
var retryableStatuses, maximumAttempts, identifierPattern, sha256Pattern, defaultSleep, readBoundedBody, parseJsonBytes, parseJsonResponse, parseRetryAfter, requireCompatibleSpec, parseClaimResponse, responseHeader, responseIntegerHeader, validateTransferMetadata, identityHeaders, sanitizeErrorText2, identifierField, errorDetail, RunnerApiClient;
|
|
153
335
|
var init_api_client = __esm({
|
|
154
336
|
"ts/api-client.ts"() {
|
|
155
337
|
init_errors();
|
|
156
338
|
init_plugins();
|
|
339
|
+
init_spec_version();
|
|
157
340
|
init_validation();
|
|
341
|
+
init_wire_schema();
|
|
158
342
|
retryableStatuses = /* @__PURE__ */ new Set([
|
|
159
343
|
429,
|
|
160
344
|
502,
|
|
@@ -164,7 +348,6 @@ var init_api_client = __esm({
|
|
|
164
348
|
maximumAttempts = 4;
|
|
165
349
|
identifierPattern = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
166
350
|
sha256Pattern = /^[a-f0-9]{64}$/;
|
|
167
|
-
timestampPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/;
|
|
168
351
|
defaultSleep = /* @__PURE__ */ __name((milliseconds, signal) => new Promise((resolve4, reject) => {
|
|
169
352
|
if (signal?.aborted) return reject(signal.reason);
|
|
170
353
|
let settled = false;
|
|
@@ -244,111 +427,39 @@ var init_api_client = __esm({
|
|
|
244
427
|
if (!Number.isFinite(timestamp)) return void 0;
|
|
245
428
|
return Math.min(Math.max(0, timestamp - Date.now()), 3e4);
|
|
246
429
|
}, "parseRetryAfter");
|
|
247
|
-
|
|
248
|
-
if (!
|
|
430
|
+
requireCompatibleSpec = /* @__PURE__ */ __name((spec, message) => {
|
|
431
|
+
if (!specMajorVersionsMatch(spec, runnerSpecVersion)) {
|
|
432
|
+
throw new ProtocolError(`${message}: coordinator specification ${spec} and runner specification ${runnerSpecVersion} have different major versions`);
|
|
433
|
+
}
|
|
434
|
+
return spec;
|
|
435
|
+
}, "requireCompatibleSpec");
|
|
436
|
+
parseClaimResponse = /* @__PURE__ */ __name((value) => {
|
|
437
|
+
if (!isRecord(value)) throw new ProtocolError("Invalid claim response");
|
|
249
438
|
const allowed = /* @__PURE__ */ new Set([
|
|
250
|
-
|
|
251
|
-
|
|
439
|
+
"serverTime",
|
|
440
|
+
"retryAfterMs",
|
|
441
|
+
"lease"
|
|
252
442
|
]);
|
|
253
|
-
if (
|
|
254
|
-
throw new ProtocolError(
|
|
443
|
+
if (!Object.hasOwn(value, "serverTime") || !Object.hasOwn(value, "lease") || Object.keys(value).some((key) => !allowed.has(key))) {
|
|
444
|
+
throw new ProtocolError("Invalid claim response");
|
|
255
445
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
stringField = /* @__PURE__ */ __name((value, field2, minimumLength, maximumLength, pattern) => {
|
|
259
|
-
if (typeof value !== "string" || value.length < minimumLength || value.length > maximumLength || pattern && !pattern.test(value)) {
|
|
260
|
-
throw new ProtocolError(`Invalid coordinator field: ${field2}`);
|
|
261
|
-
}
|
|
262
|
-
return value;
|
|
263
|
-
}, "stringField");
|
|
264
|
-
identifierField = /* @__PURE__ */ __name((value, field2) => stringField(value, field2, 1, 64, identifierPattern), "identifierField");
|
|
265
|
-
sha256Field = /* @__PURE__ */ __name((value, field2) => stringField(value, field2, 64, 64, sha256Pattern), "sha256Field");
|
|
266
|
-
integerField = /* @__PURE__ */ __name((value, field2, minimum, maximum) => {
|
|
267
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum || value > maximum) {
|
|
268
|
-
throw new ProtocolError(`Invalid coordinator field: ${field2}`);
|
|
446
|
+
if (typeof value.serverTime !== "string" || !isProtocolTimestamp(value.serverTime)) {
|
|
447
|
+
throw new ProtocolError("Invalid coordinator field: serverTime");
|
|
269
448
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
timestampField = /* @__PURE__ */ __name((value, field2) => {
|
|
273
|
-
if (typeof value !== "string") throw new ProtocolError(`Invalid coordinator field: ${field2}`);
|
|
274
|
-
const match = timestampPattern.exec(value);
|
|
275
|
-
if (!match) throw new ProtocolError(`Invalid coordinator field: ${field2}`);
|
|
276
|
-
const year = Number(match[1]);
|
|
277
|
-
const month = Number(match[2]);
|
|
278
|
-
const day = Number(match[3]);
|
|
279
|
-
const hour = Number(match[4]);
|
|
280
|
-
const minute = Number(match[5]);
|
|
281
|
-
const second = Number(match[6]);
|
|
282
|
-
const offsetHour = match[7] === void 0 ? 0 : Number(match[7]);
|
|
283
|
-
const offsetMinute = match[8] === void 0 ? 0 : Number(match[8]);
|
|
284
|
-
const lastDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
285
|
-
if (month < 1 || month > 12 || day < 1 || day > lastDay || hour > 23 || minute > 59 || second > 59 || offsetHour > 23 || offsetMinute > 59 || !Number.isFinite(Date.parse(value))) {
|
|
286
|
-
throw new ProtocolError(`Invalid coordinator field: ${field2}`);
|
|
287
|
-
}
|
|
288
|
-
return value;
|
|
289
|
-
}, "timestampField");
|
|
290
|
-
parseCredential = /* @__PURE__ */ __name((value, field2 = "credential") => {
|
|
291
|
-
const record = exactRecord(value, [
|
|
292
|
-
"credentialId",
|
|
293
|
-
"runnerId",
|
|
294
|
-
"token",
|
|
295
|
-
"expiresAt"
|
|
296
|
-
], [
|
|
297
|
-
"previousCredentialValidUntil"
|
|
298
|
-
], field2);
|
|
299
|
-
return {
|
|
300
|
-
credentialId: identifierField(record.credentialId, `${field2}.credentialId`),
|
|
301
|
-
runnerId: identifierField(record.runnerId, `${field2}.runnerId`),
|
|
302
|
-
token: stringField(record.token, `${field2}.token`, 32, 8192),
|
|
303
|
-
expiresAt: timestampField(record.expiresAt, `${field2}.expiresAt`),
|
|
304
|
-
...record.previousCredentialValidUntil === void 0 ? {} : {
|
|
305
|
-
previousCredentialValidUntil: timestampField(record.previousCredentialValidUntil, `${field2}.previousCredentialValidUntil`)
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
}, "parseCredential");
|
|
309
|
-
parseProtocolLimits = /* @__PURE__ */ __name((value) => {
|
|
310
|
-
const record = exactRecord(value, [
|
|
311
|
-
"maximumJsonBytes",
|
|
312
|
-
"maximumLogChunkBytes",
|
|
313
|
-
"maximumTotalLogBytes",
|
|
314
|
-
"minimumLeaseSeconds",
|
|
315
|
-
"maximumLeaseSeconds"
|
|
316
|
-
], [], "discovery limits");
|
|
317
|
-
const limits = {
|
|
318
|
-
maximumJsonBytes: integerField(record.maximumJsonBytes, "limits.maximumJsonBytes", 1, 2097152),
|
|
319
|
-
maximumLogChunkBytes: integerField(record.maximumLogChunkBytes, "limits.maximumLogChunkBytes", 1, 65536),
|
|
320
|
-
maximumTotalLogBytes: integerField(record.maximumTotalLogBytes, "limits.maximumTotalLogBytes", 0, 1073741824),
|
|
321
|
-
minimumLeaseSeconds: integerField(record.minimumLeaseSeconds, "limits.minimumLeaseSeconds", 30, 600),
|
|
322
|
-
maximumLeaseSeconds: integerField(record.maximumLeaseSeconds, "limits.maximumLeaseSeconds", 30, 600)
|
|
323
|
-
};
|
|
324
|
-
if (limits.minimumLeaseSeconds > limits.maximumLeaseSeconds) {
|
|
325
|
-
throw new ProtocolError("Coordinator discovery lease limits are incoherent");
|
|
449
|
+
if (value.retryAfterMs !== void 0 && (typeof value.retryAfterMs !== "number" || !Number.isSafeInteger(value.retryAfterMs) || value.retryAfterMs < 0 || value.retryAfterMs > 3e4)) {
|
|
450
|
+
throw new ProtocolError("Invalid coordinator field: retryAfterMs");
|
|
326
451
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
parseTransferRecord = /* @__PURE__ */ __name((value) => {
|
|
330
|
-
const record = exactRecord(value, [
|
|
331
|
-
"name",
|
|
332
|
-
"format",
|
|
333
|
-
"sha256",
|
|
334
|
-
"sizeBytes",
|
|
335
|
-
"extractedSizeBytes",
|
|
336
|
-
"entryCount",
|
|
337
|
-
"createdAt"
|
|
338
|
-
], [], "transfer record");
|
|
339
|
-
if (record.format !== "tar.gz") {
|
|
340
|
-
throw new ProtocolError("Invalid coordinator field: transferRecord.format");
|
|
452
|
+
if (value.lease !== null && !isRecord(value.lease)) {
|
|
453
|
+
throw new ProtocolError("Invalid coordinator field: lease");
|
|
341
454
|
}
|
|
342
455
|
return {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
entryCount: integerField(record.entryCount, "transferRecord.entryCount", 0, 1e6),
|
|
349
|
-
createdAt: timestampField(record.createdAt, "transferRecord.createdAt")
|
|
456
|
+
serverTime: value.serverTime,
|
|
457
|
+
...value.retryAfterMs === void 0 ? {} : {
|
|
458
|
+
retryAfterMs: value.retryAfterMs
|
|
459
|
+
},
|
|
460
|
+
lease: value.lease
|
|
350
461
|
};
|
|
351
|
-
}, "
|
|
462
|
+
}, "parseClaimResponse");
|
|
352
463
|
responseHeader = /* @__PURE__ */ __name((response, name, maximumLength) => {
|
|
353
464
|
const value = response.headers.get(name);
|
|
354
465
|
if (!value || value.length > maximumLength || value.includes("\0")) {
|
|
@@ -398,12 +509,18 @@ var init_api_client = __esm({
|
|
|
398
509
|
}
|
|
399
510
|
return headers;
|
|
400
511
|
}, "identityHeaders");
|
|
401
|
-
|
|
512
|
+
sanitizeErrorText2 = /* @__PURE__ */ __name((value) => [
|
|
402
513
|
...value
|
|
403
514
|
].map((character) => {
|
|
404
515
|
const codePoint = character.codePointAt(0) ?? 0;
|
|
405
516
|
return codePoint < 32 || codePoint === 127 ? "?" : character;
|
|
406
517
|
}).join(""), "sanitizeErrorText");
|
|
518
|
+
identifierField = /* @__PURE__ */ __name((value, field2) => {
|
|
519
|
+
if (!identifierPattern.test(value)) {
|
|
520
|
+
throw new ProtocolError(`Invalid runner field: ${field2}`);
|
|
521
|
+
}
|
|
522
|
+
return value;
|
|
523
|
+
}, "identifierField");
|
|
407
524
|
errorDetail = /* @__PURE__ */ __name((body) => {
|
|
408
525
|
if (body.byteLength === 0) return void 0;
|
|
409
526
|
let parsed;
|
|
@@ -412,12 +529,9 @@ var init_api_client = __esm({
|
|
|
412
529
|
} catch {
|
|
413
530
|
return void 0;
|
|
414
531
|
}
|
|
415
|
-
if (!
|
|
532
|
+
if (!isValidWireMessage("ErrorResponse", parsed)) return void 0;
|
|
416
533
|
const { code, message } = parsed.error;
|
|
417
|
-
|
|
418
|
-
return void 0;
|
|
419
|
-
}
|
|
420
|
-
return `${code}: ${sanitizeErrorText(message)}`;
|
|
534
|
+
return `${code}: ${sanitizeErrorText2(message)}`;
|
|
421
535
|
}, "errorDetail");
|
|
422
536
|
RunnerApiClient = class {
|
|
423
537
|
static {
|
|
@@ -471,182 +585,79 @@ var init_api_client = __esm({
|
|
|
471
585
|
if (response.status !== 200) {
|
|
472
586
|
await this.throwResponseError(response, false, "Coordinator discovery failed");
|
|
473
587
|
}
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
"basePath",
|
|
477
|
-
"status",
|
|
478
|
-
"serverTime",
|
|
479
|
-
"limits"
|
|
480
|
-
], [], "discovery response");
|
|
481
|
-
if (value.protocol !== runnerProtocolIdentifier || value.basePath !== runnerProtocolBasePath || value.status !== ciSpecStatus) {
|
|
588
|
+
const discovery = validateWireMessage("DiscoveryResponse", await parseJsonResponse(response, this.options.maximumResponseBytes));
|
|
589
|
+
if (discovery.basePath !== runnerProtocolBasePath) {
|
|
482
590
|
throw new ProtocolError("Coordinator discovery is incompatible with this runner");
|
|
483
591
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
limits: parseProtocolLimits(value.limits)
|
|
490
|
-
};
|
|
592
|
+
requireCompatibleSpec(discovery.spec, "Coordinator discovery is incompatible");
|
|
593
|
+
if (discovery.limits.minimumLeaseSeconds > discovery.limits.maximumLeaseSeconds) {
|
|
594
|
+
throw new ProtocolError("Coordinator discovery lease limits are incoherent");
|
|
595
|
+
}
|
|
596
|
+
return discovery;
|
|
491
597
|
}
|
|
492
598
|
throw new CoordinatorError("Coordinator discovery failed");
|
|
493
599
|
}
|
|
494
600
|
async register(request, bootstrapToken, signal) {
|
|
495
|
-
const
|
|
601
|
+
const response = validateWireMessage("RegisterRunnerResponse", await this.requestJson("runners/register", request, {
|
|
602
|
+
requestSchema: "RegisterRunnerRequest",
|
|
496
603
|
token: bootstrapToken,
|
|
497
604
|
signal
|
|
498
|
-
})
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
"registrationReplayUntil",
|
|
502
|
-
"credential"
|
|
503
|
-
], [], "registration response");
|
|
504
|
-
if (value.protocol !== runnerProtocolIdentifier) {
|
|
505
|
-
throw new ProtocolError("Coordinator returned an incompatible registration protocol");
|
|
506
|
-
}
|
|
507
|
-
return {
|
|
508
|
-
protocol: runnerProtocolIdentifier,
|
|
509
|
-
serverTime: timestampField(value.serverTime, "serverTime"),
|
|
510
|
-
registrationReplayUntil: timestampField(value.registrationReplayUntil, "registrationReplayUntil"),
|
|
511
|
-
credential: parseCredential(value.credential)
|
|
512
|
-
};
|
|
605
|
+
}));
|
|
606
|
+
requireCompatibleSpec(response.spec, "Coordinator registration is incompatible");
|
|
607
|
+
return response;
|
|
513
608
|
}
|
|
514
609
|
async startSession(request, signal) {
|
|
515
|
-
const
|
|
610
|
+
const response = validateWireMessage("StartSessionResponse", await this.requestJson(`runners/${encodeURIComponent(request.runnerId)}/sessions`, request, {
|
|
611
|
+
requestSchema: "StartSessionRequest",
|
|
516
612
|
signal
|
|
517
|
-
})
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
"serverTime"
|
|
521
|
-
], [
|
|
522
|
-
"credential"
|
|
523
|
-
], "session response");
|
|
524
|
-
if (value.protocol !== runnerProtocolIdentifier) {
|
|
525
|
-
throw new ProtocolError("Coordinator returned an incompatible session protocol");
|
|
526
|
-
}
|
|
527
|
-
return {
|
|
528
|
-
sessionId: identifierField(value.sessionId, "sessionId"),
|
|
529
|
-
protocol: runnerProtocolIdentifier,
|
|
530
|
-
serverTime: timestampField(value.serverTime, "serverTime"),
|
|
531
|
-
...value.credential === void 0 ? {} : {
|
|
532
|
-
credential: parseCredential(value.credential)
|
|
533
|
-
}
|
|
534
|
-
};
|
|
613
|
+
}));
|
|
614
|
+
requireCompatibleSpec(response.spec, "Coordinator session is incompatible");
|
|
615
|
+
return response;
|
|
535
616
|
}
|
|
536
617
|
async heartbeatRunner(request, signal) {
|
|
537
|
-
|
|
618
|
+
return validateWireMessage("RunnerHeartbeatResponse", await this.requestJson(`runners/${encodeURIComponent(request.runnerId)}/heartbeat`, request, {
|
|
619
|
+
requestSchema: "RunnerHeartbeatRequest",
|
|
538
620
|
signal
|
|
539
|
-
})
|
|
540
|
-
"serverTime",
|
|
541
|
-
"drainRequested"
|
|
542
|
-
], [
|
|
543
|
-
"credential"
|
|
544
|
-
], "runner heartbeat response");
|
|
545
|
-
if (typeof value.drainRequested !== "boolean") {
|
|
546
|
-
throw new ProtocolError("Invalid coordinator field: drainRequested");
|
|
547
|
-
}
|
|
548
|
-
return {
|
|
549
|
-
serverTime: timestampField(value.serverTime, "serverTime"),
|
|
550
|
-
drainRequested: value.drainRequested,
|
|
551
|
-
...value.credential === void 0 ? {} : {
|
|
552
|
-
credential: parseCredential(value.credential)
|
|
553
|
-
}
|
|
554
|
-
};
|
|
621
|
+
}));
|
|
555
622
|
}
|
|
556
623
|
async claimJob(request, signal) {
|
|
557
|
-
|
|
624
|
+
return parseClaimResponse(await this.requestJson("jobs/claim", request, {
|
|
625
|
+
requestSchema: "ClaimJobRequest",
|
|
558
626
|
signal
|
|
559
|
-
})
|
|
560
|
-
"serverTime",
|
|
561
|
-
"lease"
|
|
562
|
-
], [
|
|
563
|
-
"retryAfterMs"
|
|
564
|
-
], "claim response");
|
|
565
|
-
if (value.lease !== null && !isRecord(value.lease)) {
|
|
566
|
-
throw new ProtocolError("Invalid coordinator field: lease");
|
|
567
|
-
}
|
|
568
|
-
return {
|
|
569
|
-
serverTime: timestampField(value.serverTime, "serverTime"),
|
|
570
|
-
...value.retryAfterMs === void 0 ? {} : {
|
|
571
|
-
retryAfterMs: integerField(value.retryAfterMs, "retryAfterMs", 0, 3e4)
|
|
572
|
-
},
|
|
573
|
-
lease: value.lease
|
|
574
|
-
};
|
|
627
|
+
}));
|
|
575
628
|
}
|
|
576
629
|
async acceptJob(request, signal) {
|
|
577
630
|
await this.requestJson(this.jobPath(request.identity, "accept"), request, {
|
|
631
|
+
requestSchema: "AcceptJobRequest",
|
|
578
632
|
signal,
|
|
579
633
|
fenced: true,
|
|
580
634
|
expectedStatus: 204
|
|
581
635
|
});
|
|
582
636
|
}
|
|
583
637
|
async heartbeatJob(request, signal) {
|
|
584
|
-
|
|
638
|
+
return validateWireMessage("JobHeartbeatResponse", await this.requestJson(this.jobPath(request.identity, "heartbeat"), request, {
|
|
639
|
+
requestSchema: "JobHeartbeatRequest",
|
|
585
640
|
signal,
|
|
586
641
|
fenced: true
|
|
587
|
-
})
|
|
588
|
-
"serverTime",
|
|
589
|
-
"leaseExpiresAt"
|
|
590
|
-
], [
|
|
591
|
-
"cancellation"
|
|
592
|
-
], "job heartbeat response");
|
|
593
|
-
let cancellation;
|
|
594
|
-
if (value.cancellation !== void 0) {
|
|
595
|
-
const directive = exactRecord(value.cancellation, [
|
|
596
|
-
"requestId",
|
|
597
|
-
"requestedAt",
|
|
598
|
-
"reason",
|
|
599
|
-
"terminateBy"
|
|
600
|
-
], [], "cancellation directive");
|
|
601
|
-
if (directive.reason !== "user_requested" && directive.reason !== "superseded" && directive.reason !== "policy" && directive.reason !== "coordinator_shutdown") {
|
|
602
|
-
throw new ProtocolError("Invalid coordinator field: cancellation.reason");
|
|
603
|
-
}
|
|
604
|
-
cancellation = {
|
|
605
|
-
requestId: identifierField(directive.requestId, "cancellation.requestId"),
|
|
606
|
-
requestedAt: timestampField(directive.requestedAt, "cancellation.requestedAt"),
|
|
607
|
-
reason: directive.reason,
|
|
608
|
-
terminateBy: timestampField(directive.terminateBy, "cancellation.terminateBy")
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
return {
|
|
612
|
-
serverTime: timestampField(value.serverTime, "serverTime"),
|
|
613
|
-
leaseExpiresAt: timestampField(value.leaseExpiresAt, "leaseExpiresAt"),
|
|
614
|
-
...cancellation ? {
|
|
615
|
-
cancellation
|
|
616
|
-
} : {}
|
|
617
|
-
};
|
|
642
|
+
}));
|
|
618
643
|
}
|
|
619
644
|
async appendLog(chunk, signal) {
|
|
620
|
-
|
|
645
|
+
return validateWireMessage("LogAcknowledgement", await this.requestJson(this.jobPath(chunk.identity, "logs"), chunk, {
|
|
646
|
+
requestSchema: "LogChunk",
|
|
621
647
|
signal,
|
|
622
648
|
fenced: true
|
|
623
|
-
})
|
|
624
|
-
"serverTime",
|
|
625
|
-
"nextSequence"
|
|
626
|
-
], [], "log acknowledgement");
|
|
627
|
-
return {
|
|
628
|
-
serverTime: timestampField(value.serverTime, "serverTime"),
|
|
629
|
-
nextSequence: integerField(value.nextSequence, "nextSequence", 0, Number.MAX_SAFE_INTEGER)
|
|
630
|
-
};
|
|
649
|
+
}));
|
|
631
650
|
}
|
|
632
651
|
async completeJob(request, signal) {
|
|
633
|
-
|
|
652
|
+
return validateWireMessage("CompleteJobResponse", await this.requestJson(this.jobPath(request.identity, "complete"), request, {
|
|
653
|
+
requestSchema: "CompleteJobRequest",
|
|
634
654
|
signal,
|
|
635
655
|
fenced: true
|
|
636
|
-
})
|
|
637
|
-
"serverTime",
|
|
638
|
-
"accepted"
|
|
639
|
-
], [], "completion response");
|
|
640
|
-
if (value.accepted !== true) {
|
|
641
|
-
throw new ProtocolError("Invalid coordinator field: accepted");
|
|
642
|
-
}
|
|
643
|
-
return {
|
|
644
|
-
serverTime: timestampField(value.serverTime, "serverTime"),
|
|
645
|
-
accepted: true
|
|
646
|
-
};
|
|
656
|
+
}));
|
|
647
657
|
}
|
|
648
658
|
async abandonJob(request, signal) {
|
|
649
659
|
await this.requestJson(this.jobPath(request.identity, "abandon"), request, {
|
|
660
|
+
requestSchema: "AbandonJobRequest",
|
|
650
661
|
signal,
|
|
651
662
|
fenced: true,
|
|
652
663
|
expectedStatus: 204
|
|
@@ -654,6 +665,7 @@ var init_api_client = __esm({
|
|
|
654
665
|
}
|
|
655
666
|
async recoverAttempt(request, signal) {
|
|
656
667
|
await this.requestJson("jobs/recover", request, {
|
|
668
|
+
requestSchema: "RecoverAttemptRequest",
|
|
657
669
|
signal,
|
|
658
670
|
expectedStatus: 204
|
|
659
671
|
});
|
|
@@ -745,8 +757,9 @@ var init_api_client = __esm({
|
|
|
745
757
|
jobPath(identity, operation) {
|
|
746
758
|
return `jobs/${encodeURIComponent(identity.jobId)}/attempts/${encodeURIComponent(identity.attemptId)}/${operation}`;
|
|
747
759
|
}
|
|
748
|
-
async requestJson(path, body, options
|
|
760
|
+
async requestJson(path, body, options) {
|
|
749
761
|
const token = options.token ?? this.requireRunnerToken();
|
|
762
|
+
validateWireMessage(options.requestSchema, body);
|
|
750
763
|
let serializedBody;
|
|
751
764
|
try {
|
|
752
765
|
serializedBody = JSON.stringify(body);
|
|
@@ -889,7 +902,7 @@ var init_api_client = __esm({
|
|
|
889
902
|
if (response.status !== 200) {
|
|
890
903
|
await this.throwResponseError(response, true, "Coordinator upload failed");
|
|
891
904
|
}
|
|
892
|
-
const record =
|
|
905
|
+
const record = validateWireMessage("TransferRecord", await parseJsonResponse(response, this.options.maximumResponseBytes));
|
|
893
906
|
if (record.name !== name || record.sha256 !== stableMetadata.sha256 || record.sizeBytes !== stableMetadata.sizeBytes || record.extractedSizeBytes !== stableMetadata.extractedSizeBytes || record.entryCount !== stableMetadata.entryCount) {
|
|
894
907
|
throw new ProtocolError("Coordinator returned mismatched transfer metadata");
|
|
895
908
|
}
|
|
@@ -2090,12 +2103,15 @@ var init_mod = __esm({
|
|
|
2090
2103
|
|
|
2091
2104
|
// ts/transfer-archive.ts
|
|
2092
2105
|
import { createHash } from "node:crypto";
|
|
2093
|
-
async function* tarChunks(entries, root, rootDevice, openRead, signal) {
|
|
2106
|
+
async function* tarChunks(entries, root, rootDevice, openRead, redactionSet, signal) {
|
|
2094
2107
|
let index = 0;
|
|
2095
2108
|
for (const entry of entries) {
|
|
2096
2109
|
if (signal?.aborted) throw signal.reason;
|
|
2097
2110
|
await assertSafeAncestors(root, entry.path, rootDevice);
|
|
2098
2111
|
await assertSnapshot(entry.absolutePath, entry.snapshot);
|
|
2112
|
+
if (redactionSet.occursIn(entry.path) || entry.linkTarget !== void 0 && redactionSet.occursIn(entry.linkTarget)) {
|
|
2113
|
+
throw new SecretDisclosureError();
|
|
2114
|
+
}
|
|
2099
2115
|
const paxValues = [];
|
|
2100
2116
|
let pathField = ustarPath(entry.path);
|
|
2101
2117
|
if (!pathField) {
|
|
@@ -2141,6 +2157,7 @@ async function* tarChunks(entries, root, rootDevice, openRead, signal) {
|
|
|
2141
2157
|
};
|
|
2142
2158
|
try {
|
|
2143
2159
|
await assertOpenFileSnapshot(file, entry.snapshot);
|
|
2160
|
+
const contentMatcher = redactionSet.empty ? void 0 : redactionSet.createContentMatcher();
|
|
2144
2161
|
const buffer = new Uint8Array(streamBufferBytes);
|
|
2145
2162
|
let emitted = 0;
|
|
2146
2163
|
while (true) {
|
|
@@ -2151,7 +2168,9 @@ async function* tarChunks(entries, root, rootDevice, openRead, signal) {
|
|
|
2151
2168
|
if (emitted > entry.sizeBytes) {
|
|
2152
2169
|
throw new RunnerError("Workspace export file grew during archive creation");
|
|
2153
2170
|
}
|
|
2154
|
-
|
|
2171
|
+
const content = buffer.slice(0, read);
|
|
2172
|
+
if (contentMatcher?.push(content)) throw new SecretDisclosureError();
|
|
2173
|
+
yield content;
|
|
2155
2174
|
}
|
|
2156
2175
|
if (emitted !== entry.sizeBytes) {
|
|
2157
2176
|
throw new RunnerError("Workspace export file shrank during archive creation");
|
|
@@ -3676,7 +3695,7 @@ var init_transfer_archive = __esm({
|
|
|
3676
3695
|
truncate: true
|
|
3677
3696
|
});
|
|
3678
3697
|
const compressor = new CompressionStream("gzip");
|
|
3679
|
-
const compressed = iteratorStream(tarChunks(collected.entries, collected.root, collected.rootSnapshot.dev, fileOperations.openRead ?? defaultFileOperations.openRead, options.signal)).pipeThrough(compressor);
|
|
3698
|
+
const compressed = iteratorStream(tarChunks(collected.entries, collected.root, collected.rootSnapshot.dev, fileOperations.openRead ?? defaultFileOperations.openRead, options.redactionSet, options.signal)).pipeThrough(compressor);
|
|
3680
3699
|
reader = compressed.getReader();
|
|
3681
3700
|
while (true) {
|
|
3682
3701
|
if (options.signal?.aborted) throw options.signal.reason;
|
|
@@ -3702,7 +3721,7 @@ var init_transfer_archive = __esm({
|
|
|
3702
3721
|
try {
|
|
3703
3722
|
await reader?.cancel(error);
|
|
3704
3723
|
} catch (cleanupError) {
|
|
3705
|
-
errors.push(cleanupError);
|
|
3724
|
+
if (cleanupError !== error) errors.push(cleanupError);
|
|
3706
3725
|
}
|
|
3707
3726
|
try {
|
|
3708
3727
|
reader?.releaseLock();
|
|
@@ -3819,8 +3838,8 @@ var init_artifact_manager = __esm({
|
|
|
3819
3838
|
if (context.job.permissions.artifacts !== "write") {
|
|
3820
3839
|
throw new ProtocolError("Job does not permit artifact uploads");
|
|
3821
3840
|
}
|
|
3822
|
-
if (!context.job.requirements.features.includes("artifacts
|
|
3823
|
-
throw new ProtocolError("Job does not declare the artifacts
|
|
3841
|
+
if (!context.job.requirements.features.includes("artifacts")) {
|
|
3842
|
+
throw new ProtocolError("Job does not declare the artifacts feature");
|
|
3824
3843
|
}
|
|
3825
3844
|
const maximumArtifacts = Math.min(config.maximumArtifacts, context.job.requirements.limits.maximumArtifacts);
|
|
3826
3845
|
if (artifacts.length > maximumArtifacts) {
|
|
@@ -3901,6 +3920,7 @@ var init_artifact_manager = __esm({
|
|
|
3901
3920
|
maximumExtractedBytes: artifact.maximumExtractedBytes,
|
|
3902
3921
|
maximumEntries: artifact.maximumEntries,
|
|
3903
3922
|
allowSymlinks: true,
|
|
3923
|
+
redactionSet: context.redactionSet,
|
|
3904
3924
|
signal: context.signal
|
|
3905
3925
|
});
|
|
3906
3926
|
const transferRequestId = crypto.randomUUID();
|
|
@@ -3934,7 +3954,7 @@ var init_artifact_manager = __esm({
|
|
|
3934
3954
|
if (optionalFailureMustPropagate(operationError, artifact, context.signal)) {
|
|
3935
3955
|
throw operationError;
|
|
3936
3956
|
}
|
|
3937
|
-
this.onMessage?.(`Optional artifact ${artifact.name} was omitted`);
|
|
3957
|
+
this.onMessage?.(operationError instanceof SecretDisclosureError ? `Optional artifact ${artifact.name} was omitted: it contains a redacted secret value` : `Optional artifact ${artifact.name} was omitted`);
|
|
3938
3958
|
continue;
|
|
3939
3959
|
}
|
|
3940
3960
|
this.onMessage?.(`Artifact ${artifact.name} uploaded`);
|
|
@@ -3977,8 +3997,8 @@ var init_cache_manager = __esm({
|
|
|
3977
3997
|
if (job.permissions.caches === "none") {
|
|
3978
3998
|
throw new ProtocolError("Job does not permit cache transfers");
|
|
3979
3999
|
}
|
|
3980
|
-
if (!job.requirements.features.includes("caches
|
|
3981
|
-
throw new ProtocolError("Job does not declare the caches
|
|
4000
|
+
if (!job.requirements.features.includes("caches")) {
|
|
4001
|
+
throw new ProtocolError("Job does not declare the caches feature");
|
|
3982
4002
|
}
|
|
3983
4003
|
if (caches.length > limits.count) throw new ProtocolError("Job declares too many caches");
|
|
3984
4004
|
const allPaths = [];
|
|
@@ -4252,6 +4272,7 @@ var init_cache_manager = __esm({
|
|
|
4252
4272
|
maximumExtractedBytes: cache.maximumExtractedBytes,
|
|
4253
4273
|
maximumEntries: cache.maximumEntries,
|
|
4254
4274
|
allowSymlinks: false,
|
|
4275
|
+
redactionSet: context.redactionSet,
|
|
4255
4276
|
signal: context.signal
|
|
4256
4277
|
});
|
|
4257
4278
|
const transferRequestId = crypto.randomUUID();
|
|
@@ -4276,14 +4297,14 @@ var init_cache_manager = __esm({
|
|
|
4276
4297
|
});
|
|
4277
4298
|
|
|
4278
4299
|
// ts/config.ts
|
|
4279
|
-
var identifierPattern2,
|
|
4300
|
+
var identifierPattern2, timestampPattern, defaultOciConfig, defaultRunnerConfig, optionalString, stringValue, booleanValue, integerValue, numberValue, stringArray, validTimestamp2, requireEnforceableNetworks, parseOciConfig, parseRunnerConfig, validateRunnerConfig, applyEnvironment, loadRunnerConfig, saveRunnerConfig, withRunnerCredential, maskRunnerConfig;
|
|
4280
4301
|
var init_config = __esm({
|
|
4281
4302
|
"ts/config.ts"() {
|
|
4282
4303
|
init_mod();
|
|
4283
4304
|
init_errors();
|
|
4284
4305
|
init_validation();
|
|
4285
4306
|
identifierPattern2 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
4286
|
-
|
|
4307
|
+
timestampPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/;
|
|
4287
4308
|
defaultOciConfig = {
|
|
4288
4309
|
runtime: "docker",
|
|
4289
4310
|
runtimePath: "/usr/bin/docker",
|
|
@@ -4300,6 +4321,8 @@ var init_config = __esm({
|
|
|
4300
4321
|
maximumCpus: 8,
|
|
4301
4322
|
defaultPids: 256,
|
|
4302
4323
|
maximumPids: 1024,
|
|
4324
|
+
defaultSharedMemoryBytes: 64 * 1024 * 1024,
|
|
4325
|
+
maximumSharedMemoryBytes: 1024 * 1024 * 1024,
|
|
4303
4326
|
workspaceSizeBytes: 4 * 1024 * 1024 * 1024,
|
|
4304
4327
|
temporarySizeBytes: 256 * 1024 * 1024,
|
|
4305
4328
|
stopTimeoutSeconds: 10
|
|
@@ -4388,7 +4411,7 @@ var init_config = __esm({
|
|
|
4388
4411
|
];
|
|
4389
4412
|
}, "stringArray");
|
|
4390
4413
|
validTimestamp2 = /* @__PURE__ */ __name((value) => {
|
|
4391
|
-
const match =
|
|
4414
|
+
const match = timestampPattern.exec(value);
|
|
4392
4415
|
if (!match || !Number.isFinite(Date.parse(value))) return false;
|
|
4393
4416
|
const year = Number(match[1]);
|
|
4394
4417
|
const month = Number(match[2]);
|
|
@@ -4400,20 +4423,23 @@ var init_config = __esm({
|
|
|
4400
4423
|
const offsetMinute = match[8] === void 0 ? 0 : Number(match[8]);
|
|
4401
4424
|
return month >= 1 && month <= 12 && day >= 1 && day <= new Date(Date.UTC(year, month, 0)).getUTCDate() && hour <= 23 && minute <= 59 && second <= 59 && offsetHour <= 23 && offsetMinute <= 59;
|
|
4402
4425
|
}, "validTimestamp");
|
|
4426
|
+
requireEnforceableNetworks = /* @__PURE__ */ __name((networks) => {
|
|
4427
|
+
if (networks.length !== 1 || networks[0] !== "none") {
|
|
4428
|
+
throw new ConfigurationError('oci.allowedNetworks must be ["none"]: this runner does not enforce egress allowlists');
|
|
4429
|
+
}
|
|
4430
|
+
}, "requireEnforceableNetworks");
|
|
4403
4431
|
parseOciConfig = /* @__PURE__ */ __name((input, fallback) => {
|
|
4404
4432
|
const value = input === void 0 ? {} : input;
|
|
4405
4433
|
if (!isRecord(value)) throw new ConfigurationError("oci must be an object");
|
|
4406
4434
|
if (Object.hasOwn(value, "allowMutableImages")) {
|
|
4407
|
-
throw new ConfigurationError("oci.allowMutableImages is not supported by runner protocol
|
|
4435
|
+
throw new ConfigurationError("oci.allowMutableImages is not supported by the runner protocol");
|
|
4408
4436
|
}
|
|
4409
4437
|
const runtime = value.runtime ?? fallback.runtime;
|
|
4410
4438
|
if (runtime !== "docker" && runtime !== "podman") {
|
|
4411
4439
|
throw new ConfigurationError("oci.runtime must be docker or podman");
|
|
4412
4440
|
}
|
|
4413
4441
|
const allowedNetworks = stringArray(value.allowedNetworks, fallback.allowedNetworks, "oci.allowedNetworks", 2);
|
|
4414
|
-
|
|
4415
|
-
throw new ConfigurationError("oci.allowedNetworks may only contain none or bridge");
|
|
4416
|
-
}
|
|
4442
|
+
requireEnforceableNetworks(allowedNetworks);
|
|
4417
4443
|
return {
|
|
4418
4444
|
runtime,
|
|
4419
4445
|
runtimePath: stringValue(value.runtimePath, fallback.runtimePath, "oci.runtimePath"),
|
|
@@ -4429,6 +4455,8 @@ var init_config = __esm({
|
|
|
4429
4455
|
maximumCpus: numberValue(value.maximumCpus, fallback.maximumCpus, "oci.maximumCpus", 0, 1024),
|
|
4430
4456
|
defaultPids: integerValue(value.defaultPids, fallback.defaultPids, "oci.defaultPids", 1, 1048576),
|
|
4431
4457
|
maximumPids: integerValue(value.maximumPids, fallback.maximumPids, "oci.maximumPids", 1, 1048576),
|
|
4458
|
+
defaultSharedMemoryBytes: integerValue(value.defaultSharedMemoryBytes, fallback.defaultSharedMemoryBytes, "oci.defaultSharedMemoryBytes", 1048576, 1099511627776),
|
|
4459
|
+
maximumSharedMemoryBytes: integerValue(value.maximumSharedMemoryBytes, fallback.maximumSharedMemoryBytes, "oci.maximumSharedMemoryBytes", 1048576, 1099511627776),
|
|
4432
4460
|
workspaceSizeBytes: integerValue(value.workspaceSizeBytes, fallback.workspaceSizeBytes, "oci.workspaceSizeBytes", 16777216, 1099511627776),
|
|
4433
4461
|
temporarySizeBytes: integerValue(value.temporarySizeBytes, fallback.temporarySizeBytes, "oci.temporarySizeBytes", 1, 1099511627776),
|
|
4434
4462
|
stopTimeoutSeconds: integerValue(value.stopTimeoutSeconds, fallback.stopTimeoutSeconds, "oci.stopTimeoutSeconds", 1, 30)
|
|
@@ -4713,6 +4741,18 @@ var init_config = __esm({
|
|
|
4713
4741
|
1,
|
|
4714
4742
|
1048576
|
|
4715
4743
|
],
|
|
4744
|
+
[
|
|
4745
|
+
config.oci.defaultSharedMemoryBytes,
|
|
4746
|
+
"oci.defaultSharedMemoryBytes",
|
|
4747
|
+
1048576,
|
|
4748
|
+
1099511627776
|
|
4749
|
+
],
|
|
4750
|
+
[
|
|
4751
|
+
config.oci.maximumSharedMemoryBytes,
|
|
4752
|
+
"oci.maximumSharedMemoryBytes",
|
|
4753
|
+
1048576,
|
|
4754
|
+
1099511627776
|
|
4755
|
+
],
|
|
4716
4756
|
[
|
|
4717
4757
|
config.oci.workspaceSizeBytes,
|
|
4718
4758
|
"oci.workspaceSizeBytes",
|
|
@@ -4740,9 +4780,7 @@ var init_config = __esm({
|
|
|
4740
4780
|
if (config.oci.runtime !== "docker" && config.oci.runtime !== "podman") {
|
|
4741
4781
|
throw new ConfigurationError("oci.runtime must be docker or podman");
|
|
4742
4782
|
}
|
|
4743
|
-
|
|
4744
|
-
throw new ConfigurationError("oci.allowedNetworks may only contain unique none or bridge values");
|
|
4745
|
-
}
|
|
4783
|
+
requireEnforceableNetworks(config.oci.allowedNetworks);
|
|
4746
4784
|
if (!isAbsolute3(config.oci.runtimePath)) {
|
|
4747
4785
|
throw new ConfigurationError("oci.runtimePath must be absolute");
|
|
4748
4786
|
}
|
|
@@ -4768,6 +4806,9 @@ var init_config = __esm({
|
|
|
4768
4806
|
if (config.oci.defaultPids > config.oci.maximumPids) {
|
|
4769
4807
|
throw new ConfigurationError("oci.defaultPids exceeds oci.maximumPids");
|
|
4770
4808
|
}
|
|
4809
|
+
if (config.oci.defaultSharedMemoryBytes > config.oci.maximumSharedMemoryBytes) {
|
|
4810
|
+
throw new ConfigurationError("oci.defaultSharedMemoryBytes exceeds oci.maximumSharedMemoryBytes");
|
|
4811
|
+
}
|
|
4771
4812
|
if (config.maximumSourceExtractedBytes > config.oci.workspaceSizeBytes || config.maximumArtifactExtractedBytes > config.oci.workspaceSizeBytes || config.maximumCacheExtractedBytes > config.oci.workspaceSizeBytes) {
|
|
4772
4813
|
throw new ConfigurationError("Extracted transfer limits exceed the workspace byte limit");
|
|
4773
4814
|
}
|
|
@@ -4919,9 +4960,17 @@ var init_deno = __esm({
|
|
|
4919
4960
|
"deno.json"() {
|
|
4920
4961
|
deno_default = {
|
|
4921
4962
|
name: "@ship.zone/runner",
|
|
4922
|
-
version: "
|
|
4963
|
+
version: "1.1.0",
|
|
4923
4964
|
exports: "./mod.ts",
|
|
4924
4965
|
nodeModulesDir: "none",
|
|
4966
|
+
minimumDependencyAge: {
|
|
4967
|
+
age: "P1D",
|
|
4968
|
+
exclude: [
|
|
4969
|
+
"npm:@foss.global/*",
|
|
4970
|
+
"npm:@git.zone/*",
|
|
4971
|
+
"npm:@push.rocks/*"
|
|
4972
|
+
]
|
|
4973
|
+
},
|
|
4925
4974
|
tasks: {
|
|
4926
4975
|
dev: "deno run --allow-all mod.ts",
|
|
4927
4976
|
bundle: "deno bundle --frozen --check --platform=deno --keep-names --external '@foss.global/ci-spec' --external '@foss.global/ci-spec/*' --external 'ajv/*' --declaration --outdir dist_npm mod.ts",
|
|
@@ -4951,9 +5000,15 @@ var init_deno = __esm({
|
|
|
4951
5000
|
strict: true
|
|
4952
5001
|
},
|
|
4953
5002
|
imports: {
|
|
4954
|
-
"@foss.global/ci-spec": "npm:@foss.global/ci-spec@
|
|
4955
|
-
"@foss.global/ci-spec/archive-cases.json": "npm:@foss.global/ci-spec@
|
|
4956
|
-
"@foss.global/ci-spec/
|
|
5003
|
+
"@foss.global/ci-spec": "npm:@foss.global/ci-spec@1.2.0",
|
|
5004
|
+
"@foss.global/ci-spec/archive-cases.json": "npm:@foss.global/ci-spec@1.2.0/archive-cases.json",
|
|
5005
|
+
"@foss.global/ci-spec/digest-cases.json": "npm:@foss.global/ci-spec@1.2.0/digest-cases.json",
|
|
5006
|
+
"@foss.global/ci-spec/runner-cases.json": "npm:@foss.global/ci-spec@1.2.0/runner-cases.json",
|
|
5007
|
+
"@foss.global/ci-spec/runner-job.schema.json": "npm:@foss.global/ci-spec@1.2.0/runner-job.schema.json",
|
|
5008
|
+
"@foss.global/ci-spec/runner-messages.json": "npm:@foss.global/ci-spec@1.2.0/runner-messages.json",
|
|
5009
|
+
"@foss.global/ci-spec/runner.openapi.json": "npm:@foss.global/ci-spec@1.2.0/runner.openapi.json",
|
|
5010
|
+
"@foss.global/ci-spec/version-cases.json": "npm:@foss.global/ci-spec@1.2.0/version-cases.json",
|
|
5011
|
+
"@foss.global/ci-spec/conformance/runner-jobs/": "npm:/@foss.global/ci-spec@1.2.0/conformance/runner-jobs/",
|
|
4957
5012
|
"@std/assert": "jsr:@std/assert@^1.0.14",
|
|
4958
5013
|
"@std/path": "jsr:@std/path@^1.1.2",
|
|
4959
5014
|
"ajv/dist/2020.js": "npm:ajv@8.20.0/dist/2020.js"
|
|
@@ -4963,60 +5018,253 @@ var init_deno = __esm({
|
|
|
4963
5018
|
});
|
|
4964
5019
|
|
|
4965
5020
|
// ts/interfaces.ts
|
|
4966
|
-
var runnerVersion
|
|
5021
|
+
var runnerVersion;
|
|
4967
5022
|
var init_interfaces = __esm({
|
|
4968
5023
|
"ts/interfaces.ts"() {
|
|
4969
|
-
init_plugins();
|
|
4970
5024
|
init_deno();
|
|
4971
5025
|
runnerVersion = deno_default.version;
|
|
4972
|
-
runnerProtocolIdentifier2 = runnerProtocolIdentifier;
|
|
4973
5026
|
}
|
|
4974
5027
|
});
|
|
4975
5028
|
|
|
4976
5029
|
// ts/redactor.ts
|
|
4977
|
-
var StreamingSecretRedactor;
|
|
5030
|
+
var minimumRedactionMemberBytes, redactionReplacement, textEncoder2, membersFor, SecretRedactionSet, SecretContentMatcher, StreamingSecretRedactor, LogSequenceRedactor;
|
|
4978
5031
|
var init_redactor = __esm({
|
|
4979
5032
|
"ts/redactor.ts"() {
|
|
5033
|
+
init_validation();
|
|
5034
|
+
minimumRedactionMemberBytes = 8;
|
|
5035
|
+
redactionReplacement = "***";
|
|
5036
|
+
textEncoder2 = new TextEncoder();
|
|
5037
|
+
membersFor = /* @__PURE__ */ __name((values) => {
|
|
5038
|
+
const members = /* @__PURE__ */ new Set();
|
|
5039
|
+
for (const value of values) {
|
|
5040
|
+
const candidates = [
|
|
5041
|
+
value
|
|
5042
|
+
];
|
|
5043
|
+
const lines = value.split(/\r\n|\n|\r/);
|
|
5044
|
+
if (lines.length > 1) candidates.push(...lines);
|
|
5045
|
+
for (const candidate of candidates) {
|
|
5046
|
+
if (utf8Length(candidate) >= minimumRedactionMemberBytes) members.add(candidate);
|
|
5047
|
+
}
|
|
5048
|
+
}
|
|
5049
|
+
return [
|
|
5050
|
+
...members
|
|
5051
|
+
].sort((left, right) => right.length - left.length);
|
|
5052
|
+
}, "membersFor");
|
|
5053
|
+
SecretRedactionSet = class _SecretRedactionSet {
|
|
5054
|
+
static {
|
|
5055
|
+
__name(this, "SecretRedactionSet");
|
|
5056
|
+
}
|
|
5057
|
+
members;
|
|
5058
|
+
membersByFirstCodeUnit;
|
|
5059
|
+
memberBytes;
|
|
5060
|
+
constructor(values) {
|
|
5061
|
+
this.members = Object.freeze(membersFor(values));
|
|
5062
|
+
const byFirst = /* @__PURE__ */ new Map();
|
|
5063
|
+
for (const member of this.members) {
|
|
5064
|
+
const first = member.charCodeAt(0);
|
|
5065
|
+
const entries = byFirst.get(first);
|
|
5066
|
+
if (entries) entries.push(member);
|
|
5067
|
+
else byFirst.set(first, [
|
|
5068
|
+
member
|
|
5069
|
+
]);
|
|
5070
|
+
}
|
|
5071
|
+
this.membersByFirstCodeUnit = byFirst;
|
|
5072
|
+
this.memberBytes = Object.freeze(this.members.map((member) => textEncoder2.encode(member)));
|
|
5073
|
+
}
|
|
5074
|
+
static forLease(source) {
|
|
5075
|
+
return new _SecretRedactionSet([
|
|
5076
|
+
...Object.values(source.job.secrets),
|
|
5077
|
+
...(source.npmGrants ?? []).map((grant) => grant.secret)
|
|
5078
|
+
]);
|
|
5079
|
+
}
|
|
5080
|
+
get empty() {
|
|
5081
|
+
return this.members.length === 0;
|
|
5082
|
+
}
|
|
5083
|
+
/** The longest member in UTF-16 code units, the look-ahead a streaming redactor retains. */
|
|
5084
|
+
get maximumMemberLength() {
|
|
5085
|
+
return this.members[0]?.length ?? 0;
|
|
5086
|
+
}
|
|
5087
|
+
/** The longest member at `index` of `text`, when one starts there. */
|
|
5088
|
+
memberAt(text, index) {
|
|
5089
|
+
const candidates = this.membersByFirstCodeUnit.get(text.charCodeAt(index));
|
|
5090
|
+
return candidates?.find((member) => text.startsWith(member, index));
|
|
5091
|
+
}
|
|
5092
|
+
/** Whether any member occurs in `text`. */
|
|
5093
|
+
occursIn(text) {
|
|
5094
|
+
return this.members.some((member) => text.includes(member));
|
|
5095
|
+
}
|
|
5096
|
+
/** A streaming matcher over bytes that reports whether any member occurs in them. */
|
|
5097
|
+
createContentMatcher() {
|
|
5098
|
+
return new SecretContentMatcher(this.memberBytes);
|
|
5099
|
+
}
|
|
5100
|
+
};
|
|
5101
|
+
SecretContentMatcher = class {
|
|
5102
|
+
static {
|
|
5103
|
+
__name(this, "SecretContentMatcher");
|
|
5104
|
+
}
|
|
5105
|
+
transitions = /* @__PURE__ */ new Map();
|
|
5106
|
+
failure = [
|
|
5107
|
+
0
|
|
5108
|
+
];
|
|
5109
|
+
terminal = [
|
|
5110
|
+
false
|
|
5111
|
+
];
|
|
5112
|
+
state = 0;
|
|
5113
|
+
matched = false;
|
|
5114
|
+
constructor(members) {
|
|
5115
|
+
const children = [
|
|
5116
|
+
[]
|
|
5117
|
+
];
|
|
5118
|
+
for (const member of members) {
|
|
5119
|
+
let current = 0;
|
|
5120
|
+
for (const byte of member) {
|
|
5121
|
+
let next = this.transitions.get(current * 256 + byte);
|
|
5122
|
+
if (next === void 0) {
|
|
5123
|
+
next = this.failure.length;
|
|
5124
|
+
this.failure.push(0);
|
|
5125
|
+
this.terminal.push(false);
|
|
5126
|
+
children.push([]);
|
|
5127
|
+
this.transitions.set(current * 256 + byte, next);
|
|
5128
|
+
children[current].push(byte);
|
|
5129
|
+
}
|
|
5130
|
+
current = next;
|
|
5131
|
+
}
|
|
5132
|
+
this.terminal[current] = true;
|
|
5133
|
+
}
|
|
5134
|
+
const queue = children[0].map((byte) => this.transitions.get(byte));
|
|
5135
|
+
for (let head = 0; head < queue.length; head++) {
|
|
5136
|
+
const current = queue[head];
|
|
5137
|
+
for (const byte of children[current]) {
|
|
5138
|
+
const child = this.transitions.get(current * 256 + byte);
|
|
5139
|
+
let fallback = this.failure[current];
|
|
5140
|
+
while (fallback !== 0 && !this.transitions.has(fallback * 256 + byte)) {
|
|
5141
|
+
fallback = this.failure[fallback];
|
|
5142
|
+
}
|
|
5143
|
+
this.failure[child] = this.transitions.get(fallback * 256 + byte) ?? 0;
|
|
5144
|
+
this.terminal[child] ||= this.terminal[this.failure[child]];
|
|
5145
|
+
queue.push(child);
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5148
|
+
}
|
|
5149
|
+
/** Feeds bytes and returns whether a member has occurred anywhere in the stream so far. */
|
|
5150
|
+
push(bytes) {
|
|
5151
|
+
if (this.matched || this.failure.length === 1) return this.matched;
|
|
5152
|
+
let state = this.state;
|
|
5153
|
+
for (const byte of bytes) {
|
|
5154
|
+
let next = this.transitions.get(state * 256 + byte);
|
|
5155
|
+
while (next === void 0 && state !== 0) {
|
|
5156
|
+
state = this.failure[state];
|
|
5157
|
+
next = this.transitions.get(state * 256 + byte);
|
|
5158
|
+
}
|
|
5159
|
+
state = next ?? 0;
|
|
5160
|
+
if (this.terminal[state]) {
|
|
5161
|
+
this.matched = true;
|
|
5162
|
+
break;
|
|
5163
|
+
}
|
|
5164
|
+
}
|
|
5165
|
+
this.state = state;
|
|
5166
|
+
return this.matched;
|
|
5167
|
+
}
|
|
5168
|
+
get found() {
|
|
5169
|
+
return this.matched;
|
|
5170
|
+
}
|
|
5171
|
+
};
|
|
4980
5172
|
StreamingSecretRedactor = class {
|
|
4981
5173
|
static {
|
|
4982
5174
|
__name(this, "StreamingSecretRedactor");
|
|
4983
5175
|
}
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
this.
|
|
4989
|
-
...new Set([
|
|
4990
|
-
...secrets
|
|
4991
|
-
].filter((secret) => secret.length > 0))
|
|
4992
|
-
].sort((left, right) => right.length - left.length);
|
|
4993
|
-
this.maximumSecretLength = this.secrets.reduce((maximum, secret) => Math.max(maximum, secret.length), 0);
|
|
5176
|
+
redactionSet;
|
|
5177
|
+
buffer;
|
|
5178
|
+
constructor(redactionSet) {
|
|
5179
|
+
this.redactionSet = redactionSet;
|
|
5180
|
+
this.buffer = "";
|
|
4994
5181
|
}
|
|
4995
5182
|
push(chunk) {
|
|
4996
|
-
if (this.
|
|
5183
|
+
if (this.redactionSet.empty) return chunk;
|
|
4997
5184
|
this.buffer += chunk;
|
|
4998
5185
|
return this.consume(false);
|
|
4999
5186
|
}
|
|
5000
5187
|
flush() {
|
|
5001
|
-
if (this.
|
|
5188
|
+
if (this.redactionSet.empty) return "";
|
|
5002
5189
|
return this.consume(true);
|
|
5003
5190
|
}
|
|
5004
5191
|
consume(flush) {
|
|
5192
|
+
const buffer = this.buffer;
|
|
5193
|
+
const lookAhead = this.redactionSet.maximumMemberLength;
|
|
5005
5194
|
let output = "";
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5195
|
+
let index = 0;
|
|
5196
|
+
while (index < buffer.length && (flush || buffer.length - index >= lookAhead)) {
|
|
5197
|
+
const member = this.redactionSet.memberAt(buffer, index);
|
|
5198
|
+
if (member) {
|
|
5199
|
+
output += redactionReplacement;
|
|
5200
|
+
index += member.length;
|
|
5011
5201
|
} else {
|
|
5012
|
-
const
|
|
5013
|
-
output +=
|
|
5014
|
-
|
|
5202
|
+
const width = (buffer.codePointAt(index) ?? 0) > 65535 ? 2 : 1;
|
|
5203
|
+
output += buffer.slice(index, index + width);
|
|
5204
|
+
index += width;
|
|
5015
5205
|
}
|
|
5016
5206
|
}
|
|
5207
|
+
this.buffer = buffer.slice(index);
|
|
5017
5208
|
return output;
|
|
5018
5209
|
}
|
|
5019
5210
|
};
|
|
5211
|
+
LogSequenceRedactor = class {
|
|
5212
|
+
static {
|
|
5213
|
+
__name(this, "LogSequenceRedactor");
|
|
5214
|
+
}
|
|
5215
|
+
redactionSet;
|
|
5216
|
+
text;
|
|
5217
|
+
streams;
|
|
5218
|
+
constructor(redactionSet) {
|
|
5219
|
+
this.redactionSet = redactionSet;
|
|
5220
|
+
this.text = "";
|
|
5221
|
+
this.streams = [];
|
|
5222
|
+
}
|
|
5223
|
+
push(stream, data) {
|
|
5224
|
+
if (data.length === 0) return [];
|
|
5225
|
+
if (this.redactionSet.empty) return [
|
|
5226
|
+
{
|
|
5227
|
+
stream,
|
|
5228
|
+
data
|
|
5229
|
+
}
|
|
5230
|
+
];
|
|
5231
|
+
this.text += data;
|
|
5232
|
+
for (let index = 0; index < data.length; index++) this.streams.push(stream);
|
|
5233
|
+
return this.consume(false);
|
|
5234
|
+
}
|
|
5235
|
+
flush() {
|
|
5236
|
+
if (this.redactionSet.empty) return [];
|
|
5237
|
+
return this.consume(true);
|
|
5238
|
+
}
|
|
5239
|
+
consume(flush) {
|
|
5240
|
+
const text = this.text;
|
|
5241
|
+
const lookAhead = this.redactionSet.maximumMemberLength;
|
|
5242
|
+
const segments = [];
|
|
5243
|
+
const emit = /* @__PURE__ */ __name((stream, data) => {
|
|
5244
|
+
const last = segments[segments.length - 1];
|
|
5245
|
+
if (last && last.stream === stream) last.data += data;
|
|
5246
|
+
else segments.push({
|
|
5247
|
+
stream,
|
|
5248
|
+
data
|
|
5249
|
+
});
|
|
5250
|
+
}, "emit");
|
|
5251
|
+
let index = 0;
|
|
5252
|
+
while (index < text.length && (flush || text.length - index >= lookAhead)) {
|
|
5253
|
+
const member = this.redactionSet.memberAt(text, index);
|
|
5254
|
+
if (member) {
|
|
5255
|
+
emit(this.streams[index], redactionReplacement);
|
|
5256
|
+
index += member.length;
|
|
5257
|
+
} else {
|
|
5258
|
+
const width = (text.codePointAt(index) ?? 0) > 65535 ? 2 : 1;
|
|
5259
|
+
emit(this.streams[index], text.slice(index, index + width));
|
|
5260
|
+
index += width;
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
this.text = text.slice(index);
|
|
5264
|
+
this.streams = this.streams.slice(index);
|
|
5265
|
+
return segments;
|
|
5266
|
+
}
|
|
5267
|
+
};
|
|
5020
5268
|
}
|
|
5021
5269
|
});
|
|
5022
5270
|
|
|
@@ -5057,13 +5305,14 @@ var init_log_sender = __esm({
|
|
|
5057
5305
|
maximumChunkBytes;
|
|
5058
5306
|
signal;
|
|
5059
5307
|
redactors;
|
|
5308
|
+
sequenceRedactor;
|
|
5060
5309
|
sequence;
|
|
5061
5310
|
sentBytes;
|
|
5062
5311
|
operationQueue;
|
|
5063
5312
|
terminalError;
|
|
5064
5313
|
observationSequence;
|
|
5065
5314
|
lastObservation;
|
|
5066
|
-
constructor(api, identity,
|
|
5315
|
+
constructor(api, identity, redactionSet, maximumBytes, maximumChunkBytes, signal) {
|
|
5067
5316
|
this.api = api;
|
|
5068
5317
|
this.identity = identity;
|
|
5069
5318
|
this.maximumBytes = maximumBytes;
|
|
@@ -5083,32 +5332,20 @@ var init_log_sender = __esm({
|
|
|
5083
5332
|
if (!Number.isSafeInteger(maximumChunkBytes) || maximumChunkBytes <= 0) {
|
|
5084
5333
|
throw new ProtocolError("Maximum log chunk bytes must be a positive integer");
|
|
5085
5334
|
}
|
|
5086
|
-
const secretValues = [
|
|
5087
|
-
...secrets
|
|
5088
|
-
];
|
|
5089
5335
|
this.redactors = {
|
|
5090
|
-
stdout: new StreamingSecretRedactor(
|
|
5091
|
-
stderr: new StreamingSecretRedactor(
|
|
5336
|
+
stdout: new StreamingSecretRedactor(redactionSet),
|
|
5337
|
+
stderr: new StreamingSecretRedactor(redactionSet)
|
|
5092
5338
|
};
|
|
5339
|
+
this.sequenceRedactor = new LogSequenceRedactor(redactionSet);
|
|
5093
5340
|
}
|
|
5094
5341
|
write(stream, rawData) {
|
|
5095
5342
|
return this.schedule(async () => {
|
|
5096
5343
|
this.lastObservation[stream] = ++this.observationSequence;
|
|
5097
|
-
await this.sendBatch([
|
|
5098
|
-
{
|
|
5099
|
-
stream,
|
|
5100
|
-
data: this.redactors[stream].push(rawData)
|
|
5101
|
-
}
|
|
5102
|
-
]);
|
|
5344
|
+
await this.sendBatch(this.sequenceRedactor.push(stream, this.redactors[stream].push(rawData)));
|
|
5103
5345
|
});
|
|
5104
5346
|
}
|
|
5105
5347
|
writeRunnerMessage(data) {
|
|
5106
|
-
return this.schedule(() => this.sendBatch(
|
|
5107
|
-
{
|
|
5108
|
-
stream: "runner",
|
|
5109
|
-
data
|
|
5110
|
-
}
|
|
5111
|
-
]));
|
|
5348
|
+
return this.schedule(() => this.sendBatch(this.sequenceRedactor.push("runner", data)));
|
|
5112
5349
|
}
|
|
5113
5350
|
flush() {
|
|
5114
5351
|
return this.schedule(async () => {
|
|
@@ -5117,11 +5354,11 @@ var init_log_sender = __esm({
|
|
|
5117
5354
|
"stderr"
|
|
5118
5355
|
];
|
|
5119
5356
|
streams.sort((left, right) => this.lastObservation[left] - this.lastObservation[right]);
|
|
5120
|
-
const writes = streams.
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5357
|
+
const writes = streams.flatMap((stream) => this.sequenceRedactor.push(stream, this.redactors[stream].flush()));
|
|
5358
|
+
await this.sendBatch([
|
|
5359
|
+
...writes,
|
|
5360
|
+
...this.sequenceRedactor.flush()
|
|
5361
|
+
]);
|
|
5125
5362
|
});
|
|
5126
5363
|
}
|
|
5127
5364
|
schedule(operation) {
|
|
@@ -5174,7 +5411,7 @@ var init_log_sender = __esm({
|
|
|
5174
5411
|
});
|
|
5175
5412
|
|
|
5176
5413
|
// ts/oci-executor.ts
|
|
5177
|
-
var runtimeEnvironmentNames, managedLabel, runnerLabel, sessionLabel, attemptLabel, runtimeProbeLabel, runtimeProbeOwnerLabel, helperContainerPath, maximumRuntimeOutputBytes, runtimeCommandTimeoutMs, runtimeTerminationGraceMs, helperMemoryBytes, helperPids, helperCpus, probeVolumeBytes, probeVolumeEntries, maximumCommandArguments, maximumCommandArgumentBytes, maximumCommandBytes, maximumWorkspaceHelperErrorBytes, hostTmpfsProbeMaximumAgeMs, runtimeProbeVolumeMaximumAgeMs, runtimeProbeOwnerIdPattern, hostTmpfsProbeNamePattern, runtimeProbeVolumeNamePattern, workspaceHelperDirectoryName, workspaceHelperLockName, runtimeProbeOwnerMarkerPrefix, runtimeProbeOwnerMarkerPattern, workspaceHelperExecutableMode, workspaceHelperMaximumBytes, workspaceHelperRetainedFinalCount, workspaceHelperTemporaryMaximumBytes, workspaceHelperTemporaryMaximumCount, workspaceHelperTemporaryMaximumAgeMs, workspaceHelperLockTimeoutMs, workspaceHelperLockRetryMs, workspaceHelperFinalNamePattern, workspaceHelperTemporaryNamePattern, workspaceHelperReserveBytes, workspaceFixedInodes, WorkspaceResourceError, isRecord2, field, readRuntimeEnvironment, concatChunks, consumeCommandStream, withTimeout, terminateChild, defaultCommandRunner, requireSuccess, decode, scavengeHostTmpfsProbes, parseJson, firstObject, positiveSafeInteger, nonNegativeSafeInteger, checkedAdd3, checkedMultiply2, roundUp, calculateWorkspaceVolumeLimits, parseContainerUser, validateImage, validateWorkingDirectory, validateStepCommand, validateGeneratedName, validateHostMountPath, validateResources, labels, isolatedContainerArgs, collectStepEnvironment, buildOciRunCommand, validateLeasePolicy, buildOciHelperCreateCommand, mapArchitecture, sha256Bytes, sameFileIdentity, withFsFile, readBoundedRegularFile, sha256File, writeAll2, lstatIfPresent2, safeSelections, isStopReason, PreparedOciLease, OciExecutor, copyOciConfig;
|
|
5414
|
+
var runtimeEnvironmentNames, managedLabel, runnerLabel, sessionLabel, attemptLabel, runtimeProbeLabel, runtimeProbeOwnerLabel, helperContainerPath, maximumRuntimeOutputBytes, runtimeCommandTimeoutMs, runtimeTerminationGraceMs, helperMemoryBytes, helperPids, helperCpus, probeVolumeBytes, probeVolumeEntries, maximumCommandArguments, maximumCommandArgumentBytes, maximumCommandBytes, maximumWorkspaceHelperErrorBytes, hostTmpfsProbeMaximumAgeMs, runtimeProbeVolumeMaximumAgeMs, runtimeProbeOwnerIdPattern, hostTmpfsProbeNamePattern, runtimeProbeVolumeNamePattern, workspaceHelperDirectoryName, workspaceHelperLockName, runtimeProbeOwnerMarkerPrefix, runtimeProbeOwnerMarkerPattern, workspaceHelperExecutableMode, workspaceHelperMaximumBytes, workspaceHelperRetainedFinalCount, workspaceHelperTemporaryMaximumBytes, workspaceHelperTemporaryMaximumCount, workspaceHelperTemporaryMaximumAgeMs, workspaceHelperLockTimeoutMs, workspaceHelperLockRetryMs, workspaceHelperFinalNamePattern, workspaceHelperTemporaryNamePattern, workspaceHelperReserveBytes, workspaceFixedInodes, WorkspaceResourceError, isRecord2, field, readRuntimeEnvironment, concatChunks, consumeCommandStream, withTimeout, terminateChild, defaultCommandRunner, requireSuccess, decode, scavengeHostTmpfsProbes, parseJson, firstObject, positiveSafeInteger, nonNegativeSafeInteger, checkedAdd3, checkedMultiply2, roundUp, calculateWorkspaceVolumeLimits, parseContainerUser, validateImage, validateWorkingDirectory, validateStepCommand, validateGeneratedName, validateHostMountPath, validateResources, requireNoNetwork, labels, isolatedContainerArgs, collectStepEnvironment, buildOciRunCommand, validateLeasePolicy, buildOciHelperCreateCommand, mapArchitecture, sha256Bytes, sameFileIdentity, withFsFile, readBoundedRegularFile, sha256File, writeAll2, lstatIfPresent2, safeSelections, isStopReason, PreparedOciLease, OciExecutor, copyOciConfig;
|
|
5178
5415
|
var init_oci_executor = __esm({
|
|
5179
5416
|
"ts/oci-executor.ts"() {
|
|
5180
5417
|
init_mod();
|
|
@@ -5564,9 +5801,17 @@ var init_oci_executor = __esm({
|
|
|
5564
5801
|
return {
|
|
5565
5802
|
memoryBytes: bounded(lease.job.resources?.memoryBytes, config.oci.defaultMemoryBytes, config.oci.maximumMemoryBytes, "memory limit", true),
|
|
5566
5803
|
cpus: bounded(lease.job.resources?.cpus, config.oci.defaultCpus, config.oci.maximumCpus, "CPU limit"),
|
|
5567
|
-
pids: bounded(lease.job.resources?.pids, config.oci.defaultPids, config.oci.maximumPids, "PID limit", true)
|
|
5804
|
+
pids: bounded(lease.job.resources?.pids, config.oci.defaultPids, config.oci.maximumPids, "PID limit", true),
|
|
5805
|
+
sharedMemoryBytes: bounded(lease.job.resources?.sharedMemoryBytes, config.oci.defaultSharedMemoryBytes, config.oci.maximumSharedMemoryBytes, "shared memory limit", true)
|
|
5568
5806
|
};
|
|
5569
5807
|
}, "validateResources");
|
|
5808
|
+
requireNoNetwork = /* @__PURE__ */ __name((config, lease) => {
|
|
5809
|
+
const mode = lease.job.network.mode;
|
|
5810
|
+
if (mode !== "none" || !config.oci.allowedNetworks.includes("none")) {
|
|
5811
|
+
throw new ProtocolError(`Job network ${mode} is not enforced by this runner`);
|
|
5812
|
+
}
|
|
5813
|
+
return "none";
|
|
5814
|
+
}, "requireNoNetwork");
|
|
5570
5815
|
labels = /* @__PURE__ */ __name((runnerId, sessionId, attemptId) => [
|
|
5571
5816
|
"--label",
|
|
5572
5817
|
`${managedLabel}=true`,
|
|
@@ -5658,11 +5903,8 @@ var init_oci_executor = __esm({
|
|
|
5658
5903
|
validateGeneratedName(input.volumeName, "volume");
|
|
5659
5904
|
validateImage(input.lease.job.execution.image);
|
|
5660
5905
|
validateStepCommand(input.step.command);
|
|
5661
|
-
const network = input.lease
|
|
5662
|
-
|
|
5663
|
-
throw new ProtocolError(`Job network ${network} is not allowed by runner policy`);
|
|
5664
|
-
}
|
|
5665
|
-
const resources = validateResources(config, input.lease);
|
|
5906
|
+
const network = requireNoNetwork(config, input.lease);
|
|
5907
|
+
const { sharedMemoryBytes, ...resources } = validateResources(config, input.lease);
|
|
5666
5908
|
const environment = collectStepEnvironment(config, input);
|
|
5667
5909
|
const volumeMountOptions = config.oci.runtime === "docker" ? "volume-subpath=workspace,volume-nocopy" : "subpath=/workspace";
|
|
5668
5910
|
const args = isolatedContainerArgs(config, {
|
|
@@ -5675,7 +5917,7 @@ var init_oci_executor = __esm({
|
|
|
5675
5917
|
workdir: validateWorkingDirectory(input.lease.job.execution.workingDirectory),
|
|
5676
5918
|
...resources
|
|
5677
5919
|
});
|
|
5678
|
-
args.push("--mount", `type=volume,source=${input.volumeName},target=/workspace,${volumeMountOptions}`);
|
|
5920
|
+
args.push("--shm-size", String(sharedMemoryBytes), "--mount", `type=volume,source=${input.volumeName},target=/workspace,${volumeMountOptions}`);
|
|
5679
5921
|
for (const name of Object.keys(environment).sort()) args.push("--env", name);
|
|
5680
5922
|
args.push(input.lease.job.execution.image, ...input.step.command);
|
|
5681
5923
|
return {
|
|
@@ -5687,9 +5929,7 @@ var init_oci_executor = __esm({
|
|
|
5687
5929
|
parseContainerUser(config.oci.containerUser);
|
|
5688
5930
|
validateImage(context.lease.job.execution.image);
|
|
5689
5931
|
validateWorkingDirectory(context.lease.job.execution.workingDirectory);
|
|
5690
|
-
|
|
5691
|
-
throw new ProtocolError(`Job network ${context.lease.job.execution.network} is not allowed by runner policy`);
|
|
5692
|
-
}
|
|
5932
|
+
requireNoNetwork(config, context.lease);
|
|
5693
5933
|
if (!Number.isSafeInteger(context.lease.job.timeoutMs) || context.lease.job.timeoutMs <= 0 || context.lease.job.timeoutMs > config.oci.maximumTimeoutMs) {
|
|
5694
5934
|
throw new ProtocolError("Job timeout exceeds runner policy");
|
|
5695
5935
|
}
|
|
@@ -6227,7 +6467,10 @@ var init_oci_executor = __esm({
|
|
|
6227
6467
|
const activeContainers = /* @__PURE__ */ new Set();
|
|
6228
6468
|
const lifetimeContainers = /* @__PURE__ */ new Set();
|
|
6229
6469
|
const exportPaths = /* @__PURE__ */ new Set();
|
|
6230
|
-
|
|
6470
|
+
if (!Number.isSafeInteger(context.timeoutMs) || context.timeoutMs < 0) {
|
|
6471
|
+
throw new RunnerError("Execution requires a non-negative remaining attempt timeout");
|
|
6472
|
+
}
|
|
6473
|
+
const deadline = this.now() + context.timeoutMs;
|
|
6231
6474
|
let stopReason;
|
|
6232
6475
|
let activeContainer;
|
|
6233
6476
|
const stopPromises = /* @__PURE__ */ new Map();
|
|
@@ -6262,7 +6505,7 @@ var init_oci_executor = __esm({
|
|
|
6262
6505
|
context.signal.addEventListener("abort", abortListener, {
|
|
6263
6506
|
once: true
|
|
6264
6507
|
});
|
|
6265
|
-
const timeout = setTimeout(() => stopActive("job_timeout"), context.
|
|
6508
|
+
const timeout = setTimeout(() => stopActive("job_timeout"), context.timeoutMs);
|
|
6266
6509
|
const setActive = /* @__PURE__ */ __name((name) => {
|
|
6267
6510
|
activeContainer = name;
|
|
6268
6511
|
if (name && stopReason) stopActive(stopReason);
|
|
@@ -7422,7 +7665,8 @@ var init_oci_executor = __esm({
|
|
|
7422
7665
|
return containerState;
|
|
7423
7666
|
}
|
|
7424
7667
|
async stopContainer(name, deadline, signal) {
|
|
7425
|
-
const
|
|
7668
|
+
const stopRequestedAt = this.now();
|
|
7669
|
+
const defaultDeadline = stopRequestedAt + this.config.oci.stopTimeoutSeconds * 1e3;
|
|
7426
7670
|
let forceAt = Number.POSITIVE_INFINITY;
|
|
7427
7671
|
let forceTimer;
|
|
7428
7672
|
let forcePromise;
|
|
@@ -7450,7 +7694,7 @@ var init_oci_executor = __esm({
|
|
|
7450
7694
|
});
|
|
7451
7695
|
scheduleForceRemoval();
|
|
7452
7696
|
if (signal?.aborted) deadlineChanged();
|
|
7453
|
-
const remainingMs = Math.max(0, forceAt -
|
|
7697
|
+
const remainingMs = Math.max(0, forceAt - stopRequestedAt);
|
|
7454
7698
|
const graceSeconds = Math.max(0, Math.floor(remainingMs / 1e3));
|
|
7455
7699
|
let stopError;
|
|
7456
7700
|
try {
|
|
@@ -7596,17 +7840,19 @@ var init_oci_executor = __esm({
|
|
|
7596
7840
|
});
|
|
7597
7841
|
|
|
7598
7842
|
// ts/protocol-validator.ts
|
|
7599
|
-
var
|
|
7843
|
+
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;
|
|
7600
7844
|
var init_protocol_validator = __esm({
|
|
7601
7845
|
"ts/protocol-validator.ts"() {
|
|
7602
7846
|
init_errors();
|
|
7603
|
-
|
|
7604
|
-
|
|
7847
|
+
init_spec_version();
|
|
7848
|
+
init_validation();
|
|
7849
|
+
init_wire_schema();
|
|
7605
7850
|
sha256Pattern3 = /^[a-f0-9]{64}$/;
|
|
7606
7851
|
reservedEnvironmentNames = [
|
|
7607
7852
|
"FOSS_CI_INPUTS_JSON",
|
|
7608
7853
|
"FOSS_CI_MATRIX_JSON"
|
|
7609
7854
|
];
|
|
7855
|
+
npmUserConfigEnvironmentName = "NPM_CONFIG_USERCONFIG";
|
|
7610
7856
|
maximumCommandArgumentBytes2 = 16 * 1024;
|
|
7611
7857
|
maximumCommandBytes2 = 128 * 1024;
|
|
7612
7858
|
maximumCombinedEnvironmentEntries = 128;
|
|
@@ -7627,102 +7873,6 @@ var init_protocol_validator = __esm({
|
|
|
7627
7873
|
"maximumWorkspaceBytes",
|
|
7628
7874
|
"maximumWorkspaceEntries"
|
|
7629
7875
|
];
|
|
7630
|
-
transferLimitBounds = {
|
|
7631
|
-
maximumSourceArchiveBytes: [
|
|
7632
|
-
0,
|
|
7633
|
-
8589934592
|
|
7634
|
-
],
|
|
7635
|
-
maximumSourceExtractedBytes: [
|
|
7636
|
-
0,
|
|
7637
|
-
68719476736
|
|
7638
|
-
],
|
|
7639
|
-
maximumSourceEntries: [
|
|
7640
|
-
0,
|
|
7641
|
-
1e6
|
|
7642
|
-
],
|
|
7643
|
-
maximumArtifactArchiveBytes: [
|
|
7644
|
-
0,
|
|
7645
|
-
17179869184
|
|
7646
|
-
],
|
|
7647
|
-
maximumArtifactExtractedBytes: [
|
|
7648
|
-
0,
|
|
7649
|
-
137438953472
|
|
7650
|
-
],
|
|
7651
|
-
maximumArtifactEntries: [
|
|
7652
|
-
0,
|
|
7653
|
-
1e6
|
|
7654
|
-
],
|
|
7655
|
-
maximumArtifacts: [
|
|
7656
|
-
0,
|
|
7657
|
-
64
|
|
7658
|
-
],
|
|
7659
|
-
maximumCacheArchiveBytes: [
|
|
7660
|
-
0,
|
|
7661
|
-
17179869184
|
|
7662
|
-
],
|
|
7663
|
-
maximumCacheExtractedBytes: [
|
|
7664
|
-
0,
|
|
7665
|
-
137438953472
|
|
7666
|
-
],
|
|
7667
|
-
maximumCacheEntries: [
|
|
7668
|
-
0,
|
|
7669
|
-
1e6
|
|
7670
|
-
],
|
|
7671
|
-
maximumCaches: [
|
|
7672
|
-
0,
|
|
7673
|
-
32
|
|
7674
|
-
],
|
|
7675
|
-
maximumLogChunkBytes: [
|
|
7676
|
-
1,
|
|
7677
|
-
65536
|
|
7678
|
-
],
|
|
7679
|
-
maximumTotalLogBytes: [
|
|
7680
|
-
0,
|
|
7681
|
-
1073741824
|
|
7682
|
-
],
|
|
7683
|
-
maximumWorkspaceBytes: [
|
|
7684
|
-
16777216,
|
|
7685
|
-
1099511627776
|
|
7686
|
-
],
|
|
7687
|
-
maximumWorkspaceEntries: [
|
|
7688
|
-
1,
|
|
7689
|
-
2e6
|
|
7690
|
-
]
|
|
7691
|
-
};
|
|
7692
|
-
isRecord3 = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRecord");
|
|
7693
|
-
assertExactKeys = /* @__PURE__ */ __name((value, required, optional = [], field2 = "value") => {
|
|
7694
|
-
const allowed = /* @__PURE__ */ new Set([
|
|
7695
|
-
...required,
|
|
7696
|
-
...optional
|
|
7697
|
-
]);
|
|
7698
|
-
if (required.some((key) => !Object.hasOwn(value, key)) || Object.keys(value).some((key) => !allowed.has(key))) {
|
|
7699
|
-
throw new ProtocolError(`Invalid ${field2} shape`);
|
|
7700
|
-
}
|
|
7701
|
-
}, "assertExactKeys");
|
|
7702
|
-
sanitizeErrorText2 = /* @__PURE__ */ __name((value) => [
|
|
7703
|
-
...value
|
|
7704
|
-
].map((character) => {
|
|
7705
|
-
const codePoint = character.codePointAt(0) ?? 0;
|
|
7706
|
-
return codePoint < 32 || codePoint === 127 ? "?" : character;
|
|
7707
|
-
}).join(""), "sanitizeErrorText");
|
|
7708
|
-
safeAjvErrors = /* @__PURE__ */ __name(() => {
|
|
7709
|
-
const validationErrors = validateRunnerJobSchema.errors;
|
|
7710
|
-
const errors = Array.isArray(validationErrors) ? validationErrors.slice(0, 8) : [];
|
|
7711
|
-
const details = errors.map((errorUnknown) => {
|
|
7712
|
-
const error = isRecord3(errorUnknown) ? errorUnknown : {};
|
|
7713
|
-
const instancePath = typeof error.instancePath === "string" ? error.instancePath : "/";
|
|
7714
|
-
const errorMessage = typeof error.message === "string" ? error.message : "is invalid";
|
|
7715
|
-
const path = sanitizeErrorText2(instancePath).slice(0, 160);
|
|
7716
|
-
const message = sanitizeErrorText2(errorMessage).slice(0, 160);
|
|
7717
|
-
return `${path} ${message}`;
|
|
7718
|
-
}).join("; ");
|
|
7719
|
-
return details.slice(0, 1024);
|
|
7720
|
-
}, "safeAjvErrors");
|
|
7721
|
-
ajv = new Ajv2020({
|
|
7722
|
-
allErrors: true,
|
|
7723
|
-
strict: true
|
|
7724
|
-
});
|
|
7725
|
-
validateRunnerJobSchema = ajv.compile(runnerJobSchema);
|
|
7726
7876
|
assertWellFormedUnicode = /* @__PURE__ */ __name((value) => {
|
|
7727
7877
|
for (let index = 0; index < value.length; index += 1) {
|
|
7728
7878
|
const codeUnit = value.charCodeAt(index);
|
|
@@ -7775,7 +7925,7 @@ var init_protocol_validator = __esm({
|
|
|
7775
7925
|
return value;
|
|
7776
7926
|
}, "toJsonValue");
|
|
7777
7927
|
projectCompiledPlan = /* @__PURE__ */ __name((job) => {
|
|
7778
|
-
if (!
|
|
7928
|
+
if (!isRecord(job) || !isRecord(job.secrets)) {
|
|
7779
7929
|
throw new ProtocolError("Compiled runner job secrets must be an object");
|
|
7780
7930
|
}
|
|
7781
7931
|
const projection = {};
|
|
@@ -7799,129 +7949,119 @@ var init_protocol_validator = __esm({
|
|
|
7799
7949
|
].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
7800
7950
|
}, "sha256");
|
|
7801
7951
|
computeCompiledPlanDigest = /* @__PURE__ */ __name(async (job) => await sha256(canonicalizeJson(projectCompiledPlan(job))), "computeCompiledPlanDigest");
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
}
|
|
7806
|
-
return value;
|
|
7807
|
-
}, "validateIdentifier");
|
|
7808
|
-
timestampPattern3 = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/;
|
|
7809
|
-
validateTimestamp = /* @__PURE__ */ __name((value, field2) => {
|
|
7810
|
-
if (typeof value !== "string") throw new ProtocolError(`Invalid ${field2}`);
|
|
7811
|
-
const match = timestampPattern3.exec(value);
|
|
7812
|
-
if (!match) throw new ProtocolError(`Invalid ${field2}`);
|
|
7813
|
-
const year = Number(match[1]);
|
|
7814
|
-
const month = Number(match[2]);
|
|
7815
|
-
const day = Number(match[3]);
|
|
7816
|
-
const hour = Number(match[4]);
|
|
7817
|
-
const minute = Number(match[5]);
|
|
7818
|
-
const second = Number(match[6]);
|
|
7819
|
-
const offsetHour = match[7] === void 0 ? 0 : Number(match[7]);
|
|
7820
|
-
const offsetMinute = match[8] === void 0 ? 0 : Number(match[8]);
|
|
7821
|
-
const lastDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
7822
|
-
if (month < 1 || month > 12 || day < 1 || day > lastDay || hour > 23 || minute > 59 || second > 59 || offsetHour > 23 || offsetMinute > 59 || !Number.isFinite(Date.parse(value))) {
|
|
7823
|
-
throw new ProtocolError(`Invalid ${field2}`);
|
|
7824
|
-
}
|
|
7825
|
-
return value;
|
|
7826
|
-
}, "validateTimestamp");
|
|
7827
|
-
validateTransferLimits = /* @__PURE__ */ __name((value, field2) => {
|
|
7828
|
-
if (!isRecord3(value)) throw new ProtocolError(`Invalid ${field2}`);
|
|
7829
|
-
assertExactKeys(value, transferLimitNames, [], field2);
|
|
7830
|
-
const limits = {};
|
|
7831
|
-
for (const name of transferLimitNames) {
|
|
7832
|
-
const entry = value[name];
|
|
7833
|
-
const [minimum, maximum] = transferLimitBounds[name];
|
|
7834
|
-
if (typeof entry !== "number" || !Number.isSafeInteger(entry) || entry < minimum || entry > maximum) {
|
|
7835
|
-
throw new ProtocolError(`Invalid ${field2}.${name}`);
|
|
7836
|
-
}
|
|
7837
|
-
limits[name] = entry;
|
|
7952
|
+
UnsupportedJobError = class extends ProtocolError {
|
|
7953
|
+
static {
|
|
7954
|
+
__name(this, "UnsupportedJobError");
|
|
7838
7955
|
}
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
if (!Array.isArray(value) || value.length < minimum || value.length > maximum || value.some((entry) => typeof entry !== "string")) {
|
|
7843
|
-
throw new ProtocolError(`Invalid runner capabilities ${field2}`);
|
|
7956
|
+
constructor(message) {
|
|
7957
|
+
super(message);
|
|
7958
|
+
this.name = "UnsupportedJobError";
|
|
7844
7959
|
}
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7960
|
+
};
|
|
7961
|
+
deepFreeze = /* @__PURE__ */ __name((value) => {
|
|
7962
|
+
if (typeof value === "object" && value !== null) {
|
|
7963
|
+
for (const entry of Object.values(value)) deepFreeze(entry);
|
|
7964
|
+
Object.freeze(value);
|
|
7848
7965
|
}
|
|
7849
|
-
return
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
const value = capabilities;
|
|
7855
|
-
if (!isRecord3(value)) throw new ProtocolError("Invalid runner capabilities");
|
|
7856
|
-
assertExactKeys(value, [
|
|
7857
|
-
"executionProfiles",
|
|
7858
|
-
"labels",
|
|
7859
|
-
"features",
|
|
7860
|
-
"networks",
|
|
7861
|
-
"sourceFormats",
|
|
7862
|
-
"limits"
|
|
7863
|
-
], [], "runner capabilities");
|
|
7864
|
-
const executionProfiles = validateCapabilityArray(value.executionProfiles, "executionProfiles", 1, 16, /* @__PURE__ */ new Set([
|
|
7865
|
-
"oci.v1"
|
|
7866
|
-
]));
|
|
7867
|
-
const labels2 = validateCapabilityArray(value.labels, "labels", 0, 32, void 0, true);
|
|
7868
|
-
const features = validateCapabilityArray(value.features, "features", 0, 16, /* @__PURE__ */ new Set([
|
|
7869
|
-
"source.tar-gz",
|
|
7870
|
-
"artifacts.v1",
|
|
7871
|
-
"caches.v1"
|
|
7872
|
-
]));
|
|
7873
|
-
const networks = validateCapabilityArray(value.networks, "networks", 1, 2, /* @__PURE__ */ new Set([
|
|
7874
|
-
"none",
|
|
7875
|
-
"bridge"
|
|
7876
|
-
]));
|
|
7877
|
-
const sourceFormats = validateCapabilityArray(value.sourceFormats, "sourceFormats", 1, 1, /* @__PURE__ */ new Set([
|
|
7878
|
-
"tar.gz"
|
|
7879
|
-
]));
|
|
7880
|
-
const limits = validateTransferLimits(value.limits, "runner capabilities limits");
|
|
7881
|
-
Object.freeze(executionProfiles);
|
|
7882
|
-
Object.freeze(labels2);
|
|
7883
|
-
Object.freeze(features);
|
|
7884
|
-
Object.freeze(networks);
|
|
7885
|
-
Object.freeze(sourceFormats);
|
|
7886
|
-
Object.freeze(limits);
|
|
7887
|
-
return Object.freeze({
|
|
7888
|
-
executionProfiles,
|
|
7889
|
-
labels: labels2,
|
|
7890
|
-
features,
|
|
7891
|
-
networks,
|
|
7892
|
-
sourceFormats,
|
|
7893
|
-
limits
|
|
7894
|
-
});
|
|
7895
|
-
}, "createRunnerCapabilitySnapshot");
|
|
7966
|
+
return value;
|
|
7967
|
+
}, "deepFreeze");
|
|
7968
|
+
createRunnerCapabilitySnapshot = /* @__PURE__ */ __name((capabilities) => deepFreeze(validateWireMessage("RunnerCapabilities", structuredClone(capabilities))), "createRunnerCapabilitySnapshot");
|
|
7969
|
+
hasSteps = /* @__PURE__ */ __name((job) => "steps" in job, "hasSteps");
|
|
7970
|
+
isLinuxPlatform = /* @__PURE__ */ __name((platform) => platform.startsWith("linux/"), "isLinuxPlatform");
|
|
7896
7971
|
requireCapabilityFit = /* @__PURE__ */ __name((job, capabilities) => {
|
|
7897
|
-
|
|
7972
|
+
const requirements = job.requirements;
|
|
7973
|
+
if (!capabilities.executionProfiles.includes(requirements.executionProfile)) {
|
|
7898
7974
|
throw new ProtocolError("Job execution profile is not supported by this runner");
|
|
7899
7975
|
}
|
|
7900
|
-
if (
|
|
7901
|
-
throw new ProtocolError("Job
|
|
7976
|
+
if (!capabilities.isolation.includes(requirements.isolation)) {
|
|
7977
|
+
throw new ProtocolError("Job isolation is not supported by this runner");
|
|
7978
|
+
}
|
|
7979
|
+
if (requirements.platform !== void 0) {
|
|
7980
|
+
if (!capabilities.platforms.includes(requirements.platform)) {
|
|
7981
|
+
throw new ProtocolError("Job platform is not executed natively by this runner");
|
|
7982
|
+
}
|
|
7983
|
+
} else if (!capabilities.platforms.some(isLinuxPlatform)) {
|
|
7984
|
+
throw new ProtocolError("Job requires a linux platform this runner does not execute");
|
|
7902
7985
|
}
|
|
7903
|
-
for (const label of
|
|
7986
|
+
for (const label of requirements.labels) {
|
|
7904
7987
|
if (!capabilities.labels.includes(label)) {
|
|
7905
7988
|
throw new ProtocolError("Job requires an unavailable runner label");
|
|
7906
7989
|
}
|
|
7907
7990
|
}
|
|
7908
|
-
for (const feature of
|
|
7991
|
+
for (const feature of requirements.features) {
|
|
7909
7992
|
if (!capabilities.features.includes(feature)) {
|
|
7910
7993
|
throw new ProtocolError("Job requires an unavailable runner feature");
|
|
7911
7994
|
}
|
|
7912
7995
|
}
|
|
7913
|
-
if (!capabilities.networks.includes(job.
|
|
7996
|
+
if (!capabilities.networks.includes(job.network.mode)) {
|
|
7914
7997
|
throw new ProtocolError("Job network mode is not supported by this runner");
|
|
7915
7998
|
}
|
|
7916
7999
|
if (!capabilities.sourceFormats.includes(job.source.format)) {
|
|
7917
8000
|
throw new ProtocolError("Job source format is not supported by this runner");
|
|
7918
8001
|
}
|
|
7919
8002
|
for (const name of transferLimitNames) {
|
|
7920
|
-
if (
|
|
8003
|
+
if (requirements.limits[name] > capabilities.limits[name]) {
|
|
7921
8004
|
throw new ProtocolError(`Job requirement ${name} exceeds runner capability`);
|
|
7922
8005
|
}
|
|
7923
8006
|
}
|
|
8007
|
+
const resources = job.resources;
|
|
8008
|
+
const maxima = capabilities.resources;
|
|
8009
|
+
if (resources && maxima) {
|
|
8010
|
+
const pairs = [
|
|
8011
|
+
[
|
|
8012
|
+
resources.memoryBytes,
|
|
8013
|
+
maxima.maximumMemoryBytes,
|
|
8014
|
+
"memoryBytes"
|
|
8015
|
+
],
|
|
8016
|
+
[
|
|
8017
|
+
resources.cpus,
|
|
8018
|
+
maxima.maximumCpus,
|
|
8019
|
+
"cpus"
|
|
8020
|
+
],
|
|
8021
|
+
[
|
|
8022
|
+
resources.pids,
|
|
8023
|
+
maxima.maximumPids,
|
|
8024
|
+
"pids"
|
|
8025
|
+
],
|
|
8026
|
+
[
|
|
8027
|
+
resources.sharedMemoryBytes,
|
|
8028
|
+
maxima.maximumSharedMemoryBytes,
|
|
8029
|
+
"sharedMemoryBytes"
|
|
8030
|
+
]
|
|
8031
|
+
];
|
|
8032
|
+
for (const [value, maximum, name] of pairs) {
|
|
8033
|
+
if (value !== void 0 && value > maximum) {
|
|
8034
|
+
throw new ProtocolError(`Job resource ${name} exceeds runner capability`);
|
|
8035
|
+
}
|
|
8036
|
+
}
|
|
8037
|
+
}
|
|
8038
|
+
if (capabilities.maximumTimeoutMs !== void 0 && job.timeoutMs > capabilities.maximumTimeoutMs) {
|
|
8039
|
+
throw new ProtocolError("Job timeoutMs exceeds runner capability");
|
|
8040
|
+
}
|
|
7924
8041
|
}, "requireCapabilityFit");
|
|
8042
|
+
requireLeaseFeatureFit = /* @__PURE__ */ __name((lease, capabilities) => {
|
|
8043
|
+
const advertised = capabilities.leaseFeatures;
|
|
8044
|
+
if (advertised === void 0) return;
|
|
8045
|
+
const used = [
|
|
8046
|
+
[
|
|
8047
|
+
lease.grants.some((grant) => grant.access === "pull"),
|
|
8048
|
+
"image-pull-grants"
|
|
8049
|
+
],
|
|
8050
|
+
[
|
|
8051
|
+
lease.bindings.length > 0,
|
|
8052
|
+
"candidate-bindings"
|
|
8053
|
+
],
|
|
8054
|
+
[
|
|
8055
|
+
lease.npmGrants !== void 0,
|
|
8056
|
+
"npm-read-grants"
|
|
8057
|
+
]
|
|
8058
|
+
];
|
|
8059
|
+
for (const [uses, feature] of used) {
|
|
8060
|
+
if (uses && !advertised.includes(feature)) {
|
|
8061
|
+
throw new ProtocolError(`Lease uses ${feature}, a lease feature this runner does not advertise`);
|
|
8062
|
+
}
|
|
8063
|
+
}
|
|
8064
|
+
}, "requireLeaseFeatureFit");
|
|
7925
8065
|
requireTransferCoherence = /* @__PURE__ */ __name((job) => {
|
|
7926
8066
|
const limits = job.requirements.limits;
|
|
7927
8067
|
if (!job.requirements.features.includes("source.tar-gz")) {
|
|
@@ -7955,7 +8095,7 @@ var init_protocol_validator = __esm({
|
|
|
7955
8095
|
if (cache.access === "read-write" && job.permissions.caches !== "read-write") {
|
|
7956
8096
|
throw new ProtocolError("Read-write cache declaration lacks read-write permission");
|
|
7957
8097
|
}
|
|
7958
|
-
for (const path of cache.paths) {
|
|
8098
|
+
for (const path of "paths" in cache ? cache.paths : []) {
|
|
7959
8099
|
if (cachePaths.some((existing) => existing === path || existing.startsWith(`${path}/`) || path.startsWith(`${existing}/`))) {
|
|
7960
8100
|
throw new ProtocolError("Job cache paths must not overlap");
|
|
7961
8101
|
}
|
|
@@ -7963,12 +8103,12 @@ var init_protocol_validator = __esm({
|
|
|
7963
8103
|
}
|
|
7964
8104
|
}
|
|
7965
8105
|
if (job.artifacts.length > 0) {
|
|
7966
|
-
if (job.permissions.artifacts !== "write" || !job.requirements.features.includes("artifacts
|
|
8106
|
+
if (job.permissions.artifacts !== "write" || !job.requirements.features.includes("artifacts")) {
|
|
7967
8107
|
throw new ProtocolError("Job artifact declarations are not authorized");
|
|
7968
8108
|
}
|
|
7969
8109
|
}
|
|
7970
8110
|
if (job.caches.length > 0) {
|
|
7971
|
-
if (job.permissions.caches === "none" || !job.requirements.features.includes("caches
|
|
8111
|
+
if (job.permissions.caches === "none" || !job.requirements.features.includes("caches")) {
|
|
7972
8112
|
throw new ProtocolError("Job cache declarations are not authorized");
|
|
7973
8113
|
}
|
|
7974
8114
|
}
|
|
@@ -7985,10 +8125,29 @@ var init_protocol_validator = __esm({
|
|
|
7985
8125
|
}
|
|
7986
8126
|
}, "requireCanonicalReservedJson");
|
|
7987
8127
|
requireExecutionCoherence = /* @__PURE__ */ __name((job) => {
|
|
7988
|
-
|
|
8128
|
+
const secretTargets = Object.keys(job.secrets);
|
|
8129
|
+
const npmRead = job.npmRead !== void 0;
|
|
8130
|
+
for (const secretName of secretTargets) {
|
|
7989
8131
|
if (secretName.startsWith("FOSS_CI_")) {
|
|
7990
8132
|
throw new ProtocolError("Secret targets may not use reserved FOSS_CI names");
|
|
7991
8133
|
}
|
|
8134
|
+
if (npmRead && secretName === npmUserConfigEnvironmentName) {
|
|
8135
|
+
throw new ProtocolError(`Secret targets may not use the reserved ${secretName}`);
|
|
8136
|
+
}
|
|
8137
|
+
}
|
|
8138
|
+
if (job.resources?.sharedMemoryBytes !== void 0 && job.resources.memoryBytes !== void 0) {
|
|
8139
|
+
if (job.resources.sharedMemoryBytes > job.resources.memoryBytes) {
|
|
8140
|
+
throw new ProtocolError("Job shared memory exceeds its memory ceiling");
|
|
8141
|
+
}
|
|
8142
|
+
}
|
|
8143
|
+
if (!hasSteps(job)) {
|
|
8144
|
+
const referenced = new Set(job.build.secrets.map((secret) => secret.environment));
|
|
8145
|
+
if ([
|
|
8146
|
+
...referenced
|
|
8147
|
+
].some((target) => !Object.hasOwn(job.secrets, target)) || secretTargets.some((target) => !referenced.has(target))) {
|
|
8148
|
+
throw new ProtocolError("Build secrets and job secret targets must correspond exactly");
|
|
8149
|
+
}
|
|
8150
|
+
return;
|
|
7992
8151
|
}
|
|
7993
8152
|
for (const step of job.steps) {
|
|
7994
8153
|
const environmentNames = Object.keys(step.environment);
|
|
@@ -7996,6 +8155,9 @@ var init_protocol_validator = __esm({
|
|
|
7996
8155
|
if (name.startsWith("FOSS_CI_") && !reservedEnvironmentNames.includes(name)) {
|
|
7997
8156
|
throw new ProtocolError("Step environment uses an unknown reserved FOSS_CI name");
|
|
7998
8157
|
}
|
|
8158
|
+
if (npmRead && name === npmUserConfigEnvironmentName) {
|
|
8159
|
+
throw new ProtocolError(`Step environment may not define the reserved ${name}`);
|
|
8160
|
+
}
|
|
7999
8161
|
if (Object.hasOwn(job.secrets, name)) {
|
|
8000
8162
|
throw new ProtocolError("Step environment and secret targets must be unique");
|
|
8001
8163
|
}
|
|
@@ -8006,7 +8168,7 @@ var init_protocol_validator = __esm({
|
|
|
8006
8168
|
}
|
|
8007
8169
|
requireCanonicalReservedJson(step.environment[name], name);
|
|
8008
8170
|
}
|
|
8009
|
-
if (environmentNames.length +
|
|
8171
|
+
if (environmentNames.length + secretTargets.length + (npmRead ? 1 : 0) > maximumCombinedEnvironmentEntries) {
|
|
8010
8172
|
throw new ProtocolError("Step environment and secret targets exceed the protocol limit");
|
|
8011
8173
|
}
|
|
8012
8174
|
const commandBytes = step.command.reduce((total, argument) => {
|
|
@@ -8021,6 +8183,102 @@ var init_protocol_validator = __esm({
|
|
|
8021
8183
|
}
|
|
8022
8184
|
}
|
|
8023
8185
|
}, "requireExecutionCoherence");
|
|
8186
|
+
candidateReferences = /* @__PURE__ */ __name((job) => {
|
|
8187
|
+
const images = hasSteps(job) ? [
|
|
8188
|
+
job.execution.image
|
|
8189
|
+
] : job.build.baseImages.map((baseImage) => baseImage.image);
|
|
8190
|
+
return images.flatMap((image) => typeof image === "string" ? [] : [
|
|
8191
|
+
image.candidate
|
|
8192
|
+
]);
|
|
8193
|
+
}, "candidateReferences");
|
|
8194
|
+
imageName = /* @__PURE__ */ __name((pinnedImage) => pinnedImage.slice(0, pinnedImage.indexOf("@")), "imageName");
|
|
8195
|
+
requireLeaseCoherence = /* @__PURE__ */ __name((lease) => {
|
|
8196
|
+
const references = candidateReferences(lease.job);
|
|
8197
|
+
const referenced = new Set(references);
|
|
8198
|
+
const bound = /* @__PURE__ */ new Set();
|
|
8199
|
+
for (const binding of lease.bindings) {
|
|
8200
|
+
if (!referenced.has(binding.candidate) || bound.has(binding.candidate)) {
|
|
8201
|
+
throw new ProtocolError("Lease bindings do not match the job candidate references");
|
|
8202
|
+
}
|
|
8203
|
+
bound.add(binding.candidate);
|
|
8204
|
+
}
|
|
8205
|
+
if (bound.size !== referenced.size) {
|
|
8206
|
+
throw new ProtocolError("Lease bindings do not match the job candidate references");
|
|
8207
|
+
}
|
|
8208
|
+
const grantKeys = /* @__PURE__ */ new Set();
|
|
8209
|
+
for (const grant of lease.grants) {
|
|
8210
|
+
const key = JSON.stringify([
|
|
8211
|
+
grant.registry,
|
|
8212
|
+
grant.repository,
|
|
8213
|
+
grant.access
|
|
8214
|
+
]);
|
|
8215
|
+
if (grantKeys.has(key)) {
|
|
8216
|
+
throw new ProtocolError("Lease holds more than one grant for a registry repository access");
|
|
8217
|
+
}
|
|
8218
|
+
grantKeys.add(key);
|
|
8219
|
+
}
|
|
8220
|
+
for (const binding of lease.bindings) {
|
|
8221
|
+
const name = imageName(binding.image);
|
|
8222
|
+
if (!lease.grants.some((grant) => grant.access === "pull" && `${grant.registry}/${grant.repository}` === name)) {
|
|
8223
|
+
throw new ProtocolError("Lease binds an image without a pull grant for its repository");
|
|
8224
|
+
}
|
|
8225
|
+
}
|
|
8226
|
+
const pushGrants = lease.grants.filter((grant) => grant.access === "push").length;
|
|
8227
|
+
const expectedPushGrants = lease.job.requirements.executionProfile === "oci-image" ? 1 : 0;
|
|
8228
|
+
if (pushGrants !== expectedPushGrants) {
|
|
8229
|
+
throw new ProtocolError("Lease push grants do not match the job execution profile");
|
|
8230
|
+
}
|
|
8231
|
+
const npmRead = lease.job.npmRead ?? [];
|
|
8232
|
+
const npmGrants = lease.npmGrants ?? [];
|
|
8233
|
+
const scopeKey = /* @__PURE__ */ __name((scopes) => JSON.stringify([
|
|
8234
|
+
...scopes
|
|
8235
|
+
].sort()), "scopeKey");
|
|
8236
|
+
const remaining = [
|
|
8237
|
+
...npmGrants
|
|
8238
|
+
];
|
|
8239
|
+
for (const entry of npmRead) {
|
|
8240
|
+
const index = remaining.findIndex((grant) => grant.registry === entry.registry && scopeKey(grant.scopes) === scopeKey(entry.scopes));
|
|
8241
|
+
if (index < 0) throw new ProtocolError("Lease npm grants do not match the job npmRead");
|
|
8242
|
+
remaining.splice(index, 1);
|
|
8243
|
+
}
|
|
8244
|
+
if (remaining.length > 0) {
|
|
8245
|
+
throw new ProtocolError("Lease npm grants do not match the job npmRead");
|
|
8246
|
+
}
|
|
8247
|
+
}, "requireLeaseCoherence");
|
|
8248
|
+
requireExecutableLease = /* @__PURE__ */ __name((lease) => {
|
|
8249
|
+
const job = lease.job;
|
|
8250
|
+
if (job.requirements.executionProfile !== "oci" || !hasSteps(job)) {
|
|
8251
|
+
throw new UnsupportedJobError(`Execution profile ${job.requirements.executionProfile} is not supported by this runner`);
|
|
8252
|
+
}
|
|
8253
|
+
if (job.execution.profile !== "oci") {
|
|
8254
|
+
throw new UnsupportedJobError("Job execution does not match the oci profile");
|
|
8255
|
+
}
|
|
8256
|
+
if (job.requirements.isolation !== "container") {
|
|
8257
|
+
throw new UnsupportedJobError("microvm isolation is not supported by this runner");
|
|
8258
|
+
}
|
|
8259
|
+
if (job.network.mode !== "none") {
|
|
8260
|
+
throw new UnsupportedJobError("egress networking is not enforced by this runner");
|
|
8261
|
+
}
|
|
8262
|
+
if (typeof job.execution.image !== "string" || lease.bindings.length > 0) {
|
|
8263
|
+
throw new UnsupportedJobError("Candidate image bindings are not supported by this runner");
|
|
8264
|
+
}
|
|
8265
|
+
if (lease.grants.length > 0) {
|
|
8266
|
+
throw new UnsupportedJobError("Image grants are not supported by this runner");
|
|
8267
|
+
}
|
|
8268
|
+
if (job.npmRead !== void 0 || lease.npmGrants !== void 0) {
|
|
8269
|
+
throw new UnsupportedJobError("npm read grants are not delivered by this runner");
|
|
8270
|
+
}
|
|
8271
|
+
return {
|
|
8272
|
+
jobId: lease.jobId,
|
|
8273
|
+
attemptId: lease.attemptId,
|
|
8274
|
+
leaseId: lease.leaseId,
|
|
8275
|
+
fencingToken: lease.fencingToken,
|
|
8276
|
+
leaseExpiresAt: lease.leaseExpiresAt,
|
|
8277
|
+
job,
|
|
8278
|
+
grants: [],
|
|
8279
|
+
bindings: []
|
|
8280
|
+
};
|
|
8281
|
+
}, "requireExecutableLease");
|
|
8024
8282
|
validateCapabilityFit = /* @__PURE__ */ __name((job, capabilities) => {
|
|
8025
8283
|
const snapshot = createRunnerCapabilitySnapshot(capabilities);
|
|
8026
8284
|
requireCapabilityFit(job, snapshot);
|
|
@@ -8029,16 +8287,22 @@ var init_protocol_validator = __esm({
|
|
|
8029
8287
|
static {
|
|
8030
8288
|
__name(this, "RunnerProtocolValidator");
|
|
8031
8289
|
}
|
|
8290
|
+
implementedSpec;
|
|
8032
8291
|
capabilities;
|
|
8033
|
-
constructor(capabilities) {
|
|
8292
|
+
constructor(capabilities, implementedSpec = runnerSpecVersion) {
|
|
8293
|
+
this.implementedSpec = implementedSpec;
|
|
8034
8294
|
this.capabilities = createRunnerCapabilitySnapshot(capabilities);
|
|
8035
8295
|
}
|
|
8296
|
+
/**
|
|
8297
|
+
* Validates a compiled job: the published schema, the specification version acceptance rule,
|
|
8298
|
+
* the compiled plan digest, internal coherence, and fit against the capability snapshot.
|
|
8299
|
+
*/
|
|
8036
8300
|
async validateJob(jobUnknown) {
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8301
|
+
const job = validateCompiledJobSchema(jobUnknown);
|
|
8302
|
+
const acceptance = acceptSpecVersion(this.implementedSpec, job.spec);
|
|
8303
|
+
if (acceptance !== "accepted") {
|
|
8304
|
+
throw new ProtocolError(`Job specification version is not accepted by this runner (${acceptance})`);
|
|
8040
8305
|
}
|
|
8041
|
-
const job = jobUnknown;
|
|
8042
8306
|
const digest = await computeCompiledPlanDigest(job);
|
|
8043
8307
|
if (!sha256Pattern3.test(job.compiledPlanDigest) || digest !== job.compiledPlanDigest) {
|
|
8044
8308
|
throw new ProtocolError("Compiled runner job digest does not match");
|
|
@@ -8048,28 +8312,25 @@ var init_protocol_validator = __esm({
|
|
|
8048
8312
|
requireCapabilityFit(job, this.capabilities);
|
|
8049
8313
|
return job;
|
|
8050
8314
|
}
|
|
8315
|
+
/**
|
|
8316
|
+
* Validates a lease against the published `JobLease` schema, its job, lease coherence, and the
|
|
8317
|
+
* lease features of the capability snapshot.
|
|
8318
|
+
*/
|
|
8051
8319
|
async validateJobLease(leaseUnknown) {
|
|
8052
|
-
if (!
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
return
|
|
8066
|
-
jobId: validateIdentifier2(leaseUnknown.jobId, "job lease jobId"),
|
|
8067
|
-
attemptId: validateIdentifier2(leaseUnknown.attemptId, "job lease attemptId"),
|
|
8068
|
-
leaseId: validateIdentifier2(leaseUnknown.leaseId, "job lease leaseId"),
|
|
8069
|
-
fencingToken,
|
|
8070
|
-
leaseExpiresAt: validateTimestamp(leaseUnknown.leaseExpiresAt, "job lease leaseExpiresAt"),
|
|
8071
|
-
job: await this.validateJob(leaseUnknown.job)
|
|
8072
|
-
};
|
|
8320
|
+
if (!isRecord(leaseUnknown)) throw new ProtocolError("Invalid job lease");
|
|
8321
|
+
const { job: jobUnknown, ...envelope } = leaseUnknown;
|
|
8322
|
+
const job = await this.validateJob(jobUnknown);
|
|
8323
|
+
const lease = validateWireMessage("JobLease", {
|
|
8324
|
+
...envelope,
|
|
8325
|
+
job
|
|
8326
|
+
});
|
|
8327
|
+
requireLeaseCoherence(lease);
|
|
8328
|
+
requireLeaseFeatureFit(lease, this.capabilities);
|
|
8329
|
+
return lease;
|
|
8330
|
+
}
|
|
8331
|
+
/** Validates a lease and narrows it to the `oci` shape this runner executes. */
|
|
8332
|
+
async validateExecutableLease(leaseUnknown) {
|
|
8333
|
+
return requireExecutableLease(await this.validateJobLease(leaseUnknown));
|
|
8073
8334
|
}
|
|
8074
8335
|
};
|
|
8075
8336
|
validateJobLease = /* @__PURE__ */ __name(async (leaseUnknown, capabilities) => await new RunnerProtocolValidator(capabilities).validateJobLease(leaseUnknown), "validateJobLease");
|
|
@@ -8077,12 +8338,12 @@ var init_protocol_validator = __esm({
|
|
|
8077
8338
|
});
|
|
8078
8339
|
|
|
8079
8340
|
// ts/attempt-state.ts
|
|
8080
|
-
var
|
|
8341
|
+
var identifierPattern3, journalName, maximumJournalBytes, validateJournal, writeAll3, isNotFound, AttemptStateStore;
|
|
8081
8342
|
var init_attempt_state = __esm({
|
|
8082
8343
|
"ts/attempt-state.ts"() {
|
|
8083
8344
|
init_mod();
|
|
8084
8345
|
init_errors();
|
|
8085
|
-
|
|
8346
|
+
identifierPattern3 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
8086
8347
|
journalName = "active-attempt.json";
|
|
8087
8348
|
maximumJournalBytes = 1024;
|
|
8088
8349
|
validateJournal = /* @__PURE__ */ __name((value) => {
|
|
@@ -8103,7 +8364,7 @@ var init_attempt_state = __esm({
|
|
|
8103
8364
|
"jobId",
|
|
8104
8365
|
"attemptId"
|
|
8105
8366
|
]) {
|
|
8106
|
-
if (typeof record[field2] !== "string" || !
|
|
8367
|
+
if (typeof record[field2] !== "string" || !identifierPattern3.test(record[field2])) {
|
|
8107
8368
|
throw new RunnerError(`Attempt journal contains an invalid ${field2}`);
|
|
8108
8369
|
}
|
|
8109
8370
|
}
|
|
@@ -8335,7 +8596,7 @@ var init_staging_scavenger = __esm({
|
|
|
8335
8596
|
});
|
|
8336
8597
|
|
|
8337
8598
|
// ts/runner.ts
|
|
8338
|
-
var
|
|
8599
|
+
var identifierPattern4, genericSystemError, containsControlCharacter, defaultSleep2, identityFor, safeIdentityFromUnknown, isDefinitiveConflict, LeaseGuard, resourceLimitsSpecVersion, leaseMatchingSpecVersion, runnerCapabilities, capabilitiesForCoordinator, reconcileProtocolLimits, ShipRunner;
|
|
8339
8600
|
var init_runner = __esm({
|
|
8340
8601
|
"ts/runner.ts"() {
|
|
8341
8602
|
init_attempt_state();
|
|
@@ -8343,8 +8604,10 @@ var init_runner = __esm({
|
|
|
8343
8604
|
init_interfaces();
|
|
8344
8605
|
init_log_sender();
|
|
8345
8606
|
init_protocol_validator();
|
|
8607
|
+
init_redactor();
|
|
8608
|
+
init_spec_version();
|
|
8346
8609
|
init_staging_scavenger();
|
|
8347
|
-
|
|
8610
|
+
identifierPattern4 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
8348
8611
|
genericSystemError = "Runner system error";
|
|
8349
8612
|
containsControlCharacter = /* @__PURE__ */ __name((value) => [
|
|
8350
8613
|
...value
|
|
@@ -8390,7 +8653,7 @@ var init_runner = __esm({
|
|
|
8390
8653
|
"attemptId",
|
|
8391
8654
|
"leaseId"
|
|
8392
8655
|
];
|
|
8393
|
-
if (identifiers.some((field2) => typeof record[field2] !== "string" || !
|
|
8656
|
+
if (identifiers.some((field2) => typeof record[field2] !== "string" || !identifierPattern4.test(record[field2])) || typeof record.fencingToken !== "string" || record.fencingToken.length < 16 || record.fencingToken.length > 512 || containsControlCharacter(record.fencingToken)) {
|
|
8394
8657
|
return void 0;
|
|
8395
8658
|
}
|
|
8396
8659
|
return {
|
|
@@ -8442,12 +8705,20 @@ var init_runner = __esm({
|
|
|
8442
8705
|
if (this.timer !== void 0) clearTimeout(this.timer);
|
|
8443
8706
|
}
|
|
8444
8707
|
};
|
|
8445
|
-
|
|
8708
|
+
resourceLimitsSpecVersion = "1.1.0";
|
|
8709
|
+
leaseMatchingSpecVersion = "1.2.0";
|
|
8710
|
+
runnerCapabilities = /* @__PURE__ */ __name((config, runtime) => {
|
|
8446
8711
|
const artifactEnabled = config.maximumArtifacts > 0 && config.maximumArtifactBytes > 0 && config.maximumArtifactExtractedBytes > 0 && config.maximumArtifactEntries > 0;
|
|
8447
8712
|
const cacheEnabled = config.maximumCaches > 0 && config.maximumCacheArchiveBytes > 0 && config.maximumCacheExtractedBytes > 0 && config.maximumCacheEntries > 0;
|
|
8448
8713
|
return createRunnerCapabilitySnapshot({
|
|
8449
8714
|
executionProfiles: [
|
|
8450
|
-
"oci
|
|
8715
|
+
"oci"
|
|
8716
|
+
],
|
|
8717
|
+
isolation: [
|
|
8718
|
+
"container"
|
|
8719
|
+
],
|
|
8720
|
+
platforms: [
|
|
8721
|
+
`${runtime.os}/${runtime.architecture}`
|
|
8451
8722
|
],
|
|
8452
8723
|
labels: [
|
|
8453
8724
|
...config.labels
|
|
@@ -8455,10 +8726,10 @@ var init_runner = __esm({
|
|
|
8455
8726
|
features: [
|
|
8456
8727
|
"source.tar-gz",
|
|
8457
8728
|
...artifactEnabled ? [
|
|
8458
|
-
"artifacts
|
|
8729
|
+
"artifacts"
|
|
8459
8730
|
] : [],
|
|
8460
8731
|
...cacheEnabled ? [
|
|
8461
|
-
"caches
|
|
8732
|
+
"caches"
|
|
8462
8733
|
] : []
|
|
8463
8734
|
],
|
|
8464
8735
|
networks: [
|
|
@@ -8483,12 +8754,37 @@ var init_runner = __esm({
|
|
|
8483
8754
|
maximumTotalLogBytes: config.maximumLogBytes,
|
|
8484
8755
|
maximumWorkspaceBytes: config.oci.workspaceSizeBytes,
|
|
8485
8756
|
maximumWorkspaceEntries: config.maximumWorkspaceEntries
|
|
8486
|
-
}
|
|
8757
|
+
},
|
|
8758
|
+
resources: {
|
|
8759
|
+
maximumMemoryBytes: config.oci.maximumMemoryBytes,
|
|
8760
|
+
maximumCpus: config.oci.maximumCpus,
|
|
8761
|
+
maximumPids: config.oci.maximumPids,
|
|
8762
|
+
maximumSharedMemoryBytes: config.oci.maximumSharedMemoryBytes
|
|
8763
|
+
},
|
|
8764
|
+
leaseFeatures: [],
|
|
8765
|
+
maximumTimeoutMs: config.oci.maximumTimeoutMs
|
|
8487
8766
|
});
|
|
8488
8767
|
}, "runnerCapabilities");
|
|
8768
|
+
capabilitiesForCoordinator = /* @__PURE__ */ __name((capabilities, discovery) => {
|
|
8769
|
+
const messageSpec = lowerSpecVersion(discovery.spec, runnerSpecVersion);
|
|
8770
|
+
const defines = /* @__PURE__ */ __name((since) => compareSpecVersions(messageSpec, since) >= 0, "defines");
|
|
8771
|
+
const { resources, leaseFeatures, maximumTimeoutMs, ...defined } = capabilities;
|
|
8772
|
+
return createRunnerCapabilitySnapshot({
|
|
8773
|
+
...defined,
|
|
8774
|
+
...resources !== void 0 && defines(resourceLimitsSpecVersion) ? {
|
|
8775
|
+
resources
|
|
8776
|
+
} : {},
|
|
8777
|
+
...leaseFeatures !== void 0 && defines(leaseMatchingSpecVersion) ? {
|
|
8778
|
+
leaseFeatures
|
|
8779
|
+
} : {},
|
|
8780
|
+
...maximumTimeoutMs !== void 0 && defines(leaseMatchingSpecVersion) ? {
|
|
8781
|
+
maximumTimeoutMs
|
|
8782
|
+
} : {}
|
|
8783
|
+
});
|
|
8784
|
+
}, "capabilitiesForCoordinator");
|
|
8489
8785
|
reconcileProtocolLimits = /* @__PURE__ */ __name((config, discovery, capabilities) => {
|
|
8490
|
-
if (discovery.
|
|
8491
|
-
throw new ProtocolError(
|
|
8786
|
+
if (!specMajorVersionsMatch(discovery.spec, runnerSpecVersion)) {
|
|
8787
|
+
throw new ProtocolError(`Coordinator specification ${discovery.spec} is incompatible with runner specification ${runnerSpecVersion}`);
|
|
8492
8788
|
}
|
|
8493
8789
|
if (config.maximumResponseBytes > discovery.limits.maximumJsonBytes) {
|
|
8494
8790
|
throw new ProtocolError("Configured JSON response limit exceeds coordinator discovery");
|
|
@@ -8512,6 +8808,7 @@ var init_runner = __esm({
|
|
|
8512
8808
|
drainRequested;
|
|
8513
8809
|
sessionInvalid;
|
|
8514
8810
|
now;
|
|
8811
|
+
monotonicNow;
|
|
8515
8812
|
sleep;
|
|
8516
8813
|
constructor(config, dependencies) {
|
|
8517
8814
|
this.config = config;
|
|
@@ -8519,6 +8816,7 @@ var init_runner = __esm({
|
|
|
8519
8816
|
this.drainRequested = false;
|
|
8520
8817
|
this.sessionInvalid = false;
|
|
8521
8818
|
this.now = dependencies.now ?? Date.now;
|
|
8819
|
+
this.monotonicNow = dependencies.monotonicNow ?? (() => performance.now());
|
|
8522
8820
|
this.sleep = dependencies.sleep ?? defaultSleep2;
|
|
8523
8821
|
}
|
|
8524
8822
|
async run(options = {}) {
|
|
@@ -8529,15 +8827,15 @@ var init_runner = __esm({
|
|
|
8529
8827
|
this.drainRequested = false;
|
|
8530
8828
|
this.sessionInvalid = false;
|
|
8531
8829
|
this.dependencies.api.setRunnerToken(this.config.runnerToken);
|
|
8532
|
-
await this.dependencies.executor.verifyRuntime();
|
|
8830
|
+
const runtime = await this.dependencies.executor.verifyRuntime();
|
|
8533
8831
|
const discovery = await this.dependencies.api.discover(options.signal);
|
|
8534
|
-
const capabilities = runnerCapabilities(this.config);
|
|
8832
|
+
const capabilities = capabilitiesForCoordinator(runnerCapabilities(this.config, runtime), discovery);
|
|
8535
8833
|
reconcileProtocolLimits(this.config, discovery, capabilities);
|
|
8536
8834
|
const validator = new RunnerProtocolValidator(capabilities);
|
|
8537
8835
|
const session = await this.dependencies.api.startSession({
|
|
8538
8836
|
sessionRequestId: crypto.randomUUID(),
|
|
8539
8837
|
runnerId,
|
|
8540
|
-
|
|
8838
|
+
spec: runnerSpecVersion,
|
|
8541
8839
|
runnerVersion,
|
|
8542
8840
|
capabilities
|
|
8543
8841
|
}, options.signal);
|
|
@@ -8622,9 +8920,10 @@ var init_runner = __esm({
|
|
|
8622
8920
|
const unvalidatedIdentity = safeIdentityFromUnknown(runnerId, sessionId, claim.lease);
|
|
8623
8921
|
let lease;
|
|
8624
8922
|
try {
|
|
8625
|
-
lease = await validator.
|
|
8923
|
+
lease = await validator.validateExecutableLease(claim.lease);
|
|
8626
8924
|
} catch (error) {
|
|
8627
8925
|
if (!unvalidatedIdentity) throw error;
|
|
8926
|
+
this.dependencies.onMessage?.(`Refused lease ${unvalidatedIdentity.jobId}/${unvalidatedIdentity.attemptId}: ${error instanceof Error ? error.message : "invalid lease"}`);
|
|
8628
8927
|
await this.abandon(unvalidatedIdentity, "runner_error");
|
|
8629
8928
|
return {
|
|
8630
8929
|
claimed: true,
|
|
@@ -8764,11 +9063,13 @@ var init_runner = __esm({
|
|
|
8764
9063
|
}
|
|
8765
9064
|
async runAcceptedAttempt(runnerId, sessionId, lease, identity, preparedLease, guard, journal) {
|
|
8766
9065
|
const executionAbort = new AbortController();
|
|
9066
|
+
const acceptedAt = this.monotonicNow();
|
|
8767
9067
|
const heartbeatLifecycle = new AbortController();
|
|
8768
9068
|
const heartbeatState = {};
|
|
8769
9069
|
const heartbeat = this.jobHeartbeatLoop(identity, guard, executionAbort, heartbeatState, heartbeatLifecycle.signal);
|
|
8770
9070
|
const startedAt = new Date(this.now()).toISOString();
|
|
8771
|
-
const
|
|
9071
|
+
const redactionSet = SecretRedactionSet.forLease(lease);
|
|
9072
|
+
const logs = new LogSender(this.dependencies.api, identity, redactionSet, this.config.maximumLogBytes, this.config.maximumLogChunkBytes, guard.controller.signal);
|
|
8772
9073
|
let stagingWorkspace;
|
|
8773
9074
|
let runtimeWorkspace;
|
|
8774
9075
|
let status = "system_error";
|
|
@@ -8810,6 +9111,9 @@ var init_runner = __esm({
|
|
|
8810
9111
|
}
|
|
8811
9112
|
recordFailure(error);
|
|
8812
9113
|
}, "recordPostExecutionFailure");
|
|
9114
|
+
const deadlineTimer = setTimeout(() => {
|
|
9115
|
+
if (!executionAbort.signal.aborted) executionAbort.abort("job_timeout");
|
|
9116
|
+
}, Math.max(0, lease.job.timeoutMs - (this.monotonicNow() - acceptedAt)));
|
|
8813
9117
|
try {
|
|
8814
9118
|
if (lease.job.artifacts.length > 0 && !this.dependencies.artifactManager) {
|
|
8815
9119
|
throw new RunnerError("Artifact manager is not configured");
|
|
@@ -8837,6 +9141,7 @@ var init_runner = __esm({
|
|
|
8837
9141
|
lease,
|
|
8838
9142
|
preparedLease,
|
|
8839
9143
|
workspacePath: stagingWorkspace.path,
|
|
9144
|
+
timeoutMs: Math.max(0, Math.ceil(lease.job.timeoutMs - (this.monotonicNow() - acceptedAt))),
|
|
8840
9145
|
signal: executionSignal,
|
|
8841
9146
|
terminationDeadline: /* @__PURE__ */ __name(() => heartbeatState.cancellationDeadline, "terminationDeadline"),
|
|
8842
9147
|
onLog: /* @__PURE__ */ __name((stream, data) => logs.write(stream, data), "onLog")
|
|
@@ -8847,11 +9152,17 @@ var init_runner = __esm({
|
|
|
8847
9152
|
if (status !== "succeeded" && status !== "failed") exitCode = null;
|
|
8848
9153
|
} catch (error) {
|
|
8849
9154
|
if (error instanceof ResourceCleanupError) recordCleanupFailure(error);
|
|
8850
|
-
else if (executionAbort.signal.reason === "
|
|
9155
|
+
else if (executionAbort.signal.reason === "job_timeout" && !guard.controller.signal.aborted) {
|
|
9156
|
+
status = "timed_out";
|
|
9157
|
+
exitCode = null;
|
|
9158
|
+
} else if (executionAbort.signal.reason === "job_canceled" && heartbeatState.cancellation && !guard.controller.signal.aborted) {
|
|
8851
9159
|
status = "canceled";
|
|
8852
9160
|
exitCode = null;
|
|
8853
9161
|
} else if (!guard.controller.signal.aborted) recordFailure(error);
|
|
8854
9162
|
}
|
|
9163
|
+
clearTimeout(deadlineTimer);
|
|
9164
|
+
const timedOut = executionAbort.signal.reason === "job_timeout";
|
|
9165
|
+
const transferSignal = timedOut ? guard.controller.signal : executionSignal;
|
|
8855
9166
|
if (!cleanupFailure2 && !guard.controller.signal.aborted) {
|
|
8856
9167
|
try {
|
|
8857
9168
|
await logs.flush();
|
|
@@ -8863,33 +9174,35 @@ var init_runner = __esm({
|
|
|
8863
9174
|
if (!cleanupFailure2 && heartbeatState.systemFailure !== void 0 && !guard.controller.signal.aborted) {
|
|
8864
9175
|
recordFailure(heartbeatState.systemFailure);
|
|
8865
9176
|
}
|
|
8866
|
-
if (heartbeatState.cancellation && status !== "system_error" && !guard.controller.signal.aborted) {
|
|
9177
|
+
if (heartbeatState.cancellation && !timedOut && status !== "system_error" && !guard.controller.signal.aborted) {
|
|
8867
9178
|
status = "canceled";
|
|
8868
9179
|
exitCode = null;
|
|
8869
9180
|
}
|
|
8870
|
-
if (runtimeWorkspace && !cleanupFailure2 && !
|
|
9181
|
+
if (runtimeWorkspace && !cleanupFailure2 && !transferSignal.aborted) {
|
|
8871
9182
|
if (lease.job.caches.length > 0) {
|
|
8872
9183
|
try {
|
|
8873
9184
|
await this.dependencies.cacheManager.save({
|
|
8874
9185
|
workspace: runtimeWorkspace,
|
|
8875
9186
|
job: lease.job,
|
|
8876
9187
|
status,
|
|
9188
|
+
redactionSet,
|
|
8877
9189
|
identity,
|
|
8878
|
-
signal:
|
|
9190
|
+
signal: transferSignal
|
|
8879
9191
|
});
|
|
8880
9192
|
} catch (error) {
|
|
8881
9193
|
if (error instanceof ResourceCleanupError) recordCleanupFailure(error);
|
|
8882
9194
|
else recordPostExecutionFailure(error);
|
|
8883
9195
|
}
|
|
8884
9196
|
}
|
|
8885
|
-
if (lease.job.artifacts.length > 0 && !cleanupFailure2 && !
|
|
9197
|
+
if (lease.job.artifacts.length > 0 && !cleanupFailure2 && !transferSignal.aborted) {
|
|
8886
9198
|
try {
|
|
8887
9199
|
await this.dependencies.artifactManager.upload({
|
|
8888
9200
|
workspace: runtimeWorkspace,
|
|
8889
9201
|
job: lease.job,
|
|
8890
9202
|
status,
|
|
9203
|
+
redactionSet,
|
|
8891
9204
|
identity,
|
|
8892
|
-
signal:
|
|
9205
|
+
signal: transferSignal
|
|
8893
9206
|
});
|
|
8894
9207
|
} catch (error) {
|
|
8895
9208
|
if (error instanceof ResourceCleanupError) recordCleanupFailure(error);
|
|
@@ -8926,7 +9239,7 @@ var init_runner = __esm({
|
|
|
8926
9239
|
if (heartbeatState.systemFailure !== void 0 && !guard.controller.signal.aborted) {
|
|
8927
9240
|
recordFailure(heartbeatState.systemFailure);
|
|
8928
9241
|
}
|
|
8929
|
-
if (heartbeatState.cancellation && status !== "system_error" && !guard.controller.signal.aborted) {
|
|
9242
|
+
if (heartbeatState.cancellation && !timedOut && status !== "system_error" && !guard.controller.signal.aborted) {
|
|
8930
9243
|
status = "canceled";
|
|
8931
9244
|
exitCode = null;
|
|
8932
9245
|
}
|
|
@@ -9264,53 +9577,34 @@ var init_source_workspace = __esm({
|
|
|
9264
9577
|
});
|
|
9265
9578
|
|
|
9266
9579
|
// ts/registration-state.ts
|
|
9267
|
-
var
|
|
9580
|
+
var journalName2, maximumJournalBytes2, validateRegistrationRequest, withoutRequestId, writeAll4, isNotFound2, RegistrationStateStore;
|
|
9268
9581
|
var init_registration_state = __esm({
|
|
9269
9582
|
"ts/registration-state.ts"() {
|
|
9270
9583
|
init_mod();
|
|
9271
9584
|
init_errors();
|
|
9272
|
-
init_interfaces();
|
|
9273
9585
|
init_protocol_validator();
|
|
9274
|
-
|
|
9586
|
+
init_wire_schema();
|
|
9275
9587
|
journalName2 = "pending-registration.json";
|
|
9276
9588
|
maximumJournalBytes2 = 64 * 1024;
|
|
9277
9589
|
validateRegistrationRequest = /* @__PURE__ */ __name((value) => {
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
"runnerVersion",
|
|
9286
|
-
"name",
|
|
9287
|
-
"capabilities"
|
|
9288
|
-
];
|
|
9289
|
-
if (Object.keys(record).length !== requiredKeys.length || requiredKeys.some((key) => !Object.hasOwn(record, key)) || Object.keys(record).some((key) => !requiredKeys.includes(key))) {
|
|
9290
|
-
throw new RunnerError("Registration journal has an invalid shape");
|
|
9291
|
-
}
|
|
9292
|
-
if (typeof record.registrationRequestId !== "string" || !identifierPattern6.test(record.registrationRequestId)) {
|
|
9293
|
-
throw new RunnerError("Registration journal contains an invalid registrationRequestId");
|
|
9294
|
-
}
|
|
9295
|
-
if (record.protocol !== runnerProtocolIdentifier2) {
|
|
9296
|
-
throw new RunnerError("Registration journal contains an invalid protocol");
|
|
9297
|
-
}
|
|
9298
|
-
if (typeof record.runnerVersion !== "string" || record.runnerVersion.length < 1 || record.runnerVersion.length > 64) {
|
|
9299
|
-
throw new RunnerError("Registration journal contains an invalid runnerVersion");
|
|
9300
|
-
}
|
|
9301
|
-
if (typeof record.name !== "string" || record.name.length < 1 || record.name.length > 128) {
|
|
9302
|
-
throw new RunnerError("Registration journal contains an invalid name");
|
|
9590
|
+
let request;
|
|
9591
|
+
try {
|
|
9592
|
+
request = validateWireMessage("RegisterRunnerRequest", value);
|
|
9593
|
+
} catch (error) {
|
|
9594
|
+
throw new RunnerError("Registration journal has an invalid shape", {
|
|
9595
|
+
cause: error
|
|
9596
|
+
});
|
|
9303
9597
|
}
|
|
9304
9598
|
return {
|
|
9305
|
-
registrationRequestId:
|
|
9306
|
-
|
|
9307
|
-
runnerVersion:
|
|
9308
|
-
name:
|
|
9309
|
-
capabilities: createRunnerCapabilitySnapshot(
|
|
9599
|
+
registrationRequestId: request.registrationRequestId,
|
|
9600
|
+
spec: request.spec,
|
|
9601
|
+
runnerVersion: request.runnerVersion,
|
|
9602
|
+
name: request.name,
|
|
9603
|
+
capabilities: createRunnerCapabilitySnapshot(request.capabilities)
|
|
9310
9604
|
};
|
|
9311
9605
|
}, "validateRegistrationRequest");
|
|
9312
9606
|
withoutRequestId = /* @__PURE__ */ __name((request) => ({
|
|
9313
|
-
|
|
9607
|
+
spec: request.spec,
|
|
9314
9608
|
runnerVersion: request.runnerVersion,
|
|
9315
9609
|
name: request.name,
|
|
9316
9610
|
capabilities: request.capabilities
|
|
@@ -9510,6 +9804,7 @@ var init_cli = __esm({
|
|
|
9510
9804
|
init_oci_executor();
|
|
9511
9805
|
init_registration_state();
|
|
9512
9806
|
init_runner();
|
|
9807
|
+
init_spec_version();
|
|
9513
9808
|
init_source_workspace();
|
|
9514
9809
|
cliInvocation = "deno run --allow-all npm:@ship.zone/runner";
|
|
9515
9810
|
usage = `ship.zone runner ${runnerVersion}
|
|
@@ -9568,7 +9863,7 @@ Bootstrap credentials must be supplied through SHIP_RUNNER_BOOTSTRAP_TOKEN or th
|
|
|
9568
9863
|
}
|
|
9569
9864
|
const stateStore = options.stateStore ?? new RegistrationStateStore(options.config.stateDirectory);
|
|
9570
9865
|
const request = await stateStore.loadOrCreate({
|
|
9571
|
-
|
|
9866
|
+
spec: runnerSpecVersion,
|
|
9572
9867
|
runnerVersion,
|
|
9573
9868
|
name: options.config.name,
|
|
9574
9869
|
capabilities: options.capabilities
|
|
@@ -9590,10 +9885,9 @@ Bootstrap credentials must be supplied through SHIP_RUNNER_BOOTSTRAP_TOKEN or th
|
|
|
9590
9885
|
const helperPath = stringOption(options, "workspace-helper-path");
|
|
9591
9886
|
if (helperPath) config.oci.workspaceHelperPath = helperPath;
|
|
9592
9887
|
if (options.has("allow-insecure-loopback")) config.allowInsecureLoopback = true;
|
|
9593
|
-
if (options.has("allow-network"))
|
|
9594
|
-
"
|
|
9595
|
-
|
|
9596
|
-
];
|
|
9888
|
+
if (options.has("allow-network")) {
|
|
9889
|
+
throw new ConfigurationError("--allow-network is not supported: this runner does not enforce egress allowlists");
|
|
9890
|
+
}
|
|
9597
9891
|
validateRunnerConfig(config);
|
|
9598
9892
|
const path = configPath(options);
|
|
9599
9893
|
await saveRunnerConfig(path, config);
|
|
@@ -9607,9 +9901,9 @@ Bootstrap credentials must be supplied through SHIP_RUNNER_BOOTSTRAP_TOKEN or th
|
|
|
9607
9901
|
}
|
|
9608
9902
|
const api = apiFor(config);
|
|
9609
9903
|
const executor = new OciExecutor(config);
|
|
9610
|
-
await executor.verifyRuntime();
|
|
9904
|
+
const runtime = await executor.verifyRuntime();
|
|
9611
9905
|
const discovery = await api.discover();
|
|
9612
|
-
const capabilities = runnerCapabilities(config);
|
|
9906
|
+
const capabilities = capabilitiesForCoordinator(runnerCapabilities(config, runtime), discovery);
|
|
9613
9907
|
reconcileProtocolLimits(config, discovery, capabilities);
|
|
9614
9908
|
const registered = await registerRunnerDurably({
|
|
9615
9909
|
configPath: path,
|
|
@@ -9717,7 +10011,9 @@ init_protocol_validator();
|
|
|
9717
10011
|
init_redactor();
|
|
9718
10012
|
init_runner();
|
|
9719
10013
|
init_source_workspace();
|
|
10014
|
+
init_spec_version();
|
|
9720
10015
|
init_staging_scavenger();
|
|
10016
|
+
init_wire_schema();
|
|
9721
10017
|
|
|
9722
10018
|
// mod.ts
|
|
9723
10019
|
if (import.meta.main) {
|
|
@@ -9732,37 +10028,54 @@ export {
|
|
|
9732
10028
|
CoordinatorError,
|
|
9733
10029
|
LeaseLostError,
|
|
9734
10030
|
LogSender,
|
|
10031
|
+
LogSequenceRedactor,
|
|
9735
10032
|
OciExecutor,
|
|
9736
10033
|
ProtocolError,
|
|
9737
10034
|
ResourceCleanupError,
|
|
9738
10035
|
RunnerApiClient,
|
|
9739
10036
|
RunnerError,
|
|
9740
10037
|
RunnerProtocolValidator,
|
|
10038
|
+
SecretContentMatcher,
|
|
10039
|
+
SecretDisclosureError,
|
|
10040
|
+
SecretRedactionSet,
|
|
9741
10041
|
ShipRunner,
|
|
9742
10042
|
SourceWorkspaceManager,
|
|
9743
10043
|
StreamingSecretRedactor,
|
|
10044
|
+
UnsupportedJobError,
|
|
10045
|
+
acceptSpecVersion,
|
|
9744
10046
|
buildOciHelperCreateCommand,
|
|
9745
10047
|
buildOciRunCommand,
|
|
9746
10048
|
calculateWorkspaceVolumeLimits,
|
|
9747
10049
|
canonicalizeJson,
|
|
10050
|
+
capabilitiesForCoordinator,
|
|
10051
|
+
compareSpecVersions,
|
|
9748
10052
|
computeCompiledPlanDigest,
|
|
9749
10053
|
copyOciConfig,
|
|
9750
10054
|
createRunnerCapabilitySnapshot,
|
|
9751
10055
|
defaultRunnerConfig,
|
|
10056
|
+
isValidWireMessage,
|
|
10057
|
+
isWireSchemaName,
|
|
9752
10058
|
loadRunnerConfig,
|
|
10059
|
+
lowerSpecVersion,
|
|
9753
10060
|
maskRunnerConfig,
|
|
10061
|
+
minimumRedactionMemberBytes,
|
|
9754
10062
|
parseRunnerConfig,
|
|
9755
10063
|
projectCompiledPlan,
|
|
9756
10064
|
reconcileProtocolLimits,
|
|
10065
|
+
requireExecutableLease,
|
|
9757
10066
|
runnerCapabilities,
|
|
9758
|
-
|
|
10067
|
+
runnerSpecVersion,
|
|
9759
10068
|
runnerVersion,
|
|
9760
10069
|
saveRunnerConfig,
|
|
9761
10070
|
scavengeHostTmpfsProbes,
|
|
9762
10071
|
scavengeRunnerStaging,
|
|
10072
|
+
specMajorVersionsMatch,
|
|
9763
10073
|
validateCapabilityFit,
|
|
10074
|
+
validateCompiledJobSchema,
|
|
9764
10075
|
validateJobLease,
|
|
9765
10076
|
validateRunnerConfig,
|
|
10077
|
+
validateWireMessage,
|
|
10078
|
+
wireSchemaNames,
|
|
9766
10079
|
withRunnerCredential,
|
|
9767
10080
|
workspaceFixedInodes,
|
|
9768
10081
|
workspaceHelperReserveBytes
|