@jigging/jig 0.1.0-alpha.26 → 0.1.0-alpha.29

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.
@@ -9081,13 +9081,13 @@ import { fileURLToPath as fileURLToPath5 } from "url";
9081
9081
  // src/cli.ts
9082
9082
  import { randomBytes as randomBytes7 } from "crypto";
9083
9083
  import { lstat as lstat19 } from "fs/promises";
9084
- import { basename as basename4, resolve as resolve11 } from "path";
9084
+ import { basename as basename5, resolve as resolve11 } from "path";
9085
9085
  import { createInterface } from "readline";
9086
9086
  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.26",
9090
+ version: "0.1.0-alpha.29",
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
- #events = [];
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
- writeSync3(this.#fd, `${JSON.stringify(header)}
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.#events.push(JSON.stringify({ kind: "start", spanId: span.spanId, phase, timeMs: span.startMs }));
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.#events.push(JSON.stringify({
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 || this.#events.length >= MAX_SPANS * 2) {
25951
- this.#truncated = true;
25949
+ if (this.#closed)
25952
25950
  return;
25953
- }
25954
25951
  const timeMs = elapsed(this.#startedAtMs);
25955
- this.#events.push(JSON.stringify({ kind: "instant", phase, timeMs }));
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
- writeSync3(this.#fd, `${JSON.stringify({ kind: "truncated", phaseLimit: MAX_SPANS })}
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;
@@ -26112,10 +26119,20 @@ function privateMacosExecutionPlan(intent, allocation) {
26112
26119
  return value;
26113
26120
  };
26114
26121
  const embedded = (value) => {
26115
- let result2 = value;
26116
- for (const [destination, source] of mappings)
26117
- result2 = result2.split(destination).join(source);
26118
- return result2.split("/jig-output").join(join4(data, "output")).split("/tmp/").join(`${join4(data, "tmp")}/`);
26122
+ try {
26123
+ let changed = false;
26124
+ const parsed = JSON.parse(value, (_name, entry) => {
26125
+ if (typeof entry !== "string")
26126
+ return entry;
26127
+ const relocated = path(entry);
26128
+ if (relocated !== entry)
26129
+ changed = true;
26130
+ return relocated;
26131
+ });
26132
+ return changed ? JSON.stringify(parsed) : value;
26133
+ } catch {
26134
+ return path(value);
26135
+ }
26119
26136
  };
26120
26137
  const environment = Object.fromEntries(Object.entries(intent.environment ?? {}).map(([name, value]) => [
26121
26138
  name,
@@ -26151,7 +26168,7 @@ function privateMacosExecutionPlan(intent, allocation) {
26151
26168
  network: intent.network ?? "isolated"
26152
26169
  },
26153
26170
  maxOutputBytes: intent.maxOutputBytes,
26154
- ...intent.readOnlyCwd === undefined ? {
26171
+ ...intent.readOnlyCwd === undefined || (intent.inputDirectories?.length ?? 0) > 0 ? {
26155
26172
  storage: {
26156
26173
  mountPath: data,
26157
26174
  bytes: intent.storageBytes,
@@ -27351,6 +27368,7 @@ var STOP_REASONS = new Set([
27351
27368
  "coordinator_lost",
27352
27369
  "deadline",
27353
27370
  "payload_exit",
27371
+ "core_dump",
27354
27372
  "setup_failed",
27355
27373
  "recovered"
27356
27374
  ]);
@@ -28018,6 +28036,7 @@ var SUPERVISOR_STOP_REASONS = new Set([
28018
28036
  "coordinator_lost",
28019
28037
  "deadline",
28020
28038
  "payload_exit",
28039
+ "core_dump",
28021
28040
  "setup_failed"
28022
28041
  ]);
28023
28042
  function receiptFor(prepared, final) {
@@ -29795,7 +29814,9 @@ function requirePrivateMacosGuardianStorage(storage, files, cwd) {
29795
29814
  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
29815
  throw new TypeError("invalid macOS guardian storage");
29797
29816
  const roots = ["work", "tmp", "output"].map((name) => join10(storage.mountPath, name));
29798
- if (files.writableTrees.some((path) => !roots.includes(path)) || !roots.some((root) => cwd === root || cwd.startsWith(`${root}/`)))
29817
+ const inputs = join10(storage.mountPath, "inputs");
29818
+ const readOnlyInputCwd = files.writableTrees.length === 0 && storage.collect === null && files.readOnlyTrees.includes(inputs) && (cwd === inputs || cwd.startsWith(`${inputs}/`));
29819
+ if (files.writableTrees.some((path) => !roots.includes(path)) || !roots.some((root) => cwd === root || cwd.startsWith(`${root}/`)) && !readOnlyInputCwd)
29799
29820
  throw new TypeError("macOS writable projection is outside bounded storage");
29800
29821
  }
29801
29822
  async function allocatePrivateMacosGuardianStorage(owner, token, storage) {
@@ -31421,6 +31442,9 @@ function recordKind(value) {
31421
31442
  return value !== null && typeof value === "object" ? value.kind : undefined;
31422
31443
  }
31423
31444
 
31445
+ // src/project/author-evaluator.ts
31446
+ init_input_capture();
31447
+
31424
31448
  // src/internal/installed-bun-support.ts
31425
31449
  init_macos_process_controls();
31426
31450
  import { constants as constants18 } from "fs";
@@ -31644,6 +31668,28 @@ async function exactDirectory(path2, label) {
31644
31668
  return resolved;
31645
31669
  }
31646
31670
 
31671
+ // src/internal/project-evaluator-policy.ts
31672
+ var PRIVATE_AUTHOR_EVALUATOR_PROTOCOL = "jig-author-evaluator/1";
31673
+ var PRIVATE_AUTHOR_EVALUATOR_MAX_ENTRIES = 256;
31674
+ var PRIVATE_AUTHOR_EVALUATOR_ENTRY_MS = 3000;
31675
+ var PRIVATE_AUTHOR_EVALUATOR_MACOS_ENTRY_MS = 1e4;
31676
+ var PRIVATE_AUTHOR_EVALUATOR_BATCH_FIXED_OVERHEAD_MS = 2000;
31677
+ var PRIVATE_AUTHOR_EVALUATOR_BATCH_ENTRY_OVERHEAD_MS = 500;
31678
+ function privateAuthorEvaluatorWallClockCeilingMs(entries, entryWallClockCeilingMs = PRIVATE_AUTHOR_EVALUATOR_ENTRY_MS) {
31679
+ return entryWallClockCeilingMs * entries + (entries > 1 ? PRIVATE_AUTHOR_EVALUATOR_BATCH_FIXED_OVERHEAD_MS + PRIVATE_AUTHOR_EVALUATOR_BATCH_ENTRY_OVERHEAD_MS * entries : 0);
31680
+ }
31681
+ var PRIVATE_AUTHOR_EVALUATOR_DIRECTORY = "/jig-input/evaluator";
31682
+ var PRIVATE_AUTHOR_EVALUATOR_WORKER = `${PRIVATE_AUTHOR_EVALUATOR_DIRECTORY}/project-evaluator-worker.js`;
31683
+ var PRIVATE_AUTHOR_EVALUATOR_LIMITS = Object.freeze({
31684
+ memoryBytes: 256 * 1024 * 1024,
31685
+ pids: 64,
31686
+ cpuQuotaMicros: 50000,
31687
+ cpuPeriodMicros: 1e5,
31688
+ wallClockCeilingMs: PRIVATE_AUTHOR_EVALUATOR_ENTRY_MS,
31689
+ cancellationGraceMs: 1000,
31690
+ cleanupTimeoutMs: 5000
31691
+ });
31692
+
31647
31693
  // src/project/author-module.ts
31648
31694
  import { createHash as createHash11 } from "crypto";
31649
31695
  import { constants as constants19 } from "fs";
@@ -32038,19 +32084,10 @@ function errorText7(error) {
32038
32084
  }
32039
32085
 
32040
32086
  // src/project/author-evaluator.ts
32041
- var PROTOCOL = "jig-author-evaluator/1";
32087
+ var PROTOCOL = PRIVATE_AUTHOR_EVALUATOR_PROTOCOL;
32042
32088
  var MAX_STDERR_BYTES = 64 * 1024;
32043
32089
  var MAX_STDOUT_BYTES = JSON_1_LIMITS.bytes + 16 * 1024;
32044
- var EVALUATOR_LIMIT_POLICY = Object.freeze({
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;
32090
+ var EVALUATOR_LIMIT_POLICY = PRIVATE_AUTHOR_EVALUATOR_LIMITS;
32054
32091
  var EVALUATION_CODES = new Set([
32055
32092
  "PROJECT_AUTHORING_VALUE",
32056
32093
  "PROJECT_DEFAULT_EXPORT",
@@ -32058,19 +32095,38 @@ var EVALUATION_CODES = new Set([
32058
32095
  "PROJECT_EVALUATION_LIMIT",
32059
32096
  "PROJECT_EVALUATOR_COMPILE",
32060
32097
  "PROJECT_EVALUATOR_IMPORT",
32061
- "PROJECT_EVALUATOR_PROTOCOL"
32098
+ "PROJECT_EVALUATOR_PROTOCOL",
32099
+ "PROJECT_EVALUATOR_DEADLINE"
32062
32100
  ]);
32063
32101
  var decoder6 = new TextDecoder("utf-8", { fatal: true });
32064
32102
  var evaluationSequence = 0;
32065
32103
  async function evaluateAuthorClosure(options, captured, entryProjectPath, expected, signal) {
32104
+ const results = await evaluateAuthorClosureBatch(options, captured, [{ entryProjectPath, expected }], signal);
32105
+ return results[0];
32106
+ }
32107
+ async function evaluateAuthorClosureBatch(options, captured, requestedEntries, signal) {
32108
+ const entries = Object.freeze(requestedEntries.map(({ entryProjectPath: entryProjectPath2, expected }) => Object.freeze({ entryProjectPath: entryProjectPath2, expected })));
32066
32109
  if (!isCapturedAuthorClosure(captured)) {
32067
32110
  invalid("PROJECT_AUTHOR_CAPTURE", "author closure was not produced by the capture boundary");
32068
32111
  }
32069
- if (!captured.entries.includes(entryProjectPath)) {
32070
- invalid("PROJECT_AUTHOR_CAPTURE", "selected entry is outside the author closure", entryProjectPath);
32112
+ if (entries.length === 0 || entries.length > PRIVATE_AUTHOR_EVALUATOR_MAX_ENTRIES) {
32113
+ invalid("PROJECT_AUTHOR_CAPTURE", "evaluator batch has an invalid declaration count");
32114
+ }
32115
+ const selected = new Set;
32116
+ for (const { entryProjectPath: entryProjectPath2 } of entries) {
32117
+ if (!captured.entries.includes(entryProjectPath2) || selected.has(entryProjectPath2)) {
32118
+ invalid("PROJECT_AUTHOR_CAPTURE", "selected entry is absent or repeated", entryProjectPath2);
32119
+ }
32120
+ selected.add(entryProjectPath2);
32071
32121
  }
32122
+ const entryProjectPath = entries[0].entryProjectPath;
32123
+ const entryWallClockCeilingMs = privateExecutionBackendKind(options.backend) === "macos" ? PRIVATE_AUTHOR_EVALUATOR_MACOS_ENTRY_MS : PRIVATE_AUTHOR_EVALUATOR_ENTRY_MS;
32124
+ const limitPolicy = Object.freeze({
32125
+ ...EVALUATOR_LIMIT_POLICY,
32126
+ wallClockCeilingMs: privateAuthorEvaluatorWallClockCeilingMs(entries.length, entryWallClockCeilingMs)
32127
+ });
32072
32128
  const installedSupport = requirePrivateInstalledBunSupport(options.installedSupport);
32073
- await revalidatePrivateInstalledBunSupport(installedSupport).catch((error) => unavailable("PROJECT_EVALUATOR_SUPPORT", `installed evaluator support is unavailable: ${errorText8(error)}`, entryProjectPath));
32129
+ await privateProfileSpan("author-support-verification", () => revalidatePrivateInstalledBunSupport(installedSupport)).catch((error) => unavailable("PROJECT_EVALUATOR_SUPPORT", `installed evaluator support is unavailable: ${errorText8(error)}`, entryProjectPath));
32074
32130
  const runtimeMounts = installedSupport.runtimeMounts;
32075
32131
  const [workerBytes, sdkBytes, schemaBytes] = await Promise.all([
32076
32132
  readFile3(join15(installedSupport.evaluatorSupportPath, "project-evaluator-worker.js")),
@@ -32078,6 +32134,14 @@ async function evaluateAuthorClosure(options, captured, entryProjectPath, expect
32078
32134
  readFile3(join15(installedSupport.evaluatorSupportPath, "project-authoring-1.schema.json"))
32079
32135
  ]).catch((error) => unavailable("PROJECT_EVALUATOR_SUPPORT", `cannot seal evaluator toolchain: ${errorText8(error)}`, entryProjectPath));
32080
32136
  const authoringProfile = "project-authoring/1";
32137
+ const capturedSupportDigest = privateDomainDigest("JIG-Installed-Evaluator-Support/1", [
32138
+ { name: "project-evaluator-worker.js", digest: digestBytes(workerBytes) },
32139
+ { name: "project-evaluator-sdk.bundle.js", digest: digestBytes(sdkBytes) },
32140
+ { name: "project-authoring-1.schema.json", digest: digestBytes(schemaBytes) }
32141
+ ]);
32142
+ if (capturedSupportDigest !== installedSupport.evaluatorSupportDigest) {
32143
+ unavailable("PROJECT_EVALUATOR_SUPPORT", "evaluator support changed during capture", entryProjectPath);
32144
+ }
32081
32145
  const profileBase = Object.freeze({
32082
32146
  protocol: PROTOCOL,
32083
32147
  authoringProfile,
@@ -32092,7 +32156,12 @@ async function evaluateAuthorClosure(options, captured, entryProjectPath, expect
32092
32156
  kind: installedSupport.kind,
32093
32157
  digest: installedSupport.digest
32094
32158
  }),
32095
- buildOptions: "bun-cjs-closed-static-closure/1"
32159
+ buildOptions: "bun-cjs-closed-static-closure/1",
32160
+ evaluation: Object.freeze({
32161
+ kind: "finite-isolated-declarations/1",
32162
+ entries: entries.length,
32163
+ entryWallClockCeilingMs
32164
+ })
32096
32165
  });
32097
32166
  const modules = captured.modules.map((module) => ({
32098
32167
  projectPath: module.projectPath,
@@ -32102,177 +32171,213 @@ async function evaluateAuthorClosure(options, captured, entryProjectPath, expect
32102
32171
  const request = canonicalJson({
32103
32172
  protocol: PROTOCOL,
32104
32173
  authoringProfile,
32105
- entryProjectPath,
32174
+ entries: entries.map(({ entryProjectPath: entryProjectPath2 }) => entryProjectPath2),
32106
32175
  modules
32107
32176
  });
32108
32177
  const runId = `config-${process.pid.toString(36)}-${(++evaluationSequence).toString(36)}`;
32109
- const policy = evaluatorLimitPolicy(options.backend);
32110
- const limits = evaluatorLimits(policy);
32111
- const component = await launchPrivateExecution(options.backend, evaluatorLaunchPlan(installedSupport, runId, limits), signal).catch((error) => {
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);
32178
+ const limits = evaluatorLimits(limitPolicy);
32179
+ const inputs = [];
32180
+ let operationFailure;
32157
32181
  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
32182
  try {
32187
- response = decodeJson1(output);
32188
- } catch (error) {
32189
- if (error instanceof Json1Error) {
32190
- unavailable("PROJECT_EVALUATOR_PROTOCOL", error.message, entryProjectPath);
32183
+ for (const [name, bytes] of [
32184
+ ["project-evaluator-worker.js", workerBytes],
32185
+ ["project-evaluator-sdk.bundle.js", sdkBytes]
32186
+ ]) {
32187
+ inputs.push({
32188
+ input: capturePrivateInput(bytes),
32189
+ destination: `${PRIVATE_AUTHOR_EVALUATOR_DIRECTORY}/${name}`
32190
+ });
32191
32191
  }
32192
- throw error;
32192
+ } catch {
32193
+ unavailable("PROJECT_EVALUATOR_SUPPORT", "cannot seal evaluator support", entryProjectPath);
32193
32194
  }
32194
- const value = checkedResponse(response, entryProjectPath);
32195
- contextualAuthorSchema(schemaBytes, expected, entryProjectPath).validate(value, "PROJECT_AUTHORING_SCHEMA_INVALID");
32196
- let normalized;
32195
+ const component = await privateProfileSpan("author-envelope-startup", () => launchPrivateExecution(options.backend, evaluatorLaunchPlan(installedSupport, runId, limits, inputs), signal)).catch((error) => {
32196
+ return unavailable("PROJECT_EVALUATOR_LAUNCH", `cannot launch evaluator envelope: ${errorText8(error)}`, entryProjectPath);
32197
+ });
32198
+ 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);
32199
+ if (!validEnvelope) {
32200
+ await component.terminate().catch(() => {
32201
+ return;
32202
+ });
32203
+ const completion = await component.completion.catch((error) => unavailable("PROJECT_EVALUATOR_CLEANUP", `evaluator envelope lost while rejecting its predicates: ${errorText8(error)}`, entryProjectPath));
32204
+ if (!completion.fenced || completion.cleanupError !== undefined) {
32205
+ unavailable("PROJECT_EVALUATOR_CLEANUP", "evaluator envelope predicates were absent and cleanup was not proven", entryProjectPath);
32206
+ }
32207
+ unavailable("PROJECT_EVALUATOR_ENVELOPE", "evaluator envelope did not preserve its sealed runtime or root-only predicates", entryProjectPath);
32208
+ }
32209
+ const profile = Object.freeze({
32210
+ ...profileBase,
32211
+ sandbox: component.envelope.kind === "linux-rootless-cgroup-v2-bubblewrap/1" ? Object.freeze({
32212
+ kind: component.envelope.kind,
32213
+ mechanismDigest: component.envelope.mechanismDigest,
32214
+ sealedPlanDigest: component.envelope.sealedPlanDigest,
32215
+ bubblewrapPath: component.envelope.trustedBubblewrapPath,
32216
+ bubblewrapDigest: component.envelope.trustedBubblewrapDigest,
32217
+ coordinatorRuntimePath: component.envelope.trustedCoordinatorBunPath,
32218
+ coordinatorRuntimeDigest: component.envelope.trustedCoordinatorBunDigest,
32219
+ supervisorPath: component.envelope.trustedSupervisorPath,
32220
+ supervisorDigest: component.envelope.trustedSupervisorDigest,
32221
+ payloadUid: component.envelope.payloadUid,
32222
+ payloadGid: component.envelope.payloadGid,
32223
+ limits: limitPolicy,
32224
+ privateProcessFilesystem: component.envelope.privateProcessFilesystem,
32225
+ privateRuntimeDevices: component.envelope.privateRuntimeDevices
32226
+ }) : Object.freeze({
32227
+ kind: component.envelope.kind,
32228
+ mechanismDigest: component.envelope.mechanismDigest,
32229
+ sealedPlanDigest: component.envelope.sealedPlanDigest,
32230
+ supervisorPath: installedSupport.supervisorPath,
32231
+ supervisorDigest: installedSupport.supervisorDigest,
32232
+ launcherPath: installedSupport.launcherPath,
32233
+ launcherDigest: installedSupport.launcherDigest,
32234
+ limits: limitPolicy,
32235
+ resourceAccounting: component.envelope.resourceAccounting,
32236
+ resourceOvershoot: component.envelope.resourceOvershoot
32237
+ })
32238
+ });
32239
+ const stdout = collectBounded(component.stdout, MAX_STDOUT_BYTES, component.terminate);
32240
+ const stderr = collectBounded(component.stderr, MAX_STDERR_BYTES, component.terminate);
32197
32241
  try {
32198
- normalized = expected === "project" ? normalizeJigDefinition(value) : normalizePackageBindingDefinition(value);
32242
+ await component.write(request);
32243
+ await component.closeInput();
32244
+ const [output, diagnostics, exit, evidence, terminationReason] = await privateProfileSpan("author-execution-settlement", () => Promise.all([
32245
+ stdout,
32246
+ stderr,
32247
+ component.completion,
32248
+ component.evidence,
32249
+ component.terminationReason
32250
+ ]));
32251
+ if (exit.cleanupError !== undefined || !exit.fenced) {
32252
+ unavailable("PROJECT_EVALUATOR_CLEANUP", `evaluator cleanup was not proven: ${exit.cleanupError ?? "not fenced"}`, entryProjectPath);
32253
+ }
32254
+ if ("memoryEvents" in evidence && (evidence.memoryEvents.max ?? 0) > 0 || terminationReason === "memory_limit") {
32255
+ invalid("PROJECT_EVALUATOR_MEMORY_LIMIT", "evaluator reached its hard memory limit", entryProjectPath);
32256
+ }
32257
+ if ("pidsEvents" in evidence && (evidence.pidsEvents.max ?? 0) > 0 || terminationReason === "process_limit") {
32258
+ invalid("PROJECT_EVALUATOR_PROCESS_LIMIT", "evaluator reached its hard process limit", entryProjectPath);
32259
+ }
32260
+ if (terminationReason === "deadline") {
32261
+ invalid("PROJECT_EVALUATOR_DEADLINE", "evaluator reached its hard wall deadline", entryProjectPath);
32262
+ }
32263
+ if (terminationReason !== "payload_exit") {
32264
+ unavailable("PROJECT_EVALUATOR_INTERRUPTED", `evaluator ended for an unexpected reason: ${terminationReason}`, entryProjectPath);
32265
+ }
32266
+ if (exit.exitCode !== 0 || exit.signal !== null) {
32267
+ invalid("PROJECT_EVALUATION_FAILED", `evaluator exited ${exit.exitCode ?? exit.signal}${diagnostics.length === 0 ? "" : `: ${safeText2(diagnostics)}`}`, entryProjectPath);
32268
+ }
32269
+ let response;
32270
+ try {
32271
+ response = decodeJson1(output);
32272
+ } catch (error) {
32273
+ if (error instanceof Json1Error) {
32274
+ unavailable("PROJECT_EVALUATOR_PROTOCOL", error.message, entryProjectPath);
32275
+ }
32276
+ throw error;
32277
+ }
32278
+ const values = checkedResponse(response, entries);
32279
+ return Object.freeze(entries.map(({ entryProjectPath: entryProjectPath2, expected }, index) => {
32280
+ const value = values[index];
32281
+ contextualAuthorSchema(schemaBytes, expected, entryProjectPath2).validate(value, "PROJECT_AUTHORING_SCHEMA_INVALID");
32282
+ let normalized;
32283
+ try {
32284
+ normalized = expected === "project" ? normalizeJigDefinition(value) : normalizePackageBindingDefinition(value);
32285
+ } catch (error) {
32286
+ invalid("PROJECT_DECLARATION_INVALID", errorText8(error), entryProjectPath2);
32287
+ }
32288
+ const outputBytes = canonicalJson(normalized);
32289
+ return Object.freeze({
32290
+ expected,
32291
+ source: Object.freeze({
32292
+ entryProjectPath: entryProjectPath2,
32293
+ bytes: captured.sourceBytes,
32294
+ digest: captured.closureDigest,
32295
+ modules: Object.freeze(captured.modules.map((module) => Object.freeze({
32296
+ projectPath: module.projectPath,
32297
+ bytes: module.sourceBytes,
32298
+ digest: module.sourceDigest,
32299
+ imports: Object.freeze(module.imports.map((edge) => Object.freeze({ ...edge })))
32300
+ })))
32301
+ }),
32302
+ profile,
32303
+ outputDigest: digestBytes(outputBytes),
32304
+ value: normalized,
32305
+ enforcement: Object.freeze({
32306
+ owner: "cgroup" in component ? Object.freeze({ kind: "linux-cgroup", ...component.cgroup }) : Object.freeze({ kind: "macos-process", ...component.process }),
32307
+ terminal: Object.freeze({
32308
+ reason: terminationReason,
32309
+ exitCode: exit.exitCode,
32310
+ signal: exit.signal,
32311
+ fenced: exit.fenced
32312
+ }),
32313
+ evidence: "cpuStat" in evidence ? Object.freeze({
32314
+ ...prefixNumbers("cpu", evidence.cpuStat),
32315
+ ...prefixNumbers("memory", evidence.memoryEvents),
32316
+ ...prefixNumbers("pids", evidence.pidsEvents)
32317
+ }) : Object.freeze({ ...evidence })
32318
+ })
32319
+ });
32320
+ }));
32199
32321
  } catch (error) {
32200
- invalid("PROJECT_DECLARATION_INVALID", errorText8(error), entryProjectPath);
32322
+ await component.terminate().catch(() => {
32323
+ return;
32324
+ });
32325
+ const settled = await Promise.allSettled([
32326
+ stdout,
32327
+ stderr,
32328
+ component.completion,
32329
+ component.evidence
32330
+ ]);
32331
+ const cleanup = settled[2];
32332
+ if (cleanup.status === "rejected") {
32333
+ throw new AggregateError([error, cleanup.reason], "evaluator failed and cleanup was not confirmed");
32334
+ }
32335
+ if (!cleanup.value.fenced || cleanup.value.cleanupError !== undefined) {
32336
+ throw new AggregateError([error, cleanup.value], "evaluator failed without a clean fence");
32337
+ }
32338
+ throw error;
32201
32339
  }
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
32340
  } catch (error) {
32235
- await component.terminate().catch(() => {
32236
- return;
32237
- });
32238
- const settled = await Promise.allSettled([
32239
- stdout,
32240
- stderr,
32241
- component.completion,
32242
- component.evidence
32243
- ]);
32244
- const cleanup = settled[2];
32245
- if (cleanup.status === "rejected") {
32246
- throw new AggregateError([error, cleanup.reason], "evaluator failed and cleanup was not confirmed");
32341
+ operationFailure = error;
32342
+ throw error;
32343
+ } finally {
32344
+ const failures = [];
32345
+ for (const { input } of inputs) {
32346
+ try {
32347
+ input.close();
32348
+ } catch (error) {
32349
+ failures.push(error);
32350
+ }
32247
32351
  }
32248
- if (!cleanup.value.fenced || cleanup.value.cleanupError !== undefined) {
32249
- throw new AggregateError([error, cleanup.value], "evaluator failed without a clean fence");
32352
+ if (failures.length > 0) {
32353
+ throw new AggregateError(operationFailure === undefined ? failures : [operationFailure, ...failures], "evaluator input cleanup failed");
32250
32354
  }
32251
- throw error;
32252
32355
  }
32253
32356
  }
32254
- function checkedResponse(response, projectPath) {
32357
+ function checkedResponse(response, entries) {
32358
+ const projectPath = entries[0].entryProjectPath;
32255
32359
  if (!isRecord(response) || response.protocol !== PROTOCOL || response.status !== "ok" && response.status !== "error") {
32256
32360
  unavailable("PROJECT_EVALUATOR_PROTOCOL", "evaluator returned an invalid envelope", projectPath);
32257
32361
  }
32258
32362
  if (response.status === "error") {
32259
- if (!exactKeys(response, ["code", "message", "protocol", "status"]) || typeof response.code !== "string" || typeof response.message !== "string") {
32363
+ 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
32364
  unavailable("PROJECT_EVALUATOR_PROTOCOL", "evaluator error has an invalid shape", projectPath);
32261
32365
  }
32262
32366
  if (!EVALUATION_CODES.has(response.code)) {
32263
32367
  unavailable("PROJECT_EVALUATOR_PROTOCOL", "evaluator returned an unknown error code", projectPath);
32264
32368
  }
32265
32369
  const code2 = response.code;
32370
+ const location = response.entryIndex === null ? projectPath : entries[response.entryIndex].entryProjectPath;
32266
32371
  if (code2 === "PROJECT_EVALUATOR_PROTOCOL") {
32267
- unavailable(code2, response.message, projectPath);
32372
+ unavailable(code2, response.message, location);
32268
32373
  }
32269
32374
  const message2 = response.message;
32270
- invalid(code2, message2, projectPath);
32375
+ invalid(code2, message2, location);
32271
32376
  }
32272
- if (!exactKeys(response, ["protocol", "status", "value"])) {
32377
+ if (!exactKeys(response, ["protocol", "status", "values"]) || !Array.isArray(response.values) || response.values.length !== entries.length) {
32273
32378
  unavailable("PROJECT_EVALUATOR_PROTOCOL", "evaluator success has an invalid shape", projectPath);
32274
32379
  }
32275
- return response.value;
32380
+ return response.values;
32276
32381
  }
32277
32382
  function contextualAuthorSchema(bytes, expected, projectPath) {
32278
32383
  let document;
@@ -32287,41 +32392,36 @@ function contextualAuthorSchema(bytes, expected, projectPath) {
32287
32392
  const definition = expected === "project" ? "project" : "bindingDefinition";
32288
32393
  try {
32289
32394
  return compileEmbeddedSchema(Object.freeze({ $ref: `#/$defs/${definition}` }), {
32290
- path: "project-authoring-1.schema.json",
32395
+ path: projectPath,
32291
32396
  rootDefs: document.$defs
32292
32397
  });
32293
32398
  } catch (error) {
32294
32399
  unavailable("PROJECT_EVALUATOR_SUPPORT", `captured authoring schema cannot compile: ${errorText8(error)}`, projectPath);
32295
32400
  }
32296
32401
  }
32297
- function evaluatorLaunchPlan(support, runId, limits) {
32402
+ function evaluatorLaunchPlan(support, runId, limits, inputs) {
32298
32403
  return {
32299
32404
  runId,
32300
32405
  limits,
32301
- projections: [
32302
- ...privateExecutionFileProjections(support.runtimeMounts),
32303
- { source: support.evaluatorSupportPath, destination: "/jig-evaluator", kind: "tree" }
32304
- ],
32406
+ projections: [...privateExecutionFileProjections(support.runtimeMounts)],
32305
32407
  command: [
32306
32408
  privateExecutionPath(support.sandboxExecutablePath),
32307
- privateExecutionPath("/jig-evaluator/project-evaluator-worker.js")
32409
+ privateExecutionPath(PRIVATE_AUTHOR_EVALUATOR_WORKER)
32308
32410
  ],
32309
- readOnlyCwd: "/jig-evaluator",
32310
- relocatedEnvironment: { JIG_EVALUATOR_SDK: "/jig-evaluator/project-evaluator-sdk.bundle.js" },
32411
+ capturedInputs: inputs,
32412
+ inputDirectories: [PRIVATE_AUTHOR_EVALUATOR_DIRECTORY],
32413
+ readOnlyCwd: PRIVATE_AUTHOR_EVALUATOR_DIRECTORY,
32414
+ relocatedEnvironment: {
32415
+ JIG_EVALUATOR_SDK: `${PRIVATE_AUTHOR_EVALUATOR_DIRECTORY}/project-evaluator-sdk.bundle.js`
32416
+ },
32311
32417
  maxOutputBytes: MAX_STDOUT_BYTES + MAX_STDERR_BYTES,
32312
- storageBytes: 0
32418
+ storageBytes: 16 * 1024 * 1024
32313
32419
  };
32314
32420
  }
32315
32421
  function exactKeys(value, expected) {
32316
32422
  const keys = Object.keys(value).sort();
32317
32423
  return keys.length === expected.length && keys.every((key, index) => key === expected[index]);
32318
32424
  }
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
32425
  function evaluatorLimits(policy) {
32326
32426
  return Object.freeze({
32327
32427
  memoryBytes: policy.memoryBytes,
@@ -32901,14 +33001,21 @@ async function retainOpenedPackageProject(options, signal) {
32901
33001
  ]);
32902
33002
  closure = capturedClosure;
32903
33003
  assertBootstrapPreserved(bootstrapClosure, capturedClosure);
32904
- const project = await privateProfileSpan("author-configuration-evaluation", () => evaluateAuthorClosure(options.evaluator, capturedClosure, entry, "project", signal));
33004
+ const evaluations = await privateProfileSpan("author-configuration-evaluation", () => evaluateAuthorClosureBatch(options.evaluator, capturedClosure, [
33005
+ { entryProjectPath: entry, expected: "project" },
33006
+ ...bindingSource.members.map(({ projectPath }) => ({
33007
+ entryProjectPath: projectPath,
33008
+ expected: "binding"
33009
+ }))
33010
+ ], signal));
33011
+ const project = evaluations[0];
32905
33012
  if (project.outputDigest !== bootstrapProject.outputDigest) {
32906
33013
  invalid("PROJECT_SOURCE_CHANGED", "project definition changed while its complete declaration closure was captured", entry);
32907
33014
  }
32908
33015
  const grantSource = await captureGrantSource(root, project.value.grants);
32909
33016
  const bindings = [];
32910
- for (const member2 of bindingSource.members) {
32911
- const evaluation = await privateProfileSpan("author-configuration-evaluation", () => evaluateAuthorClosure(options.evaluator, capturedClosure, member2.projectPath, "binding", signal));
33017
+ for (const [index, member2] of bindingSource.members.entries()) {
33018
+ const evaluation = evaluations[index + 1];
32912
33019
  let attachments;
32913
33020
  try {
32914
33021
  if (evaluation.value.attachments !== undefined)
@@ -33585,22 +33692,28 @@ function assertPrivateBunExecutionLayoutFiles(layout, files) {
33585
33692
  assertPrivatePackageAliasFiles(layout.aliases, files);
33586
33693
  }
33587
33694
  function normalizePrivateBunExecutionArtifact(value) {
33588
- const record3 = exact5(value, ["package", "layout"], ["preparationInputDigest"]);
33589
- if (Object.hasOwn(record3, "preparationInputDigest") && (typeof record3.preparationInputDigest !== "string" || !/^sha256:[0-9a-f]{64}$/.test(record3.preparationInputDigest)))
33590
- invalid3();
33695
+ const record3 = exact5(value, ["package", "layout"], ["preparation"]);
33696
+ let preparation;
33697
+ if (Object.hasOwn(record3, "preparation")) {
33698
+ const evidence = exact5(record3.preparation, ["inputDigest", "package"]);
33699
+ if (typeof evidence.inputDigest !== "string" || !/^sha256:[0-9a-f]{64}$/.test(evidence.inputDigest))
33700
+ invalid3();
33701
+ preparation = Object.freeze({
33702
+ inputDigest: evidence.inputDigest,
33703
+ package: normalizePackageArtifactRef(exact5(evidence.package, ["kind", "digest"]))
33704
+ });
33705
+ }
33591
33706
  return Object.freeze({
33592
33707
  package: normalizePackageArtifactRef(exact5(record3.package, ["kind", "digest"])),
33593
33708
  layout: normalizePrivateBunExecutionLayout(record3.layout),
33594
- ...record3.preparationInputDigest === undefined ? {} : {
33595
- preparationInputDigest: record3.preparationInputDigest
33596
- }
33709
+ ...preparation === undefined ? {} : { preparation }
33597
33710
  });
33598
33711
  }
33599
- function privateBunExecutionArtifact(artifact, layout = EMPTY_PRIVATE_BUN_EXECUTION_LAYOUT, preparationInputDigest) {
33712
+ function privateBunExecutionArtifact(artifact, layout = EMPTY_PRIVATE_BUN_EXECUTION_LAYOUT, preparation) {
33600
33713
  return normalizePrivateBunExecutionArtifact({
33601
33714
  package: artifact,
33602
33715
  layout,
33603
- ...preparationInputDigest === undefined ? {} : { preparationInputDigest }
33716
+ ...preparation === undefined ? {} : { preparation }
33604
33717
  });
33605
33718
  }
33606
33719
  function privateBunExecutionMaterialization(execution) {
@@ -34615,8 +34728,7 @@ import { join as join18 } from "path";
34615
34728
  // src/internal/native-agent-executable.ts
34616
34729
  import { constants as constants22 } from "fs";
34617
34730
  import { access as access4, lstat as lstat11, readlink as readlink2, realpath as realpath11 } from "fs/promises";
34618
- import { delimiter, dirname as dirname9, isAbsolute as isAbsolute3, join as join16, relative as relative2, resolve as resolve7, sep } from "path";
34619
-
34731
+ import { basename, delimiter, dirname as dirname9, isAbsolute as isAbsolute3, join as join16, relative as relative2, resolve as resolve7, sep } from "path";
34620
34732
  class PrivateNativeAgentExecutableUnavailableError extends Error {
34621
34733
  client;
34622
34734
  constructor(client) {
@@ -34651,7 +34763,9 @@ async function resolvePrivateNativeAgentExecutable(client, environment, projectD
34651
34763
  throw error;
34652
34764
  }
34653
34765
  }
34654
- } catch {
34766
+ } catch (error) {
34767
+ if (error instanceof PrivateAcpSetupError)
34768
+ throw error;
34655
34769
  throw new PrivateNativeAgentExecutableUnavailableError(client);
34656
34770
  }
34657
34771
  throw new PrivateNativeAgentExecutableUnavailableError(client);
@@ -34707,6 +34821,8 @@ async function outsideProject(candidate, forbidden) {
34707
34821
  }
34708
34822
  async function executable(candidate) {
34709
34823
  const path2 = await realpath11(candidate);
34824
+ if (basename(path2) === "volta-shim")
34825
+ throw new PrivateAcpSetupError("wrapper");
34710
34826
  const information = await lstat11(path2);
34711
34827
  if (!information.isFile() || (information.mode & 73) === 0) {
34712
34828
  throw Object.assign(new Error("not an executable file"), { code: "EACCES" });
@@ -35399,7 +35515,7 @@ async function ordinaryFile(path2, label) {
35399
35515
  // src/internal/codex-agent-provider.ts
35400
35516
  import { lstat as lstat15, readFile as readFile4, realpath as realpath15 } from "fs/promises";
35401
35517
  import { homedir as homedir2 } from "os";
35402
- import { basename, dirname as dirname12, join as join19 } from "path";
35518
+ import { basename as basename2, dirname as dirname12, join as join19 } from "path";
35403
35519
  var CODEX_CLIENT = "openai-codex";
35404
35520
  var SANDBOX_LAUNCHER_PATH2 = "/agent/codex-agent-launcher.js";
35405
35521
  var SANDBOX_ADAPTER_PATH2 = "/agent/codex-acp.js";
@@ -35446,7 +35562,9 @@ async function openPrivateCodexAgentProvider(releaseRoot, environment = process.
35446
35562
  let executablePath;
35447
35563
  try {
35448
35564
  executablePath = await resolvePrivateNativeAgentExecutable("codex", environment, projectDirectory);
35449
- } catch {
35565
+ } catch (error) {
35566
+ if (error instanceof PrivateAcpSetupError)
35567
+ throw error;
35450
35568
  throw new PrivateCodexExecutableUnavailableError("the native Codex executable is unavailable");
35451
35569
  }
35452
35570
  let runtime;
@@ -35712,7 +35830,7 @@ async function nativeBubblewrapFor(executablePath, environment, projectDirectory
35712
35830
  const executableDirectory = dirname12(executablePath);
35713
35831
  const adjacent = join19(executableDirectory, "codex-resources", "bwrap");
35714
35832
  const packageResource = join19(executableDirectory, "..", "codex-resources", "bwrap");
35715
- const candidates = basename(executableDirectory) === "bin" ? [packageResource, adjacent] : [adjacent, packageResource];
35833
+ const candidates = basename2(executableDirectory) === "bin" ? [packageResource, adjacent] : [adjacent, packageResource];
35716
35834
  try {
35717
35835
  for (const candidate of candidates) {
35718
35836
  let path2;
@@ -37890,12 +38008,10 @@ async function capturePrivateActivationPlanningBase(input) {
37890
38008
  function readPrivateAdmittedExecutionReuse(input) {
37891
38009
  const base = requirePrivateActivationPlanningBase(input.planningBase);
37892
38010
  const request = requirePrivateActivationRequest(input.request);
37893
- const target = base.admittedCandidate?.candidate.targets.find((candidate) => candidate.request.digest === request.digest);
38011
+ const target = base.admittedCandidate?.candidate.targets.find((candidate) => privateActivationTargetKey(candidate.request.target) === privateActivationTargetKey(request.target) && candidate.request.packagePath === request.packagePath);
37894
38012
  if (target?.disposition.state !== "ready")
37895
38013
  return;
37896
38014
  return Object.freeze({
37897
- recipeDigest: target.disposition.recipeDigest,
37898
- observationDigest: target.disposition.observationDigest,
37899
38015
  execution: target.disposition.execution
37900
38016
  });
37901
38017
  }
@@ -40880,7 +40996,10 @@ async function reacquireCandidateArtifacts(packageStoreRoot, candidate) {
40880
40996
  candidate.candidate.declarationArtifact.package.digest,
40881
40997
  ...Object.values(candidate.lock.packages).map((entry) => entry.digest),
40882
40998
  ...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" ? [target.disposition.execution.package.digest] : [])
40999
+ ...candidate.candidate.targets.flatMap((target) => target.disposition.state === "ready" ? [
41000
+ target.disposition.execution.package.digest,
41001
+ ...target.disposition.execution.preparation === undefined ? [] : [target.disposition.execution.preparation.package.digest]
41002
+ ] : [])
40884
41003
  ]);
40885
41004
  for (const digest6 of [...digests].sort()) {
40886
41005
  const reference = normalizePackageArtifactRef({ kind: "flow-package/0", digest: digest6 });
@@ -41169,7 +41288,7 @@ function hasCode3(error, code2) {
41169
41288
  import { randomBytes as randomBytes6 } from "crypto";
41170
41289
  import { constants as constants24 } from "fs";
41171
41290
  import { lstat as lstat17, open as open14, realpath as realpath18 } from "fs/promises";
41172
- import { basename as basename2, dirname as dirname14, resolve as resolve9 } from "path";
41291
+ import { basename as basename3, dirname as dirname14, resolve as resolve9 } from "path";
41173
41292
  init_file_input();
41174
41293
  async function installedDescriptor(selector, destination) {
41175
41294
  let name;
@@ -41204,7 +41323,7 @@ async function importContract(source, destination, signal) {
41204
41323
  try {
41205
41324
  signal?.throwIfAborted();
41206
41325
  const selected = source.startsWith("npm:") ? await installedDescriptor(source, destination) : source;
41207
- const name = basename2(selected);
41326
+ const name = basename3(selected);
41208
41327
  root = await open14(await realpath18(dirname14(resolve9(selected))), constants24.O_RDONLY | constants24.O_DIRECTORY | constants24.O_NOFOLLOW);
41209
41328
  const capture = (paths3) => captureOpenedPackageDirectory(selected, root, {
41210
41329
  includes: (path2) => paths3.some((p) => p === path2 || p.startsWith(`${path2}/`)),
@@ -41228,7 +41347,7 @@ async function importContract(source, destination, signal) {
41228
41347
  signal?.throwIfAborted();
41229
41348
  phase = "destination";
41230
41349
  const target = resolve9(destination);
41231
- const leaf = privateFilePath(basename2(target));
41350
+ const leaf = privateFilePath(basename3(target));
41232
41351
  parent = await open14(await realpath18(dirname14(target)), constants24.O_RDONLY | constants24.O_DIRECTORY | constants24.O_NOFOLLOW);
41233
41352
  const allocation = privateChildLocation(parent, `.jig-contract-${randomBytes6(16).toString("hex")}`);
41234
41353
  await mkdirPrivateFile(allocation);
@@ -41363,6 +41482,9 @@ class PrivateRunDiagnostics {
41363
41482
 
41364
41483
  // src/project/evaluator-diagnostics.ts
41365
41484
  var EVALUATOR_HINTS = Object.freeze({
41485
+ 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.",
41486
+ 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.",
41487
+ 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
41488
  PROJECT_EVALUATOR_SUPPORT: "Jig could not verify its configuration evaluator files. Restore the complete Jig installation and retry review. No Flow was started.",
41367
41489
  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
41490
  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.",
@@ -41385,7 +41507,7 @@ import {
41385
41507
  unlink as unlink3,
41386
41508
  writeFile as writeFile2
41387
41509
  } from "fs/promises";
41388
- import { basename as basename3, join as join22, resolve as resolve10 } from "path";
41510
+ import { basename as basename4, join as join22, resolve as resolve10 } from "path";
41389
41511
  init_file_input();
41390
41512
  var DEFAULT_FILE_SYSTEM = {
41391
41513
  mkdir: mkdir6,
@@ -41394,7 +41516,7 @@ var DEFAULT_FILE_SYSTEM = {
41394
41516
  writeFile: writeFile2
41395
41517
  };
41396
41518
  var GREETING_SDK_VERSION = "0.1.0-alpha.13";
41397
- var AGENT_ACP_VERSION = "0.1.0-alpha.6";
41519
+ var AGENT_ACP_VERSION = "0.1.0-alpha.7";
41398
41520
 
41399
41521
  class ProjectInitError extends Error {
41400
41522
  code;
@@ -41470,14 +41592,14 @@ async function createFlow(project, name, uses = [], signal) {
41470
41592
  throw new ProjectInitError("invalid", "JIG_NEW_EXISTS", "That Flow directory already exists. Choose a different name; existing files were not changed.");
41471
41593
  throw error;
41472
41594
  }
41473
- const projectName = basename3(resolve10(project)).toLowerCase().replace(/[^a-z0-9-]/g, "-").slice(0, 64);
41595
+ const projectName = basename4(resolve10(project)).toLowerCase().replace(/[^a-z0-9-]/g, "-").slice(0, 64);
41474
41596
  const authoredAt = staged ?? destination;
41475
41597
  const declarations = Object.create(null);
41476
41598
  if (uses.length > 0)
41477
41599
  await mkdir6(join22(authoredAt, "contracts"));
41478
41600
  for (const { slot, source } of uses) {
41479
41601
  const imported = await importContract(source.startsWith("npm:") ? source : resolve10(project, source), join22(authoredAt, "contracts", slot), signal);
41480
- declarations[slot] = { contract: `./contracts/${slot}/${basename3(imported.descriptor)}` };
41602
+ declarations[slot] = { contract: `./contracts/${slot}/${basename4(imported.descriptor)}` };
41481
41603
  }
41482
41604
  const files = {
41483
41605
  "FLOW.meta.json": `${JSON.stringify({ name, description: "Describe what this method does.", ...uses.length === 0 ? {} : { uses: declarations } }, null, 2)}
@@ -41504,7 +41626,7 @@ await handle(async (run) => {
41504
41626
  const flowsDirectory = await openPrivateChild(projectDirectory, "flows", constants25.O_RDONLY | constants25.O_DIRECTORY | constants25.O_NOFOLLOW);
41505
41627
  try {
41506
41628
  signal?.throwIfAborted();
41507
- privatePublishDirectory(flowsDirectory.fd, basename3(staged), name, projectDirectory.fd);
41629
+ privatePublishDirectory(flowsDirectory.fd, basename4(staged), name, projectDirectory.fd);
41508
41630
  staged = undefined;
41509
41631
  } finally {
41510
41632
  await flowsDirectory.close();
@@ -42087,7 +42209,7 @@ async function executeImportContract(arguments_, runtime) {
42087
42209
  try {
42088
42210
  const result2 = await importContract(arguments_[1].startsWith("npm:") ? arguments_[1] : resolve11(runtime.currentDirectory, arguments_[1]), resolve11(runtime.currentDirectory, arguments_[2]), runtime.signal);
42089
42211
  runtime.writeOutput(`Imported ${result2.files} contract files into ${asciiJsonString(arguments_[2])}.
42090
- Use ${asciiJsonString(basename4(result2.descriptor))} in the caller's slot declaration, then review the project.
42212
+ Use ${asciiJsonString(basename5(result2.descriptor))} in the caller's slot declaration, then review the project.
42091
42213
  `);
42092
42214
  return 0;
42093
42215
  } catch (error) {
@@ -42243,7 +42365,7 @@ function shellWord(value) {
42243
42365
  async function executeReview(arguments_, runtime) {
42244
42366
  let resolutionNoticeShown = false;
42245
42367
  const parsed = parseReview(arguments_, runtime.currentDirectory);
42246
- runtime.progress.note(`Reviewing ${asciiJsonString(basename4(resolve11(runtime.currentDirectory, parsed.project)))}`);
42368
+ runtime.progress.note(`Reviewing ${asciiJsonString(basename5(resolve11(runtime.currentDirectory, parsed.project)))}`);
42247
42369
  const result2 = await withProjectSession(parsed.project, runtime, async (session) => {
42248
42370
  const plan = await privateProfileSpan("project-planning", () => session.plan({ lockMode: "update" }));
42249
42371
  runtime.progress.complete(true);
@@ -42800,6 +42922,7 @@ function renderFailure(error, runtime) {
42800
42922
  PROJECT_BINDING_ATTACHMENTS_INVALID: "check the Binding attachment directories: use stable project-relative regular-file trees without links, protected state or nested mounts, within the file limits",
42801
42923
  PROJECT_BINDING_ATTACHMENT_UNDECLARED: "select only attachment names declared read-only in the Flow contract",
42802
42924
  PROJECT_BINDING_ATTACHMENTS_NOT_CAPTURED: "the selected Binding files could not be retained consistently; review stable source directories again",
42925
+ PROJECT_CHECKPOINT_ATTACHMENT: "declare a read-write attachment in FLOW.contract.json for the root Flow that uses Run Checkpoint",
42803
42926
  PROJECT_BINDING_PACKAGE_MISSING: "the Binding references a Flow not selected by jig.ts; correct the path or project membership",
42804
42927
  PROJECT_ENTRYPOINT_INVALID: "Fix entrypoint in jig.ts: use an invokable Flow or Binding followed by valid jig run invocation arguments, project-relative paths, and declared unbound attachments or outgoing channels. Operator flags such as --verification are not project defaults.",
42805
42928
  PROJECT_DEFAULT_MISSING: "defaultProviders in jig.ts names a missing Flow or Binding; create the selected local Binding and include its Flow in discovery, or correct the selector. Provider selection does not create Bindings",
@@ -42819,7 +42942,7 @@ function renderFailure(error, runtime) {
42819
42942
  PROJECT_MEMBER_MISSING: "a selected project member is missing; restore it or update the membership in jig.ts",
42820
42943
  PROJECT_MEMBER_COLLISION: "project members have colliding paths or names; give each selected member a distinct identity",
42821
42944
  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 its resource or time limit; keep authoring modules small and inert. If they already are, check host load before retrying review. No Flow was started",
42945
+ 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
42946
  PROJECT_DECLARATION_INVALID: "export a valid defineJig or defineBinding declaration from the indicated module",
42824
42947
  CHANNEL_FIELD: "check channel declarations and descriptors against FLOW Channel Contract/0",
42825
42948
  CHANNEL_LIMIT: "check channel declaration counts and descriptor bounds",
@@ -42947,7 +43070,7 @@ Inspect any effects before starting new work. See https://jig.md/guide/results.`
42947
43070
  UNAVAILABLE: "Required execution support was unavailable.",
42948
43071
  PERMISSION_DENIED: "The requested action was outside the approved permissions.",
42949
43072
  RESOURCE_EXHAUSTED: "Execution reached a resource limit.",
42950
- INVALID_RESULT: "The Flow returned a result that does not match its declared contract.",
43073
+ INVALID_RESULT: "A Flow or one of its operations rejected a returned result.",
42951
43074
  UNCERTAIN: "The operation may have produced effects; do not blindly repeat the Run.",
42952
43075
  EXECUTION_FAILED: "The Flow could not complete execution.",
42953
43076
  CHANNEL_LOST: "A required connection was lost.",
@@ -43067,7 +43190,7 @@ import { dirname as dirname16, join as join24 } from "path";
43067
43190
  import { randomBytes as randomBytes8 } from "crypto";
43068
43191
  import { closeSync as closeSync13, constants as constants27, fstatSync as fstatSync11 } from "fs";
43069
43192
  import { statfs as statfs3 } from "fs/promises";
43070
- import { basename as basename5, dirname as dirname15, resolve as resolve12 } from "path";
43193
+ import { basename as basename6, dirname as dirname15, resolve as resolve12 } from "path";
43071
43194
 
43072
43195
  // src/internal/file-delivery-storage.ts
43073
43196
  import { constants as constants26 } from "fs";
@@ -43166,7 +43289,7 @@ class PrivateFileDeliveryOwner {
43166
43289
  let parent;
43167
43290
  try {
43168
43291
  this.signal.throwIfAborted();
43169
- const destination = resolve12(directory), parentPath = dirname15(destination), leaf = privateFilePath(basename5(destination));
43292
+ const destination = resolve12(directory), parentPath = dirname15(destination), leaf = privateFilePath(basename6(destination));
43170
43293
  if (destination === parentPath || leaf.includes("/"))
43171
43294
  throw new TypeError("output requires a new directory");
43172
43295
  const selected = privateOpenFileRoot(parentPath);
@@ -45446,6 +45569,120 @@ function limit(code2, message2, path2) {
45446
45569
  return new CheckError("invalid", code2, message2, path2);
45447
45570
  }
45448
45571
 
45572
+ // src/internal/bun-preparation-evidence.ts
45573
+ import { createHash as createHash14 } from "crypto";
45574
+
45575
+ // src/internal/bun-native-inputs.ts
45576
+ async function privateBunNativeInputs(input) {
45577
+ const manifests = [
45578
+ "package.json",
45579
+ ...input.members?.map((path2) => `${path2}/package.json`) ?? []
45580
+ ];
45581
+ const paths2 = new Set(manifests);
45582
+ if (input.paths.includes("bun.lock"))
45583
+ paths2.add("bun.lock");
45584
+ let patches = {};
45585
+ for (const path2 of manifests) {
45586
+ const bytes = await input.read(path2);
45587
+ if (bytes.byteLength > 1024 * 1024)
45588
+ throw new TypeError("oversized native manifest");
45589
+ const manifest = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
45590
+ requirePrivateBunResolutionManifest(manifest, input.members === undefined ? undefined : path2 === "package.json" ? "root" : "member");
45591
+ if (path2 === "package.json")
45592
+ patches = requirePrivateBunPatches(manifest.patchedDependencies);
45593
+ }
45594
+ for (const path2 of Object.values(patches)) {
45595
+ if ((await input.read(path2)).byteLength > 1024 * 1024)
45596
+ throw new TypeError("oversized captured patch");
45597
+ paths2.add(path2);
45598
+ }
45599
+ return Object.freeze({ paths: paths2, patches });
45600
+ }
45601
+
45602
+ // src/internal/bun-preparation-evidence.ts
45603
+ async function privateBunPreparationInputs(input) {
45604
+ const { captured, workspace } = input;
45605
+ if (captured.files.length > PRIVATE_BUN_PREPARATION_LIMITS.sourceFiles || captured.files.reduce((sum, file) => sum + file.size, 0) > PRIVATE_BUN_PREPARATION_LIMITS.sourceBytes)
45606
+ throw failure("PACKAGE_BUN_INPUT_LIMIT", "Bun preparation source exceeds its bounded input limits");
45607
+ let paths2;
45608
+ try {
45609
+ paths2 = (await privateBunNativeInputs({
45610
+ paths: captured.files.map(({ path: path2 }) => path2),
45611
+ ...workspace === undefined ? {} : { members: workspace.members },
45612
+ read: (path2) => captured.read(path2, 1024 * 1024)
45613
+ })).paths;
45614
+ } catch {
45615
+ throw failure("PACKAGE_BUN_SOURCE_UNSUPPORTED", "native manifests or declared patch inputs are unsupported or incomplete");
45616
+ }
45617
+ const nativeFiles = [];
45618
+ for (const path2 of [...paths2].sort(comparePathBytes)) {
45619
+ const hash = createHash14("sha256");
45620
+ for await (const bytes of captured.stream(path2))
45621
+ hash.update(bytes);
45622
+ nativeFiles.push({ path: path2, digest: `sha256:${hash.digest("hex")}` });
45623
+ }
45624
+ 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));
45625
+ if (workspace !== undefined) {
45626
+ for (const member2 of workspace.members)
45627
+ if (!workspace.selected.includes(member2))
45628
+ sourcePaths.delete(`${member2}/package.json`);
45629
+ }
45630
+ return Object.freeze({
45631
+ digest: privateDomainDigest("JIG-Bun-Preparation-Inputs/1", {
45632
+ supportDigest: input.supportDigest,
45633
+ workspace: workspace === undefined ? null : {
45634
+ target: workspace.target,
45635
+ members: [...workspace.members],
45636
+ selected: [...workspace.selected]
45637
+ },
45638
+ nativeFiles
45639
+ }),
45640
+ sourcePaths
45641
+ });
45642
+ }
45643
+ async function capturePrivateBunDependencies(prepared, sourcePaths) {
45644
+ const files = prepared.files.filter(({ path: path2 }) => !sourcePaths.has(path2));
45645
+ requireDependencyFiles(files);
45646
+ return captureView("retained Bun dependencies", files, () => prepared);
45647
+ }
45648
+ async function assemblePrivateBunExecution(input) {
45649
+ requireDependencyFiles(input.dependencies.files);
45650
+ const source = input.source.files.filter(({ path: path2 }) => input.sourcePaths.has(path2));
45651
+ const sourcePaths = new Set(source.map(({ path: path2 }) => path2));
45652
+ const files = [...source, ...input.dependencies.files].sort((a, b) => comparePathBytes(a.path, b.path));
45653
+ try {
45654
+ assertNoPathCollisions(files.map(({ path: path2 }) => path2));
45655
+ const regularPaths = new Set(files.map(({ path: path2 }) => path2));
45656
+ for (const file of files) {
45657
+ const parts = file.path.split("/");
45658
+ for (let length = 1;length < parts.length; length++)
45659
+ if (regularPaths.has(parts.slice(0, length).join("/")))
45660
+ throw new TypeError("file parent collision");
45661
+ }
45662
+ assertPrivateBunExecutionLayoutFiles(input.layout, files);
45663
+ } catch {
45664
+ throw failure("PACKAGE_BUN_SOURCE_UNSUPPORTED", "fresh source conflicts with the retained dependency layout");
45665
+ }
45666
+ 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)
45667
+ throw failure("PACKAGE_BUN_OUTPUT_LIMIT", "assembled Bun execution exceeds its bounded output limits");
45668
+ return captureView("fresh Bun execution image", files, (path2) => sourcePaths.has(path2) ? input.source : input.dependencies);
45669
+ }
45670
+ function requireDependencyFiles(files) {
45671
+ if (files.some(({ path: path2 }) => path2 !== "bun.lock" && !path2.split("/").includes("node_modules")))
45672
+ throw failure("PACKAGE_BUN_PROTOCOL", "retained Bun dependency evidence contains authored source");
45673
+ }
45674
+ async function captureView(label, files, owner) {
45675
+ const frozenFiles = Object.freeze([...files]);
45676
+ const backing2 = {
45677
+ stream: (path2) => owner(path2).stream(path2),
45678
+ async dispose() {}
45679
+ };
45680
+ return createCapturedPackage(label, frozenFiles, await packageDigest(frozenFiles, (file) => backing2.stream(file.path)), backing2);
45681
+ }
45682
+ function failure(code2, message2) {
45683
+ return new CheckError("invalid", code2, message2);
45684
+ }
45685
+
45449
45686
  // src/internal/bun-workspace-capture.ts
45450
45687
  import { constants as constants29 } from "fs";
45451
45688
  import { dirname as dirname17, relative as relative3, resolve as resolve13 } from "path";
@@ -45848,7 +46085,7 @@ function fail(code2, message2) {
45848
46085
  }
45849
46086
 
45850
46087
  // src/internal/contract-generation.ts
45851
- import { createHash as createHash14, randomUUID as randomUUID4 } from "crypto";
46088
+ import { createHash as createHash15, randomUUID as randomUUID4 } from "crypto";
45852
46089
  import { constants as constants30 } from "fs";
45853
46090
 
45854
46091
  // ../agent-method/dist/errors.js
@@ -46222,7 +46459,7 @@ async function generateContract(source, signal, workerPath) {
46222
46459
  var SOURCE = "FLOW.contract.tsp";
46223
46460
  var DESCRIPTOR = "FLOW.contract.json";
46224
46461
  var MAX_RECORD = 4 * 1024 * 1024;
46225
- var hash = (s) => createHash14("sha256").update(s).digest("hex");
46462
+ var hash = (s) => createHash15("sha256").update(s).digest("hex");
46226
46463
  var conflict = (name) => invalid("AUTHORING_CONFLICT", "Generated files or source changed. Preserve edits and resolve ownership before generation.", name);
46227
46464
  function inputNames(inputs) {
46228
46465
  if (!inputs || typeof inputs !== "object" || Array.isArray(inputs) || Object.keys(inputs).length > 256)
@@ -46798,9 +47035,9 @@ function executionChangeExplanation(before, after) {
46798
47035
  reasons.push("The execution request changed; see the package, settings and permission changes in this review.");
46799
47036
  if (!samePolicy(before.disposition.execution?.package, after.disposition.execution?.package) || !samePolicy(before.disposition.execution?.layout, after.disposition.execution?.layout))
46800
47037
  reasons.push("Prepared execution files or dependency layout changed.");
46801
- else if (before.disposition.execution?.preparationInputDigest !== after.disposition.execution?.preparationInputDigest)
46802
- reasons.push(before.disposition.execution?.preparationInputDigest === undefined ? `This review records captured workspace inputs for future preparation reuse.
46803
- Prepared files and dependency layout are unchanged.` : `Workspace preparation inputs changed.
47038
+ else if (!samePolicy(before.disposition.execution?.preparation, after.disposition.execution?.preparation))
47039
+ reasons.push(before.disposition.execution?.preparation === undefined ? `This review records dependency inputs and installed bytes for future preparation reuse.
47040
+ Prepared files and dependency layout are unchanged.` : `Dependency preparation evidence changed.
46804
47041
  Prepared files and dependency layout are unchanged.`);
46805
47042
  if (reasons.length === 0) {
46806
47043
  reasons.push("Execution environment changed: Jig installation, Agent configuration, or sandbox support.");
@@ -47467,7 +47704,7 @@ import { lstat as lstat24, mkdir as mkdir11, realpath as realpath24 } from "fs/p
47467
47704
  import { join as join30 } from "path";
47468
47705
 
47469
47706
  // src/run/session.ts
47470
- import { createHash as createHash15 } from "crypto";
47707
+ import { createHash as createHash16 } from "crypto";
47471
47708
  var ROOT_ID = "host:1";
47472
47709
  var MAX_PENDING_COMPONENT_REQUESTS = 64;
47473
47710
  var MAX_COMPONENT_REQUEST_IDS = 65536;
@@ -47902,16 +48139,16 @@ class RunHostSession {
47902
48139
  this.failProtocol("component returned its root error before owned requests settled");
47903
48140
  return;
47904
48141
  }
47905
- let failure;
48142
+ let failure2;
47906
48143
  try {
47907
- failure = parseRootFailure(response.error);
48144
+ failure2 = parseRootFailure(response.error);
47908
48145
  } catch (error) {
47909
48146
  this.failProtocol(`invalid root error: ${errorText10(error)}`);
47910
48147
  return;
47911
48148
  }
47912
48149
  this.rootOpen = false;
47913
48150
  this.dispatcher?.channels?.finalize(false);
47914
- this.rootResponse = failure;
48151
+ this.rootResponse = failure2;
47915
48152
  this.closeProtocolInput();
47916
48153
  }
47917
48154
  queueResponse(id, value) {
@@ -48125,7 +48362,7 @@ class RunHostSession {
48125
48362
  }
48126
48363
  finish(exit) {
48127
48364
  const diagnostics = this.diagnostics();
48128
- const failure = (code2, message2, details) => ({
48365
+ const failure2 = (code2, message2, details) => ({
48129
48366
  status: "failed",
48130
48367
  code: code2,
48131
48368
  message: message2,
@@ -48133,40 +48370,43 @@ class RunHostSession {
48133
48370
  diagnostics
48134
48371
  });
48135
48372
  if (this.protocolFailure !== undefined) {
48136
- return failure("PROTOCOL_ERROR", this.protocolFailure);
48373
+ return failure2("PROTOCOL_ERROR", this.protocolFailure);
48374
+ }
48375
+ if (exit?.stopReason === "core_dump" && exit.fenced && exit.cleanupError === undefined && this.localTerminal === undefined) {
48376
+ return failure2("EXECUTION_FAILED", "owned execution crashed and was fenced during core dumping");
48137
48377
  }
48138
48378
  if (this.channelFailure !== undefined) {
48139
48379
  if (this.rootResponse === undefined && exit?.stopReason === "deadline") {
48140
- return failure("DEADLINE_EXCEEDED", "root Run hard deadline elapsed before a terminal response");
48380
+ return failure2("DEADLINE_EXCEEDED", "root Run hard deadline elapsed before a terminal response");
48141
48381
  }
48142
- return failure("CHANNEL_LOST", this.channelFailure);
48382
+ return failure2("CHANNEL_LOST", this.channelFailure);
48143
48383
  }
48144
48384
  if (exit === undefined) {
48145
- return failure("CHANNEL_LOST", "component completion was unavailable");
48385
+ return failure2("CHANNEL_LOST", "component completion was unavailable");
48146
48386
  }
48147
48387
  if (exit?.cleanupError !== undefined || exit?.fenced !== true) {
48148
- return failure("EXECUTION_FAILED", "component cleanup or fencing failed");
48388
+ return failure2("EXECUTION_FAILED", "component cleanup or fencing failed");
48149
48389
  }
48150
48390
  if (this.localTerminal !== undefined) {
48151
- return failure(this.localTerminal.code, this.localTerminal.message);
48391
+ return failure2(this.localTerminal.code, this.localTerminal.message);
48152
48392
  }
48153
48393
  if (this.postResponseTermination) {
48154
- return failure("EXECUTION_FAILED", "component did not quiesce after its terminal response");
48394
+ return failure2("EXECUTION_FAILED", "component did not quiesce after its terminal response");
48155
48395
  }
48156
48396
  if (exit.exitCode !== 0 || exit.signal !== null) {
48157
- return failure("EXECUTION_FAILED", `component exited with code ${String(exit.exitCode)} and signal ${String(exit.signal)}`);
48397
+ return failure2("EXECUTION_FAILED", `component exited with code ${String(exit.exitCode)} and signal ${String(exit.signal)}`);
48158
48398
  }
48159
48399
  if (this.rootResponse === undefined) {
48160
48400
  if (exit.stopReason === "deadline") {
48161
- return failure("DEADLINE_EXCEEDED", "root Run hard deadline elapsed before a terminal response");
48401
+ return failure2("DEADLINE_EXCEEDED", "root Run hard deadline elapsed before a terminal response");
48162
48402
  }
48163
- return failure("CHANNEL_LOST", "component exited before a root response");
48403
+ return failure2("CHANNEL_LOST", "component exited before a root response");
48164
48404
  }
48165
48405
  if (this.pendingResponses !== 0 || this.operationWaiters.size !== 0 || this.channelRequests.size !== 0) {
48166
- return failure("EXECUTION_FAILED", "component exited with pending owned protocol work");
48406
+ return failure2("EXECUTION_FAILED", "component exited with pending owned protocol work");
48167
48407
  }
48168
48408
  if (this.rootResponse.kind === "failure") {
48169
- return failure(this.rootResponse.code, this.rootResponse.message, this.rootResponse.details);
48409
+ return failure2(this.rootResponse.code, this.rootResponse.message, this.rootResponse.details);
48170
48410
  }
48171
48411
  return { status: "succeeded", result: this.rootResponse.result, diagnostics };
48172
48412
  }
@@ -48390,7 +48630,7 @@ function operationSignature(params) {
48390
48630
  if (key !== "operationId")
48391
48631
  semantic[key] = value;
48392
48632
  }
48393
- return createHash15("sha256").update(Buffer.from("FLOW-Call/0\x00", "ascii")).update(canonicalJson(semantic)).digest("hex");
48633
+ return createHash16("sha256").update(Buffer.from("FLOW-Call/0\x00", "ascii")).update(canonicalJson(semantic)).digest("hex");
48394
48634
  }
48395
48635
  function errorMessage(id, code2, message2) {
48396
48636
  return { jsonrpc: "2.0", id, error: { code: code2, message: message2 } };
@@ -48569,7 +48809,7 @@ async function materializePrivatePackageLease(captured, value) {
48569
48809
  let packageDirectory;
48570
48810
  let transactionInformation;
48571
48811
  let created = false;
48572
- let failure;
48812
+ let failure2;
48573
48813
  try {
48574
48814
  await mkdirPrivateFile(privateChildLocation(parent.handle, allocation.name));
48575
48815
  created = true;
@@ -48629,9 +48869,9 @@ async function materializePrivatePackageLease(captured, value) {
48629
48869
  await requireChildIdentity(transaction, PACKAGE_NAME, packageInformation);
48630
48870
  return leaseFromObserved(allocation, transactionInformation, packageInformation);
48631
48871
  } catch (error) {
48632
- failure = error;
48872
+ failure2 = error;
48633
48873
  } finally {
48634
- if (failure !== undefined && created) {
48874
+ if (failure2 !== undefined && created) {
48635
48875
  try {
48636
48876
  if (transaction === undefined) {
48637
48877
  const opened = await openOwnedDirectory(parent.handle, allocation.name, parent.information, [0o700n, 0o711n]);
@@ -48644,7 +48884,7 @@ async function materializePrivatePackageLease(captured, value) {
48644
48884
  await removeTransaction(parent, transaction, allocation.name, transactionInformation, allocation.aliases);
48645
48885
  transaction = undefined;
48646
48886
  } catch (cleanupError) {
48647
- failure = new AggregateError([failure, cleanupError], "durable materialization and exact cleanup did not both complete");
48887
+ failure2 = new AggregateError([failure2, cleanupError], "durable materialization and exact cleanup did not both complete");
48648
48888
  }
48649
48889
  }
48650
48890
  await packageDirectory?.close().catch(() => {
@@ -48657,7 +48897,7 @@ async function materializePrivatePackageLease(captured, value) {
48657
48897
  return;
48658
48898
  });
48659
48899
  }
48660
- throw failure;
48900
+ throw failure2;
48661
48901
  }
48662
48902
  async function recoverPrivatePackageMaterializationAllocation(protectedParent, value) {
48663
48903
  const allocation = parseAllocation(value);
@@ -51530,6 +51770,7 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
51530
51770
  throw error;
51531
51771
  }
51532
51772
  let attemptedDispatch = false;
51773
+ let phase = "verifying the admitted runtime";
51533
51774
  let execution;
51534
51775
  let output;
51535
51776
  let retained;
@@ -51540,9 +51781,10 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
51540
51781
  const scopeDigest = nativeSessionScope(input, provider);
51541
51782
  let failurePhase = "preparation";
51542
51783
  try {
51543
- await revalidateProviderSupport(recipe, provider, input);
51784
+ await privateProfileSpan("finite-acp-revalidation", () => revalidateProviderSupport(recipe, provider, input));
51544
51785
  let restored;
51545
51786
  if (operation.session !== undefined && "restore" in operation.session) {
51787
+ phase = "restoring the authorized session";
51546
51788
  const snapshot2 = await claimPrivateNativeSession({
51547
51789
  coordinator: input.coordinator,
51548
51790
  projectRoot: input.projectRoot,
@@ -51565,8 +51807,9 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
51565
51807
  if (operation.session !== undefined)
51566
51808
  credentialBootstrap = runtime.startupInput?.();
51567
51809
  const secrets2 = operation.session === undefined ? [] : privateCodexSessionSecrets(runtime, credentialBootstrap);
51810
+ phase = "preparing containment";
51568
51811
  failurePhase = "sealing";
51569
- const sealed = await sealPrivateExecutionOwner(input.backend, agentExecutionIntent(recipe, provider, effectiveDeadlineUnixMs, identity3, operation.session !== undefined), ownerAllocation);
51812
+ const sealed = await privateProfileSpan("finite-acp-containment", () => sealPrivateExecutionOwner(input.backend, agentExecutionIntent(recipe, provider, effectiveDeadlineUnixMs, identity3, operation.session !== undefined), ownerAllocation));
51570
51813
  const sandbox = Object.freeze({ kind: SANDBOX_KIND, owner: sealed.identity });
51571
51814
  lifecycle = await recordPrivateRootChildSandbox({
51572
51815
  coordinator: input.coordinator,
@@ -51578,19 +51821,22 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
51578
51821
  sandbox
51579
51822
  });
51580
51823
  attemptedDispatch = true;
51824
+ phase = "starting the native client";
51581
51825
  failurePhase = "admission";
51582
- const component = await admitPrivateExecutionOwner(sealed, input.signal);
51826
+ const component = await privateProfileSpan("finite-acp-launch", () => admitPrivateExecutionOwner(sealed, input.signal));
51583
51827
  output = component.output;
51828
+ phase = "exchanging native messages";
51584
51829
  failurePhase = "protocol";
51585
- execution = await runPrivateFiniteAcpResource(component, runtime, endpoints, input.signal, operation.maxTurns, ...operation.session === undefined ? [] : [
51830
+ execution = await privateProfileSpan("finite-acp-exchange", () => runPrivateFiniteAcpResource(component, runtime, endpoints, input.signal, operation.maxTurns, ...operation.session === undefined ? [] : [
51586
51831
  {
51587
51832
  bootstrap: privateCodexSessionBootstrap(restored),
51588
51833
  ...restored === undefined ? {} : { restoreSessionId: restored.nativeId },
51589
51834
  ...credentialBootstrap === undefined ? {} : { credentialBootstrap }
51590
51835
  }
51591
- ]);
51836
+ ]));
51592
51837
  failurePhase = "settlement";
51593
51838
  if (operation.session !== undefined && !execution.closed && execution.fence.stopReason === "payload_exit" && execution.fence.exitCode === 0 && execution.fence.signal === null && !input.signal.aborted) {
51839
+ phase = "collecting authorized session state";
51594
51840
  if (output === undefined || execution.sessionId === undefined)
51595
51841
  throw new Error("Clean native retention lacks owned output or session identity");
51596
51842
  try {
@@ -51604,13 +51850,14 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
51604
51850
  throw error;
51605
51851
  }
51606
51852
  }
51607
- await releaseKnownAcp(input, lifecycle, execution.fence);
51853
+ phase = "fencing and cleanup";
51854
+ await privateProfileSpan("finite-acp-release", () => releaseKnownAcp(input, lifecycle, execution.fence));
51608
51855
  } catch (error) {
51609
51856
  reportFailure(input, failurePhase, error);
51610
51857
  try {
51611
51858
  const active = await findLifecycle(input, input.call.operationId);
51612
51859
  if (active !== undefined)
51613
- await recoverPrivateRootFiniteAcpOwner(input, active);
51860
+ await privateProfileSpan("finite-acp-recovery", () => recoverPrivateRootFiniteAcpOwner(input, active));
51614
51861
  } catch (cleanupError) {
51615
51862
  reportFailure(input, "cleanup", cleanupError);
51616
51863
  throw new RunHostFatalOperationError(isPrivateExecutionFenceUnconfirmed(cleanupError) ? "UNCERTAIN" : "EXECUTION_FAILED", {
@@ -51618,14 +51865,14 @@ async function executeOwnedProvider(input, provider, recipe, operation) {
51618
51865
  });
51619
51866
  }
51620
51867
  if (input.signal.aborted)
51621
- return failed2("CANCELLED", "the finite ACP operation was cancelled");
51868
+ return failed2("CANCELLED", `the finite ACP operation was cancelled while ${phase}`);
51622
51869
  if (Date.now() >= effectiveDeadlineUnixMs) {
51623
- return failed2("DEADLINE_EXCEEDED", "the finite ACP operation deadline elapsed");
51870
+ 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
51871
  }
51625
51872
  if (error instanceof NativeSessionUnavailable)
51626
51873
  return failed2("UNAVAILABLE", "the retained session is unavailable for this admitted caller");
51627
51874
  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", "finite ACP execution failed before dispatch");
51875
+ 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
51876
  } finally {
51630
51877
  credentialBootstrap?.fill(0);
51631
51878
  try {
@@ -53188,19 +53435,23 @@ async function releaseAdmitAndClose(input, initial) {
53188
53435
  }
53189
53436
  if (work.lifecycle.backing !== undefined) {
53190
53437
  const backing2 = parseBacking(work.lifecycle.backing.value);
53191
- await disposePrivatePackageMaterializationLease(plan.packageAllocation.parent.path, backing2.lease);
53438
+ await privateProfileSpan("root-package-release", () => disposePrivatePackageMaterializationLease(plan.packageAllocation.parent.path, backing2.lease));
53192
53439
  } else {
53193
- const recovered = await recoverPrivatePackageMaterializationAllocation(plan.packageAllocation.parent.path, plan.packageAllocation);
53194
- if (recovered.state === "complete")
53195
- await recovered.lease.dispose();
53440
+ await privateProfileSpan("root-package-release", async () => {
53441
+ const recovered = await recoverPrivatePackageMaterializationAllocation(plan.packageAllocation.parent.path, plan.packageAllocation);
53442
+ if (recovered.state === "complete")
53443
+ await recovered.lease.dispose();
53444
+ });
53196
53445
  }
53197
53446
  if (work.lifecycle.sandbox !== undefined) {
53198
53447
  const sandbox = parseSandbox3(work.lifecycle.sandbox.value);
53199
53448
  const fence = parseFence3(work.lifecycle.fence.value);
53200
- ownerRelease = await releasePrivateExecutionOwnerState(sandbox.owner, fence.receipt);
53449
+ ownerRelease = await privateProfileSpan("root-owner-release", () => releasePrivateExecutionOwnerState(sandbox.owner, fence.receipt));
53201
53450
  } else {
53202
- const cancelled2 = await cancelPrivateExecutionOwnerStateAllocation(plan.ownerAllocation);
53203
- ownerRelease = await releasePrivateExecutionOwnerState(plan.ownerAllocation, cancelled2);
53451
+ ownerRelease = await privateProfileSpan("root-owner-release", async () => {
53452
+ const cancelled2 = await cancelPrivateExecutionOwnerStateAllocation(plan.ownerAllocation);
53453
+ return await releasePrivateExecutionOwnerState(plan.ownerAllocation, cancelled2);
53454
+ });
53204
53455
  }
53205
53456
  }
53206
53457
  work = await advanceCheckpoint(input, work, "release", {
@@ -53927,55 +54178,15 @@ function createSession(owner, roots, packageStore, host, onOperationFailure) {
53927
54178
  const source = await captureStoredPackage(packageStoreRoot, request2.package);
53928
54179
  try {
53929
54180
  host.onStage?.(`Capturing dependency inputs for ${packageLabel}`);
53930
- const workspace = await capturePrivateBunWorkspace({
54181
+ const workspace = await privateProfileSpan("dependency-workspace-capture", () => capturePrivateBunWorkspace({
53931
54182
  projectRoot: owner.root,
53932
54183
  packagePath: request2.packagePath,
53933
54184
  captured: source,
53934
54185
  signal: budget2.signal
53935
- });
54186
+ }));
53936
54187
  if (workspace !== undefined) {
53937
54188
  try {
53938
- const admitted = readPrivateAdmittedExecutionReuse({ planningBase, request: request2 });
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
- }
54189
+ execution = await prepareExecution(workspace.captured, workspace);
53979
54190
  } finally {
53980
54191
  await workspace.captured.dispose();
53981
54192
  }
@@ -53984,44 +54195,74 @@ function createSession(owner, roots, packageStore, host, onOperationFailure) {
53984
54195
  if (dependencyInput.state === "direct") {
53985
54196
  execution = privateBunExecutionArtifact(request2.package);
53986
54197
  } else {
53987
- const admitted = readPrivateAdmittedExecutionReuse({ planningBase, request: request2 });
53988
- if (admitted !== undefined) {
53989
- const current2 = await planPrivateDirectRun({
53990
- request: request2,
53991
- execution: admitted.execution,
53992
- installedSupport: host.installedBunSupport,
53993
- backend: host.backend,
53994
- httpGrants: host.httpGrants,
53995
- acpResources: host.acpResources
54198
+ execution = await prepareExecution(source);
54199
+ }
54200
+ }
54201
+ async function prepareExecution(captured, workspace2) {
54202
+ const inputs = await privateBunPreparationInputs({
54203
+ captured,
54204
+ ...workspace2 === undefined ? {} : { workspace: workspace2 },
54205
+ supportDigest: privateDomainDigest("JIG-Bun-Preparation-Support/1", {
54206
+ installation: host.installedBunSupport.digest,
54207
+ mechanism: (await host.backend.inspectSupport()).digest
54208
+ })
54209
+ });
54210
+ const admitted = readPrivateAdmittedExecutionReuse({ planningBase, request: request2 });
54211
+ const evidence = admitted?.execution.preparation;
54212
+ if (admitted !== undefined && evidence?.inputDigest === inputs.digest) {
54213
+ const previous = await captureStoredPackage(packageStoreRoot, admitted.execution.package);
54214
+ await previous.dispose();
54215
+ const dependencies = await captureStoredPackage(packageStoreRoot, evidence.package);
54216
+ try {
54217
+ const assembled = await assemblePrivateBunExecution({
54218
+ source: captured,
54219
+ sourcePaths: inputs.sourcePaths,
54220
+ dependencies,
54221
+ layout: admitted.execution.layout
53996
54222
  });
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
54223
  try {
54019
- budget2.retain(prepared.captured.files, request2.packagePath, Buffer.byteLength(JSON.stringify(prepared.layout)));
54020
- execution = privateBunExecutionArtifact(await publishCapturedPackage(packageStoreRoot, prepared.captured), prepared.layout);
54224
+ budget2.signal.throwIfAborted();
54225
+ const execution2 = privateBunExecutionArtifact(await publishCapturedPackage(packageStoreRoot, assembled), admitted.execution.layout, evidence);
54226
+ privateProfileInstant("dependency-reuse");
54227
+ host.onStage?.(`Reusing approved dependencies for ${packageLabel}`);
54228
+ return execution2;
54021
54229
  } finally {
54022
- await prepared.captured.dispose();
54230
+ await assembled.dispose();
54023
54231
  }
54232
+ } finally {
54233
+ await dependencies.dispose();
54234
+ }
54235
+ }
54236
+ const unlocked = !captured.files.some(({ path: path2 }) => path2 === "bun.lock");
54237
+ requirePrivateBunResolutionPermission(unlocked ? { state: "unlocked", manifestPath: "package.json" } : { state: "locked", manifestPath: "package.json", lockPath: "bun.lock" }, host.allowResolutionNetwork);
54238
+ budget2.reserve(captured.digest, request2.packagePath);
54239
+ if (unlocked)
54240
+ host.onResolution?.(request2.packagePath);
54241
+ host.onStage?.(`Preparing dependencies for ${packageLabel}`);
54242
+ const prepared = await privateProfileSpan("dependency-preparation", () => preparePrivateBunPackage({
54243
+ captured,
54244
+ ...workspace2 === undefined ? {} : { workspace: workspace2 },
54245
+ installedSupport: host.installedBunSupport,
54246
+ backend: host.backend,
54247
+ projectRoot: owner.root.requestedPath,
54248
+ coordinator: owner.coordinator,
54249
+ deadlineUnixMs: budget2.deadlineUnixMs,
54250
+ signal: budget2.signal,
54251
+ allowResolutionNetwork: host.allowResolutionNetwork === true
54252
+ }));
54253
+ try {
54254
+ budget2.retain(prepared.captured.files, request2.packagePath, Buffer.byteLength(JSON.stringify(prepared.layout)));
54255
+ const dependencies = await capturePrivateBunDependencies(prepared.captured, inputs.sourcePaths);
54256
+ try {
54257
+ return privateBunExecutionArtifact(await publishCapturedPackage(packageStoreRoot, prepared.captured), prepared.layout, {
54258
+ inputDigest: inputs.digest,
54259
+ package: await publishCapturedPackage(packageStoreRoot, dependencies)
54260
+ });
54261
+ } finally {
54262
+ await dependencies.dispose();
54024
54263
  }
54264
+ } finally {
54265
+ await prepared.captured.dispose();
54025
54266
  }
54026
54267
  }
54027
54268
  } finally {
@@ -54061,17 +54302,17 @@ function createSession(owner, roots, packageStore, host, onOperationFailure) {
54061
54302
  }),
54062
54303
  mechanismDigest: recipes[0]?.mechanismDigest ?? (await host.backend.inspectSupport()).digest,
54063
54304
  entries: requests.map((request2) => {
54064
- const failure = featureFailures.get(privateActivationTargetKey(request2.target));
54305
+ const failure2 = featureFailures.get(privateActivationTargetKey(request2.target));
54065
54306
  return {
54066
54307
  target: request2.target,
54067
54308
  requestDigest: request2.digest,
54068
- disposition: failure === undefined ? {
54309
+ disposition: failure2 === undefined ? {
54069
54310
  state: "planned",
54070
54311
  observation: recipes.find((recipe) => recipe.request.digest === request2.digest).observation
54071
54312
  } : {
54072
54313
  state: "unavailable",
54073
54314
  code: "FEATURE_UNAVAILABLE",
54074
- evidenceDigests: [failure]
54315
+ evidenceDigests: [failure2]
54075
54316
  }
54076
54317
  };
54077
54318
  })
@@ -54371,7 +54612,8 @@ function isCandidateDiagnosticCode(code2) {
54371
54612
  "PACKAGE_SPECIAL_FILE",
54372
54613
  "PACKAGE_SYMLINK",
54373
54614
  "PROJECT_FLOW_COLLISION",
54374
- "PROJECT_FLOW_MODE_UNSUPPORTED"
54615
+ "PROJECT_FLOW_MODE_UNSUPPORTED",
54616
+ "PROJECT_CHECKPOINT_ATTACHMENT"
54375
54617
  ].includes(code2);
54376
54618
  }
54377
54619
  function isRootIdentityLoss(error, owner) {