@jigging/jig 0.1.0-alpha.26 → 0.1.0-alpha.27
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/libexec/evaluator/project-evaluator-worker.js +420 -10
- package/libexec/installed-cli.js +563 -338
- package/libexec/linux-rootless-supervisor.js +54 -0
- package/libexec/macos-native-supervisor.js +3 -1
- package/libexec/markdown-runtime.js +3 -3
- package/libexec/preparation/bun-native-preparation-worker.js +40 -21
- package/package.json +1 -1
package/libexec/installed-cli.js
CHANGED
|
@@ -9087,7 +9087,7 @@ import { setTimeout as delay } from "timers/promises";
|
|
|
9087
9087
|
// package.json
|
|
9088
9088
|
var package_default = {
|
|
9089
9089
|
name: "@jigging/jig",
|
|
9090
|
-
version: "0.1.0-alpha.
|
|
9090
|
+
version: "0.1.0-alpha.27",
|
|
9091
9091
|
description: "A local, secure host for admitted FLOW packages",
|
|
9092
9092
|
license: "SEE LICENSE IN LICENSE.md",
|
|
9093
9093
|
repository: {
|
|
@@ -21199,6 +21199,7 @@ async function captureAttempt(root, backing, selection) {
|
|
|
21199
21199
|
const directories = new Set([identityKey(root.information)]);
|
|
21200
21200
|
let totalBytes = 0;
|
|
21201
21201
|
let directoryCount = 0;
|
|
21202
|
+
const copyBuffer = new Uint8Array(COPY_CHUNK_BYTES);
|
|
21202
21203
|
async function walk(directory, logicalDirectory) {
|
|
21203
21204
|
directoryCount += 1;
|
|
21204
21205
|
if (directoryCount > MAX_DIRECTORIES) {
|
|
@@ -21224,7 +21225,7 @@ async function captureAttempt(root, backing, selection) {
|
|
|
21224
21225
|
invalid("PACKAGE_LIMIT", "selected dependency source exceeds its capture budget", logicalPath);
|
|
21225
21226
|
await rejectKnownOversizeFile(entry.handle, entry.information, logicalPath);
|
|
21226
21227
|
const offset = totalBytes;
|
|
21227
|
-
const size = await copyToBacking(entry.handle, backing, offset, totalBytes, logicalPath, selection?.maximumBytes);
|
|
21228
|
+
const size = await copyToBacking(entry.handle, backing, offset, totalBytes, logicalPath, copyBuffer, selection?.maximumBytes);
|
|
21228
21229
|
totalBytes += size;
|
|
21229
21230
|
if (selection !== undefined && totalBytes > selection.maximumBytes)
|
|
21230
21231
|
invalid("PACKAGE_LIMIT", "selected dependency source exceeds its capture budget", logicalPath);
|
|
@@ -21248,10 +21249,9 @@ async function captureAttempt(root, backing, selection) {
|
|
|
21248
21249
|
}
|
|
21249
21250
|
return { records, fingerprints };
|
|
21250
21251
|
}
|
|
21251
|
-
async function copyToBacking(source, backing, backingOffset, priorTotal, logicalPath, maximumBytes = MAX_TOTAL_BYTES2) {
|
|
21252
|
+
async function copyToBacking(source, backing, backingOffset, priorTotal, logicalPath, buffer, maximumBytes = MAX_TOTAL_BYTES2) {
|
|
21252
21253
|
let sourceOffset = 0;
|
|
21253
21254
|
while (true) {
|
|
21254
|
-
const buffer = new Uint8Array(COPY_CHUNK_BYTES);
|
|
21255
21255
|
let bytesRead;
|
|
21256
21256
|
try {
|
|
21257
21257
|
({ bytesRead } = await source.read(buffer, 0, buffer.byteLength, sourceOffset));
|
|
@@ -25903,7 +25903,7 @@ var MAX_RECORD_BYTES = 192;
|
|
|
25903
25903
|
class PrivateProfileCapture {
|
|
25904
25904
|
#fd;
|
|
25905
25905
|
#startedAtMs = performance.now();
|
|
25906
|
-
#
|
|
25906
|
+
#recordCount = 0;
|
|
25907
25907
|
#nextSpanId = 1;
|
|
25908
25908
|
#truncated = false;
|
|
25909
25909
|
#closed = false;
|
|
@@ -25919,8 +25919,7 @@ class PrivateProfileCapture {
|
|
|
25919
25919
|
timeOriginMs: performance.timeOrigin
|
|
25920
25920
|
};
|
|
25921
25921
|
try {
|
|
25922
|
-
|
|
25923
|
-
`);
|
|
25922
|
+
this.#write(JSON.stringify(header));
|
|
25924
25923
|
} catch (error) {
|
|
25925
25924
|
closeSync9(this.#fd);
|
|
25926
25925
|
throw error;
|
|
@@ -25932,13 +25931,13 @@ class PrivateProfileCapture {
|
|
|
25932
25931
|
return;
|
|
25933
25932
|
}
|
|
25934
25933
|
const span = { spanId: this.#nextSpanId++, phase, startMs: elapsed(this.#startedAtMs) };
|
|
25935
|
-
this.#
|
|
25934
|
+
this.#record(JSON.stringify({ kind: "start", spanId: span.spanId, phase, timeMs: span.startMs }));
|
|
25936
25935
|
return span;
|
|
25937
25936
|
}
|
|
25938
25937
|
end(span, outcome) {
|
|
25939
25938
|
if (this.#closed)
|
|
25940
25939
|
return;
|
|
25941
|
-
this.#
|
|
25940
|
+
this.#record(JSON.stringify({
|
|
25942
25941
|
kind: "end",
|
|
25943
25942
|
spanId: span.spanId,
|
|
25944
25943
|
phase: span.phase,
|
|
@@ -25947,29 +25946,18 @@ class PrivateProfileCapture {
|
|
|
25947
25946
|
}));
|
|
25948
25947
|
}
|
|
25949
25948
|
instant(phase) {
|
|
25950
|
-
if (this.#closed
|
|
25951
|
-
this.#truncated = true;
|
|
25949
|
+
if (this.#closed)
|
|
25952
25950
|
return;
|
|
25953
|
-
}
|
|
25954
25951
|
const timeMs = elapsed(this.#startedAtMs);
|
|
25955
|
-
this.#
|
|
25952
|
+
this.#record(JSON.stringify({ kind: "instant", phase, timeMs }));
|
|
25956
25953
|
}
|
|
25957
25954
|
finish() {
|
|
25958
25955
|
if (this.#closed)
|
|
25959
25956
|
return;
|
|
25960
25957
|
this.#closed = true;
|
|
25961
25958
|
try {
|
|
25962
|
-
for (const event of this.#events) {
|
|
25963
|
-
if (Buffer.byteLength(event) > MAX_RECORD_BYTES) {
|
|
25964
|
-
this.#truncated = true;
|
|
25965
|
-
continue;
|
|
25966
|
-
}
|
|
25967
|
-
writeSync3(this.#fd, `${event}
|
|
25968
|
-
`);
|
|
25969
|
-
}
|
|
25970
25959
|
if (this.#truncated) {
|
|
25971
|
-
|
|
25972
|
-
`);
|
|
25960
|
+
this.#write(JSON.stringify({ kind: "truncated", phaseLimit: MAX_SPANS }));
|
|
25973
25961
|
}
|
|
25974
25962
|
} finally {
|
|
25975
25963
|
closeSync9(this.#fd);
|
|
@@ -25981,6 +25969,25 @@ class PrivateProfileCapture {
|
|
|
25981
25969
|
this.#closed = true;
|
|
25982
25970
|
closeSync9(this.#fd);
|
|
25983
25971
|
}
|
|
25972
|
+
#record(event) {
|
|
25973
|
+
if (this.#recordCount >= MAX_SPANS * 2 || Buffer.byteLength(event) > MAX_RECORD_BYTES) {
|
|
25974
|
+
this.#truncated = true;
|
|
25975
|
+
return;
|
|
25976
|
+
}
|
|
25977
|
+
this.#recordCount++;
|
|
25978
|
+
this.#write(event);
|
|
25979
|
+
}
|
|
25980
|
+
#write(event) {
|
|
25981
|
+
const bytes = Buffer.from(`${event}
|
|
25982
|
+
`);
|
|
25983
|
+
let offset = 0;
|
|
25984
|
+
while (offset < bytes.length) {
|
|
25985
|
+
const written = writeSync3(this.#fd, bytes, offset, bytes.length - offset);
|
|
25986
|
+
if (written === 0)
|
|
25987
|
+
throw new Error("private profile write made no progress");
|
|
25988
|
+
offset += written;
|
|
25989
|
+
}
|
|
25990
|
+
}
|
|
25984
25991
|
}
|
|
25985
25992
|
var configuredPath = process.env[PROFILE_ENVIRONMENT_KEY];
|
|
25986
25993
|
var activeCapture;
|
|
@@ -26151,7 +26158,7 @@ function privateMacosExecutionPlan(intent, allocation) {
|
|
|
26151
26158
|
network: intent.network ?? "isolated"
|
|
26152
26159
|
},
|
|
26153
26160
|
maxOutputBytes: intent.maxOutputBytes,
|
|
26154
|
-
...intent.readOnlyCwd === undefined ? {
|
|
26161
|
+
...intent.readOnlyCwd === undefined || (intent.inputDirectories?.length ?? 0) > 0 ? {
|
|
26155
26162
|
storage: {
|
|
26156
26163
|
mountPath: data,
|
|
26157
26164
|
bytes: intent.storageBytes,
|
|
@@ -27351,6 +27358,7 @@ var STOP_REASONS = new Set([
|
|
|
27351
27358
|
"coordinator_lost",
|
|
27352
27359
|
"deadline",
|
|
27353
27360
|
"payload_exit",
|
|
27361
|
+
"core_dump",
|
|
27354
27362
|
"setup_failed",
|
|
27355
27363
|
"recovered"
|
|
27356
27364
|
]);
|
|
@@ -28018,6 +28026,7 @@ var SUPERVISOR_STOP_REASONS = new Set([
|
|
|
28018
28026
|
"coordinator_lost",
|
|
28019
28027
|
"deadline",
|
|
28020
28028
|
"payload_exit",
|
|
28029
|
+
"core_dump",
|
|
28021
28030
|
"setup_failed"
|
|
28022
28031
|
]);
|
|
28023
28032
|
function receiptFor(prepared, final) {
|
|
@@ -29795,7 +29804,9 @@ function requirePrivateMacosGuardianStorage(storage, files, cwd) {
|
|
|
29795
29804
|
if (storage === null || typeof storage !== "object" || Object.keys(storage).sort().join() !== "bytes,collect,mountPath" || typeof storage.mountPath !== "string" || !storage.mountPath.startsWith("/") || storage.mountPath === "/" || posix8.normalize(storage.mountPath) !== storage.mountPath || !Number.isSafeInteger(storage.bytes) || storage.bytes < 16 * 1024 * 1024 || storage.bytes > 512 * 1024 * 1024 || storage.bytes % (1024 * 1024) !== 0 || ![null, "output", "work"].includes(storage.collect))
|
|
29796
29805
|
throw new TypeError("invalid macOS guardian storage");
|
|
29797
29806
|
const roots = ["work", "tmp", "output"].map((name) => join10(storage.mountPath, name));
|
|
29798
|
-
|
|
29807
|
+
const inputs = join10(storage.mountPath, "inputs");
|
|
29808
|
+
const readOnlyInputCwd = files.writableTrees.length === 0 && storage.collect === null && files.readOnlyTrees.includes(inputs) && (cwd === inputs || cwd.startsWith(`${inputs}/`));
|
|
29809
|
+
if (files.writableTrees.some((path) => !roots.includes(path)) || !roots.some((root) => cwd === root || cwd.startsWith(`${root}/`)) && !readOnlyInputCwd)
|
|
29799
29810
|
throw new TypeError("macOS writable projection is outside bounded storage");
|
|
29800
29811
|
}
|
|
29801
29812
|
async function allocatePrivateMacosGuardianStorage(owner, token, storage) {
|
|
@@ -31421,6 +31432,9 @@ function recordKind(value) {
|
|
|
31421
31432
|
return value !== null && typeof value === "object" ? value.kind : undefined;
|
|
31422
31433
|
}
|
|
31423
31434
|
|
|
31435
|
+
// src/project/author-evaluator.ts
|
|
31436
|
+
init_input_capture();
|
|
31437
|
+
|
|
31424
31438
|
// src/internal/installed-bun-support.ts
|
|
31425
31439
|
init_macos_process_controls();
|
|
31426
31440
|
import { constants as constants18 } from "fs";
|
|
@@ -31644,6 +31658,28 @@ async function exactDirectory(path2, label) {
|
|
|
31644
31658
|
return resolved;
|
|
31645
31659
|
}
|
|
31646
31660
|
|
|
31661
|
+
// src/internal/project-evaluator-policy.ts
|
|
31662
|
+
var PRIVATE_AUTHOR_EVALUATOR_PROTOCOL = "jig-author-evaluator/1";
|
|
31663
|
+
var PRIVATE_AUTHOR_EVALUATOR_MAX_ENTRIES = 256;
|
|
31664
|
+
var PRIVATE_AUTHOR_EVALUATOR_ENTRY_MS = 3000;
|
|
31665
|
+
var PRIVATE_AUTHOR_EVALUATOR_MACOS_ENTRY_MS = 1e4;
|
|
31666
|
+
var PRIVATE_AUTHOR_EVALUATOR_BATCH_FIXED_OVERHEAD_MS = 2000;
|
|
31667
|
+
var PRIVATE_AUTHOR_EVALUATOR_BATCH_ENTRY_OVERHEAD_MS = 500;
|
|
31668
|
+
function privateAuthorEvaluatorWallClockCeilingMs(entries, entryWallClockCeilingMs = PRIVATE_AUTHOR_EVALUATOR_ENTRY_MS) {
|
|
31669
|
+
return entryWallClockCeilingMs * entries + (entries > 1 ? PRIVATE_AUTHOR_EVALUATOR_BATCH_FIXED_OVERHEAD_MS + PRIVATE_AUTHOR_EVALUATOR_BATCH_ENTRY_OVERHEAD_MS * entries : 0);
|
|
31670
|
+
}
|
|
31671
|
+
var PRIVATE_AUTHOR_EVALUATOR_DIRECTORY = "/jig-input/evaluator";
|
|
31672
|
+
var PRIVATE_AUTHOR_EVALUATOR_WORKER = `${PRIVATE_AUTHOR_EVALUATOR_DIRECTORY}/project-evaluator-worker.js`;
|
|
31673
|
+
var PRIVATE_AUTHOR_EVALUATOR_LIMITS = Object.freeze({
|
|
31674
|
+
memoryBytes: 256 * 1024 * 1024,
|
|
31675
|
+
pids: 64,
|
|
31676
|
+
cpuQuotaMicros: 50000,
|
|
31677
|
+
cpuPeriodMicros: 1e5,
|
|
31678
|
+
wallClockCeilingMs: PRIVATE_AUTHOR_EVALUATOR_ENTRY_MS,
|
|
31679
|
+
cancellationGraceMs: 1000,
|
|
31680
|
+
cleanupTimeoutMs: 5000
|
|
31681
|
+
});
|
|
31682
|
+
|
|
31647
31683
|
// src/project/author-module.ts
|
|
31648
31684
|
import { createHash as createHash11 } from "crypto";
|
|
31649
31685
|
import { constants as constants19 } from "fs";
|
|
@@ -32038,19 +32074,10 @@ function errorText7(error) {
|
|
|
32038
32074
|
}
|
|
32039
32075
|
|
|
32040
32076
|
// src/project/author-evaluator.ts
|
|
32041
|
-
var PROTOCOL =
|
|
32077
|
+
var PROTOCOL = PRIVATE_AUTHOR_EVALUATOR_PROTOCOL;
|
|
32042
32078
|
var MAX_STDERR_BYTES = 64 * 1024;
|
|
32043
32079
|
var MAX_STDOUT_BYTES = JSON_1_LIMITS.bytes + 16 * 1024;
|
|
32044
|
-
var EVALUATOR_LIMIT_POLICY =
|
|
32045
|
-
memoryBytes: 256 * 1024 * 1024,
|
|
32046
|
-
pids: 64,
|
|
32047
|
-
cpuQuotaMicros: 50000,
|
|
32048
|
-
cpuPeriodMicros: 1e5,
|
|
32049
|
-
wallClockCeilingMs: 3000,
|
|
32050
|
-
cancellationGraceMs: 1000,
|
|
32051
|
-
cleanupTimeoutMs: 5000
|
|
32052
|
-
});
|
|
32053
|
-
var MACOS_EVALUATOR_WALL_CLOCK_CEILING_MS = 1e4;
|
|
32080
|
+
var EVALUATOR_LIMIT_POLICY = PRIVATE_AUTHOR_EVALUATOR_LIMITS;
|
|
32054
32081
|
var EVALUATION_CODES = new Set([
|
|
32055
32082
|
"PROJECT_AUTHORING_VALUE",
|
|
32056
32083
|
"PROJECT_DEFAULT_EXPORT",
|
|
@@ -32058,19 +32085,38 @@ var EVALUATION_CODES = new Set([
|
|
|
32058
32085
|
"PROJECT_EVALUATION_LIMIT",
|
|
32059
32086
|
"PROJECT_EVALUATOR_COMPILE",
|
|
32060
32087
|
"PROJECT_EVALUATOR_IMPORT",
|
|
32061
|
-
"PROJECT_EVALUATOR_PROTOCOL"
|
|
32088
|
+
"PROJECT_EVALUATOR_PROTOCOL",
|
|
32089
|
+
"PROJECT_EVALUATOR_DEADLINE"
|
|
32062
32090
|
]);
|
|
32063
32091
|
var decoder6 = new TextDecoder("utf-8", { fatal: true });
|
|
32064
32092
|
var evaluationSequence = 0;
|
|
32065
32093
|
async function evaluateAuthorClosure(options, captured, entryProjectPath, expected, signal) {
|
|
32094
|
+
const results = await evaluateAuthorClosureBatch(options, captured, [{ entryProjectPath, expected }], signal);
|
|
32095
|
+
return results[0];
|
|
32096
|
+
}
|
|
32097
|
+
async function evaluateAuthorClosureBatch(options, captured, requestedEntries, signal) {
|
|
32098
|
+
const entries = Object.freeze(requestedEntries.map(({ entryProjectPath: entryProjectPath2, expected }) => Object.freeze({ entryProjectPath: entryProjectPath2, expected })));
|
|
32066
32099
|
if (!isCapturedAuthorClosure(captured)) {
|
|
32067
32100
|
invalid("PROJECT_AUTHOR_CAPTURE", "author closure was not produced by the capture boundary");
|
|
32068
32101
|
}
|
|
32069
|
-
if (
|
|
32070
|
-
invalid("PROJECT_AUTHOR_CAPTURE", "
|
|
32102
|
+
if (entries.length === 0 || entries.length > PRIVATE_AUTHOR_EVALUATOR_MAX_ENTRIES) {
|
|
32103
|
+
invalid("PROJECT_AUTHOR_CAPTURE", "evaluator batch has an invalid declaration count");
|
|
32104
|
+
}
|
|
32105
|
+
const selected = new Set;
|
|
32106
|
+
for (const { entryProjectPath: entryProjectPath2 } of entries) {
|
|
32107
|
+
if (!captured.entries.includes(entryProjectPath2) || selected.has(entryProjectPath2)) {
|
|
32108
|
+
invalid("PROJECT_AUTHOR_CAPTURE", "selected entry is absent or repeated", entryProjectPath2);
|
|
32109
|
+
}
|
|
32110
|
+
selected.add(entryProjectPath2);
|
|
32071
32111
|
}
|
|
32112
|
+
const entryProjectPath = entries[0].entryProjectPath;
|
|
32113
|
+
const entryWallClockCeilingMs = privateExecutionBackendKind(options.backend) === "macos" ? PRIVATE_AUTHOR_EVALUATOR_MACOS_ENTRY_MS : PRIVATE_AUTHOR_EVALUATOR_ENTRY_MS;
|
|
32114
|
+
const limitPolicy = Object.freeze({
|
|
32115
|
+
...EVALUATOR_LIMIT_POLICY,
|
|
32116
|
+
wallClockCeilingMs: privateAuthorEvaluatorWallClockCeilingMs(entries.length, entryWallClockCeilingMs)
|
|
32117
|
+
});
|
|
32072
32118
|
const installedSupport = requirePrivateInstalledBunSupport(options.installedSupport);
|
|
32073
|
-
await revalidatePrivateInstalledBunSupport(installedSupport).catch((error) => unavailable("PROJECT_EVALUATOR_SUPPORT", `installed evaluator support is unavailable: ${errorText8(error)}`, entryProjectPath));
|
|
32119
|
+
await privateProfileSpan("author-support-verification", () => revalidatePrivateInstalledBunSupport(installedSupport)).catch((error) => unavailable("PROJECT_EVALUATOR_SUPPORT", `installed evaluator support is unavailable: ${errorText8(error)}`, entryProjectPath));
|
|
32074
32120
|
const runtimeMounts = installedSupport.runtimeMounts;
|
|
32075
32121
|
const [workerBytes, sdkBytes, schemaBytes] = await Promise.all([
|
|
32076
32122
|
readFile3(join15(installedSupport.evaluatorSupportPath, "project-evaluator-worker.js")),
|
|
@@ -32078,6 +32124,14 @@ async function evaluateAuthorClosure(options, captured, entryProjectPath, expect
|
|
|
32078
32124
|
readFile3(join15(installedSupport.evaluatorSupportPath, "project-authoring-1.schema.json"))
|
|
32079
32125
|
]).catch((error) => unavailable("PROJECT_EVALUATOR_SUPPORT", `cannot seal evaluator toolchain: ${errorText8(error)}`, entryProjectPath));
|
|
32080
32126
|
const authoringProfile = "project-authoring/1";
|
|
32127
|
+
const capturedSupportDigest = privateDomainDigest("JIG-Installed-Evaluator-Support/1", [
|
|
32128
|
+
{ name: "project-evaluator-worker.js", digest: digestBytes(workerBytes) },
|
|
32129
|
+
{ name: "project-evaluator-sdk.bundle.js", digest: digestBytes(sdkBytes) },
|
|
32130
|
+
{ name: "project-authoring-1.schema.json", digest: digestBytes(schemaBytes) }
|
|
32131
|
+
]);
|
|
32132
|
+
if (capturedSupportDigest !== installedSupport.evaluatorSupportDigest) {
|
|
32133
|
+
unavailable("PROJECT_EVALUATOR_SUPPORT", "evaluator support changed during capture", entryProjectPath);
|
|
32134
|
+
}
|
|
32081
32135
|
const profileBase = Object.freeze({
|
|
32082
32136
|
protocol: PROTOCOL,
|
|
32083
32137
|
authoringProfile,
|
|
@@ -32092,7 +32146,12 @@ async function evaluateAuthorClosure(options, captured, entryProjectPath, expect
|
|
|
32092
32146
|
kind: installedSupport.kind,
|
|
32093
32147
|
digest: installedSupport.digest
|
|
32094
32148
|
}),
|
|
32095
|
-
buildOptions: "bun-cjs-closed-static-closure/1"
|
|
32149
|
+
buildOptions: "bun-cjs-closed-static-closure/1",
|
|
32150
|
+
evaluation: Object.freeze({
|
|
32151
|
+
kind: "finite-isolated-declarations/1",
|
|
32152
|
+
entries: entries.length,
|
|
32153
|
+
entryWallClockCeilingMs
|
|
32154
|
+
})
|
|
32096
32155
|
});
|
|
32097
32156
|
const modules = captured.modules.map((module) => ({
|
|
32098
32157
|
projectPath: module.projectPath,
|
|
@@ -32102,177 +32161,213 @@ async function evaluateAuthorClosure(options, captured, entryProjectPath, expect
|
|
|
32102
32161
|
const request = canonicalJson({
|
|
32103
32162
|
protocol: PROTOCOL,
|
|
32104
32163
|
authoringProfile,
|
|
32105
|
-
entryProjectPath,
|
|
32164
|
+
entries: entries.map(({ entryProjectPath: entryProjectPath2 }) => entryProjectPath2),
|
|
32106
32165
|
modules
|
|
32107
32166
|
});
|
|
32108
32167
|
const runId = `config-${process.pid.toString(36)}-${(++evaluationSequence).toString(36)}`;
|
|
32109
|
-
const
|
|
32110
|
-
const
|
|
32111
|
-
|
|
32112
|
-
return unavailable("PROJECT_EVALUATOR_LAUNCH", `cannot launch evaluator envelope: ${errorText8(error)}`, entryProjectPath);
|
|
32113
|
-
});
|
|
32114
|
-
const validEnvelope = component.envelope.kind === "linux-rootless-cgroup-v2-bubblewrap/1" ? component.envelope.privateProcessFilesystem && component.envelope.privateRuntimeDevices && sameEvaluatorLimits(component.envelope.limits, limits) && component.envelope.trustedCoordinatorBunDigest === installedSupport.executableDigest : component.envelope.resourceAccounting === "supervised-sampled-with-termination" && component.envelope.resourceOvershoot === true && sameEvaluatorLimits(component.envelope.limits, limits);
|
|
32115
|
-
if (!validEnvelope) {
|
|
32116
|
-
await component.terminate().catch(() => {
|
|
32117
|
-
return;
|
|
32118
|
-
});
|
|
32119
|
-
const completion = await component.completion.catch((error) => unavailable("PROJECT_EVALUATOR_CLEANUP", `evaluator envelope lost while rejecting its predicates: ${errorText8(error)}`, entryProjectPath));
|
|
32120
|
-
if (!completion.fenced || completion.cleanupError !== undefined) {
|
|
32121
|
-
unavailable("PROJECT_EVALUATOR_CLEANUP", "evaluator envelope predicates were absent and cleanup was not proven", entryProjectPath);
|
|
32122
|
-
}
|
|
32123
|
-
unavailable("PROJECT_EVALUATOR_ENVELOPE", "evaluator envelope did not preserve its sealed runtime or root-only predicates", entryProjectPath);
|
|
32124
|
-
}
|
|
32125
|
-
const profile = Object.freeze({
|
|
32126
|
-
...profileBase,
|
|
32127
|
-
sandbox: component.envelope.kind === "linux-rootless-cgroup-v2-bubblewrap/1" ? Object.freeze({
|
|
32128
|
-
kind: component.envelope.kind,
|
|
32129
|
-
mechanismDigest: component.envelope.mechanismDigest,
|
|
32130
|
-
sealedPlanDigest: component.envelope.sealedPlanDigest,
|
|
32131
|
-
bubblewrapPath: component.envelope.trustedBubblewrapPath,
|
|
32132
|
-
bubblewrapDigest: component.envelope.trustedBubblewrapDigest,
|
|
32133
|
-
coordinatorRuntimePath: component.envelope.trustedCoordinatorBunPath,
|
|
32134
|
-
coordinatorRuntimeDigest: component.envelope.trustedCoordinatorBunDigest,
|
|
32135
|
-
supervisorPath: component.envelope.trustedSupervisorPath,
|
|
32136
|
-
supervisorDigest: component.envelope.trustedSupervisorDigest,
|
|
32137
|
-
payloadUid: component.envelope.payloadUid,
|
|
32138
|
-
payloadGid: component.envelope.payloadGid,
|
|
32139
|
-
limits: policy,
|
|
32140
|
-
privateProcessFilesystem: component.envelope.privateProcessFilesystem,
|
|
32141
|
-
privateRuntimeDevices: component.envelope.privateRuntimeDevices
|
|
32142
|
-
}) : Object.freeze({
|
|
32143
|
-
kind: component.envelope.kind,
|
|
32144
|
-
mechanismDigest: component.envelope.mechanismDigest,
|
|
32145
|
-
sealedPlanDigest: component.envelope.sealedPlanDigest,
|
|
32146
|
-
supervisorPath: installedSupport.supervisorPath,
|
|
32147
|
-
supervisorDigest: installedSupport.supervisorDigest,
|
|
32148
|
-
launcherPath: installedSupport.launcherPath,
|
|
32149
|
-
launcherDigest: installedSupport.launcherDigest,
|
|
32150
|
-
limits: policy,
|
|
32151
|
-
resourceAccounting: component.envelope.resourceAccounting,
|
|
32152
|
-
resourceOvershoot: component.envelope.resourceOvershoot
|
|
32153
|
-
})
|
|
32154
|
-
});
|
|
32155
|
-
const stdout = collectBounded(component.stdout, MAX_STDOUT_BYTES, component.terminate);
|
|
32156
|
-
const stderr = collectBounded(component.stderr, MAX_STDERR_BYTES, component.terminate);
|
|
32168
|
+
const limits = evaluatorLimits(limitPolicy);
|
|
32169
|
+
const inputs = [];
|
|
32170
|
+
let operationFailure;
|
|
32157
32171
|
try {
|
|
32158
|
-
await component.write(request);
|
|
32159
|
-
await component.closeInput();
|
|
32160
|
-
const [output, diagnostics, exit, evidence, terminationReason] = await Promise.all([
|
|
32161
|
-
stdout,
|
|
32162
|
-
stderr,
|
|
32163
|
-
component.completion,
|
|
32164
|
-
component.evidence,
|
|
32165
|
-
component.terminationReason
|
|
32166
|
-
]);
|
|
32167
|
-
if (exit.cleanupError !== undefined || !exit.fenced) {
|
|
32168
|
-
unavailable("PROJECT_EVALUATOR_CLEANUP", `evaluator cleanup was not proven: ${exit.cleanupError ?? "not fenced"}`, entryProjectPath);
|
|
32169
|
-
}
|
|
32170
|
-
if ("memoryEvents" in evidence && (evidence.memoryEvents.max ?? 0) > 0 || terminationReason === "memory_limit") {
|
|
32171
|
-
invalid("PROJECT_EVALUATION_LIMIT", "evaluator reached its hard memory limit", entryProjectPath);
|
|
32172
|
-
}
|
|
32173
|
-
if ("pidsEvents" in evidence && (evidence.pidsEvents.max ?? 0) > 0 || terminationReason === "process_limit") {
|
|
32174
|
-
invalid("PROJECT_EVALUATION_LIMIT", "evaluator reached its hard process limit", entryProjectPath);
|
|
32175
|
-
}
|
|
32176
|
-
if (terminationReason === "deadline") {
|
|
32177
|
-
invalid("PROJECT_EVALUATION_LIMIT", "evaluator reached its hard wall deadline", entryProjectPath);
|
|
32178
|
-
}
|
|
32179
|
-
if (terminationReason !== "payload_exit") {
|
|
32180
|
-
unavailable("PROJECT_EVALUATOR_INTERRUPTED", `evaluator ended for an unexpected reason: ${terminationReason}`, entryProjectPath);
|
|
32181
|
-
}
|
|
32182
|
-
if (exit.exitCode !== 0 || exit.signal !== null) {
|
|
32183
|
-
invalid("PROJECT_EVALUATION_FAILED", `evaluator exited ${exit.exitCode ?? exit.signal}${diagnostics.length === 0 ? "" : `: ${safeText2(diagnostics)}`}`, entryProjectPath);
|
|
32184
|
-
}
|
|
32185
|
-
let response;
|
|
32186
32172
|
try {
|
|
32187
|
-
|
|
32188
|
-
|
|
32189
|
-
|
|
32190
|
-
|
|
32173
|
+
for (const [name, bytes] of [
|
|
32174
|
+
["project-evaluator-worker.js", workerBytes],
|
|
32175
|
+
["project-evaluator-sdk.bundle.js", sdkBytes]
|
|
32176
|
+
]) {
|
|
32177
|
+
inputs.push({
|
|
32178
|
+
input: capturePrivateInput(bytes),
|
|
32179
|
+
destination: `${PRIVATE_AUTHOR_EVALUATOR_DIRECTORY}/${name}`
|
|
32180
|
+
});
|
|
32191
32181
|
}
|
|
32192
|
-
|
|
32182
|
+
} catch {
|
|
32183
|
+
unavailable("PROJECT_EVALUATOR_SUPPORT", "cannot seal evaluator support", entryProjectPath);
|
|
32193
32184
|
}
|
|
32194
|
-
const
|
|
32195
|
-
|
|
32196
|
-
|
|
32185
|
+
const component = await privateProfileSpan("author-envelope-startup", () => launchPrivateExecution(options.backend, evaluatorLaunchPlan(installedSupport, runId, limits, inputs), signal)).catch((error) => {
|
|
32186
|
+
return unavailable("PROJECT_EVALUATOR_LAUNCH", `cannot launch evaluator envelope: ${errorText8(error)}`, entryProjectPath);
|
|
32187
|
+
});
|
|
32188
|
+
const validEnvelope = component.envelope.kind === "linux-rootless-cgroup-v2-bubblewrap/1" ? component.envelope.privateProcessFilesystem && component.envelope.privateRuntimeDevices && sameEvaluatorLimits(component.envelope.limits, limits) && component.envelope.trustedCoordinatorBunDigest === installedSupport.executableDigest : component.envelope.resourceAccounting === "supervised-sampled-with-termination" && component.envelope.resourceOvershoot === true && sameEvaluatorLimits(component.envelope.limits, limits);
|
|
32189
|
+
if (!validEnvelope) {
|
|
32190
|
+
await component.terminate().catch(() => {
|
|
32191
|
+
return;
|
|
32192
|
+
});
|
|
32193
|
+
const completion = await component.completion.catch((error) => unavailable("PROJECT_EVALUATOR_CLEANUP", `evaluator envelope lost while rejecting its predicates: ${errorText8(error)}`, entryProjectPath));
|
|
32194
|
+
if (!completion.fenced || completion.cleanupError !== undefined) {
|
|
32195
|
+
unavailable("PROJECT_EVALUATOR_CLEANUP", "evaluator envelope predicates were absent and cleanup was not proven", entryProjectPath);
|
|
32196
|
+
}
|
|
32197
|
+
unavailable("PROJECT_EVALUATOR_ENVELOPE", "evaluator envelope did not preserve its sealed runtime or root-only predicates", entryProjectPath);
|
|
32198
|
+
}
|
|
32199
|
+
const profile = Object.freeze({
|
|
32200
|
+
...profileBase,
|
|
32201
|
+
sandbox: component.envelope.kind === "linux-rootless-cgroup-v2-bubblewrap/1" ? Object.freeze({
|
|
32202
|
+
kind: component.envelope.kind,
|
|
32203
|
+
mechanismDigest: component.envelope.mechanismDigest,
|
|
32204
|
+
sealedPlanDigest: component.envelope.sealedPlanDigest,
|
|
32205
|
+
bubblewrapPath: component.envelope.trustedBubblewrapPath,
|
|
32206
|
+
bubblewrapDigest: component.envelope.trustedBubblewrapDigest,
|
|
32207
|
+
coordinatorRuntimePath: component.envelope.trustedCoordinatorBunPath,
|
|
32208
|
+
coordinatorRuntimeDigest: component.envelope.trustedCoordinatorBunDigest,
|
|
32209
|
+
supervisorPath: component.envelope.trustedSupervisorPath,
|
|
32210
|
+
supervisorDigest: component.envelope.trustedSupervisorDigest,
|
|
32211
|
+
payloadUid: component.envelope.payloadUid,
|
|
32212
|
+
payloadGid: component.envelope.payloadGid,
|
|
32213
|
+
limits: limitPolicy,
|
|
32214
|
+
privateProcessFilesystem: component.envelope.privateProcessFilesystem,
|
|
32215
|
+
privateRuntimeDevices: component.envelope.privateRuntimeDevices
|
|
32216
|
+
}) : Object.freeze({
|
|
32217
|
+
kind: component.envelope.kind,
|
|
32218
|
+
mechanismDigest: component.envelope.mechanismDigest,
|
|
32219
|
+
sealedPlanDigest: component.envelope.sealedPlanDigest,
|
|
32220
|
+
supervisorPath: installedSupport.supervisorPath,
|
|
32221
|
+
supervisorDigest: installedSupport.supervisorDigest,
|
|
32222
|
+
launcherPath: installedSupport.launcherPath,
|
|
32223
|
+
launcherDigest: installedSupport.launcherDigest,
|
|
32224
|
+
limits: limitPolicy,
|
|
32225
|
+
resourceAccounting: component.envelope.resourceAccounting,
|
|
32226
|
+
resourceOvershoot: component.envelope.resourceOvershoot
|
|
32227
|
+
})
|
|
32228
|
+
});
|
|
32229
|
+
const stdout = collectBounded(component.stdout, MAX_STDOUT_BYTES, component.terminate);
|
|
32230
|
+
const stderr = collectBounded(component.stderr, MAX_STDERR_BYTES, component.terminate);
|
|
32197
32231
|
try {
|
|
32198
|
-
|
|
32232
|
+
await component.write(request);
|
|
32233
|
+
await component.closeInput();
|
|
32234
|
+
const [output, diagnostics, exit, evidence, terminationReason] = await privateProfileSpan("author-execution-settlement", () => Promise.all([
|
|
32235
|
+
stdout,
|
|
32236
|
+
stderr,
|
|
32237
|
+
component.completion,
|
|
32238
|
+
component.evidence,
|
|
32239
|
+
component.terminationReason
|
|
32240
|
+
]));
|
|
32241
|
+
if (exit.cleanupError !== undefined || !exit.fenced) {
|
|
32242
|
+
unavailable("PROJECT_EVALUATOR_CLEANUP", `evaluator cleanup was not proven: ${exit.cleanupError ?? "not fenced"}`, entryProjectPath);
|
|
32243
|
+
}
|
|
32244
|
+
if ("memoryEvents" in evidence && (evidence.memoryEvents.max ?? 0) > 0 || terminationReason === "memory_limit") {
|
|
32245
|
+
invalid("PROJECT_EVALUATOR_MEMORY_LIMIT", "evaluator reached its hard memory limit", entryProjectPath);
|
|
32246
|
+
}
|
|
32247
|
+
if ("pidsEvents" in evidence && (evidence.pidsEvents.max ?? 0) > 0 || terminationReason === "process_limit") {
|
|
32248
|
+
invalid("PROJECT_EVALUATOR_PROCESS_LIMIT", "evaluator reached its hard process limit", entryProjectPath);
|
|
32249
|
+
}
|
|
32250
|
+
if (terminationReason === "deadline") {
|
|
32251
|
+
invalid("PROJECT_EVALUATOR_DEADLINE", "evaluator reached its hard wall deadline", entryProjectPath);
|
|
32252
|
+
}
|
|
32253
|
+
if (terminationReason !== "payload_exit") {
|
|
32254
|
+
unavailable("PROJECT_EVALUATOR_INTERRUPTED", `evaluator ended for an unexpected reason: ${terminationReason}`, entryProjectPath);
|
|
32255
|
+
}
|
|
32256
|
+
if (exit.exitCode !== 0 || exit.signal !== null) {
|
|
32257
|
+
invalid("PROJECT_EVALUATION_FAILED", `evaluator exited ${exit.exitCode ?? exit.signal}${diagnostics.length === 0 ? "" : `: ${safeText2(diagnostics)}`}`, entryProjectPath);
|
|
32258
|
+
}
|
|
32259
|
+
let response;
|
|
32260
|
+
try {
|
|
32261
|
+
response = decodeJson1(output);
|
|
32262
|
+
} catch (error) {
|
|
32263
|
+
if (error instanceof Json1Error) {
|
|
32264
|
+
unavailable("PROJECT_EVALUATOR_PROTOCOL", error.message, entryProjectPath);
|
|
32265
|
+
}
|
|
32266
|
+
throw error;
|
|
32267
|
+
}
|
|
32268
|
+
const values = checkedResponse(response, entries);
|
|
32269
|
+
return Object.freeze(entries.map(({ entryProjectPath: entryProjectPath2, expected }, index) => {
|
|
32270
|
+
const value = values[index];
|
|
32271
|
+
contextualAuthorSchema(schemaBytes, expected, entryProjectPath2).validate(value, "PROJECT_AUTHORING_SCHEMA_INVALID");
|
|
32272
|
+
let normalized;
|
|
32273
|
+
try {
|
|
32274
|
+
normalized = expected === "project" ? normalizeJigDefinition(value) : normalizePackageBindingDefinition(value);
|
|
32275
|
+
} catch (error) {
|
|
32276
|
+
invalid("PROJECT_DECLARATION_INVALID", errorText8(error), entryProjectPath2);
|
|
32277
|
+
}
|
|
32278
|
+
const outputBytes = canonicalJson(normalized);
|
|
32279
|
+
return Object.freeze({
|
|
32280
|
+
expected,
|
|
32281
|
+
source: Object.freeze({
|
|
32282
|
+
entryProjectPath: entryProjectPath2,
|
|
32283
|
+
bytes: captured.sourceBytes,
|
|
32284
|
+
digest: captured.closureDigest,
|
|
32285
|
+
modules: Object.freeze(captured.modules.map((module) => Object.freeze({
|
|
32286
|
+
projectPath: module.projectPath,
|
|
32287
|
+
bytes: module.sourceBytes,
|
|
32288
|
+
digest: module.sourceDigest,
|
|
32289
|
+
imports: Object.freeze(module.imports.map((edge) => Object.freeze({ ...edge })))
|
|
32290
|
+
})))
|
|
32291
|
+
}),
|
|
32292
|
+
profile,
|
|
32293
|
+
outputDigest: digestBytes(outputBytes),
|
|
32294
|
+
value: normalized,
|
|
32295
|
+
enforcement: Object.freeze({
|
|
32296
|
+
owner: "cgroup" in component ? Object.freeze({ kind: "linux-cgroup", ...component.cgroup }) : Object.freeze({ kind: "macos-process", ...component.process }),
|
|
32297
|
+
terminal: Object.freeze({
|
|
32298
|
+
reason: terminationReason,
|
|
32299
|
+
exitCode: exit.exitCode,
|
|
32300
|
+
signal: exit.signal,
|
|
32301
|
+
fenced: exit.fenced
|
|
32302
|
+
}),
|
|
32303
|
+
evidence: "cpuStat" in evidence ? Object.freeze({
|
|
32304
|
+
...prefixNumbers("cpu", evidence.cpuStat),
|
|
32305
|
+
...prefixNumbers("memory", evidence.memoryEvents),
|
|
32306
|
+
...prefixNumbers("pids", evidence.pidsEvents)
|
|
32307
|
+
}) : Object.freeze({ ...evidence })
|
|
32308
|
+
})
|
|
32309
|
+
});
|
|
32310
|
+
}));
|
|
32199
32311
|
} catch (error) {
|
|
32200
|
-
|
|
32312
|
+
await component.terminate().catch(() => {
|
|
32313
|
+
return;
|
|
32314
|
+
});
|
|
32315
|
+
const settled = await Promise.allSettled([
|
|
32316
|
+
stdout,
|
|
32317
|
+
stderr,
|
|
32318
|
+
component.completion,
|
|
32319
|
+
component.evidence
|
|
32320
|
+
]);
|
|
32321
|
+
const cleanup = settled[2];
|
|
32322
|
+
if (cleanup.status === "rejected") {
|
|
32323
|
+
throw new AggregateError([error, cleanup.reason], "evaluator failed and cleanup was not confirmed");
|
|
32324
|
+
}
|
|
32325
|
+
if (!cleanup.value.fenced || cleanup.value.cleanupError !== undefined) {
|
|
32326
|
+
throw new AggregateError([error, cleanup.value], "evaluator failed without a clean fence");
|
|
32327
|
+
}
|
|
32328
|
+
throw error;
|
|
32201
32329
|
}
|
|
32202
|
-
const outputBytes = canonicalJson(normalized);
|
|
32203
|
-
return Object.freeze({
|
|
32204
|
-
expected,
|
|
32205
|
-
source: Object.freeze({
|
|
32206
|
-
entryProjectPath,
|
|
32207
|
-
bytes: captured.sourceBytes,
|
|
32208
|
-
digest: captured.closureDigest,
|
|
32209
|
-
modules: Object.freeze(captured.modules.map((module) => Object.freeze({
|
|
32210
|
-
projectPath: module.projectPath,
|
|
32211
|
-
bytes: module.sourceBytes,
|
|
32212
|
-
digest: module.sourceDigest,
|
|
32213
|
-
imports: Object.freeze(module.imports.map((edge) => Object.freeze({ ...edge })))
|
|
32214
|
-
})))
|
|
32215
|
-
}),
|
|
32216
|
-
profile,
|
|
32217
|
-
outputDigest: digestBytes(outputBytes),
|
|
32218
|
-
value: normalized,
|
|
32219
|
-
enforcement: Object.freeze({
|
|
32220
|
-
owner: "cgroup" in component ? Object.freeze({ kind: "linux-cgroup", ...component.cgroup }) : Object.freeze({ kind: "macos-process", ...component.process }),
|
|
32221
|
-
terminal: Object.freeze({
|
|
32222
|
-
reason: terminationReason,
|
|
32223
|
-
exitCode: exit.exitCode,
|
|
32224
|
-
signal: exit.signal,
|
|
32225
|
-
fenced: exit.fenced
|
|
32226
|
-
}),
|
|
32227
|
-
evidence: "cpuStat" in evidence ? Object.freeze({
|
|
32228
|
-
...prefixNumbers("cpu", evidence.cpuStat),
|
|
32229
|
-
...prefixNumbers("memory", evidence.memoryEvents),
|
|
32230
|
-
...prefixNumbers("pids", evidence.pidsEvents)
|
|
32231
|
-
}) : Object.freeze({ ...evidence })
|
|
32232
|
-
})
|
|
32233
|
-
});
|
|
32234
32330
|
} catch (error) {
|
|
32235
|
-
|
|
32236
|
-
|
|
32237
|
-
|
|
32238
|
-
const
|
|
32239
|
-
|
|
32240
|
-
|
|
32241
|
-
|
|
32242
|
-
|
|
32243
|
-
|
|
32244
|
-
|
|
32245
|
-
if (cleanup.status === "rejected") {
|
|
32246
|
-
throw new AggregateError([error, cleanup.reason], "evaluator failed and cleanup was not confirmed");
|
|
32331
|
+
operationFailure = error;
|
|
32332
|
+
throw error;
|
|
32333
|
+
} finally {
|
|
32334
|
+
const failures = [];
|
|
32335
|
+
for (const { input } of inputs) {
|
|
32336
|
+
try {
|
|
32337
|
+
input.close();
|
|
32338
|
+
} catch (error) {
|
|
32339
|
+
failures.push(error);
|
|
32340
|
+
}
|
|
32247
32341
|
}
|
|
32248
|
-
if (
|
|
32249
|
-
throw new AggregateError([
|
|
32342
|
+
if (failures.length > 0) {
|
|
32343
|
+
throw new AggregateError(operationFailure === undefined ? failures : [operationFailure, ...failures], "evaluator input cleanup failed");
|
|
32250
32344
|
}
|
|
32251
|
-
throw error;
|
|
32252
32345
|
}
|
|
32253
32346
|
}
|
|
32254
|
-
function checkedResponse(response,
|
|
32347
|
+
function checkedResponse(response, entries) {
|
|
32348
|
+
const projectPath = entries[0].entryProjectPath;
|
|
32255
32349
|
if (!isRecord(response) || response.protocol !== PROTOCOL || response.status !== "ok" && response.status !== "error") {
|
|
32256
32350
|
unavailable("PROJECT_EVALUATOR_PROTOCOL", "evaluator returned an invalid envelope", projectPath);
|
|
32257
32351
|
}
|
|
32258
32352
|
if (response.status === "error") {
|
|
32259
|
-
if (!exactKeys(response, ["code", "message", "protocol", "status"]) || typeof response.code !== "string" || typeof response.message !== "string") {
|
|
32353
|
+
if (!exactKeys(response, ["code", "entryIndex", "message", "protocol", "status"]) || typeof response.code !== "string" || typeof response.message !== "string" || !(response.entryIndex === null || typeof response.entryIndex === "number" && Number.isInteger(response.entryIndex) && response.entryIndex >= 0 && response.entryIndex < entries.length)) {
|
|
32260
32354
|
unavailable("PROJECT_EVALUATOR_PROTOCOL", "evaluator error has an invalid shape", projectPath);
|
|
32261
32355
|
}
|
|
32262
32356
|
if (!EVALUATION_CODES.has(response.code)) {
|
|
32263
32357
|
unavailable("PROJECT_EVALUATOR_PROTOCOL", "evaluator returned an unknown error code", projectPath);
|
|
32264
32358
|
}
|
|
32265
32359
|
const code2 = response.code;
|
|
32360
|
+
const location = response.entryIndex === null ? projectPath : entries[response.entryIndex].entryProjectPath;
|
|
32266
32361
|
if (code2 === "PROJECT_EVALUATOR_PROTOCOL") {
|
|
32267
|
-
unavailable(code2, response.message,
|
|
32362
|
+
unavailable(code2, response.message, location);
|
|
32268
32363
|
}
|
|
32269
32364
|
const message2 = response.message;
|
|
32270
|
-
invalid(code2, message2,
|
|
32365
|
+
invalid(code2, message2, location);
|
|
32271
32366
|
}
|
|
32272
|
-
if (!exactKeys(response, ["protocol", "status", "
|
|
32367
|
+
if (!exactKeys(response, ["protocol", "status", "values"]) || !Array.isArray(response.values) || response.values.length !== entries.length) {
|
|
32273
32368
|
unavailable("PROJECT_EVALUATOR_PROTOCOL", "evaluator success has an invalid shape", projectPath);
|
|
32274
32369
|
}
|
|
32275
|
-
return response.
|
|
32370
|
+
return response.values;
|
|
32276
32371
|
}
|
|
32277
32372
|
function contextualAuthorSchema(bytes, expected, projectPath) {
|
|
32278
32373
|
let document;
|
|
@@ -32287,41 +32382,36 @@ function contextualAuthorSchema(bytes, expected, projectPath) {
|
|
|
32287
32382
|
const definition = expected === "project" ? "project" : "bindingDefinition";
|
|
32288
32383
|
try {
|
|
32289
32384
|
return compileEmbeddedSchema(Object.freeze({ $ref: `#/$defs/${definition}` }), {
|
|
32290
|
-
path:
|
|
32385
|
+
path: projectPath,
|
|
32291
32386
|
rootDefs: document.$defs
|
|
32292
32387
|
});
|
|
32293
32388
|
} catch (error) {
|
|
32294
32389
|
unavailable("PROJECT_EVALUATOR_SUPPORT", `captured authoring schema cannot compile: ${errorText8(error)}`, projectPath);
|
|
32295
32390
|
}
|
|
32296
32391
|
}
|
|
32297
|
-
function evaluatorLaunchPlan(support, runId, limits) {
|
|
32392
|
+
function evaluatorLaunchPlan(support, runId, limits, inputs) {
|
|
32298
32393
|
return {
|
|
32299
32394
|
runId,
|
|
32300
32395
|
limits,
|
|
32301
|
-
projections: [
|
|
32302
|
-
...privateExecutionFileProjections(support.runtimeMounts),
|
|
32303
|
-
{ source: support.evaluatorSupportPath, destination: "/jig-evaluator", kind: "tree" }
|
|
32304
|
-
],
|
|
32396
|
+
projections: [...privateExecutionFileProjections(support.runtimeMounts)],
|
|
32305
32397
|
command: [
|
|
32306
32398
|
privateExecutionPath(support.sandboxExecutablePath),
|
|
32307
|
-
privateExecutionPath(
|
|
32399
|
+
privateExecutionPath(PRIVATE_AUTHOR_EVALUATOR_WORKER)
|
|
32308
32400
|
],
|
|
32309
|
-
|
|
32310
|
-
|
|
32401
|
+
capturedInputs: inputs,
|
|
32402
|
+
inputDirectories: [PRIVATE_AUTHOR_EVALUATOR_DIRECTORY],
|
|
32403
|
+
readOnlyCwd: PRIVATE_AUTHOR_EVALUATOR_DIRECTORY,
|
|
32404
|
+
relocatedEnvironment: {
|
|
32405
|
+
JIG_EVALUATOR_SDK: `${PRIVATE_AUTHOR_EVALUATOR_DIRECTORY}/project-evaluator-sdk.bundle.js`
|
|
32406
|
+
},
|
|
32311
32407
|
maxOutputBytes: MAX_STDOUT_BYTES + MAX_STDERR_BYTES,
|
|
32312
|
-
storageBytes:
|
|
32408
|
+
storageBytes: 16 * 1024 * 1024
|
|
32313
32409
|
};
|
|
32314
32410
|
}
|
|
32315
32411
|
function exactKeys(value, expected) {
|
|
32316
32412
|
const keys = Object.keys(value).sort();
|
|
32317
32413
|
return keys.length === expected.length && keys.every((key, index) => key === expected[index]);
|
|
32318
32414
|
}
|
|
32319
|
-
function evaluatorLimitPolicy(backend) {
|
|
32320
|
-
return privateExecutionBackendKind(backend) === "macos" ? Object.freeze({
|
|
32321
|
-
...EVALUATOR_LIMIT_POLICY,
|
|
32322
|
-
wallClockCeilingMs: MACOS_EVALUATOR_WALL_CLOCK_CEILING_MS
|
|
32323
|
-
}) : EVALUATOR_LIMIT_POLICY;
|
|
32324
|
-
}
|
|
32325
32415
|
function evaluatorLimits(policy) {
|
|
32326
32416
|
return Object.freeze({
|
|
32327
32417
|
memoryBytes: policy.memoryBytes,
|
|
@@ -32901,14 +32991,21 @@ async function retainOpenedPackageProject(options, signal) {
|
|
|
32901
32991
|
]);
|
|
32902
32992
|
closure = capturedClosure;
|
|
32903
32993
|
assertBootstrapPreserved(bootstrapClosure, capturedClosure);
|
|
32904
|
-
const
|
|
32994
|
+
const evaluations = await privateProfileSpan("author-configuration-evaluation", () => evaluateAuthorClosureBatch(options.evaluator, capturedClosure, [
|
|
32995
|
+
{ entryProjectPath: entry, expected: "project" },
|
|
32996
|
+
...bindingSource.members.map(({ projectPath }) => ({
|
|
32997
|
+
entryProjectPath: projectPath,
|
|
32998
|
+
expected: "binding"
|
|
32999
|
+
}))
|
|
33000
|
+
], signal));
|
|
33001
|
+
const project = evaluations[0];
|
|
32905
33002
|
if (project.outputDigest !== bootstrapProject.outputDigest) {
|
|
32906
33003
|
invalid("PROJECT_SOURCE_CHANGED", "project definition changed while its complete declaration closure was captured", entry);
|
|
32907
33004
|
}
|
|
32908
33005
|
const grantSource = await captureGrantSource(root, project.value.grants);
|
|
32909
33006
|
const bindings = [];
|
|
32910
|
-
for (const member2 of bindingSource.members) {
|
|
32911
|
-
const evaluation =
|
|
33007
|
+
for (const [index, member2] of bindingSource.members.entries()) {
|
|
33008
|
+
const evaluation = evaluations[index + 1];
|
|
32912
33009
|
let attachments;
|
|
32913
33010
|
try {
|
|
32914
33011
|
if (evaluation.value.attachments !== undefined)
|
|
@@ -33585,22 +33682,28 @@ function assertPrivateBunExecutionLayoutFiles(layout, files) {
|
|
|
33585
33682
|
assertPrivatePackageAliasFiles(layout.aliases, files);
|
|
33586
33683
|
}
|
|
33587
33684
|
function normalizePrivateBunExecutionArtifact(value) {
|
|
33588
|
-
const record3 = exact5(value, ["package", "layout"], ["
|
|
33589
|
-
|
|
33590
|
-
|
|
33685
|
+
const record3 = exact5(value, ["package", "layout"], ["preparation"]);
|
|
33686
|
+
let preparation;
|
|
33687
|
+
if (Object.hasOwn(record3, "preparation")) {
|
|
33688
|
+
const evidence = exact5(record3.preparation, ["inputDigest", "package"]);
|
|
33689
|
+
if (typeof evidence.inputDigest !== "string" || !/^sha256:[0-9a-f]{64}$/.test(evidence.inputDigest))
|
|
33690
|
+
invalid3();
|
|
33691
|
+
preparation = Object.freeze({
|
|
33692
|
+
inputDigest: evidence.inputDigest,
|
|
33693
|
+
package: normalizePackageArtifactRef(exact5(evidence.package, ["kind", "digest"]))
|
|
33694
|
+
});
|
|
33695
|
+
}
|
|
33591
33696
|
return Object.freeze({
|
|
33592
33697
|
package: normalizePackageArtifactRef(exact5(record3.package, ["kind", "digest"])),
|
|
33593
33698
|
layout: normalizePrivateBunExecutionLayout(record3.layout),
|
|
33594
|
-
...
|
|
33595
|
-
preparationInputDigest: record3.preparationInputDigest
|
|
33596
|
-
}
|
|
33699
|
+
...preparation === undefined ? {} : { preparation }
|
|
33597
33700
|
});
|
|
33598
33701
|
}
|
|
33599
|
-
function privateBunExecutionArtifact(artifact, layout = EMPTY_PRIVATE_BUN_EXECUTION_LAYOUT,
|
|
33702
|
+
function privateBunExecutionArtifact(artifact, layout = EMPTY_PRIVATE_BUN_EXECUTION_LAYOUT, preparation) {
|
|
33600
33703
|
return normalizePrivateBunExecutionArtifact({
|
|
33601
33704
|
package: artifact,
|
|
33602
33705
|
layout,
|
|
33603
|
-
...
|
|
33706
|
+
...preparation === undefined ? {} : { preparation }
|
|
33604
33707
|
});
|
|
33605
33708
|
}
|
|
33606
33709
|
function privateBunExecutionMaterialization(execution) {
|
|
@@ -37890,12 +37993,10 @@ async function capturePrivateActivationPlanningBase(input) {
|
|
|
37890
37993
|
function readPrivateAdmittedExecutionReuse(input) {
|
|
37891
37994
|
const base = requirePrivateActivationPlanningBase(input.planningBase);
|
|
37892
37995
|
const request = requirePrivateActivationRequest(input.request);
|
|
37893
|
-
const target = base.admittedCandidate?.candidate.targets.find((candidate) => candidate.request.
|
|
37996
|
+
const target = base.admittedCandidate?.candidate.targets.find((candidate) => privateActivationTargetKey(candidate.request.target) === privateActivationTargetKey(request.target) && candidate.request.packagePath === request.packagePath);
|
|
37894
37997
|
if (target?.disposition.state !== "ready")
|
|
37895
37998
|
return;
|
|
37896
37999
|
return Object.freeze({
|
|
37897
|
-
recipeDigest: target.disposition.recipeDigest,
|
|
37898
|
-
observationDigest: target.disposition.observationDigest,
|
|
37899
38000
|
execution: target.disposition.execution
|
|
37900
38001
|
});
|
|
37901
38002
|
}
|
|
@@ -40880,7 +40981,10 @@ async function reacquireCandidateArtifacts(packageStoreRoot, candidate) {
|
|
|
40880
40981
|
candidate.candidate.declarationArtifact.package.digest,
|
|
40881
40982
|
...Object.values(candidate.lock.packages).map((entry) => entry.digest),
|
|
40882
40983
|
...Object.values(candidate.lock.bindings).flatMap((entry) => Object.values(entry.attachments ?? {}).map((item2) => item2.digest)),
|
|
40883
|
-
...candidate.candidate.targets.flatMap((target) => target.disposition.state === "ready" ? [
|
|
40984
|
+
...candidate.candidate.targets.flatMap((target) => target.disposition.state === "ready" ? [
|
|
40985
|
+
target.disposition.execution.package.digest,
|
|
40986
|
+
...target.disposition.execution.preparation === undefined ? [] : [target.disposition.execution.preparation.package.digest]
|
|
40987
|
+
] : [])
|
|
40884
40988
|
]);
|
|
40885
40989
|
for (const digest6 of [...digests].sort()) {
|
|
40886
40990
|
const reference = normalizePackageArtifactRef({ kind: "flow-package/0", digest: digest6 });
|
|
@@ -41363,6 +41467,9 @@ class PrivateRunDiagnostics {
|
|
|
41363
41467
|
|
|
41364
41468
|
// src/project/evaluator-diagnostics.ts
|
|
41365
41469
|
var EVALUATOR_HINTS = Object.freeze({
|
|
41470
|
+
PROJECT_EVALUATOR_MEMORY_LIMIT: "The configuration evaluator reached its enforced memory limit. Keep declarations small and inert; preserve this diagnostic if a small declaration fails. No Flow was started.",
|
|
41471
|
+
PROJECT_EVALUATOR_PROCESS_LIMIT: "The configuration evaluator reached its enforced process limit. Preserve this diagnostic and report it with the indicated declaration; changing a Flow deadline will not fix review. No Flow was started.",
|
|
41472
|
+
PROJECT_EVALUATOR_DEADLINE: "The configuration evaluator reached its enforced wall-clock deadline. This does not establish whether authored work or runtime startup consumed the budget. Preserve this diagnostic if a small, inert declaration fails. No Flow was started.",
|
|
41366
41473
|
PROJECT_EVALUATOR_SUPPORT: "Jig could not verify its configuration evaluator files. Restore the complete Jig installation and retry review. No Flow was started.",
|
|
41367
41474
|
PROJECT_EVALUATOR_LAUNCH: "Jig could not start the contained configuration evaluator. Check supported host prerequisites and host load before retrying review; the underlying cause is not established. No Flow was started.",
|
|
41368
41475
|
PROJECT_EVALUATOR_ENVELOPE: "The configuration evaluator did not establish its required isolation. Check the supported host prerequisites; do not bypass containment. No Flow was started.",
|
|
@@ -42819,7 +42926,7 @@ function renderFailure(error, runtime) {
|
|
|
42819
42926
|
PROJECT_MEMBER_MISSING: "a selected project member is missing; restore it or update the membership in jig.ts",
|
|
42820
42927
|
PROJECT_MEMBER_COLLISION: "project members have colliding paths or names; give each selected member a distinct identity",
|
|
42821
42928
|
PROJECT_EVALUATION_FAILED: "the project definition could not be evaluated; check the indicated module for unknown fields, invalid values, syntax or import errors. defineJig accepts only flows, bindings, grants, defaultProviders and entrypoint",
|
|
42822
|
-
PROJECT_EVALUATION_LIMIT: "project evaluation exceeded
|
|
42929
|
+
PROJECT_EVALUATION_LIMIT: "project evaluation exceeded a capture or execution limit; keep authoring modules small and inert. The specific limiting resource was not retained. Preserve this diagnostic if a small declaration fails. No Flow was started",
|
|
42823
42930
|
PROJECT_DECLARATION_INVALID: "export a valid defineJig or defineBinding declaration from the indicated module",
|
|
42824
42931
|
CHANNEL_FIELD: "check channel declarations and descriptors against FLOW Channel Contract/0",
|
|
42825
42932
|
CHANNEL_LIMIT: "check channel declaration counts and descriptor bounds",
|
|
@@ -42947,7 +43054,7 @@ Inspect any effects before starting new work. See https://jig.md/guide/results.`
|
|
|
42947
43054
|
UNAVAILABLE: "Required execution support was unavailable.",
|
|
42948
43055
|
PERMISSION_DENIED: "The requested action was outside the approved permissions.",
|
|
42949
43056
|
RESOURCE_EXHAUSTED: "Execution reached a resource limit.",
|
|
42950
|
-
INVALID_RESULT: "
|
|
43057
|
+
INVALID_RESULT: "A Flow or one of its operations rejected a returned result.",
|
|
42951
43058
|
UNCERTAIN: "The operation may have produced effects; do not blindly repeat the Run.",
|
|
42952
43059
|
EXECUTION_FAILED: "The Flow could not complete execution.",
|
|
42953
43060
|
CHANNEL_LOST: "A required connection was lost.",
|
|
@@ -45446,6 +45553,120 @@ function limit(code2, message2, path2) {
|
|
|
45446
45553
|
return new CheckError("invalid", code2, message2, path2);
|
|
45447
45554
|
}
|
|
45448
45555
|
|
|
45556
|
+
// src/internal/bun-preparation-evidence.ts
|
|
45557
|
+
import { createHash as createHash14 } from "crypto";
|
|
45558
|
+
|
|
45559
|
+
// src/internal/bun-native-inputs.ts
|
|
45560
|
+
async function privateBunNativeInputs(input) {
|
|
45561
|
+
const manifests = [
|
|
45562
|
+
"package.json",
|
|
45563
|
+
...input.members?.map((path2) => `${path2}/package.json`) ?? []
|
|
45564
|
+
];
|
|
45565
|
+
const paths2 = new Set(manifests);
|
|
45566
|
+
if (input.paths.includes("bun.lock"))
|
|
45567
|
+
paths2.add("bun.lock");
|
|
45568
|
+
let patches = {};
|
|
45569
|
+
for (const path2 of manifests) {
|
|
45570
|
+
const bytes = await input.read(path2);
|
|
45571
|
+
if (bytes.byteLength > 1024 * 1024)
|
|
45572
|
+
throw new TypeError("oversized native manifest");
|
|
45573
|
+
const manifest = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
45574
|
+
requirePrivateBunResolutionManifest(manifest, input.members === undefined ? undefined : path2 === "package.json" ? "root" : "member");
|
|
45575
|
+
if (path2 === "package.json")
|
|
45576
|
+
patches = requirePrivateBunPatches(manifest.patchedDependencies);
|
|
45577
|
+
}
|
|
45578
|
+
for (const path2 of Object.values(patches)) {
|
|
45579
|
+
if ((await input.read(path2)).byteLength > 1024 * 1024)
|
|
45580
|
+
throw new TypeError("oversized captured patch");
|
|
45581
|
+
paths2.add(path2);
|
|
45582
|
+
}
|
|
45583
|
+
return Object.freeze({ paths: paths2, patches });
|
|
45584
|
+
}
|
|
45585
|
+
|
|
45586
|
+
// src/internal/bun-preparation-evidence.ts
|
|
45587
|
+
async function privateBunPreparationInputs(input) {
|
|
45588
|
+
const { captured, workspace } = input;
|
|
45589
|
+
if (captured.files.length > PRIVATE_BUN_PREPARATION_LIMITS.sourceFiles || captured.files.reduce((sum, file) => sum + file.size, 0) > PRIVATE_BUN_PREPARATION_LIMITS.sourceBytes)
|
|
45590
|
+
throw failure("PACKAGE_BUN_INPUT_LIMIT", "Bun preparation source exceeds its bounded input limits");
|
|
45591
|
+
let paths2;
|
|
45592
|
+
try {
|
|
45593
|
+
paths2 = (await privateBunNativeInputs({
|
|
45594
|
+
paths: captured.files.map(({ path: path2 }) => path2),
|
|
45595
|
+
...workspace === undefined ? {} : { members: workspace.members },
|
|
45596
|
+
read: (path2) => captured.read(path2, 1024 * 1024)
|
|
45597
|
+
})).paths;
|
|
45598
|
+
} catch {
|
|
45599
|
+
throw failure("PACKAGE_BUN_SOURCE_UNSUPPORTED", "native manifests or declared patch inputs are unsupported or incomplete");
|
|
45600
|
+
}
|
|
45601
|
+
const nativeFiles = [];
|
|
45602
|
+
for (const path2 of [...paths2].sort(comparePathBytes)) {
|
|
45603
|
+
const hash = createHash14("sha256");
|
|
45604
|
+
for await (const bytes of captured.stream(path2))
|
|
45605
|
+
hash.update(bytes);
|
|
45606
|
+
nativeFiles.push({ path: path2, digest: `sha256:${hash.digest("hex")}` });
|
|
45607
|
+
}
|
|
45608
|
+
const sourcePaths = new Set(captured.files.filter(({ path: path2 }) => workspace === undefined || paths2.has(path2) || workspace.selected.some((member2) => path2.startsWith(`${member2}/`))).map(({ path: path2 }) => path2));
|
|
45609
|
+
if (workspace !== undefined) {
|
|
45610
|
+
for (const member2 of workspace.members)
|
|
45611
|
+
if (!workspace.selected.includes(member2))
|
|
45612
|
+
sourcePaths.delete(`${member2}/package.json`);
|
|
45613
|
+
}
|
|
45614
|
+
return Object.freeze({
|
|
45615
|
+
digest: privateDomainDigest("JIG-Bun-Preparation-Inputs/1", {
|
|
45616
|
+
supportDigest: input.supportDigest,
|
|
45617
|
+
workspace: workspace === undefined ? null : {
|
|
45618
|
+
target: workspace.target,
|
|
45619
|
+
members: [...workspace.members],
|
|
45620
|
+
selected: [...workspace.selected]
|
|
45621
|
+
},
|
|
45622
|
+
nativeFiles
|
|
45623
|
+
}),
|
|
45624
|
+
sourcePaths
|
|
45625
|
+
});
|
|
45626
|
+
}
|
|
45627
|
+
async function capturePrivateBunDependencies(prepared, sourcePaths) {
|
|
45628
|
+
const files = prepared.files.filter(({ path: path2 }) => !sourcePaths.has(path2));
|
|
45629
|
+
requireDependencyFiles(files);
|
|
45630
|
+
return captureView("retained Bun dependencies", files, () => prepared);
|
|
45631
|
+
}
|
|
45632
|
+
async function assemblePrivateBunExecution(input) {
|
|
45633
|
+
requireDependencyFiles(input.dependencies.files);
|
|
45634
|
+
const source = input.source.files.filter(({ path: path2 }) => input.sourcePaths.has(path2));
|
|
45635
|
+
const sourcePaths = new Set(source.map(({ path: path2 }) => path2));
|
|
45636
|
+
const files = [...source, ...input.dependencies.files].sort((a, b) => comparePathBytes(a.path, b.path));
|
|
45637
|
+
try {
|
|
45638
|
+
assertNoPathCollisions(files.map(({ path: path2 }) => path2));
|
|
45639
|
+
const regularPaths = new Set(files.map(({ path: path2 }) => path2));
|
|
45640
|
+
for (const file of files) {
|
|
45641
|
+
const parts = file.path.split("/");
|
|
45642
|
+
for (let length = 1;length < parts.length; length++)
|
|
45643
|
+
if (regularPaths.has(parts.slice(0, length).join("/")))
|
|
45644
|
+
throw new TypeError("file parent collision");
|
|
45645
|
+
}
|
|
45646
|
+
assertPrivateBunExecutionLayoutFiles(input.layout, files);
|
|
45647
|
+
} catch {
|
|
45648
|
+
throw failure("PACKAGE_BUN_SOURCE_UNSUPPORTED", "fresh source conflicts with the retained dependency layout");
|
|
45649
|
+
}
|
|
45650
|
+
if (files.length + input.layout.aliases.length > PRIVATE_BUN_PREPARATION_LIMITS.preparedFiles || files.reduce((sum, file) => sum + file.size, Buffer.byteLength(JSON.stringify(input.layout))) > PRIVATE_BUN_PREPARATION_LIMITS.preparedBytes)
|
|
45651
|
+
throw failure("PACKAGE_BUN_OUTPUT_LIMIT", "assembled Bun execution exceeds its bounded output limits");
|
|
45652
|
+
return captureView("fresh Bun execution image", files, (path2) => sourcePaths.has(path2) ? input.source : input.dependencies);
|
|
45653
|
+
}
|
|
45654
|
+
function requireDependencyFiles(files) {
|
|
45655
|
+
if (files.some(({ path: path2 }) => path2 !== "bun.lock" && !path2.split("/").includes("node_modules")))
|
|
45656
|
+
throw failure("PACKAGE_BUN_PROTOCOL", "retained Bun dependency evidence contains authored source");
|
|
45657
|
+
}
|
|
45658
|
+
async function captureView(label, files, owner) {
|
|
45659
|
+
const frozenFiles = Object.freeze([...files]);
|
|
45660
|
+
const backing2 = {
|
|
45661
|
+
stream: (path2) => owner(path2).stream(path2),
|
|
45662
|
+
async dispose() {}
|
|
45663
|
+
};
|
|
45664
|
+
return createCapturedPackage(label, frozenFiles, await packageDigest(frozenFiles, (file) => backing2.stream(file.path)), backing2);
|
|
45665
|
+
}
|
|
45666
|
+
function failure(code2, message2) {
|
|
45667
|
+
return new CheckError("invalid", code2, message2);
|
|
45668
|
+
}
|
|
45669
|
+
|
|
45449
45670
|
// src/internal/bun-workspace-capture.ts
|
|
45450
45671
|
import { constants as constants29 } from "fs";
|
|
45451
45672
|
import { dirname as dirname17, relative as relative3, resolve as resolve13 } from "path";
|
|
@@ -45848,7 +46069,7 @@ function fail(code2, message2) {
|
|
|
45848
46069
|
}
|
|
45849
46070
|
|
|
45850
46071
|
// src/internal/contract-generation.ts
|
|
45851
|
-
import { createHash as
|
|
46072
|
+
import { createHash as createHash15, randomUUID as randomUUID4 } from "crypto";
|
|
45852
46073
|
import { constants as constants30 } from "fs";
|
|
45853
46074
|
|
|
45854
46075
|
// ../agent-method/dist/errors.js
|
|
@@ -46222,7 +46443,7 @@ async function generateContract(source, signal, workerPath) {
|
|
|
46222
46443
|
var SOURCE = "FLOW.contract.tsp";
|
|
46223
46444
|
var DESCRIPTOR = "FLOW.contract.json";
|
|
46224
46445
|
var MAX_RECORD = 4 * 1024 * 1024;
|
|
46225
|
-
var hash = (s) =>
|
|
46446
|
+
var hash = (s) => createHash15("sha256").update(s).digest("hex");
|
|
46226
46447
|
var conflict = (name) => invalid("AUTHORING_CONFLICT", "Generated files or source changed. Preserve edits and resolve ownership before generation.", name);
|
|
46227
46448
|
function inputNames(inputs) {
|
|
46228
46449
|
if (!inputs || typeof inputs !== "object" || Array.isArray(inputs) || Object.keys(inputs).length > 256)
|
|
@@ -46798,9 +47019,9 @@ function executionChangeExplanation(before, after) {
|
|
|
46798
47019
|
reasons.push("The execution request changed; see the package, settings and permission changes in this review.");
|
|
46799
47020
|
if (!samePolicy(before.disposition.execution?.package, after.disposition.execution?.package) || !samePolicy(before.disposition.execution?.layout, after.disposition.execution?.layout))
|
|
46800
47021
|
reasons.push("Prepared execution files or dependency layout changed.");
|
|
46801
|
-
else if (before.disposition.execution?.
|
|
46802
|
-
reasons.push(before.disposition.execution?.
|
|
46803
|
-
Prepared files and dependency layout are unchanged.` : `
|
|
47022
|
+
else if (!samePolicy(before.disposition.execution?.preparation, after.disposition.execution?.preparation))
|
|
47023
|
+
reasons.push(before.disposition.execution?.preparation === undefined ? `This review records dependency inputs and installed bytes for future preparation reuse.
|
|
47024
|
+
Prepared files and dependency layout are unchanged.` : `Dependency preparation evidence changed.
|
|
46804
47025
|
Prepared files and dependency layout are unchanged.`);
|
|
46805
47026
|
if (reasons.length === 0) {
|
|
46806
47027
|
reasons.push("Execution environment changed: Jig installation, Agent configuration, or sandbox support.");
|
|
@@ -47467,7 +47688,7 @@ import { lstat as lstat24, mkdir as mkdir11, realpath as realpath24 } from "fs/p
|
|
|
47467
47688
|
import { join as join30 } from "path";
|
|
47468
47689
|
|
|
47469
47690
|
// src/run/session.ts
|
|
47470
|
-
import { createHash as
|
|
47691
|
+
import { createHash as createHash16 } from "crypto";
|
|
47471
47692
|
var ROOT_ID = "host:1";
|
|
47472
47693
|
var MAX_PENDING_COMPONENT_REQUESTS = 64;
|
|
47473
47694
|
var MAX_COMPONENT_REQUEST_IDS = 65536;
|
|
@@ -47902,16 +48123,16 @@ class RunHostSession {
|
|
|
47902
48123
|
this.failProtocol("component returned its root error before owned requests settled");
|
|
47903
48124
|
return;
|
|
47904
48125
|
}
|
|
47905
|
-
let
|
|
48126
|
+
let failure2;
|
|
47906
48127
|
try {
|
|
47907
|
-
|
|
48128
|
+
failure2 = parseRootFailure(response.error);
|
|
47908
48129
|
} catch (error) {
|
|
47909
48130
|
this.failProtocol(`invalid root error: ${errorText10(error)}`);
|
|
47910
48131
|
return;
|
|
47911
48132
|
}
|
|
47912
48133
|
this.rootOpen = false;
|
|
47913
48134
|
this.dispatcher?.channels?.finalize(false);
|
|
47914
|
-
this.rootResponse =
|
|
48135
|
+
this.rootResponse = failure2;
|
|
47915
48136
|
this.closeProtocolInput();
|
|
47916
48137
|
}
|
|
47917
48138
|
queueResponse(id, value) {
|
|
@@ -48125,7 +48346,7 @@ class RunHostSession {
|
|
|
48125
48346
|
}
|
|
48126
48347
|
finish(exit) {
|
|
48127
48348
|
const diagnostics = this.diagnostics();
|
|
48128
|
-
const
|
|
48349
|
+
const failure2 = (code2, message2, details) => ({
|
|
48129
48350
|
status: "failed",
|
|
48130
48351
|
code: code2,
|
|
48131
48352
|
message: message2,
|
|
@@ -48133,40 +48354,43 @@ class RunHostSession {
|
|
|
48133
48354
|
diagnostics
|
|
48134
48355
|
});
|
|
48135
48356
|
if (this.protocolFailure !== undefined) {
|
|
48136
|
-
return
|
|
48357
|
+
return failure2("PROTOCOL_ERROR", this.protocolFailure);
|
|
48358
|
+
}
|
|
48359
|
+
if (exit?.stopReason === "core_dump" && exit.fenced && exit.cleanupError === undefined && this.localTerminal === undefined) {
|
|
48360
|
+
return failure2("EXECUTION_FAILED", "owned execution crashed and was fenced during core dumping");
|
|
48137
48361
|
}
|
|
48138
48362
|
if (this.channelFailure !== undefined) {
|
|
48139
48363
|
if (this.rootResponse === undefined && exit?.stopReason === "deadline") {
|
|
48140
|
-
return
|
|
48364
|
+
return failure2("DEADLINE_EXCEEDED", "root Run hard deadline elapsed before a terminal response");
|
|
48141
48365
|
}
|
|
48142
|
-
return
|
|
48366
|
+
return failure2("CHANNEL_LOST", this.channelFailure);
|
|
48143
48367
|
}
|
|
48144
48368
|
if (exit === undefined) {
|
|
48145
|
-
return
|
|
48369
|
+
return failure2("CHANNEL_LOST", "component completion was unavailable");
|
|
48146
48370
|
}
|
|
48147
48371
|
if (exit?.cleanupError !== undefined || exit?.fenced !== true) {
|
|
48148
|
-
return
|
|
48372
|
+
return failure2("EXECUTION_FAILED", "component cleanup or fencing failed");
|
|
48149
48373
|
}
|
|
48150
48374
|
if (this.localTerminal !== undefined) {
|
|
48151
|
-
return
|
|
48375
|
+
return failure2(this.localTerminal.code, this.localTerminal.message);
|
|
48152
48376
|
}
|
|
48153
48377
|
if (this.postResponseTermination) {
|
|
48154
|
-
return
|
|
48378
|
+
return failure2("EXECUTION_FAILED", "component did not quiesce after its terminal response");
|
|
48155
48379
|
}
|
|
48156
48380
|
if (exit.exitCode !== 0 || exit.signal !== null) {
|
|
48157
|
-
return
|
|
48381
|
+
return failure2("EXECUTION_FAILED", `component exited with code ${String(exit.exitCode)} and signal ${String(exit.signal)}`);
|
|
48158
48382
|
}
|
|
48159
48383
|
if (this.rootResponse === undefined) {
|
|
48160
48384
|
if (exit.stopReason === "deadline") {
|
|
48161
|
-
return
|
|
48385
|
+
return failure2("DEADLINE_EXCEEDED", "root Run hard deadline elapsed before a terminal response");
|
|
48162
48386
|
}
|
|
48163
|
-
return
|
|
48387
|
+
return failure2("CHANNEL_LOST", "component exited before a root response");
|
|
48164
48388
|
}
|
|
48165
48389
|
if (this.pendingResponses !== 0 || this.operationWaiters.size !== 0 || this.channelRequests.size !== 0) {
|
|
48166
|
-
return
|
|
48390
|
+
return failure2("EXECUTION_FAILED", "component exited with pending owned protocol work");
|
|
48167
48391
|
}
|
|
48168
48392
|
if (this.rootResponse.kind === "failure") {
|
|
48169
|
-
return
|
|
48393
|
+
return failure2(this.rootResponse.code, this.rootResponse.message, this.rootResponse.details);
|
|
48170
48394
|
}
|
|
48171
48395
|
return { status: "succeeded", result: this.rootResponse.result, diagnostics };
|
|
48172
48396
|
}
|
|
@@ -48390,7 +48614,7 @@ function operationSignature(params) {
|
|
|
48390
48614
|
if (key !== "operationId")
|
|
48391
48615
|
semantic[key] = value;
|
|
48392
48616
|
}
|
|
48393
|
-
return
|
|
48617
|
+
return createHash16("sha256").update(Buffer.from("FLOW-Call/0\x00", "ascii")).update(canonicalJson(semantic)).digest("hex");
|
|
48394
48618
|
}
|
|
48395
48619
|
function errorMessage(id, code2, message2) {
|
|
48396
48620
|
return { jsonrpc: "2.0", id, error: { code: code2, message: message2 } };
|
|
@@ -48569,7 +48793,7 @@ async function materializePrivatePackageLease(captured, value) {
|
|
|
48569
48793
|
let packageDirectory;
|
|
48570
48794
|
let transactionInformation;
|
|
48571
48795
|
let created = false;
|
|
48572
|
-
let
|
|
48796
|
+
let failure2;
|
|
48573
48797
|
try {
|
|
48574
48798
|
await mkdirPrivateFile(privateChildLocation(parent.handle, allocation.name));
|
|
48575
48799
|
created = true;
|
|
@@ -48629,9 +48853,9 @@ async function materializePrivatePackageLease(captured, value) {
|
|
|
48629
48853
|
await requireChildIdentity(transaction, PACKAGE_NAME, packageInformation);
|
|
48630
48854
|
return leaseFromObserved(allocation, transactionInformation, packageInformation);
|
|
48631
48855
|
} catch (error) {
|
|
48632
|
-
|
|
48856
|
+
failure2 = error;
|
|
48633
48857
|
} finally {
|
|
48634
|
-
if (
|
|
48858
|
+
if (failure2 !== undefined && created) {
|
|
48635
48859
|
try {
|
|
48636
48860
|
if (transaction === undefined) {
|
|
48637
48861
|
const opened = await openOwnedDirectory(parent.handle, allocation.name, parent.information, [0o700n, 0o711n]);
|
|
@@ -48644,7 +48868,7 @@ async function materializePrivatePackageLease(captured, value) {
|
|
|
48644
48868
|
await removeTransaction(parent, transaction, allocation.name, transactionInformation, allocation.aliases);
|
|
48645
48869
|
transaction = undefined;
|
|
48646
48870
|
} catch (cleanupError) {
|
|
48647
|
-
|
|
48871
|
+
failure2 = new AggregateError([failure2, cleanupError], "durable materialization and exact cleanup did not both complete");
|
|
48648
48872
|
}
|
|
48649
48873
|
}
|
|
48650
48874
|
await packageDirectory?.close().catch(() => {
|
|
@@ -48657,7 +48881,7 @@ async function materializePrivatePackageLease(captured, value) {
|
|
|
48657
48881
|
return;
|
|
48658
48882
|
});
|
|
48659
48883
|
}
|
|
48660
|
-
throw
|
|
48884
|
+
throw failure2;
|
|
48661
48885
|
}
|
|
48662
48886
|
async function recoverPrivatePackageMaterializationAllocation(protectedParent, value) {
|
|
48663
48887
|
const allocation = parseAllocation(value);
|
|
@@ -51530,6 +51754,7 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
|
|
|
51530
51754
|
throw error;
|
|
51531
51755
|
}
|
|
51532
51756
|
let attemptedDispatch = false;
|
|
51757
|
+
let phase = "verifying the admitted runtime";
|
|
51533
51758
|
let execution;
|
|
51534
51759
|
let output;
|
|
51535
51760
|
let retained;
|
|
@@ -51540,9 +51765,10 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
|
|
|
51540
51765
|
const scopeDigest = nativeSessionScope(input, provider);
|
|
51541
51766
|
let failurePhase = "preparation";
|
|
51542
51767
|
try {
|
|
51543
|
-
await revalidateProviderSupport(recipe, provider, input);
|
|
51768
|
+
await privateProfileSpan("finite-acp-revalidation", () => revalidateProviderSupport(recipe, provider, input));
|
|
51544
51769
|
let restored;
|
|
51545
51770
|
if (operation.session !== undefined && "restore" in operation.session) {
|
|
51771
|
+
phase = "restoring the authorized session";
|
|
51546
51772
|
const snapshot2 = await claimPrivateNativeSession({
|
|
51547
51773
|
coordinator: input.coordinator,
|
|
51548
51774
|
projectRoot: input.projectRoot,
|
|
@@ -51565,8 +51791,9 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
|
|
|
51565
51791
|
if (operation.session !== undefined)
|
|
51566
51792
|
credentialBootstrap = runtime.startupInput?.();
|
|
51567
51793
|
const secrets2 = operation.session === undefined ? [] : privateCodexSessionSecrets(runtime, credentialBootstrap);
|
|
51794
|
+
phase = "preparing containment";
|
|
51568
51795
|
failurePhase = "sealing";
|
|
51569
|
-
const sealed = await sealPrivateExecutionOwner(input.backend, agentExecutionIntent(recipe, provider, effectiveDeadlineUnixMs, identity3, operation.session !== undefined), ownerAllocation);
|
|
51796
|
+
const sealed = await privateProfileSpan("finite-acp-containment", () => sealPrivateExecutionOwner(input.backend, agentExecutionIntent(recipe, provider, effectiveDeadlineUnixMs, identity3, operation.session !== undefined), ownerAllocation));
|
|
51570
51797
|
const sandbox = Object.freeze({ kind: SANDBOX_KIND, owner: sealed.identity });
|
|
51571
51798
|
lifecycle = await recordPrivateRootChildSandbox({
|
|
51572
51799
|
coordinator: input.coordinator,
|
|
@@ -51578,19 +51805,22 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
|
|
|
51578
51805
|
sandbox
|
|
51579
51806
|
});
|
|
51580
51807
|
attemptedDispatch = true;
|
|
51808
|
+
phase = "starting the native client";
|
|
51581
51809
|
failurePhase = "admission";
|
|
51582
|
-
const component = await admitPrivateExecutionOwner(sealed, input.signal);
|
|
51810
|
+
const component = await privateProfileSpan("finite-acp-launch", () => admitPrivateExecutionOwner(sealed, input.signal));
|
|
51583
51811
|
output = component.output;
|
|
51812
|
+
phase = "exchanging native messages";
|
|
51584
51813
|
failurePhase = "protocol";
|
|
51585
|
-
execution = await runPrivateFiniteAcpResource(component, runtime, endpoints, input.signal, operation.maxTurns, ...operation.session === undefined ? [] : [
|
|
51814
|
+
execution = await privateProfileSpan("finite-acp-exchange", () => runPrivateFiniteAcpResource(component, runtime, endpoints, input.signal, operation.maxTurns, ...operation.session === undefined ? [] : [
|
|
51586
51815
|
{
|
|
51587
51816
|
bootstrap: privateCodexSessionBootstrap(restored),
|
|
51588
51817
|
...restored === undefined ? {} : { restoreSessionId: restored.nativeId },
|
|
51589
51818
|
...credentialBootstrap === undefined ? {} : { credentialBootstrap }
|
|
51590
51819
|
}
|
|
51591
|
-
]);
|
|
51820
|
+
]));
|
|
51592
51821
|
failurePhase = "settlement";
|
|
51593
51822
|
if (operation.session !== undefined && !execution.closed && execution.fence.stopReason === "payload_exit" && execution.fence.exitCode === 0 && execution.fence.signal === null && !input.signal.aborted) {
|
|
51823
|
+
phase = "collecting authorized session state";
|
|
51594
51824
|
if (output === undefined || execution.sessionId === undefined)
|
|
51595
51825
|
throw new Error("Clean native retention lacks owned output or session identity");
|
|
51596
51826
|
try {
|
|
@@ -51604,13 +51834,14 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
|
|
|
51604
51834
|
throw error;
|
|
51605
51835
|
}
|
|
51606
51836
|
}
|
|
51607
|
-
|
|
51837
|
+
phase = "fencing and cleanup";
|
|
51838
|
+
await privateProfileSpan("finite-acp-release", () => releaseKnownAcp(input, lifecycle, execution.fence));
|
|
51608
51839
|
} catch (error) {
|
|
51609
51840
|
reportFailure(input, failurePhase, error);
|
|
51610
51841
|
try {
|
|
51611
51842
|
const active = await findLifecycle(input, input.call.operationId);
|
|
51612
51843
|
if (active !== undefined)
|
|
51613
|
-
await recoverPrivateRootFiniteAcpOwner(input, active);
|
|
51844
|
+
await privateProfileSpan("finite-acp-recovery", () => recoverPrivateRootFiniteAcpOwner(input, active));
|
|
51614
51845
|
} catch (cleanupError) {
|
|
51615
51846
|
reportFailure(input, "cleanup", cleanupError);
|
|
51616
51847
|
throw new RunHostFatalOperationError(isPrivateExecutionFenceUnconfirmed(cleanupError) ? "UNCERTAIN" : "EXECUTION_FAILED", {
|
|
@@ -51618,14 +51849,14 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
|
|
|
51618
51849
|
});
|
|
51619
51850
|
}
|
|
51620
51851
|
if (input.signal.aborted)
|
|
51621
|
-
return failed2("CANCELLED",
|
|
51852
|
+
return failed2("CANCELLED", `the finite ACP operation was cancelled while ${phase}`);
|
|
51622
51853
|
if (Date.now() >= effectiveDeadlineUnixMs) {
|
|
51623
|
-
return failed2("DEADLINE_EXCEEDED",
|
|
51854
|
+
return failed2("DEADLINE_EXCEEDED", `the finite ACP operation deadline elapsed while ${phase}; ${attemptedDispatch ? "dispatch may have occurred and no result was proved" : "dispatch was not attempted"}`);
|
|
51624
51855
|
}
|
|
51625
51856
|
if (error instanceof NativeSessionUnavailable)
|
|
51626
51857
|
return failed2("UNAVAILABLE", "the retained session is unavailable for this admitted caller");
|
|
51627
51858
|
const explanation = error instanceof PrivateFiniteAcpPolicyError ? error.reason === "native-session" ? " The native client reported a session failure; private details were withheld." : " The finite ACP exchange violated its validated protocol." : "";
|
|
51628
|
-
return attemptedDispatch ? failed2("UNCERTAIN", `Finite ACP dispatch may have occurred but no result was proved.${explanation}`) : failed2("EXECUTION_FAILED",
|
|
51859
|
+
return attemptedDispatch ? failed2("UNCERTAIN", `Finite ACP dispatch may have occurred but no result was proved while ${phase}.${explanation}`) : failed2("EXECUTION_FAILED", `finite ACP execution failed before dispatch while ${phase}`);
|
|
51629
51860
|
} finally {
|
|
51630
51861
|
credentialBootstrap?.fill(0);
|
|
51631
51862
|
try {
|
|
@@ -53188,19 +53419,23 @@ async function releaseAdmitAndClose(input, initial) {
|
|
|
53188
53419
|
}
|
|
53189
53420
|
if (work.lifecycle.backing !== undefined) {
|
|
53190
53421
|
const backing2 = parseBacking(work.lifecycle.backing.value);
|
|
53191
|
-
await disposePrivatePackageMaterializationLease(plan.packageAllocation.parent.path, backing2.lease);
|
|
53422
|
+
await privateProfileSpan("root-package-release", () => disposePrivatePackageMaterializationLease(plan.packageAllocation.parent.path, backing2.lease));
|
|
53192
53423
|
} else {
|
|
53193
|
-
|
|
53194
|
-
|
|
53195
|
-
|
|
53424
|
+
await privateProfileSpan("root-package-release", async () => {
|
|
53425
|
+
const recovered = await recoverPrivatePackageMaterializationAllocation(plan.packageAllocation.parent.path, plan.packageAllocation);
|
|
53426
|
+
if (recovered.state === "complete")
|
|
53427
|
+
await recovered.lease.dispose();
|
|
53428
|
+
});
|
|
53196
53429
|
}
|
|
53197
53430
|
if (work.lifecycle.sandbox !== undefined) {
|
|
53198
53431
|
const sandbox = parseSandbox3(work.lifecycle.sandbox.value);
|
|
53199
53432
|
const fence = parseFence3(work.lifecycle.fence.value);
|
|
53200
|
-
ownerRelease = await releasePrivateExecutionOwnerState(sandbox.owner, fence.receipt);
|
|
53433
|
+
ownerRelease = await privateProfileSpan("root-owner-release", () => releasePrivateExecutionOwnerState(sandbox.owner, fence.receipt));
|
|
53201
53434
|
} else {
|
|
53202
|
-
|
|
53203
|
-
|
|
53435
|
+
ownerRelease = await privateProfileSpan("root-owner-release", async () => {
|
|
53436
|
+
const cancelled2 = await cancelPrivateExecutionOwnerStateAllocation(plan.ownerAllocation);
|
|
53437
|
+
return await releasePrivateExecutionOwnerState(plan.ownerAllocation, cancelled2);
|
|
53438
|
+
});
|
|
53204
53439
|
}
|
|
53205
53440
|
}
|
|
53206
53441
|
work = await advanceCheckpoint(input, work, "release", {
|
|
@@ -53927,55 +54162,15 @@ function createSession(owner, roots, packageStore, host, onOperationFailure) {
|
|
|
53927
54162
|
const source = await captureStoredPackage(packageStoreRoot, request2.package);
|
|
53928
54163
|
try {
|
|
53929
54164
|
host.onStage?.(`Capturing dependency inputs for ${packageLabel}`);
|
|
53930
|
-
const workspace = await capturePrivateBunWorkspace({
|
|
54165
|
+
const workspace = await privateProfileSpan("dependency-workspace-capture", () => capturePrivateBunWorkspace({
|
|
53931
54166
|
projectRoot: owner.root,
|
|
53932
54167
|
packagePath: request2.packagePath,
|
|
53933
54168
|
captured: source,
|
|
53934
54169
|
signal: budget2.signal
|
|
53935
|
-
});
|
|
54170
|
+
}));
|
|
53936
54171
|
if (workspace !== undefined) {
|
|
53937
54172
|
try {
|
|
53938
|
-
|
|
53939
|
-
if (admitted?.execution.preparationInputDigest === workspace.captured.digest && admitted.execution.layout.flowRoot === workspace.target) {
|
|
53940
|
-
const current2 = await planPrivateDirectRun({
|
|
53941
|
-
request: request2,
|
|
53942
|
-
execution: admitted.execution,
|
|
53943
|
-
installedSupport: host.installedBunSupport,
|
|
53944
|
-
backend: host.backend,
|
|
53945
|
-
httpGrants: host.httpGrants,
|
|
53946
|
-
acpResources: host.acpResources
|
|
53947
|
-
});
|
|
53948
|
-
if (current2.digest === admitted.recipeDigest && current2.observation.digest === admitted.observationDigest) {
|
|
53949
|
-
execution = admitted.execution;
|
|
53950
|
-
privateProfileInstant("dependency-reuse");
|
|
53951
|
-
host.onStage?.(`Reusing approved dependencies for ${packageLabel}`);
|
|
53952
|
-
}
|
|
53953
|
-
}
|
|
53954
|
-
if (execution === undefined) {
|
|
53955
|
-
budget2.reserve(workspace.captured.digest, request2.packagePath);
|
|
53956
|
-
const unlocked = !workspace.captured.files.some(({ path: path2 }) => path2 === "bun.lock");
|
|
53957
|
-
requirePrivateBunResolutionPermission(unlocked ? { state: "unlocked", manifestPath: "package.json" } : { state: "locked", manifestPath: "package.json", lockPath: "bun.lock" }, host.allowResolutionNetwork);
|
|
53958
|
-
if (unlocked)
|
|
53959
|
-
host.onResolution?.(request2.packagePath);
|
|
53960
|
-
host.onStage?.(`Preparing dependencies for ${packageLabel}`);
|
|
53961
|
-
const prepared = await privateProfileSpan("dependency-preparation", () => preparePrivateBunPackage({
|
|
53962
|
-
captured: workspace.captured,
|
|
53963
|
-
workspace,
|
|
53964
|
-
installedSupport: host.installedBunSupport,
|
|
53965
|
-
backend: host.backend,
|
|
53966
|
-
projectRoot: owner.root.requestedPath,
|
|
53967
|
-
coordinator: owner.coordinator,
|
|
53968
|
-
deadlineUnixMs: budget2.deadlineUnixMs,
|
|
53969
|
-
signal: budget2.signal,
|
|
53970
|
-
allowResolutionNetwork: host.allowResolutionNetwork === true
|
|
53971
|
-
}));
|
|
53972
|
-
try {
|
|
53973
|
-
budget2.retain(prepared.captured.files, request2.packagePath, Buffer.byteLength(JSON.stringify(prepared.layout)));
|
|
53974
|
-
execution = privateBunExecutionArtifact(await publishCapturedPackage(packageStoreRoot, prepared.captured), prepared.layout, workspace.captured.digest);
|
|
53975
|
-
} finally {
|
|
53976
|
-
await prepared.captured.dispose();
|
|
53977
|
-
}
|
|
53978
|
-
}
|
|
54173
|
+
execution = await prepareExecution(workspace.captured, workspace);
|
|
53979
54174
|
} finally {
|
|
53980
54175
|
await workspace.captured.dispose();
|
|
53981
54176
|
}
|
|
@@ -53984,45 +54179,75 @@ function createSession(owner, roots, packageStore, host, onOperationFailure) {
|
|
|
53984
54179
|
if (dependencyInput.state === "direct") {
|
|
53985
54180
|
execution = privateBunExecutionArtifact(request2.package);
|
|
53986
54181
|
} else {
|
|
53987
|
-
|
|
53988
|
-
|
|
53989
|
-
|
|
53990
|
-
|
|
53991
|
-
|
|
53992
|
-
|
|
53993
|
-
|
|
53994
|
-
|
|
53995
|
-
|
|
54182
|
+
execution = await prepareExecution(source);
|
|
54183
|
+
}
|
|
54184
|
+
}
|
|
54185
|
+
async function prepareExecution(captured, workspace2) {
|
|
54186
|
+
const inputs = await privateBunPreparationInputs({
|
|
54187
|
+
captured,
|
|
54188
|
+
...workspace2 === undefined ? {} : { workspace: workspace2 },
|
|
54189
|
+
supportDigest: privateDomainDigest("JIG-Bun-Preparation-Support/1", {
|
|
54190
|
+
installation: host.installedBunSupport.digest,
|
|
54191
|
+
mechanism: (await host.backend.inspectSupport()).digest
|
|
54192
|
+
})
|
|
54193
|
+
});
|
|
54194
|
+
const admitted = readPrivateAdmittedExecutionReuse({ planningBase, request: request2 });
|
|
54195
|
+
const evidence = admitted?.execution.preparation;
|
|
54196
|
+
if (admitted !== undefined && evidence?.inputDigest === inputs.digest) {
|
|
54197
|
+
const previous = await captureStoredPackage(packageStoreRoot, admitted.execution.package);
|
|
54198
|
+
await previous.dispose();
|
|
54199
|
+
const dependencies = await captureStoredPackage(packageStoreRoot, evidence.package);
|
|
54200
|
+
try {
|
|
54201
|
+
const assembled = await assemblePrivateBunExecution({
|
|
54202
|
+
source: captured,
|
|
54203
|
+
sourcePaths: inputs.sourcePaths,
|
|
54204
|
+
dependencies,
|
|
54205
|
+
layout: admitted.execution.layout
|
|
53996
54206
|
});
|
|
53997
|
-
if (current2.digest === admitted.recipeDigest && current2.observation.digest === admitted.observationDigest) {
|
|
53998
|
-
execution = admitted.execution;
|
|
53999
|
-
privateProfileInstant("dependency-reuse");
|
|
54000
|
-
}
|
|
54001
|
-
}
|
|
54002
|
-
if (execution === undefined) {
|
|
54003
|
-
requirePrivateBunResolutionPermission(dependencyInput, host.allowResolutionNetwork);
|
|
54004
|
-
budget2.reserve(request2.package.digest, request2.packagePath);
|
|
54005
|
-
if (dependencyInput.state === "unlocked")
|
|
54006
|
-
host.onResolution?.(request2.packagePath);
|
|
54007
|
-
host.onStage?.(`Preparing dependencies for ${packageLabel}`);
|
|
54008
|
-
const prepared = await privateProfileSpan("dependency-preparation", () => preparePrivateBunPackage({
|
|
54009
|
-
captured: source,
|
|
54010
|
-
installedSupport: host.installedBunSupport,
|
|
54011
|
-
backend: host.backend,
|
|
54012
|
-
projectRoot: owner.root.requestedPath,
|
|
54013
|
-
coordinator: owner.coordinator,
|
|
54014
|
-
deadlineUnixMs: budget2.deadlineUnixMs,
|
|
54015
|
-
signal: budget2.signal,
|
|
54016
|
-
allowResolutionNetwork: host.allowResolutionNetwork === true
|
|
54017
|
-
}));
|
|
54018
54207
|
try {
|
|
54019
|
-
budget2.
|
|
54020
|
-
|
|
54208
|
+
budget2.signal.throwIfAborted();
|
|
54209
|
+
const execution2 = privateBunExecutionArtifact(await publishCapturedPackage(packageStoreRoot, assembled), admitted.execution.layout, evidence);
|
|
54210
|
+
privateProfileInstant("dependency-reuse");
|
|
54211
|
+
host.onStage?.(`Reusing approved dependencies for ${packageLabel}`);
|
|
54212
|
+
return execution2;
|
|
54021
54213
|
} finally {
|
|
54022
|
-
await
|
|
54214
|
+
await assembled.dispose();
|
|
54023
54215
|
}
|
|
54216
|
+
} finally {
|
|
54217
|
+
await dependencies.dispose();
|
|
54024
54218
|
}
|
|
54025
54219
|
}
|
|
54220
|
+
const unlocked = !captured.files.some(({ path: path2 }) => path2 === "bun.lock");
|
|
54221
|
+
requirePrivateBunResolutionPermission(unlocked ? { state: "unlocked", manifestPath: "package.json" } : { state: "locked", manifestPath: "package.json", lockPath: "bun.lock" }, host.allowResolutionNetwork);
|
|
54222
|
+
budget2.reserve(captured.digest, request2.packagePath);
|
|
54223
|
+
if (unlocked)
|
|
54224
|
+
host.onResolution?.(request2.packagePath);
|
|
54225
|
+
host.onStage?.(`Preparing dependencies for ${packageLabel}`);
|
|
54226
|
+
const prepared = await privateProfileSpan("dependency-preparation", () => preparePrivateBunPackage({
|
|
54227
|
+
captured,
|
|
54228
|
+
...workspace2 === undefined ? {} : { workspace: workspace2 },
|
|
54229
|
+
installedSupport: host.installedBunSupport,
|
|
54230
|
+
backend: host.backend,
|
|
54231
|
+
projectRoot: owner.root.requestedPath,
|
|
54232
|
+
coordinator: owner.coordinator,
|
|
54233
|
+
deadlineUnixMs: budget2.deadlineUnixMs,
|
|
54234
|
+
signal: budget2.signal,
|
|
54235
|
+
allowResolutionNetwork: host.allowResolutionNetwork === true
|
|
54236
|
+
}));
|
|
54237
|
+
try {
|
|
54238
|
+
budget2.retain(prepared.captured.files, request2.packagePath, Buffer.byteLength(JSON.stringify(prepared.layout)));
|
|
54239
|
+
const dependencies = await capturePrivateBunDependencies(prepared.captured, inputs.sourcePaths);
|
|
54240
|
+
try {
|
|
54241
|
+
return privateBunExecutionArtifact(await publishCapturedPackage(packageStoreRoot, prepared.captured), prepared.layout, {
|
|
54242
|
+
inputDigest: inputs.digest,
|
|
54243
|
+
package: await publishCapturedPackage(packageStoreRoot, dependencies)
|
|
54244
|
+
});
|
|
54245
|
+
} finally {
|
|
54246
|
+
await dependencies.dispose();
|
|
54247
|
+
}
|
|
54248
|
+
} finally {
|
|
54249
|
+
await prepared.captured.dispose();
|
|
54250
|
+
}
|
|
54026
54251
|
}
|
|
54027
54252
|
} finally {
|
|
54028
54253
|
await source.dispose();
|
|
@@ -54061,17 +54286,17 @@ function createSession(owner, roots, packageStore, host, onOperationFailure) {
|
|
|
54061
54286
|
}),
|
|
54062
54287
|
mechanismDigest: recipes[0]?.mechanismDigest ?? (await host.backend.inspectSupport()).digest,
|
|
54063
54288
|
entries: requests.map((request2) => {
|
|
54064
|
-
const
|
|
54289
|
+
const failure2 = featureFailures.get(privateActivationTargetKey(request2.target));
|
|
54065
54290
|
return {
|
|
54066
54291
|
target: request2.target,
|
|
54067
54292
|
requestDigest: request2.digest,
|
|
54068
|
-
disposition:
|
|
54293
|
+
disposition: failure2 === undefined ? {
|
|
54069
54294
|
state: "planned",
|
|
54070
54295
|
observation: recipes.find((recipe) => recipe.request.digest === request2.digest).observation
|
|
54071
54296
|
} : {
|
|
54072
54297
|
state: "unavailable",
|
|
54073
54298
|
code: "FEATURE_UNAVAILABLE",
|
|
54074
|
-
evidenceDigests: [
|
|
54299
|
+
evidenceDigests: [failure2]
|
|
54075
54300
|
}
|
|
54076
54301
|
};
|
|
54077
54302
|
})
|