@adea-ai/app-framework-release-tools 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -18,6 +18,10 @@ var __export = (target, all) => {
18
18
  var exports_src = {};
19
19
  __export(exports_src, {
20
20
  buildLinuxFormats: () => buildLinuxFormats,
21
+ compareLinuxReproducibility: () => compareLinuxReproducibility,
22
+ createDailyBatchR2Client: () => createDailyBatchR2Client,
23
+ createDailyBatchR2Store: () => createDailyBatchR2Store,
24
+ createDailyBatchS3Transport: () => createDailyBatchS3Transport,
21
25
  createDailyNativeReceipt: () => createDailyNativeReceipt,
22
26
  createGitHubPromotionProvider: () => createGitHubPromotionProvider,
23
27
  createGitHubReleasePublisher: () => createGitHubReleasePublisher,
@@ -25,15 +29,19 @@ __export(exports_src, {
25
29
  desktopDailyProfile: () => desktopDailyProfile,
26
30
  fileIdentity: () => fileIdentity2,
27
31
  finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
32
+ inspectDailyBatch: () => inspectDailyBatch,
28
33
  inspectStagedStep: () => inspectStagedStep,
29
34
  planDailyReleaseMatrix: () => planDailyReleaseMatrix,
30
35
  planQualificationRun: () => planQualificationRun2,
31
36
  planReleaseAssets: () => planReleaseAssets2,
37
+ promoteDailyBatch: () => promoteDailyBatch,
32
38
  publishFrameworkPackage: () => publishFrameworkPackage,
33
39
  publishQualifiedRelease: () => publishQualifiedRelease,
34
40
  qualifyGitHubRelease: () => qualifyGitHubRelease,
35
41
  qualifyStep: () => qualifyStep,
36
42
  qualifyUpgradeStep: () => qualifyUpgradeStep,
43
+ readDailyBatch: () => readDailyBatch,
44
+ rollbackDailyBatch: () => rollbackDailyBatch,
37
45
  runPromotionCommand: () => runPromotionCommand,
38
46
  runReleaseCutCommand: () => runReleaseCutCommand,
39
47
  runReleasePublishCommand: () => runReleasePublishCommand,
@@ -44,6 +52,8 @@ __export(exports_src, {
44
52
  stageLinuxPackagePair: () => stageLinuxPackagePair,
45
53
  stagePlatformArtifacts: () => stagePlatformArtifacts,
46
54
  stageReleaseDescriptors: () => stageReleaseDescriptors,
55
+ verifyDailyBatchDescriptor: () => verifyDailyBatchDescriptor,
56
+ verifyDailyBatchObject: () => verifyDailyBatchObject,
47
57
  verifyDailyReleaseMatrix: () => verifyDailyReleaseMatrix,
48
58
  verifyImage: () => verifyImage,
49
59
  writeDescriptors: () => writeDescriptors
@@ -176,7 +186,7 @@ function parseArchPackage(value) {
176
186
  assert(Array.isArray(links) && links.length <= 8 && links.every((link, index) => isRecord(link) && Object.keys(link).length === 2 && text(link.name, 64) && executableName.test(link.name) && link.name !== policy.executable && links.findIndex((item) => isRecord(item) && item.name === link.name) === index && bundlePath(link.target)), "Invalid Arch package links");
177
187
  assert(policy.channel === undefined || policy.channel === "stable" || policy.channel === "daily", "Invalid Arch package channel");
178
188
  const repository = policy.repository;
179
- assert(repository === undefined || isRecord(repository) && Object.keys(repository).length === 3 && typeof repository.name === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(repository.name) && httpsUrl(repository.base) && repository.base.endsWith("/") && httpsUrl(repository.publicKey), "Invalid Arch package repository");
189
+ assert(repository === undefined || isRecord(repository) && Object.keys(repository).every((key) => ["name", "base", "publicKey", "keyFingerprint"].includes(key)) && typeof repository.name === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(repository.name) && httpsUrl(repository.base) && repository.base.endsWith("/") && httpsUrl(repository.publicKey) && (repository.keyFingerprint === undefined || typeof repository.keyFingerprint === "string" && /^[0-9A-F]{40}$/.test(repository.keyFingerprint)), "Invalid Arch package repository");
180
190
  return {
181
191
  pkgname: policy.pkgname,
182
192
  pkgdesc: policy.pkgdesc,
@@ -240,7 +250,8 @@ function parseArchPackage(value) {
240
250
  repository: {
241
251
  name: repository.name,
242
252
  base: repository.base,
243
- publicKey: repository.publicKey
253
+ publicKey: repository.publicKey,
254
+ ...typeof repository.keyFingerprint === "string" ? { keyFingerprint: repository.keyFingerprint } : {}
244
255
  }
245
256
  }
246
257
  };
@@ -800,15 +811,122 @@ async function runReleaseEffect(effect) {
800
811
  }
801
812
 
802
813
  // src/release-ports.ts
803
- import { execFile, spawnSync } from "child_process";
814
+ import { execFile, spawn, spawnSync } from "child_process";
804
815
  import { createPrivateKey } from "crypto";
805
816
  import * as fsp from "fs/promises";
806
817
  import { Context, Effect as Effect2 } from "effect";
818
+ import { promisify } from "util";
807
819
  import { Effect as Effect3, Fiber, Option } from "effect";
808
820
 
809
821
  class ReleaseGit extends Context.Service()("ReleaseTools/Git") {
810
822
  }
811
823
 
824
+ class ReleaseLinuxBuild extends Context.Service()("ReleaseTools/LinuxBuild") {
825
+ }
826
+ var execFileAsync = promisify(execFile);
827
+ var liveLinuxBuild = {
828
+ async git(args, cwd) {
829
+ const { stdout } = await execFileAsync("/usr/bin/git", [
830
+ "--no-replace-objects",
831
+ "-c",
832
+ "core.fsmonitor=false",
833
+ "-c",
834
+ "core.hooksPath=/dev/null",
835
+ ...args
836
+ ], {
837
+ cwd,
838
+ encoding: "buffer",
839
+ maxBuffer: 8 * 1024 * 1024,
840
+ timeout: 30000,
841
+ env: {
842
+ PATH: "/usr/bin:/bin",
843
+ HOME: "/nonexistent",
844
+ LC_ALL: "C",
845
+ GIT_CONFIG_NOSYSTEM: "1",
846
+ GIT_CONFIG_GLOBAL: "/dev/null",
847
+ GIT_NO_REPLACE_OBJECTS: "1",
848
+ GIT_OPTIONAL_LOCKS: "0",
849
+ GIT_TERMINAL_PROMPT: "0"
850
+ }
851
+ });
852
+ return stdout;
853
+ },
854
+ async tool(command, args, env, signal) {
855
+ signal?.throwIfAborted();
856
+ await new Promise((resolve, reject) => {
857
+ const child = spawn(command, [...args], { env, stdio: "inherit", detached: true });
858
+ let timer;
859
+ const stop = () => {
860
+ if (!child.pid)
861
+ return;
862
+ try {
863
+ process.kill(-child.pid, "SIGTERM");
864
+ } catch {}
865
+ timer = setTimeout(() => {
866
+ try {
867
+ process.kill(-child.pid, "SIGKILL");
868
+ } catch {}
869
+ }, 2000);
870
+ };
871
+ signal?.addEventListener("abort", stop, { once: true });
872
+ if (signal?.aborted)
873
+ stop();
874
+ let spawnError;
875
+ child.once("error", (error) => {
876
+ spawnError = error;
877
+ });
878
+ child.once("close", async (code, childSignal) => {
879
+ signal?.removeEventListener("abort", stop);
880
+ if (timer)
881
+ clearTimeout(timer);
882
+ let leftDescendants = false;
883
+ if (child.pid) {
884
+ for (;; ) {
885
+ try {
886
+ const entries = await fsp.readdir("/proc");
887
+ let live = false;
888
+ for (const entry of entries) {
889
+ if (!/^\d+$/.test(entry))
890
+ continue;
891
+ let stat;
892
+ try {
893
+ stat = await fsp.readFile(`/proc/${entry}/stat`, "utf8");
894
+ } catch (error) {
895
+ if (error.code === "ENOENT")
896
+ continue;
897
+ throw error;
898
+ }
899
+ const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
900
+ if (Number(fields[2]) === child.pid && fields[0] !== "Z" && fields[0] !== "X") {
901
+ live = true;
902
+ break;
903
+ }
904
+ }
905
+ if (!live)
906
+ break;
907
+ leftDescendants = true;
908
+ try {
909
+ process.kill(-child.pid, "SIGKILL");
910
+ } catch {}
911
+ } catch {}
912
+ await new Promise((done) => setTimeout(done, 20));
913
+ }
914
+ }
915
+ if (signal?.aborted)
916
+ reject(signal.reason);
917
+ else if (spawnError)
918
+ reject(spawnError);
919
+ else if (leftDescendants)
920
+ reject(new Error("Linux build tool left running descendants"));
921
+ else if (code === 0)
922
+ resolve();
923
+ else
924
+ reject(new Error(`Linux build tool failed (${childSignal ?? code})`));
925
+ });
926
+ });
927
+ }
928
+ };
929
+
812
930
  class ReleaseGitHub extends Context.Service()("ReleaseTools/GitHub") {
813
931
  }
814
932
 
@@ -3145,6 +3263,424 @@ var stageReleaseDescriptorsEffect = (options) => Effect15.gen(function* () {
3145
3263
  });
3146
3264
  var writeDescriptors = (directory, signed) => runReleaseLibrary(provideLibraryPorts()(writeDescriptorsEffect(directory, signed)));
3147
3265
  var stageReleaseDescriptors = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(stageReleaseDescriptorsEffect(options)));
3266
+ // src/library/daily-batch-publication.ts
3267
+ import { createHash as createHash7, randomBytes } from "crypto";
3268
+ import { createReadStream } from "fs";
3269
+
3270
+ // ../../src/updates/feed/daily-batch-pointer.ts
3271
+ import { createPublicKey as createPublicKey3, verify as verify2 } from "crypto";
3272
+ var hex = /^[a-f0-9]{64}$/;
3273
+ var keyId = /^[a-z0-9][a-z0-9._-]{0,63}$/;
3274
+ function valid2(value) {
3275
+ return isRecord(value) && hasExactOwnKeys(value, [
3276
+ "schema",
3277
+ "appId",
3278
+ "feedApp",
3279
+ "manifestDigest",
3280
+ "generation",
3281
+ "sequence",
3282
+ "operation",
3283
+ "keyId"
3284
+ ]) && value.schema === "framework/daily-pointer/v3" && typeof value.appId === "string" && /^(?=.{1,128}$)[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(value.appId) && typeof value.feedApp === "string" && /^[a-z][a-z0-9-]{0,63}$/.test(value.feedApp) && typeof value.manifestDigest === "string" && hex.test(value.manifestDigest) && typeof value.generation === "string" && hex.test(value.generation) && Number.isSafeInteger(value.sequence) && Number(value.sequence) >= 1 && (value.operation === "promote" || value.operation === "rollback") && typeof value.keyId === "string" && keyId.test(value.keyId);
3285
+ }
3286
+ function message2(pointer) {
3287
+ return Buffer.from(JSON.stringify([
3288
+ "adea-app-framework-daily-pointer-v3",
3289
+ pointer.schema,
3290
+ pointer.appId,
3291
+ pointer.feedApp,
3292
+ pointer.manifestDigest,
3293
+ pointer.generation,
3294
+ pointer.sequence,
3295
+ pointer.operation,
3296
+ pointer.keyId
3297
+ ]), "utf8");
3298
+ }
3299
+ async function signDailyPointer(pointer, signer) {
3300
+ if (!valid2(pointer) || signer.keyId !== pointer.keyId)
3301
+ throw new Error("Invalid Daily pointer signing policy");
3302
+ const signature = await signer.sign(message2(pointer));
3303
+ if (!(signature instanceof Uint8Array) || signature.length !== 64)
3304
+ throw new Error("Invalid Daily pointer signature");
3305
+ return { pointer, signature: Buffer.from(signature).toString("base64url") };
3306
+ }
3307
+ function verifyDailyPointer(value, target, keys) {
3308
+ try {
3309
+ if (!isRecord(value) || !hasExactOwnKeys(value, ["pointer", "signature"]) || !valid2(value.pointer) || value.pointer.appId !== target.appId || value.pointer.feedApp !== target.feedApp || typeof value.signature !== "string" || !/^[A-Za-z0-9_-]{86}$/.test(value.signature))
3310
+ throw new Error;
3311
+ const encoded = keys.get(value.pointer.keyId);
3312
+ if (!encoded)
3313
+ throw new Error;
3314
+ const raw = Buffer.from(encoded, "base64");
3315
+ const signature = Buffer.from(value.signature, "base64url");
3316
+ if (raw.length !== 32 || signature.length !== 64 || signature.toString("base64url") !== value.signature)
3317
+ throw new Error;
3318
+ const key = createPublicKey3({
3319
+ key: Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), raw]),
3320
+ format: "der",
3321
+ type: "spki"
3322
+ });
3323
+ if (!verify2(null, message2(value.pointer), key, signature))
3324
+ throw new Error;
3325
+ return value.pointer;
3326
+ } catch {
3327
+ throw new Error("Untrusted Daily pointer");
3328
+ }
3329
+ }
3330
+
3331
+ // src/library/daily-batch-publication.ts
3332
+ var authenticatedSnapshots = new WeakMap;
3333
+ var encoder = new TextEncoder;
3334
+ var hash = (bytes) => createHash7("sha256").update(bytes).digest("hex");
3335
+ var keyPart = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,199}$/;
3336
+ var hex2 = /^[a-f0-9]{64}$/;
3337
+ var app = /^(?=.{1,128}$)[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
3338
+ var feedApp = /^[a-z][a-z0-9-]{0,63}$/;
3339
+ var gitSha = /^[a-f0-9]{40}$/;
3340
+ var tag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
3341
+ var own = (value, keys) => {
3342
+ const actual = Object.keys(value);
3343
+ return actual.length === keys.length && keys.every((key) => Object.hasOwn(value, key));
3344
+ };
3345
+ function parseManifest(value) {
3346
+ if (!value || typeof value !== "object" || Array.isArray(value))
3347
+ throw new Error("Invalid Daily batch");
3348
+ const m = value;
3349
+ if (!own(m, ["schema", "identity", "artifacts", "receipts"]) || m.schema !== "framework/daily-batch/v1" || !m.identity || typeof m.identity !== "object" || !own(m.identity, [
3350
+ "appId",
3351
+ "feedApp",
3352
+ "tag",
3353
+ "sourceSha",
3354
+ "workflowSha",
3355
+ "runId",
3356
+ "runAttempt"
3357
+ ]) || typeof m.identity.appId !== "string" || !app.test(m.identity.appId) || typeof m.identity.feedApp !== "string" || !feedApp.test(m.identity.feedApp) || typeof m.identity.tag !== "string" || !tag.test(m.identity.tag) || typeof m.identity.sourceSha !== "string" || !gitSha.test(m.identity.sourceSha) || m.identity.workflowSha !== m.identity.sourceSha || typeof m.identity.runId !== "string" || !/^[1-9]\d{0,19}$/.test(m.identity.runId) || !Number.isSafeInteger(m.identity.runAttempt) || m.identity.runAttempt < 1)
3358
+ throw new Error("Invalid Daily batch identity");
3359
+ for (const list of [m.artifacts, m.receipts]) {
3360
+ if (!Array.isArray(list) || !list.length || list.length > 256)
3361
+ throw new Error("Invalid Daily batch inventory");
3362
+ const seen = new Set;
3363
+ for (const item of list) {
3364
+ if (!item || typeof item !== "object" || !own(item, ["name", "size", "digest"]) || typeof item.name !== "string" || !keyPart.test(item.name) || seen.has(item.name) || !Number.isSafeInteger(item.size) || item.size < 1 || typeof item.digest !== "string" || !/^sha256:[a-f0-9]{64}$/.test(item.digest))
3365
+ throw new Error("Invalid Daily batch file");
3366
+ seen.add(item.name);
3367
+ }
3368
+ }
3369
+ return m;
3370
+ }
3371
+ async function verifyBytes(bytes, expected) {
3372
+ const digest = createHash7("sha256");
3373
+ let size = 0;
3374
+ for await (const chunk of bytes) {
3375
+ size += chunk.byteLength;
3376
+ if (size > expected.size)
3377
+ throw new Error(`Daily batch object too large: ${expected.name}`);
3378
+ digest.update(chunk);
3379
+ }
3380
+ if (size !== expected.size || `sha256:${digest.digest("hex")}` !== expected.digest)
3381
+ throw new Error(`Daily batch object differs: ${expected.name}`);
3382
+ }
3383
+ async function readSmall(bytes, limit) {
3384
+ const parts = [];
3385
+ let size = 0;
3386
+ for await (const part of bytes) {
3387
+ size += part.byteLength;
3388
+ if (size > limit)
3389
+ throw new Error("Daily batch record too large");
3390
+ parts.push(part);
3391
+ }
3392
+ return Buffer.concat(parts);
3393
+ }
3394
+ var one = async function* (bytes) {
3395
+ yield bytes;
3396
+ };
3397
+ var prefix = (slug, digest) => `${slug}/batches/sha256-${digest}`;
3398
+ var pointer = (slug) => `${slug}/channels/daily-batch.json`;
3399
+ var parseJson = (bytes) => JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
3400
+ var compareTag = (a, b) => {
3401
+ const left = a.slice(1).split(".").map(BigInt);
3402
+ const right = b.slice(1).split(".").map(BigInt);
3403
+ for (let index = 0;index < 3; index++) {
3404
+ if (left[index] > right[index])
3405
+ return 1;
3406
+ if (left[index] < right[index])
3407
+ return -1;
3408
+ }
3409
+ return 0;
3410
+ };
3411
+ async function readDailyBatch(store, target, keys) {
3412
+ if (!app.test(target.appId) || !feedApp.test(target.feedApp))
3413
+ throw new Error("Invalid Daily app");
3414
+ const current = await store.readPointer(pointer(target.feedApp));
3415
+ if (!current)
3416
+ return null;
3417
+ if (!current.version || current.bytes.byteLength > 4096)
3418
+ throw new Error("Invalid Daily pointer");
3419
+ const signedPointer = parseJson(current.bytes);
3420
+ const p = verifyDailyPointer(signedPointer, target, keys);
3421
+ const bytes = await readSmall(await store.readObject(`${prefix(target.feedApp, p.manifestDigest)}/manifest.json`), 262144);
3422
+ if (hash(bytes) !== p.manifestDigest)
3423
+ throw new Error("Daily batch manifest changed");
3424
+ const manifest = parseManifest(parseJson(bytes));
3425
+ if (manifest.identity.appId !== target.appId || manifest.identity.feedApp !== target.feedApp)
3426
+ throw new Error("Daily batch app mismatch");
3427
+ Object.freeze(manifest.identity);
3428
+ for (const file of [...manifest.artifacts, ...manifest.receipts])
3429
+ Object.freeze(file);
3430
+ Object.freeze(manifest.artifacts);
3431
+ Object.freeze(manifest.receipts);
3432
+ Object.freeze(manifest);
3433
+ const snapshot = Object.freeze({
3434
+ version: current.version,
3435
+ sequence: p.sequence,
3436
+ manifestDigest: p.manifestDigest,
3437
+ manifest
3438
+ });
3439
+ authenticatedSnapshots.set(snapshot, signedPointer);
3440
+ return snapshot;
3441
+ }
3442
+ async function verifyDailyBatchDescriptor(store, snapshot, discoveryName, trust) {
3443
+ if (!authenticatedSnapshots.has(snapshot))
3444
+ throw new Error("Untrusted Daily snapshot");
3445
+ const { identity, artifacts } = snapshot.manifest;
3446
+ verifyDailyPointer(authenticatedSnapshots.get(snapshot), identity, trust.keys);
3447
+ let feed;
3448
+ try {
3449
+ feed = new URL(trust.feed);
3450
+ if (feed.protocol !== "https:" || feed.href !== trust.feed || feed.username || feed.password || feed.port || feed.search || feed.hash || !feed.pathname.endsWith(`/${identity.feedApp}/`) || trust.appId !== identity.appId || trust.channel !== "daily")
3451
+ throw new Error;
3452
+ } catch {
3453
+ throw new Error("Untrusted Daily feed");
3454
+ }
3455
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}\.json$/.test(discoveryName))
3456
+ throw new Error("Invalid Daily descriptor name");
3457
+ const listed = artifacts.find((file) => file.name === discoveryName);
3458
+ if (!listed || listed.size > 65536)
3459
+ throw new Error("Daily descriptor is missing");
3460
+ const base = prefix(identity.feedApp, snapshot.manifestDigest);
3461
+ const bytes = await readSmall(await store.readObject(`${base}/artifacts/${discoveryName}`), 65536);
3462
+ if (bytes.byteLength !== listed.size || `sha256:${hash(bytes)}` !== listed.digest)
3463
+ throw new Error("Daily descriptor differs from its snapshot");
3464
+ let signed;
3465
+ try {
3466
+ signed = parseJson(bytes);
3467
+ } catch {
3468
+ throw new Error("Invalid Daily descriptor");
3469
+ }
3470
+ const verified = verifyReleaseDescriptor(signed, trust);
3471
+ if (!verified.ok)
3472
+ throw new Error("Untrusted Daily descriptor");
3473
+ const descriptor = verified.descriptor;
3474
+ const payload = artifacts.find((file) => file.name === descriptor.asset.name);
3475
+ if (descriptor.tag !== identity.tag || descriptor.sourceSha !== identity.sourceSha || descriptor.workflowSha !== identity.workflowSha || descriptor.runId !== identity.runId || descriptor.runAttempt !== identity.runAttempt || !payload || payload.size !== descriptor.asset.size || payload.digest !== `sha256:${descriptor.asset.sha256}`)
3476
+ throw new Error("Daily descriptor does not match its snapshot");
3477
+ return {
3478
+ descriptor,
3479
+ artifactUrl: `${trust.feed}batches/sha256-${snapshot.manifestDigest}/artifacts/${payload.name}`
3480
+ };
3481
+ }
3482
+ async function verifyDailyBatchObject(store, snapshot, kind, name) {
3483
+ const file = snapshot.manifest[kind].find((item) => item.name === name);
3484
+ if (!file)
3485
+ throw new Error("Object is not in the selected Daily batch");
3486
+ await verifyBytes(await store.readObject(`${prefix(snapshot.manifest.identity.feedApp, snapshot.manifestDigest)}/${kind}/${name}`), file);
3487
+ }
3488
+ async function promoteDailyBatch(store, candidate, signer, keys) {
3489
+ const first = parseManifest(parseJson(encoder.encode(JSON.stringify(await candidate.verify()))));
3490
+ const { appId, feedApp: slug } = first.identity;
3491
+ const target = { appId, feedApp: slug };
3492
+ const old = await readDailyBatch(store, target, keys);
3493
+ const manifestBytes = encoder.encode(JSON.stringify(first) + `
3494
+ `);
3495
+ if (manifestBytes.byteLength > 262144)
3496
+ throw new Error("Daily manifest too large");
3497
+ const digest = hash(manifestBytes);
3498
+ if (old && compareTag(first.identity.tag, old.manifest.identity.tag) <= 0 && old.manifestDigest !== digest)
3499
+ throw new Error("Daily promotion must advance the version; use explicit rollback");
3500
+ const base = prefix(slug, digest);
3501
+ for (const kind of ["artifacts", "receipts"]) {
3502
+ for (const file of first[kind]) {
3503
+ const filePath = candidate.path(kind, file.name);
3504
+ await verifyBytes(createReadStream(filePath), file);
3505
+ const key = `${base}/${kind}/${file.name}`;
3506
+ await store.putImmutable(key, createReadStream(filePath), file.size, file.digest.slice(7));
3507
+ await verifyBytes(await store.readObject(key), file);
3508
+ }
3509
+ }
3510
+ await store.putImmutable(`${base}/manifest.json`, one(manifestBytes), manifestBytes.byteLength, digest);
3511
+ const storedManifest = await readSmall(await store.readObject(`${base}/manifest.json`), 262144);
3512
+ if (hash(storedManifest) !== digest)
3513
+ throw new Error("Daily manifest upload differs");
3514
+ if (JSON.stringify(parseManifest(await candidate.verify())) !== JSON.stringify(first))
3515
+ throw new Error("Daily candidate changed during upload");
3516
+ const signed = await signDailyPointer({
3517
+ schema: "framework/daily-pointer/v3",
3518
+ appId,
3519
+ feedApp: slug,
3520
+ manifestDigest: digest,
3521
+ generation: randomBytes(32).toString("hex"),
3522
+ sequence: (old?.sequence ?? 0) + 1,
3523
+ operation: "promote",
3524
+ keyId: signer.keyId
3525
+ }, signer);
3526
+ verifyDailyPointer(signed, target, keys);
3527
+ const bytes = encoder.encode(JSON.stringify(signed) + `
3528
+ `);
3529
+ if (!await store.compareAndSwap(pointer(slug), old?.version ?? null, bytes))
3530
+ throw new Error("Daily pointer changed during promotion");
3531
+ const selected = await readDailyBatch(store, target, keys);
3532
+ if (!selected || selected.manifestDigest !== digest)
3533
+ throw new Error("Daily promotion could not be read back");
3534
+ return selected;
3535
+ }
3536
+ async function rollbackDailyBatch(store, current, target, signer, keys) {
3537
+ const appId = current.manifest.identity.appId;
3538
+ const slug = current.manifest.identity.feedApp;
3539
+ if (target.manifest.identity.appId !== appId || target.manifest.identity.feedApp !== slug || !hex2.test(target.manifestDigest))
3540
+ throw new Error("Invalid rollback target");
3541
+ const selected = await readDailyBatch(store, { appId, feedApp: slug }, keys);
3542
+ if (!selected || selected.version !== current.version)
3543
+ throw new Error("Daily pointer changed during rollback");
3544
+ const bytes = await readSmall(await store.readObject(`${prefix(slug, target.manifestDigest)}/manifest.json`), 262144);
3545
+ if (hash(bytes) !== target.manifestDigest || JSON.stringify(parseManifest(parseJson(bytes))) !== JSON.stringify(target.manifest))
3546
+ throw new Error("Rollback target differs");
3547
+ for (const kind of ["artifacts", "receipts"])
3548
+ for (const file of target.manifest[kind])
3549
+ await verifyDailyBatchObject(store, target, kind, file.name);
3550
+ const signed = await signDailyPointer({
3551
+ schema: "framework/daily-pointer/v3",
3552
+ appId,
3553
+ feedApp: slug,
3554
+ manifestDigest: target.manifestDigest,
3555
+ generation: randomBytes(32).toString("hex"),
3556
+ sequence: selected.sequence + 1,
3557
+ operation: "rollback",
3558
+ keyId: signer.keyId
3559
+ }, signer);
3560
+ verifyDailyPointer(signed, { appId, feedApp: slug }, keys);
3561
+ const next = encoder.encode(JSON.stringify(signed) + `
3562
+ `);
3563
+ if (!await store.compareAndSwap(pointer(slug), current.version, next))
3564
+ throw new Error("Daily pointer changed during rollback");
3565
+ }
3566
+ // src/library/daily-batch-r2.ts
3567
+ import { createHash as createHash8 } from "crypto";
3568
+ var single = async function* (bytes) {
3569
+ yield bytes;
3570
+ };
3571
+ var maxSingle = 4 * 1024 * 1024 * 1024;
3572
+ var keyPattern = /^(?:[a-zA-Z0-9][a-zA-Z0-9._-]*\/)*[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
3573
+ var safeKey = (key) => {
3574
+ if (key.length > 1024 || !keyPattern.test(key))
3575
+ throw new Error("Invalid R2 object key");
3576
+ return key;
3577
+ };
3578
+ async function drain(body) {
3579
+ for await (const _ of body) {}
3580
+ }
3581
+ async function bounded(body, limit) {
3582
+ const chunks = [];
3583
+ let size = 0;
3584
+ for await (const chunk of body) {
3585
+ size += chunk.byteLength;
3586
+ if (size > limit)
3587
+ throw new Error("R2 pointer too large");
3588
+ chunks.push(chunk);
3589
+ }
3590
+ return Buffer.concat(chunks);
3591
+ }
3592
+ async function verify3(body, size, sha256) {
3593
+ const digest = createHash8("sha256");
3594
+ let actual = 0;
3595
+ for await (const chunk of body) {
3596
+ actual += chunk.byteLength;
3597
+ if (actual > size)
3598
+ throw new Error("Existing immutable R2 object differs");
3599
+ digest.update(chunk);
3600
+ }
3601
+ if (actual !== size || digest.digest("hex") !== sha256)
3602
+ throw new Error("Existing immutable R2 object differs");
3603
+ }
3604
+ function createDailyBatchR2Store(send) {
3605
+ const get = (key) => send({ method: "GET", key: safeKey(key), headers: {} });
3606
+ return {
3607
+ async readObject(key) {
3608
+ const response = await get(key);
3609
+ if (response.status !== 200) {
3610
+ await drain(response.body);
3611
+ throw new Error(`R2 object read failed (${response.status})`);
3612
+ }
3613
+ return response.body;
3614
+ },
3615
+ async readPointer(key) {
3616
+ const response = await get(key);
3617
+ if (response.status === 404) {
3618
+ await drain(response.body);
3619
+ return null;
3620
+ }
3621
+ if (response.status !== 200) {
3622
+ await drain(response.body);
3623
+ throw new Error(`R2 pointer read failed (${response.status})`);
3624
+ }
3625
+ const version = response.headers.etag;
3626
+ if (!version || /[\r\n]/.test(version)) {
3627
+ await drain(response.body);
3628
+ throw new Error("R2 pointer has no safe ETag");
3629
+ }
3630
+ return { version, bytes: await bounded(response.body, 4096) };
3631
+ },
3632
+ async putImmutable(key, body, size, sha256) {
3633
+ if (!Number.isSafeInteger(size) || size < 1 || size > maxSingle || !/^[a-f0-9]{64}$/.test(sha256))
3634
+ throw new Error("Invalid R2 immutable object identity");
3635
+ const response = await send({
3636
+ method: "PUT",
3637
+ key: safeKey(key),
3638
+ headers: {
3639
+ "if-none-match": "*",
3640
+ "content-length": String(size),
3641
+ "content-type": "application/octet-stream",
3642
+ "cache-control": "public, max-age=31536000, immutable"
3643
+ },
3644
+ body
3645
+ });
3646
+ await drain(response.body);
3647
+ if (response.status === 412) {
3648
+ const prior = await get(key);
3649
+ if (prior.status !== 200) {
3650
+ await drain(prior.body);
3651
+ throw new Error("Cannot verify existing R2 object");
3652
+ }
3653
+ await verify3(prior.body, size, sha256);
3654
+ } else if (response.status !== 200)
3655
+ throw new Error(`R2 immutable upload failed (${response.status})`);
3656
+ },
3657
+ async compareAndSwap(key, expectedVersion, bytes) {
3658
+ if (!bytes.byteLength || bytes.byteLength > 4096 || expectedVersion !== null && (!expectedVersion || /[\r\n]/.test(expectedVersion)))
3659
+ throw new Error("Invalid R2 pointer update");
3660
+ const response = await send({
3661
+ method: "PUT",
3662
+ key: safeKey(key),
3663
+ headers: {
3664
+ ...expectedVersion === null ? { "if-none-match": "*" } : { "if-match": expectedVersion },
3665
+ "content-length": String(bytes.byteLength),
3666
+ "content-type": "application/json",
3667
+ "cache-control": "no-cache"
3668
+ },
3669
+ body: single(bytes)
3670
+ });
3671
+ await drain(response.body);
3672
+ if (response.status === 412)
3673
+ return false;
3674
+ if (response.status !== 200)
3675
+ throw new Error(`R2 pointer update failed (${response.status})`);
3676
+ return true;
3677
+ }
3678
+ };
3679
+ }
3680
+ // src/library/daily-batch-inspection.ts
3681
+ import { join as join8 } from "path";
3682
+ import { Effect as Effect17 } from "effect";
3683
+
3148
3684
  // src/library/daily-matrix.ts
3149
3685
  import { join as join7 } from "path";
3150
3686
  import { Effect as Effect16 } from "effect";
@@ -3345,10 +3881,136 @@ var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
3345
3881
  function verifyDailyReleaseMatrix(options) {
3346
3882
  return runReleaseLibrary(provideLibraryPorts()(verifyDailyReleaseMatrixEffect(options)));
3347
3883
  }
3884
+
3885
+ // src/library/daily-batch-inspection.ts
3886
+ var inspectDailyBatchEffect = (options) => Effect17.gen(function* () {
3887
+ const git = yield* ReleaseGit;
3888
+ const { identity, configPath, artifacts, receipts } = options;
3889
+ yield* attempt(() => assertDailyIdentity(identity));
3890
+ if (configPath.length > 200 || !/^[A-Za-z0-9._/-]+\.json$/.test(configPath) || configPath.startsWith("/") || configPath.split("/").some((part) => !part || part === "." || part === ".."))
3891
+ return yield* fail("Invalid committed release configuration path");
3892
+ if ((yield* step(() => git.run(["--no-replace-objects", "rev-parse", "HEAD"]))) !== identity.sourceSha)
3893
+ return yield* fail("Daily inspection checkout does not match the source commit");
3894
+ const tree = yield* step(() => git.run(["--no-replace-objects", "ls-tree", identity.sourceSha, "--", configPath]));
3895
+ const match = /^100(?:644|755) blob ([a-f0-9]{40})\t([^\n]+)$/.exec(tree);
3896
+ if (!match || match[2] !== configPath)
3897
+ return yield* fail("Daily release configuration is not a committed regular file");
3898
+ const configBlob = match[1];
3899
+ const raw = yield* step(() => git.run(["--no-replace-objects", "show", `${identity.sourceSha}:${configPath}`]));
3900
+ if (Buffer.byteLength(raw) > 1024 * 1024)
3901
+ return yield* fail("Daily release configuration is too large");
3902
+ const config = yield* attempt(() => JSON.parse(raw));
3903
+ const parsed = yield* attempt(() => parseReleaseConfig(config));
3904
+ const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
3905
+ const receiptNames = matrix.checks.map((check) => `${check.name}.json`);
3906
+ const receiptHashes = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join8(receipts, name), name));
3907
+ const verified = yield* verifyDailyReleaseMatrixEffect({
3908
+ config,
3909
+ identity,
3910
+ artifacts,
3911
+ receipts
3912
+ });
3913
+ const afterReceipts = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join8(receipts, name), name));
3914
+ const after = yield* verifyDailyReleaseMatrixEffect({ config, identity, artifacts, receipts });
3915
+ if (JSON.stringify(receiptHashes) !== JSON.stringify(afterReceipts) || JSON.stringify(verified.assets) !== JSON.stringify(after.assets) || (yield* step(() => git.run(["--no-replace-objects", "rev-parse", "HEAD"]))) !== identity.sourceSha)
3916
+ return yield* fail("Daily inputs changed during inspection");
3917
+ return {
3918
+ schema: "framework/daily-batch-inspection/v1",
3919
+ identity: { appId: matrix.appId, feedApp: parsed.feed.app, ...identity },
3920
+ config: { path: configPath, gitBlob: configBlob },
3921
+ artifacts: verified.assets,
3922
+ receipts: receiptHashes,
3923
+ promotionAuthorized: false,
3924
+ unverified: [
3925
+ "windows-10-and-11",
3926
+ "independent-clean-environments",
3927
+ "signatures-and-notarization",
3928
+ "linux-reproducibility",
3929
+ "protected-source-and-workflow"
3930
+ ]
3931
+ };
3932
+ });
3933
+ var inspectDailyBatch = (options) => runReleaseLibrary(provideLibraryPorts()(inspectDailyBatchEffect(options)));
3934
+ // src/library/daily-batch-s3.ts
3935
+ import { GetObjectCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
3936
+ import { Readable } from "stream";
3937
+ function createDailyBatchR2Client(accountId, credentials) {
3938
+ if (!/^[a-f0-9]{32}$/.test(accountId))
3939
+ throw new Error("Invalid R2 account ID");
3940
+ return new S3Client({
3941
+ endpoint: `https://${accountId}.r2.cloudflarestorage.com`,
3942
+ region: "auto",
3943
+ credentials,
3944
+ forcePathStyle: true,
3945
+ maxAttempts: 1,
3946
+ requestChecksumCalculation: "WHEN_REQUIRED",
3947
+ responseChecksumValidation: "WHEN_REQUIRED"
3948
+ });
3949
+ }
3950
+ function createDailyBatchS3Transport(client, bucket) {
3951
+ if (!/^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/.test(bucket) || bucket.includes(".."))
3952
+ throw new Error("Invalid R2 bucket");
3953
+ return async ({ method, key, headers, body }) => {
3954
+ if (await client.config.maxAttempts() !== 1)
3955
+ throw new Error("S3 retries must be disabled");
3956
+ const allowed = new Set([
3957
+ "if-match",
3958
+ "if-none-match",
3959
+ "content-length",
3960
+ "content-type",
3961
+ "cache-control"
3962
+ ]);
3963
+ if (Object.keys(headers).some((name) => !allowed.has(name)))
3964
+ throw new Error("Unexpected S3 header");
3965
+ let stream;
3966
+ try {
3967
+ if (method === "GET") {
3968
+ if (body || Object.keys(headers).length)
3969
+ throw new Error("Invalid S3 GET");
3970
+ const result = await client.send(new GetObjectCommand({ Bucket: bucket, Key: key }));
3971
+ if (!result.Body || !(Symbol.asyncIterator in result.Body))
3972
+ throw new Error("S3 body is not a stream");
3973
+ return {
3974
+ status: result.$metadata.httpStatusCode ?? 0,
3975
+ headers: { etag: result.ETag },
3976
+ body: result.Body
3977
+ };
3978
+ }
3979
+ const length = Number(headers["content-length"]);
3980
+ if (!body || !Number.isSafeInteger(length) || length < 1 || String(length) !== headers["content-length"])
3981
+ throw new Error("Invalid S3 upload length");
3982
+ stream = Readable.from(body);
3983
+ const result = await client.send(new PutObjectCommand({
3984
+ Bucket: bucket,
3985
+ Key: key,
3986
+ Body: stream,
3987
+ ContentLength: length,
3988
+ ContentType: headers["content-type"],
3989
+ CacheControl: headers["cache-control"],
3990
+ IfMatch: headers["if-match"],
3991
+ IfNoneMatch: headers["if-none-match"]
3992
+ }));
3993
+ if (!stream.readableEnded)
3994
+ throw new Error("S3 upload body not fully consumed");
3995
+ return {
3996
+ status: result.$metadata.httpStatusCode ?? 0,
3997
+ headers: { etag: result.ETag },
3998
+ body: empty()
3999
+ };
4000
+ } catch (error) {
4001
+ stream?.destroy();
4002
+ const status = error?.$metadata?.httpStatusCode;
4003
+ if (status === 404 || status === 412)
4004
+ return { status, headers: {}, body: empty() };
4005
+ throw error;
4006
+ }
4007
+ };
4008
+ }
4009
+ async function* empty() {}
3348
4010
  // src/library/daily-native-receipt.ts
3349
- import { join as join8 } from "path";
3350
- import { Effect as Effect17 } from "effect";
3351
- var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function* () {
4011
+ import { join as join9 } from "path";
4012
+ import { Effect as Effect18 } from "effect";
4013
+ var createDailyNativeReceiptEffect = (options, worker) => Effect18.gen(function* () {
3352
4014
  const { config, identity, artifacts, checkName, report } = options;
3353
4015
  yield* attempt(() => assertDailyIdentity(identity));
3354
4016
  const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
@@ -3362,7 +4024,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function*
3362
4024
  const dir = yield* step(() => fs.lstat(artifacts));
3363
4025
  if (!dir.isDirectory() || dir.isSymbolicLink())
3364
4026
  return yield* fail("Expected real native artifact directory");
3365
- const assets = yield* Effect17.forEach(check.assets, (name) => fileIdentityEffect(join8(artifacts, name), name));
4027
+ const assets = yield* Effect18.forEach(check.assets, (name) => fileIdentityEffect(join9(artifacts, name), name));
3366
4028
  const evidence = yield* attempt(() => validateDailyNativeEvidence(report, "framework/daily-native-job/v1", {
3367
4029
  appId: matrix.appId,
3368
4030
  identity,
@@ -3380,7 +4042,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function*
3380
4042
  const { baselineAsset, baselineOrigin } = evidence.observations.upgrade;
3381
4043
  const proofFiles = baselineOrigin.kind === "private-from-verified-payload" ? [baselineAsset, baselineOrigin.payload] : [baselineAsset];
3382
4044
  for (const expected of proofFiles) {
3383
- const observed = yield* fileIdentityEffect(join8(baselineDirectory, expected.name), expected.name);
4045
+ const observed = yield* fileIdentityEffect(join9(baselineDirectory, expected.name), expected.name);
3384
4046
  if (observed.size !== expected.size || observed.digest !== expected.digest)
3385
4047
  return yield* fail("Daily desktop baseline installer or prior payload differs from native observations");
3386
4048
  }
@@ -3403,6 +4065,160 @@ function createDailyNativeReceipt(options) {
3403
4065
  arch: process.arch
3404
4066
  })));
3405
4067
  }
4068
+ // src/library/linux-reproducibility.ts
4069
+ import { createHash as createHash9 } from "crypto";
4070
+ import { lstat as lstat6, readFile as readFile5, readdir as readdir4, realpath } from "fs/promises";
4071
+ import { isAbsolute as isAbsolute2, join as join10, resolve as resolve6 } from "path";
4072
+ var sha256 = /^[a-f0-9]{64}$/;
4073
+ var digest2 = /^sha256:[a-f0-9]{64}$/;
4074
+ var circleciImage = /^ubuntu-2404:[0-9]{4}\.(?:0[1-9]|1[0-2])\.[0-9]+$/;
4075
+ var identifier = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
4076
+ var filename = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,199}$/;
4077
+ function check(ok, message) {
4078
+ if (!ok)
4079
+ throw new Error(message);
4080
+ }
4081
+ async function regular(path) {
4082
+ check(typeof path === "string" && isAbsolute2(path), "Expected an absolute input path");
4083
+ const stat = await lstat6(path);
4084
+ check(stat.isFile() && !stat.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real regular input file");
4085
+ check(Number.isSafeInteger(stat.size) && stat.size > 0, "Invalid input file size");
4086
+ const result = await hashFileAt(path, stat, "Input changed during comparison");
4087
+ const after = await lstat6(path);
4088
+ check(after.isFile() && !after.isSymbolicLink() && after.dev === stat.dev && after.ino === stat.ino && after.size === stat.size && after.mtimeMs === stat.mtimeMs && after.ctimeMs === stat.ctimeMs, "Input changed during comparison");
4089
+ return { ...result, dev: stat.dev, ino: stat.ino };
4090
+ }
4091
+ async function outputDirectory(path, expected) {
4092
+ check(typeof path === "string" && isAbsolute2(path), "Expected an absolute output directory");
4093
+ const info = await lstat6(path);
4094
+ check(info.isDirectory() && !info.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real output directory");
4095
+ const entries = await readdir4(path, { withFileTypes: true });
4096
+ const names = new Set(expected);
4097
+ check(names.size === expected.length && entries.length === names.size && entries.every((entry) => entry.isFile() && names.has(entry.name)), "Build output must contain exactly the DEB, AppImage and producer receipt");
4098
+ return { path, dev: info.dev, ino: info.ino, mtimeMs: info.mtimeMs, ctimeMs: info.ctimeMs };
4099
+ }
4100
+ async function directoryUnchanged(before) {
4101
+ const after = await lstat6(before.path);
4102
+ check(after.isDirectory() && !after.isSymbolicLink() && await realpath(before.path) === resolve6(before.path) && after.dev === before.dev && after.ino === before.ino && after.mtimeMs === before.mtimeMs && after.ctimeMs === before.ctimeMs, "Build output directory changed during comparison");
4103
+ }
4104
+ function sameIdentity(a, b) {
4105
+ return a.tag === b.tag && a.sourceSha === b.sourceSha && a.workflowSha === b.workflowSha && a.runId === b.runId && a.runAttempt === b.runAttempt;
4106
+ }
4107
+ async function compareLinuxReproducibility(rawInput) {
4108
+ const input = structuredClone(rawInput);
4109
+ check(isRecord(input) && hasExactOwnKeys(input, [
4110
+ "config",
4111
+ "identity",
4112
+ "sourceDateEpoch",
4113
+ "archive",
4114
+ "imageReference",
4115
+ "toolchainDigest",
4116
+ "runs"
4117
+ ]) && isRecord(input.identity) && hasExactOwnKeys(input.identity, ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"]) && isRecord(input.archive) && hasExactOwnKeys(input.archive, ["size", "sha256"]), "Invalid Linux comparison input");
4118
+ assertDailyIdentity(input.identity);
4119
+ check(Number.isSafeInteger(input.sourceDateEpoch) && input.sourceDateEpoch > 0 && input.sourceDateEpoch <= 4294967295 && Number.isSafeInteger(input.archive?.size) && input.archive.size > 0 && sha256.test(input.archive.sha256) && circleciImage.test(input.imageReference) && digest2.test(input.toolchainDigest), "Invalid protected Linux build identity");
4120
+ check(isRecord(input.config) && typeof input.config.appId === "string", "Invalid app identity");
4121
+ const requirements = parseReleaseConfig(input.config).requirements(input.identity.tag);
4122
+ const archiveName = requirements.platforms["linux-x64"]?.[1];
4123
+ check(typeof archiveName === "string" && archiveName.endsWith(".tar.zst") && filename.test(archiveName), "Invalid configured Linux archive");
4124
+ const stem = archiveName.slice(0, -".tar.zst".length);
4125
+ const artifacts = [`${stem}.deb`, `${stem}.AppImage`];
4126
+ const outputs = [...artifacts, "linux-format-build.json"];
4127
+ check(artifacts.every((name) => filename.test(name)) && new Set(outputs).size === outputs.length, "Invalid configured Linux output names");
4128
+ check(Array.isArray(input.runs) && input.runs.length === 2, "Exactly two build runs required");
4129
+ for (const run of input.runs) {
4130
+ check(isRecord(run) && hasExactOwnKeys(run, [
4131
+ "identity",
4132
+ "appId",
4133
+ "sourceDateEpoch",
4134
+ "jobId",
4135
+ "platform",
4136
+ "imageReference",
4137
+ "toolchainDigest",
4138
+ "archive",
4139
+ "output"
4140
+ ]) && isRecord(run.identity) && hasExactOwnKeys(run.identity, ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"]) && sameIdentity(run.identity, input.identity) && run.appId === input.config.appId && run.sourceDateEpoch === input.sourceDateEpoch && typeof run.jobId === "string" && identifier.test(run.jobId) && run.platform === "linux-x86_64" && run.imageReference === input.imageReference && run.toolchainDigest === input.toolchainDigest && typeof run.archive === "string" && typeof run.output === "string", "Linux build identity mismatch");
4141
+ }
4142
+ const first = input.runs[0];
4143
+ const second = input.runs[1];
4144
+ check(first.jobId !== second.jobId, "Build jobs must be distinct");
4145
+ const firstDir = await outputDirectory(first.output, outputs);
4146
+ const secondDir = await outputDirectory(second.output, outputs);
4147
+ check(firstDir.dev !== secondDir.dev || firstDir.ino !== secondDir.ino, "Build output directories must be distinct");
4148
+ const firstArchive = await regular(first.archive);
4149
+ const secondArchive = await regular(second.archive);
4150
+ for (const archive of [firstArchive, secondArchive])
4151
+ check(archive.size === input.archive.size && archive.sha256 === input.archive.sha256, "Build archive does not match the independently verified input");
4152
+ check(firstArchive.dev !== secondArchive.dev || firstArchive.ino !== secondArchive.ino, "Build archive copies must be distinct");
4153
+ const observed = [
4154
+ { path: first.archive, file: firstArchive },
4155
+ { path: second.archive, file: secondArchive }
4156
+ ];
4157
+ const seen = new Set([
4158
+ `${firstArchive.dev}:${firstArchive.ino}`,
4159
+ `${secondArchive.dev}:${secondArchive.ino}`
4160
+ ]);
4161
+ const result = [];
4162
+ for (const name of artifacts) {
4163
+ const left = await regular(join10(first.output, name));
4164
+ const right = await regular(join10(second.output, name));
4165
+ for (const file of [left, right]) {
4166
+ const key = `${file.dev}:${file.ino}`;
4167
+ check(!seen.has(key), "Build inputs and outputs must be independent files");
4168
+ seen.add(key);
4169
+ }
4170
+ observed.push({ path: join10(first.output, name), file: left });
4171
+ observed.push({ path: join10(second.output, name), file: right });
4172
+ check(left.size === right.size && left.sha256 === right.sha256, `Linux build differs: ${name}`);
4173
+ result.push({ name, size: left.size, sha256: left.sha256 });
4174
+ }
4175
+ for (const run of input.runs) {
4176
+ const path = join10(run.output, "linux-format-build.json");
4177
+ const file = await regular(path);
4178
+ const key = `${file.dev}:${file.ino}`;
4179
+ check(!seen.has(key), "Build inputs and outputs must be independent files");
4180
+ seen.add(key);
4181
+ observed.push({ path, file });
4182
+ check(file.size <= 65536, "Producer receipt is too large");
4183
+ const bytes = await readFile5(path);
4184
+ check(bytes.length === file.size && createHash9("sha256").update(bytes).digest("hex") === file.sha256, "Producer receipt changed");
4185
+ let receipt;
4186
+ try {
4187
+ receipt = JSON.parse(bytes.toString("utf8"));
4188
+ } catch {
4189
+ throw new Error("Invalid producer receipt");
4190
+ }
4191
+ check(isRecord(receipt) && Array.isArray(receipt.artifacts), "Invalid producer receipt");
4192
+ const receiptArtifacts = receipt.artifacts;
4193
+ check(hasExactOwnKeys(receipt, [
4194
+ "schema",
4195
+ "tag",
4196
+ "sourceSha",
4197
+ "sourceDateEpoch",
4198
+ "platform",
4199
+ "updateArchiveSha256",
4200
+ "artifacts"
4201
+ ]) && receipt.schema === "linux-package-formats/v1" && receipt.tag === input.identity.tag && receipt.sourceSha === input.identity.sourceSha && receipt.sourceDateEpoch === input.sourceDateEpoch && receipt.platform === "linux-x64" && receipt.updateArchiveSha256 === input.archive.sha256 && receiptArtifacts.length === result.length && result.every((expected) => receiptArtifacts.some((item) => isRecord(item) && hasExactOwnKeys(item, ["name", "size", "sha256"]) && item.name === expected.name && item.size === expected.size && item.sha256 === expected.sha256)), "Producer receipt does not match the checked inputs and outputs");
4202
+ }
4203
+ for (const previous of observed) {
4204
+ const current = await regular(previous.path);
4205
+ check(current.dev === previous.file.dev && current.ino === previous.file.ino && current.size === previous.file.size && current.sha256 === previous.file.sha256, "Input changed during comparison");
4206
+ }
4207
+ await directoryUnchanged(firstDir);
4208
+ await directoryUnchanged(secondDir);
4209
+ return {
4210
+ schema: "framework/linux-format-byte-comparison/v1",
4211
+ qualified: false,
4212
+ appId: input.config.appId,
4213
+ identity: input.identity,
4214
+ sourceDateEpoch: input.sourceDateEpoch,
4215
+ archive: input.archive,
4216
+ imageReference: input.imageReference,
4217
+ toolchainDigest: input.toolchainDigest,
4218
+ jobs: input.runs.map((run) => ({ jobId: run.jobId })),
4219
+ artifacts: result
4220
+ };
4221
+ }
3406
4222
  // src/library/macos-dmg.ts
3407
4223
  import { execFileSync } from "child_process";
3408
4224
  import {
@@ -3414,8 +4230,8 @@ import {
3414
4230
  rmSync,
3415
4231
  symlinkSync
3416
4232
  } from "fs";
3417
- import { basename as basename4, dirname, join as join9, resolve as resolve6 } from "path";
3418
- import { Context as Context2, Effect as Effect18 } from "effect";
4233
+ import { basename as basename4, dirname, join as join11, resolve as resolve7 } from "path";
4234
+ import { Context as Context2, Effect as Effect19 } from "effect";
3419
4235
 
3420
4236
  // ../../src/release/macos-dmg.ts
3421
4237
  var MIB = 1024 * 1024;
@@ -3446,7 +4262,7 @@ function treeSize(root) {
3446
4262
  logicalBytes += info.size;
3447
4263
  else if (info.isDirectory())
3448
4264
  for (const name of readdirSync(path))
3449
- pending.push(join9(path, name));
4265
+ pending.push(join11(path, name));
3450
4266
  else if (!info.isSymbolicLink())
3451
4267
  throw new Error("Unsupported disk image entry");
3452
4268
  if (!Number.isSafeInteger(logicalBytes))
@@ -3454,29 +4270,29 @@ function treeSize(root) {
3454
4270
  }
3455
4271
  return { logicalBytes, entries };
3456
4272
  }
3457
- var verifyImageEffect = (image) => Effect18.gen(function* () {
4273
+ var verifyImageEffect = (image) => Effect19.gen(function* () {
3458
4274
  const host = yield* MacosHost;
3459
4275
  for (let tries = 1;; tries++) {
3460
- const verified = yield* attempt(() => host.run("/usr/bin/hdiutil", ["verify", image])).pipe(Effect18.as(true), Effect18.catchIf(() => tries < 6, () => Effect18.succeed(false)));
4276
+ const verified = yield* attempt(() => host.run("/usr/bin/hdiutil", ["verify", image])).pipe(Effect19.as(true), Effect19.catchIf(() => tries < 6, () => Effect19.succeed(false)));
3461
4277
  if (verified)
3462
4278
  return;
3463
4279
  host.wait(5000 * 2 ** (tries - 1));
3464
4280
  }
3465
4281
  });
3466
- var createMacosDmgEffect = (options) => Effect18.gen(function* () {
4282
+ var createMacosDmgEffect = (options) => Effect19.gen(function* () {
3467
4283
  const host = yield* MacosHost;
3468
4284
  if (host.platform !== "darwin")
3469
4285
  return yield* fail("Disk image creation requires macOS");
3470
4286
  assertPortableAppName(options.appName);
3471
- const app = resolve6(options.appPath), output = resolve6(options.outputPath);
4287
+ const app = resolve7(options.appPath), output = resolve7(options.outputPath);
3472
4288
  const info = yield* attempt(() => lstatSync(app));
3473
4289
  if (!app.endsWith(".app") || !info.isDirectory() || info.isSymbolicLink() || !output.endsWith(".dmg"))
3474
4290
  return yield* fail("Invalid disk image paths");
3475
- const staging = yield* Effect18.acquireRelease(attempt(() => mkdtempSync(join9(dirname(output), ".framework-dmg-"))), (path) => Effect18.sync(() => rmSync(path, { recursive: true, force: true })));
3476
- const payload = join9(staging, "payload"), image = join9(staging, "result.dmg");
4291
+ const staging = yield* Effect19.acquireRelease(attempt(() => mkdtempSync(join11(dirname(output), ".framework-dmg-"))), (path) => Effect19.sync(() => rmSync(path, { recursive: true, force: true })));
4292
+ const payload = join11(staging, "payload"), image = join11(staging, "result.dmg");
3477
4293
  yield* attempt(() => mkdirSync(payload));
3478
- yield* attempt(() => host.run("/usr/bin/ditto", [app, join9(payload, basename4(app))]));
3479
- yield* attempt(() => symlinkSync("/Applications", join9(payload, "Applications")));
4294
+ yield* attempt(() => host.run("/usr/bin/ditto", [app, join11(payload, basename4(app))]));
4295
+ yield* attempt(() => symlinkSync("/Applications", join11(payload, "Applications")));
3480
4296
  const capacityMiB = yield* attempt(() => dmgCapacityMiB(treeSize(payload)));
3481
4297
  yield* attempt(() => host.run("/usr/bin/hdiutil", [
3482
4298
  "create",
@@ -3493,36 +4309,36 @@ var createMacosDmgEffect = (options) => Effect18.gen(function* () {
3493
4309
  yield* verifyImageEffect(image);
3494
4310
  yield* attempt(() => linkSync(image, output));
3495
4311
  return { capacityMiB };
3496
- }).pipe(Effect18.scoped);
4312
+ }).pipe(Effect19.scoped);
3497
4313
  function verifyImage(image, io = liveHost) {
3498
- runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect18.provideService(MacosHost, {
4314
+ runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect19.provideService(MacosHost, {
3499
4315
  run: (command, args) => io.run(command, args),
3500
4316
  wait: (milliseconds) => io.wait(milliseconds),
3501
4317
  platform: process.platform
3502
4318
  })));
3503
4319
  }
3504
4320
  function createMacosDmg(options) {
3505
- return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect18.provideService(MacosHost, liveHost)));
4321
+ return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect19.provideService(MacosHost, liveHost)));
3506
4322
  }
3507
4323
  // src/library/qualification-run.ts
3508
- import { Effect as Effect21 } from "effect";
4324
+ import { Effect as Effect22 } from "effect";
3509
4325
 
3510
4326
  // src/library/local-release.ts
3511
- import { createHash as createHash8 } from "crypto";
4327
+ import { createHash as createHash11 } from "crypto";
3512
4328
  import { constants as constants3 } from "fs";
3513
- import { dirname as dirname2, join as join11, resolve as resolve8 } from "path";
3514
- import { Cause as Cause2, Effect as Effect20, Exit as Exit3 } from "effect";
4329
+ import { dirname as dirname2, join as join13, resolve as resolve9 } from "path";
4330
+ import { Cause as Cause2, Effect as Effect21, Exit as Exit3 } from "effect";
3515
4331
 
3516
4332
  // ../../src/native/native-rename.ts
3517
4333
  import { randomUUID } from "crypto";
3518
- import { mkdir as mkdir3, readFile as readFile5, rm as rm3, writeFile as writeFile3 } from "fs/promises";
4334
+ import { mkdir as mkdir3, readFile as readFile6, rm as rm3, writeFile as writeFile3 } from "fs/promises";
3519
4335
  import { dlopen, FFIType, ptr } from "bun:ffi";
3520
- import { join as join10 } from "path";
4336
+ import { join as join12 } from "path";
3521
4337
 
3522
4338
  // ../../src/native/canonical-path.ts
3523
- import { isAbsolute as isAbsolute2, resolve as resolve7 } from "path";
4339
+ import { isAbsolute as isAbsolute3, resolve as resolve8 } from "path";
3524
4340
  function isCanonicalPath(value) {
3525
- return typeof value === "string" && isAbsolute2(value) && resolve7(value) === value && !value.includes("\x00");
4341
+ return typeof value === "string" && isAbsolute3(value) && resolve8(value) === value && !value.includes("\x00");
3526
4342
  }
3527
4343
 
3528
4344
  // ../../src/native/native-rename.ts
@@ -3596,8 +4412,8 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
3596
4412
  if (!isCanonicalPath(parent))
3597
4413
  throw new Error("Invalid directory exchange probe parent");
3598
4414
  const id = randomUUID();
3599
- const first = join10(parent, `.framework-exchange-probe-${id}-a`);
3600
- const second = join10(parent, `.framework-exchange-probe-${id}-b`);
4415
+ const first = join12(parent, `.framework-exchange-probe-${id}-a`);
4416
+ const second = join12(parent, `.framework-exchange-probe-${id}-b`);
3601
4417
  const marker = "exchange-probe";
3602
4418
  const firstValue = `${id}:first`;
3603
4419
  const secondValue = `${id}:second`;
@@ -3608,12 +4424,12 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
3608
4424
  firstCreated = true;
3609
4425
  await mkdir3(second, { mode: 448 });
3610
4426
  secondCreated = true;
3611
- await writeFile3(join10(first, marker), firstValue, { flag: "wx", mode: 384 });
3612
- await writeFile3(join10(second, marker), secondValue, { flag: "wx", mode: 384 });
4427
+ await writeFile3(join12(first, marker), firstValue, { flag: "wx", mode: 384 });
4428
+ await writeFile3(join12(second, marker), secondValue, { flag: "wx", mode: 384 });
3613
4429
  exchange(first, second);
3614
4430
  const [firstAfter, secondAfter] = await Promise.all([
3615
- readFile5(join10(first, marker), "utf8"),
3616
- readFile5(join10(second, marker), "utf8")
4431
+ readFile6(join12(first, marker), "utf8"),
4432
+ readFile6(join12(second, marker), "utf8")
3617
4433
  ]);
3618
4434
  if (firstAfter !== secondValue || secondAfter !== firstValue)
3619
4435
  throw new Error("Directory exchange did not exchange both probe trees");
@@ -3678,8 +4494,8 @@ function createFeedReleaseCutProvider(options) {
3678
4494
  }
3679
4495
 
3680
4496
  // src/library/feed-state.ts
3681
- import { createHash as createHash7 } from "crypto";
3682
- import { Effect as Effect19 } from "effect";
4497
+ import { createHash as createHash10 } from "crypto";
4498
+ import { Effect as Effect20 } from "effect";
3683
4499
 
3684
4500
  // ../../src/shared/discard-stream.ts
3685
4501
  function discardStream(stream) {
@@ -3839,11 +4655,11 @@ var json = (bytes) => {
3839
4655
  throw new Error("Invalid release feed response");
3840
4656
  }
3841
4657
  };
3842
- var feedObject = (feed, path, maximum) => Effect19.gen(function* () {
4658
+ var feedObject = (feed, path, maximum) => Effect20.gen(function* () {
3843
4659
  const { fetch: fetch2 } = yield* ReleaseFetch;
3844
4660
  return yield* step(() => readFeedObject(feed, path, fetch2, maximum));
3845
4661
  });
3846
- var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
4662
+ var readFeedLedgerEffect = (feed) => Effect20.gen(function* () {
3847
4663
  const bytes = yield* feedObject(feed, "index.json", MAX_LEDGER_BYTES);
3848
4664
  const ledger = bytes ? yield* attempt(() => parseReleaseLedger(json(bytes), feed.app)) : null;
3849
4665
  if (ledger && ledger.releases.length > 0)
@@ -3855,7 +4671,7 @@ var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
3855
4671
  }
3856
4672
  return ledger ?? { schema: 1, app: feed.app, releases: [] };
3857
4673
  });
3858
- var readFeedReleaseEffect = (feed, tag) => Effect19.gen(function* () {
4674
+ var readFeedReleaseEffect = (feed, tag) => Effect20.gen(function* () {
3859
4675
  const bytes = yield* feedObject(feed, `${tag}/release.json`, MAX_RELEASE_BYTES);
3860
4676
  if (!bytes)
3861
4677
  return null;
@@ -3905,10 +4721,10 @@ class ReleaseFeedSnapshotChanged extends Error {
3905
4721
  var snapshotChanged = step(async () => {
3906
4722
  throw new ReleaseFeedSnapshotChanged;
3907
4723
  });
3908
- var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
4724
+ var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
3909
4725
  const { config, feed, tag } = options;
3910
4726
  const { fetch: fetcher } = yield* ReleaseFetch;
3911
- const ledger = yield* readFeedLedgerEffect(feed).pipe(Effect19.catchIf(() => options.expectedLedger !== undefined, () => snapshotChanged));
4727
+ const ledger = yield* readFeedLedgerEffect(feed).pipe(Effect20.catchIf(() => options.expectedLedger !== undefined, () => snapshotChanged));
3912
4728
  if (options.expectedLedger && JSON.stringify(ledger) !== JSON.stringify(options.expectedLedger))
3913
4729
  return yield* snapshotChanged;
3914
4730
  const release = yield* readFeedReleaseEffect(feed, tag);
@@ -3926,7 +4742,7 @@ var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
3926
4742
  if (!listed)
3927
4743
  return yield* fail(`Missing signed descriptor: ${policy.name}`);
3928
4744
  const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
3929
- if (!bytes || bytes.length !== listed.size || createHash7("sha256").update(bytes).digest("hex") !== listed.sha256)
4745
+ if (!bytes || bytes.length !== listed.size || createHash10("sha256").update(bytes).digest("hex") !== listed.sha256)
3930
4746
  return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
3931
4747
  const verified = verifyReleaseDescriptor(json(bytes), {
3932
4748
  appId: policy.appId,
@@ -3971,13 +4787,13 @@ var timestamp2 = (value) => {
3971
4787
  throw new Error("Invalid release clock");
3972
4788
  return new Date(value).toISOString();
3973
4789
  };
3974
- var exactFiles = (directory, names) => Effect20.gen(function* () {
4790
+ var exactFiles = (directory, names) => Effect21.gen(function* () {
3975
4791
  const fs = yield* ReleaseFs;
3976
4792
  const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
3977
4793
  if (entries.length !== names.length || entries.some((entry) => !entry.isFile() || !names.includes(entry.name)))
3978
4794
  return yield* fail("Staged directory does not hold exactly the platform release files");
3979
4795
  });
3980
- var promised2 = Effect20.gen(function* () {
4796
+ var promised2 = Effect21.gen(function* () {
3981
4797
  const fs = yield* ReleaseFs;
3982
4798
  const { fetch: fetch2 } = yield* ReleaseFetch;
3983
4799
  const { run: git } = yield* ReleaseGit;
@@ -3987,7 +4803,7 @@ var promised2 = Effect20.gen(function* () {
3987
4803
  run: (effect) => runReleaseLibrary(provideLibraryPorts({ fs, fetch: fetch2, git })(effect))
3988
4804
  };
3989
4805
  });
3990
- var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
4806
+ var runLocalReleaseCutEffect = (options) => Effect21.gen(function* () {
3991
4807
  const { kind, platform } = options;
3992
4808
  const parsed = parseReleaseConfig(options.config);
3993
4809
  const provenance = yield* resolveLocalProvenanceEffect({
@@ -4012,7 +4828,7 @@ var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
4012
4828
  }));
4013
4829
  return { ...result, version: result.tag.slice(1), platform };
4014
4830
  });
4015
- var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
4831
+ var localTagProvenanceEffect = (options) => Effect21.gen(function* () {
4016
4832
  const parsed = parseReleaseConfig(options.config);
4017
4833
  parsed.requirements(options.tag);
4018
4834
  const provenance = yield* resolveLocalProvenanceEffect({
@@ -4023,16 +4839,16 @@ var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
4023
4839
  return yield* fail("Release tag does not belong to the source version");
4024
4840
  return { repository: provenance.repository };
4025
4841
  });
4026
- var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
4842
+ var stageLocalDescriptorsEffect = (options) => Effect21.gen(function* () {
4027
4843
  const { tag, platform } = options;
4028
4844
  const local = localConfig(options.config);
4029
4845
  if (!/^[1-9]\d{0,19}$/.test(options.runId) || !isGitSha(options.sourceSha))
4030
4846
  return yield* fail("Invalid local release identity");
4031
4847
  const publicKey = configuredSigningKey(local.config, options.keyId, options.privateKey);
4032
4848
  const payloads = platformPayloads(local.requirements(tag), platform);
4033
- const directory = resolve8(options.directory);
4849
+ const directory = resolve9(options.directory);
4034
4850
  yield* exactFiles(directory, payloads);
4035
- const assets = yield* Effect20.forEach(payloads, (name) => fileIdentityEffect(join11(directory, name), name), { concurrency: "unbounded" });
4851
+ const assets = yield* Effect21.forEach(payloads, (name) => fileIdentityEffect(join13(directory, name), name), { concurrency: "unbounded" });
4036
4852
  const signed = signDiscoveryDescriptors({
4037
4853
  policies: discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform),
4038
4854
  assets,
@@ -4050,7 +4866,7 @@ var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
4050
4866
  privateKey: options.privateKey
4051
4867
  });
4052
4868
  for (const asset of assets)
4053
- if (JSON.stringify(yield* fileIdentityEffect(join11(directory, asset.name), asset.name)) !== JSON.stringify(asset))
4869
+ if (JSON.stringify(yield* fileIdentityEffect(join13(directory, asset.name), asset.name)) !== JSON.stringify(asset))
4054
4870
  return yield* fail("Staged payload changed before signing");
4055
4871
  yield* writeDescriptorsEffect(directory, signed);
4056
4872
  return signed.map((value) => value.name);
@@ -4070,22 +4886,22 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
4070
4886
  var describe = (key, bytes, cacheControl) => ({
4071
4887
  key,
4072
4888
  size: bytes.length,
4073
- sha256: createHash8("sha256").update(bytes).digest("hex"),
4889
+ sha256: createHash11("sha256").update(bytes).digest("hex"),
4074
4890
  contentType: "application/json",
4075
4891
  cacheControl
4076
4892
  });
4077
- var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* () {
4893
+ var writeStagedTree = (out, feed, assets, documents) => Effect21.gen(function* () {
4078
4894
  const fs = yield* ReleaseFs;
4079
- const root = resolve8(out);
4080
- const exists = yield* step(() => fs.lstat(root)).pipe(Effect20.as(true), Effect20.catchIf((failure) => errorCode(failure.original) === "ENOENT", () => Effect20.succeed(false)));
4895
+ const root = resolve9(out);
4896
+ const exists = yield* step(() => fs.lstat(root)).pipe(Effect21.as(true), Effect21.catchIf((failure) => errorCode(failure.original) === "ENOENT", () => Effect21.succeed(false)));
4081
4897
  if (exists)
4082
4898
  return yield* fail("Release output directory already exists");
4083
4899
  yield* step(() => fs.mkdir(dirname2(root), { recursive: true, mode: 448 }));
4084
- const staging = yield* step(() => fs.mkdtemp(join11(dirname2(root), ".release-staging-")));
4085
- const exit = yield* Effect20.exit(Effect20.gen(function* () {
4900
+ const staging = yield* step(() => fs.mkdtemp(join13(dirname2(root), ".release-staging-")));
4901
+ const exit = yield* Effect21.exit(Effect21.gen(function* () {
4086
4902
  const objects = [];
4087
4903
  for (const { key, path, artifact } of assets) {
4088
- const target = join11(staging, key);
4904
+ const target = join13(staging, key);
4089
4905
  yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
4090
4906
  yield* step(() => fs.copyFile(path, target, constants3.COPYFILE_EXCL));
4091
4907
  if (JSON.stringify(yield* fileIdentityEffect(target, artifact.name)) !== JSON.stringify(artifact))
@@ -4099,13 +4915,13 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4099
4915
  });
4100
4916
  }
4101
4917
  for (const { key, bytes } of documents) {
4102
- const target = join11(staging, key);
4918
+ const target = join13(staging, key);
4103
4919
  yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
4104
4920
  yield* step(() => fs.writeFile(target, bytes, { flag: "wx", mode: 384 }));
4105
4921
  objects.push(describe(key, bytes, MUTABLE));
4106
4922
  }
4107
4923
  const plan = { schema: 1, base: feed.base, objects };
4108
- yield* step(() => fs.writeFile(join11(staging, UPLOAD_PLAN), jsonBytes(plan), { flag: "wx", mode: 384 }));
4924
+ yield* step(() => fs.writeFile(join13(staging, UPLOAD_PLAN), jsonBytes(plan), { flag: "wx", mode: 384 }));
4109
4925
  yield* attempt(() => renameExclusive(staging, root));
4110
4926
  return plan;
4111
4927
  }));
@@ -4113,10 +4929,10 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4113
4929
  return exit.value;
4114
4930
  const error = Cause2.squash(exit.cause);
4115
4931
  const original = error instanceof ReleaseFailure ? error.original ?? error : error;
4116
- const cleanup = yield* Effect20.exit(step(() => fs.rm(staging, { recursive: true, force: true })));
4932
+ const cleanup = yield* Effect21.exit(step(() => fs.rm(staging, { recursive: true, force: true })));
4117
4933
  if (Exit3.isFailure(cleanup)) {
4118
4934
  const cleanupError = Cause2.squash(cleanup.cause);
4119
- return yield* Effect20.fail(new ReleaseFailure({
4935
+ return yield* Effect21.fail(new ReleaseFailure({
4120
4936
  reason: "cleanup",
4121
4937
  message: "Release staging failed and its private temporary tree could not be removed",
4122
4938
  original: new AggregateError([
@@ -4125,8 +4941,8 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4125
4941
  ], "Release staging failed and its private temporary tree could not be removed", { cause: original })
4126
4942
  }));
4127
4943
  }
4128
- return yield* Effect20.failCause(exit.cause);
4129
- }).pipe(Effect20.uninterruptible);
4944
+ return yield* Effect21.failCause(exit.cause);
4945
+ }).pipe(Effect21.uninterruptible);
4130
4946
  function releaseDocuments(feed, ledger, release) {
4131
4947
  return [
4132
4948
  { key: feedReleaseKey(feed, release.tag), bytes: jsonBytes(release) },
@@ -4143,23 +4959,23 @@ function releaseDocuments(feed, ledger, release) {
4143
4959
  }))
4144
4960
  ];
4145
4961
  }
4146
- var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
4962
+ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
4147
4963
  const fs = yield* ReleaseFs;
4148
4964
  const { tag, sourceSha, platform } = options;
4149
4965
  const local = localConfig(options.config);
4150
4966
  const feed = local.feed, now = timestamp2(options.now);
4151
4967
  const payloads = platformPayloads(local.requirements(tag), platform);
4152
4968
  const policies = discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform);
4153
- const directory = resolve8(options.directory);
4969
+ const directory = resolve9(options.directory);
4154
4970
  const names = [...payloads, ...policies.map((policy) => policy.name)];
4155
4971
  yield* exactFiles(directory, names);
4156
- const staged = yield* Effect20.forEach(names, (name) => fileIdentityEffect(join11(directory, name), name), { concurrency: "unbounded" });
4972
+ const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(join13(directory, name), name), { concurrency: "unbounded" });
4157
4973
  for (const policy of policies) {
4158
4974
  const artifact = staged.find((asset) => asset.name === policy.name);
4159
4975
  if (artifact.size > 65536)
4160
4976
  return yield* fail("Signed descriptor is too large");
4161
- const bytes = yield* step(() => fs.readFile(join11(directory, policy.name)));
4162
- if ("sha256:" + createHash8("sha256").update(bytes).digest("hex") !== artifact.digest)
4977
+ const bytes = yield* step(() => fs.readFile(join13(directory, policy.name)));
4978
+ if ("sha256:" + createHash11("sha256").update(bytes).digest("hex") !== artifact.digest)
4163
4979
  return yield* fail("Signed descriptor changed");
4164
4980
  let parsed;
4165
4981
  try {
@@ -4180,7 +4996,7 @@ var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
4180
4996
  if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.sourceSha !== sourceSha || verified.descriptor.workflowSha !== sourceSha || verified.descriptor.asset.name !== payload.name || verified.descriptor.asset.size !== payload.size || "sha256:" + verified.descriptor.asset.sha256 !== payload.digest)
4181
4997
  return yield* fail(`Untrusted signed descriptor: ${policy.name}`);
4182
4998
  }
4183
- const [ledger, remote] = yield* Effect20.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
4999
+ const [ledger, remote] = yield* Effect21.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
4184
5000
  const entry = ledger.releases.find((item) => item.tag === tag);
4185
5001
  if (Boolean(entry) !== Boolean(remote) || entry && remote && (entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt)))
4186
5002
  return yield* fail("Inconsistent feed release; reconcile publication before retrying");
@@ -4198,7 +5014,7 @@ var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
4198
5014
  merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
4199
5015
  uploads.push({
4200
5016
  key: feedAssetKey(feed, tag, artifact.name),
4201
- path: join11(directory, artifact.name),
5017
+ path: join13(directory, artifact.name),
4202
5018
  artifact
4203
5019
  });
4204
5020
  }
@@ -4231,7 +5047,7 @@ function stablePlatforms(config) {
4231
5047
  throw new Error("Invalid stablePlatforms in the release configuration");
4232
5048
  return value;
4233
5049
  }
4234
- var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
5050
+ var verifyLocalReleaseEffect = (options) => Effect21.gen(function* () {
4235
5051
  const local = localConfig(options.config);
4236
5052
  const { release, platforms } = yield* verifyFeedReleaseEffect({
4237
5053
  config: local.config,
@@ -4247,7 +5063,7 @@ var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
4247
5063
  missing: Object.keys(platformTargets).filter((platform) => !platforms.includes(platform))
4248
5064
  };
4249
5065
  });
4250
- var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
5066
+ var runLocalPromotionEffect = (options) => Effect21.gen(function* () {
4251
5067
  const local = localConfig(options.config);
4252
5068
  const feed = local.feed;
4253
5069
  const required = stablePlatforms(local.config);
@@ -4305,7 +5121,7 @@ var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
4305
5121
  const verification = qualified.get(selected.tag);
4306
5122
  const absent = Object.keys(platformTargets).filter((name) => !verification?.platforms.includes(name));
4307
5123
  const entry = ledger.releases.find((item) => item.tag === selected.tag);
4308
- const [currentLedger, remote] = await run(Effect20.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, selected.tag)], {
5124
+ const [currentLedger, remote] = await run(Effect21.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, selected.tag)], {
4309
5125
  concurrency: "unbounded"
4310
5126
  }));
4311
5127
  if (!entry || !remote || !verification || entry.kind === "dev" || JSON.stringify(currentLedger) !== JSON.stringify(ledger) || JSON.stringify(remote) !== JSON.stringify(verification.release))
@@ -4344,7 +5160,7 @@ var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
4344
5160
 
4345
5161
  // src/library/qualification-run.ts
4346
5162
  var REFUSAL = "Qualification requires a GitHub release-assets run, a GitLab tag pipeline or a CircleCI tag workflow";
4347
- var tagRun = (options) => Effect21.gen(function* () {
5163
+ var tagRun = (options) => Effect22.gen(function* () {
4348
5164
  const { tag, sha, runId } = options;
4349
5165
  if (options.tagName !== tag || !isGitSha(sha) || !/^[1-9]\d{0,19}$/.test(runId ?? "") || !/^v\d+\.\d+\.\d+$/.test(tag) || tag.length > 65)
4350
5166
  return yield* fail(REFUSAL);
@@ -4358,7 +5174,7 @@ var tagRun = (options) => Effect21.gen(function* () {
4358
5174
  runAttempt: 1
4359
5175
  };
4360
5176
  });
4361
- var planQualificationRunEffect = (options) => Effect21.gen(function* () {
5177
+ var planQualificationRunEffect = (options) => Effect22.gen(function* () {
4362
5178
  const { env, config, tag } = options;
4363
5179
  if (env.GITHUB_ACTIONS === "true") {
4364
5180
  const plan = yield* planReleaseAssetsEffect({ env, config, tag });
@@ -4391,8 +5207,8 @@ var planQualificationRun2 = (options) => runReleaseLibrary(provideLibraryPorts({
4391
5207
  ...options.git ? { git: options.git } : {}
4392
5208
  })(planQualificationRunEffect(options)));
4393
5209
  // src/library/retained-build.ts
4394
- import { Effect as Effect22 } from "effect";
4395
- var id = (value) => Effect22.gen(function* () {
5210
+ import { Effect as Effect23 } from "effect";
5211
+ var id = (value) => Effect23.gen(function* () {
4396
5212
  if (typeof value === "number" && !Number.isSafeInteger(value))
4397
5213
  return yield* fail("Invalid GitHub identity");
4398
5214
  const text = String(value);
@@ -4400,7 +5216,7 @@ var id = (value) => Effect22.gen(function* () {
4400
5216
  return yield* fail("Invalid GitHub identity");
4401
5217
  return text;
4402
5218
  });
4403
- var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
5219
+ var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
4404
5220
  const { env, config, tag, platform } = options;
4405
5221
  if (!["macos-arm64", "windows-x64", "linux-x64"].includes(platform) || !isRecord(config) || typeof config.appName !== "string" || env.RELEASE_TAG !== tag)
4406
5222
  return yield* fail("Invalid retained build context");
@@ -4518,12 +5334,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
4518
5334
  });
4519
5335
  var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
4520
5336
  // src/library/staging.ts
4521
- import { createHash as createHash9 } from "crypto";
4522
- import { join as join12, resolve as resolve9 } from "path";
4523
- import { Effect as Effect23 } from "effect";
4524
- var copyHashed = (input, output, size) => Effect23.tryPromise({
5337
+ import { createHash as createHash12 } from "crypto";
5338
+ import { join as join14, resolve as resolve10 } from "path";
5339
+ import { Effect as Effect24 } from "effect";
5340
+ var copyHashed = (input, output, size) => Effect24.tryPromise({
4525
5341
  try: async (signal) => {
4526
- const hash = createHash9("sha256");
5342
+ const hash = createHash12("sha256");
4527
5343
  let copied = 0;
4528
5344
  for await (const chunk of input.createReadStream({
4529
5345
  autoClose: false
@@ -4550,14 +5366,14 @@ var copyHashed = (input, output, size) => Effect23.tryPromise({
4550
5366
  original: error
4551
5367
  })
4552
5368
  });
4553
- var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
5369
+ var stageExpectedFilesEffect = (options) => Effect24.gen(function* () {
4554
5370
  const fs = yield* ReleaseFs;
4555
5371
  const { expected } = options;
4556
5372
  if (!expected.length || new Set(expected).size !== expected.length || expected.some((name) => !/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/.test(name)) || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
4557
5373
  return yield* fail("Staging sources do not match expected filenames");
4558
- const directory = resolve9(options.directory);
5374
+ const directory = resolve10(options.directory);
4559
5375
  const created = [];
4560
- const stage = Effect23.forEach(expected, (name) => Effect23.gen(function* () {
5376
+ const stage = Effect24.forEach(expected, (name) => Effect24.gen(function* () {
4561
5377
  const sourcePath = options.sources[name];
4562
5378
  if (typeof sourcePath !== "string" || !sourcePath)
4563
5379
  return yield* fail("Invalid staging source");
@@ -4568,7 +5384,7 @@ var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
4568
5384
  const before = yield* step(() => input.stat());
4569
5385
  if (!before.isFile() || before.dev !== sourceInfo.dev || before.ino !== sourceInfo.ino || before.size !== sourceInfo.size)
4570
5386
  return yield* fail("Staging source changed");
4571
- const target = join12(directory, name);
5387
+ const target = join14(directory, name);
4572
5388
  const output = yield* scopedHandle(() => fs.open(target, "wx"));
4573
5389
  created.push(target);
4574
5390
  const copied = yield* copyHashed(input, output, before.size);
@@ -4577,10 +5393,10 @@ var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
4577
5393
  if (copied.size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.dev !== before.dev || after.ino !== before.ino)
4578
5394
  return yield* fail("Staging source changed");
4579
5395
  return { name, size: copied.size, digest: copied.digest };
4580
- }).pipe(Effect23.scoped), { concurrency: 1 });
4581
- return yield* stage.pipe(Effect23.onError(() => Effect23.promise(() => Promise.all(created.map((path) => fs.rm(path, { force: true }).catch(() => {}))))));
5396
+ }).pipe(Effect24.scoped), { concurrency: 1 });
5397
+ return yield* stage.pipe(Effect24.onError(() => Effect24.promise(() => Promise.all(created.map((path) => fs.rm(path, { force: true }).catch(() => {}))))));
4582
5398
  });
4583
- var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
5399
+ var stagePlatformArtifactsEffect = (options) => Effect24.gen(function* () {
4584
5400
  const requirements = parseReleaseConfig(options.config).requirements(options.tag);
4585
5401
  const expected = platformPayloads(requirements, options.platform);
4586
5402
  if (!expected.length || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
@@ -4589,13 +5405,13 @@ var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
4589
5405
  });
4590
5406
  var stagePlatformArtifacts = (options) => runReleaseLibrary(provideLibraryPorts()(stagePlatformArtifactsEffect(options)));
4591
5407
  // src/library/steps.ts
4592
- import { join as join32 } from "path";
4593
- import { Effect as Effect24 } from "effect";
5408
+ import { join as join34 } from "path";
5409
+ import { Effect as Effect25 } from "effect";
4594
5410
 
4595
5411
  // ../../src/installer/installer-archive-members.ts
4596
- import { createHash as createHash10 } from "crypto";
4597
- import { lstat as lstat6, open as open4 } from "fs/promises";
4598
- import { isAbsolute as isAbsolute3, relative as relative3, sep as sep2 } from "path";
5412
+ import { createHash as createHash13 } from "crypto";
5413
+ import { lstat as lstat7, open as open4 } from "fs/promises";
5414
+ import { isAbsolute as isAbsolute4, relative as relative3, sep as sep2 } from "path";
4599
5415
 
4600
5416
  // ../../src/installer/native-executable.ts
4601
5417
  async function assertNativeExecutable(file, size, platform, what) {
@@ -4619,7 +5435,7 @@ async function assertNativeExecutable(file, size, platform, what) {
4619
5435
  var EMBEDDED_ARCHIVE_MARKER = Buffer.from("ELECTROBUN_ARCHIVE_V1");
4620
5436
  function isWithin(root, path) {
4621
5437
  const rel = relative3(root, path);
4622
- return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !isAbsolute3(rel);
5438
+ return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !isAbsolute4(rel);
4623
5439
  }
4624
5440
  function normalizeArchiveMember(name) {
4625
5441
  return name.replace(/^\.\//, "").replaceAll("\\", "/");
@@ -4635,7 +5451,7 @@ function findArchiveMember(entries, expected, platform, message) {
4635
5451
  return found[0];
4636
5452
  }
4637
5453
  async function assertArchiveUnchanged(archive, before, message) {
4638
- const after = await lstat6(archive);
5454
+ const after = await lstat7(archive);
4639
5455
  if (!after.isFile() || after.isSymbolicLink() || !sameFile(after, before))
4640
5456
  throw new Error(message);
4641
5457
  }
@@ -4681,7 +5497,7 @@ async function extractArchiveMember(options) {
4681
5497
  }
4682
5498
  }
4683
5499
  async function assertInstallerExecutable(path, platform) {
4684
- const info = await lstat6(path);
5500
+ const info = await lstat7(path);
4685
5501
  if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
4686
5502
  throw new Error("Invalid installer executable");
4687
5503
  const file = await open4(path, "r");
@@ -4700,7 +5516,7 @@ async function assertEmbeddedArchive(path, size, archive) {
4700
5516
  const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
4701
5517
  if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
4702
5518
  throw new Error("Installer archive marker is missing");
4703
- const hash = createHash10("sha256");
5519
+ const hash = createHash13("sha256");
4704
5520
  let read = 0;
4705
5521
  for await (const chunk of file.createReadStream({
4706
5522
  start: position + marker.length,
@@ -4717,23 +5533,23 @@ async function assertEmbeddedArchive(path, size, archive) {
4717
5533
  }
4718
5534
 
4719
5535
  // ../../src/installer/installer-identity.ts
4720
- import { lstat as lstat8, mkdtemp as mkdtemp4, readdir as readdir5, realpath } from "fs/promises";
5536
+ import { lstat as lstat9, mkdtemp as mkdtemp4, readdir as readdir6, realpath as realpath2 } from "fs/promises";
4721
5537
  import { tmpdir as tmpdir4 } from "os";
4722
- import { basename as basename5, join as join14, resolve as resolve10, win32 } from "path";
5538
+ import { basename as basename5, join as join16, resolve as resolve11, win32 } from "path";
4723
5539
 
4724
5540
  // ../../src/installer/installer-image-mount.ts
4725
- import { lstat as lstat7, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir4, rm as rm4, stat } from "fs/promises";
4726
- import { dirname as dirname3, join as join13 } from "path";
5541
+ import { lstat as lstat8, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir5, rm as rm4, stat } from "fs/promises";
5542
+ import { dirname as dirname3, join as join15 } from "path";
4727
5543
  var FAILED_ATTACH_PROBES = 5;
4728
5544
  var FAILED_ATTACH_PROBE_INTERVAL_MS = 500;
4729
5545
  async function containsMountAt(path, expectedDevice) {
4730
- const info = await lstat7(path);
5546
+ const info = await lstat8(path);
4731
5547
  if (!info.isDirectory() || info.isSymbolicLink())
4732
5548
  return false;
4733
5549
  if (info.dev !== expectedDevice)
4734
5550
  return true;
4735
- for (const name of await readdir4(path)) {
4736
- const child = join13(path, name), childInfo = await lstat7(child);
5551
+ for (const name of await readdir5(path)) {
5552
+ const child = join15(path, name), childInfo = await lstat8(child);
4737
5553
  if (!childInfo.isDirectory() || childInfo.isSymbolicLink())
4738
5554
  continue;
4739
5555
  if (childInfo.dev !== info.dev || await containsMountAt(child, info.dev))
@@ -4927,8 +5743,8 @@ async function withInstallerImageRetries(options) {
4927
5743
  };
4928
5744
  const priorErrors = () => failedAttempts.map((attempt) => attempt.error);
4929
5745
  for (let attempt = 1;attempt <= maximumAttempts; attempt++) {
4930
- const directory = await mkdtemp3(join13(options.parent, options.prefix));
4931
- const mount = join13(directory, "mount");
5746
+ const directory = await mkdtemp3(join15(options.parent, options.prefix));
5747
+ const mount = join15(directory, "mount");
4932
5748
  const io = options.createIo?.(directory, mount) ?? defaultInstallerImageMountIo(options.run);
4933
5749
  let lifecycleStarted = false;
4934
5750
  try {
@@ -5096,7 +5912,7 @@ async function runInstallerCommand(args, env, options) {
5096
5912
 
5097
5913
  // ../../src/installer/installer-identity.ts
5098
5914
  async function identity(path) {
5099
- const info = await lstat8(path);
5915
+ const info = await lstat9(path);
5100
5916
  if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || !Number.isSafeInteger(info.size))
5101
5917
  throw new Error("Invalid installer artifact");
5102
5918
  const { size, sha256 } = await hashFileAt(path, info, "Installer artifact changed");
@@ -5123,12 +5939,12 @@ async function verifyInstallerPayload(options) {
5123
5939
  else
5124
5940
  assertInstallerContext(parent, options.platform, process.platform, process.arch);
5125
5941
  assertPortableAppName(options.appName);
5126
- const installerPath = resolve10(options.installer), archivePath = resolve10(options.archive);
5942
+ const installerPath = resolve11(options.installer), archivePath = resolve11(options.archive);
5127
5943
  const before = { installer: await identity(installerPath), archive: await identity(archivePath) };
5128
5944
  if (!Number.isSafeInteger(before.archive.size + 256 * 1024 * 1024))
5129
5945
  throw new Error("Installer archive exceeds bound");
5130
5946
  const env = environment(parent);
5131
- const temporary = await mkdtemp4(join14(tmpdir4(), "framework-installer-inspect-"));
5947
+ const temporary = await mkdtemp4(join16(tmpdir4(), "framework-installer-inspect-"));
5132
5948
  const cleanupIo = defaultInstallerImageMountIo(command);
5133
5949
  try {
5134
5950
  if (options.platform === "macos-arm64") {
@@ -5139,24 +5955,24 @@ async function verifyInstallerPayload(options) {
5139
5955
  env,
5140
5956
  run: command,
5141
5957
  work: async (mount) => {
5142
- const apps = (await readdir5(mount)).filter((name) => name.endsWith(".app"));
5958
+ const apps = (await readdir6(mount)).filter((name) => name.endsWith(".app"));
5143
5959
  if (apps.length !== 1)
5144
5960
  throw new Error("Installer application is missing or ambiguous");
5145
- const resources = join14(mount, apps[0], "Contents", "Resources");
5146
- const actualRoot = await realpath(mount), actualApp = await realpath(join14(mount, apps[0])), actualResources = await realpath(resources);
5961
+ const resources = join16(mount, apps[0], "Contents", "Resources");
5962
+ const actualRoot = await realpath2(mount), actualApp = await realpath2(join16(mount, apps[0])), actualResources = await realpath2(resources);
5147
5963
  if (!isWithin(actualRoot, actualApp) || !isWithin(actualApp, actualResources))
5148
5964
  throw new Error("Installer resources escape mounted image");
5149
- const plist = join14(actualApp, "Contents", "Info.plist"), plistInfo = await lstat8(plist);
5965
+ const plist = join16(actualApp, "Contents", "Info.plist"), plistInfo = await lstat9(plist);
5150
5966
  if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
5151
5967
  throw new Error("Invalid installer property list");
5152
5968
  const executable = (await command(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], env)).trim();
5153
5969
  if (!executable || executable === "." || executable === ".." || /[\\/]/.test(executable))
5154
5970
  throw new Error("Invalid installer executable name");
5155
- await assertInstallerExecutable(join14(actualApp, "Contents", "MacOS", executable), options.platform);
5156
- const archives = (await readdir5(actualResources)).filter((name) => name.endsWith(".tar.zst"));
5971
+ await assertInstallerExecutable(join16(actualApp, "Contents", "MacOS", executable), options.platform);
5972
+ const archives = (await readdir6(actualResources)).filter((name) => name.endsWith(".tar.zst"));
5157
5973
  if (archives.length !== 1)
5158
5974
  throw new Error("Installer archive is missing or ambiguous");
5159
- const embedded = await identity(join14(actualResources, archives[0]));
5975
+ const embedded = await identity(join16(actualResources, archives[0]));
5160
5976
  if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
5161
5977
  throw new Error("Installer archive differs from release archive");
5162
5978
  }
@@ -5174,7 +5990,7 @@ async function verifyInstallerPayload(options) {
5174
5990
  const matches = names.filter((name) => candidates.includes(normalizeArchiveMember(name)));
5175
5991
  if (matches.length !== 1)
5176
5992
  throw new Error("Installer archive is missing or ambiguous");
5177
- const extracted = join14(temporary, "member");
5993
+ const extracted = join16(temporary, "member");
5178
5994
  const count = await extractArchiveMember({
5179
5995
  tar,
5180
5996
  archive: installerPath,
@@ -5185,7 +6001,7 @@ async function verifyInstallerPayload(options) {
5185
6001
  });
5186
6002
  if (options.platform === "windows-x64") {
5187
6003
  const setup = findArchiveMember(names, `${options.appName}-Setup.exe`, options.platform, "Installer executable is missing or ambiguous");
5188
- const executable = join14(temporary, "setup.exe");
6004
+ const executable = join16(temporary, "setup.exe");
5189
6005
  await extractArchiveMember({
5190
6006
  tar,
5191
6007
  archive: installerPath,
@@ -5221,19 +6037,19 @@ async function verifyInstallerPayload(options) {
5221
6037
  }
5222
6038
 
5223
6039
  // ../../src/installer/installer-qualification-command.ts
5224
- import { lstat as lstat18, writeFile as writeFile9 } from "fs/promises";
5225
- import { join as join29, resolve as resolve13 } from "path";
6040
+ import { lstat as lstat19, writeFile as writeFile9 } from "fs/promises";
6041
+ import { join as join31, resolve as resolve14 } from "path";
5226
6042
 
5227
6043
  // ../../src/installer/installer-observation.ts
5228
- import { randomBytes as randomBytes2 } from "crypto";
5229
- import { chmod as chmod2, mkdir as mkdir9, readFile as readFile9, realpath as realpath8, writeFile as writeFile8 } from "fs/promises";
6044
+ import { randomBytes as randomBytes3 } from "crypto";
6045
+ import { chmod as chmod2, mkdir as mkdir9, readFile as readFile10, realpath as realpath9, writeFile as writeFile8 } from "fs/promises";
5230
6046
  import { createServer } from "net";
5231
- import { delimiter, dirname as dirname12, join as join28 } from "path";
6047
+ import { delimiter, dirname as dirname12, join as join30 } from "path";
5232
6048
 
5233
6049
  // ../../src/installer/installer-ci-bootstrap.ts
5234
- import { randomBytes } from "crypto";
5235
- import { lstat as lstat9, mkdir as mkdir5, mkdtemp as mkdtemp5, realpath as realpath2, rm as rm5, writeFile as writeFile4 } from "fs/promises";
5236
- import { dirname as dirname4, isAbsolute as isAbsolute4, join as join15, relative as relative4, sep as sep3 } from "path";
6050
+ import { randomBytes as randomBytes2 } from "crypto";
6051
+ import { lstat as lstat10, mkdir as mkdir5, mkdtemp as mkdtemp5, realpath as realpath3, rm as rm5, writeFile as writeFile4 } from "fs/promises";
6052
+ import { dirname as dirname4, isAbsolute as isAbsolute5, join as join17, relative as relative4, sep as sep3 } from "path";
5237
6053
  import { fileURLToPath } from "url";
5238
6054
  var bootstrapModules = [
5239
6055
  "app/value-guards.js",
@@ -5256,27 +6072,27 @@ async function prepareInstallerCiBootstrap(env = process.env) {
5256
6072
  const temp = runnerTemp(env);
5257
6073
  if (!isHostedRunner(env) || !temp)
5258
6074
  throw new Error("Installer bootstrap requires a disposable hosted runner");
5259
- const parent = await realpath2(temp);
5260
- if (/\s/.test(parent) || !(await lstat9(parent)).isDirectory())
6075
+ const parent = await realpath3(temp);
6076
+ if (/\s/.test(parent) || !(await lstat10(parent)).isDirectory())
5261
6077
  throw new Error("Runner temp cannot represent a Bun preload path");
5262
6078
  const source = dirname4(dirname4(fileURLToPath(import.meta.url)));
5263
- const directory = await mkdtemp5(join15(parent, "framework-ci-"));
6079
+ const directory = await mkdtemp5(join17(parent, "framework-ci-"));
5264
6080
  try {
5265
6081
  for (const name of bootstrapModules) {
5266
- const contents = await readBoundedFile(join15(source, name), 2 * 1024 * 1024, "installer bootstrap module");
5267
- await mkdir5(dirname4(join15(directory, name)), { recursive: true, mode: 448 });
5268
- await writeFile4(join15(directory, name), contents, { flag: "wx", mode: 384 });
6082
+ const contents = await readBoundedFile(join17(source, name), 2 * 1024 * 1024, "installer bootstrap module");
6083
+ await mkdir5(dirname4(join17(directory, name)), { recursive: true, mode: 448 });
6084
+ await writeFile4(join17(directory, name), contents, { flag: "wx", mode: 384 });
5269
6085
  }
5270
- await writeFile4(join15(directory, "package.json"), `{"type":"module"}
6086
+ await writeFile4(join17(directory, "package.json"), `{"type":"module"}
5271
6087
  `, {
5272
6088
  flag: "wx",
5273
6089
  mode: 384
5274
6090
  });
5275
- const worker = join15(directory, "installer/installer-ci-worker.js");
6091
+ const worker = join17(directory, "installer/installer-ci-worker.js");
5276
6092
  return {
5277
6093
  directory,
5278
6094
  worker,
5279
- preflight: join15(directory, "installer/installer-ci-preflight.js"),
6095
+ preflight: join17(directory, "installer/installer-ci-preflight.js"),
5280
6096
  bunOptions: `--preload=${worker}`
5281
6097
  };
5282
6098
  } catch (error) {
@@ -5287,11 +6103,11 @@ async function prepareInstallerCiBootstrap(env = process.env) {
5287
6103
  async function preflightInstallerRuntime(options) {
5288
6104
  const { env, runtime, bootstrap } = options;
5289
6105
  const temp = runnerTemp(env);
5290
- if (!isHostedRunner(env) || !temp || !isAbsolute4(runtime))
6106
+ if (!isHostedRunner(env) || !temp || !isAbsolute5(runtime))
5291
6107
  throw new Error("Runtime preflight requires a disposable hosted runner");
5292
- const tempRoot = await realpath2(temp), bootstrapRoot = await realpath2(bootstrap.directory);
6108
+ const tempRoot = await realpath3(temp), bootstrapRoot = await realpath3(bootstrap.directory);
5293
6109
  const relativeBootstrap = relative4(tempRoot, bootstrapRoot);
5294
- if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute4(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !== join15(bootstrapRoot, "installer/installer-ci-worker.js") || bootstrap.preflight !== join15(bootstrapRoot, "installer/installer-ci-preflight.js") || bootstrap.bunOptions !== `--preload=${bootstrap.worker}`)
6110
+ if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute5(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !== join17(bootstrapRoot, "installer/installer-ci-worker.js") || bootstrap.preflight !== join17(bootstrapRoot, "installer/installer-ci-preflight.js") || bootstrap.bunOptions !== `--preload=${bootstrap.worker}`)
5295
6111
  throw new Error("Invalid installer bootstrap location");
5296
6112
  await runInstallerPreflight({
5297
6113
  env,
@@ -5304,14 +6120,14 @@ async function preflightInstallerRuntime(options) {
5304
6120
  async function runInstallerPreflight(options) {
5305
6121
  const { env, runtime, worker, preflight } = options;
5306
6122
  for (const path of [worker, preflight]) {
5307
- const item = await lstat9(path);
6123
+ const item = await lstat10(path);
5308
6124
  if (!item.isFile() || item.isSymbolicLink())
5309
6125
  throw new Error("Invalid installer bootstrap module");
5310
6126
  }
5311
- const info = await lstat9(runtime);
6127
+ const info = await lstat10(runtime);
5312
6128
  if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
5313
6129
  throw new Error("Invalid candidate Bun runtime");
5314
- const temporary = await mkdtemp5(join15(options.parent, "framework-preflight-"));
6130
+ const temporary = await mkdtemp5(join17(options.parent, "framework-preflight-"));
5315
6131
  try {
5316
6132
  const clean = {};
5317
6133
  for (const key of [
@@ -5328,7 +6144,7 @@ async function runInstallerPreflight(options) {
5328
6144
  ])
5329
6145
  if (env[key])
5330
6146
  clean[key] = env[key];
5331
- const nonce = randomBytes(24).toString("hex");
6147
+ const nonce = randomBytes2(24).toString("hex");
5332
6148
  Object.assign(clean, {
5333
6149
  CI: "true",
5334
6150
  GITHUB_ACTIONS: "true",
@@ -5336,11 +6152,11 @@ async function runInstallerPreflight(options) {
5336
6152
  BUN_OPTIONS: `--preload=${worker}`,
5337
6153
  FRAMEWORK_CI_WORKER_ENTRY: preflight,
5338
6154
  FRAMEWORK_CI_NONCE: nonce,
5339
- FRAMEWORK_CI_ACK: join15(temporary, "ack"),
5340
- FRAMEWORK_CI_PERMIT: join15(temporary, "permit"),
6155
+ FRAMEWORK_CI_ACK: join17(temporary, "ack"),
6156
+ FRAMEWORK_CI_PERMIT: join17(temporary, "permit"),
5341
6157
  FRAMEWORK_CI_ORIGIN: "http://127.0.0.1:48999",
5342
- FRAMEWORK_CI_OBSERVATION: join15(temporary, "observation"),
5343
- FRAMEWORK_CI_UNEXPECTED: join15(temporary, "unexpected"),
6158
+ FRAMEWORK_CI_OBSERVATION: join17(temporary, "observation"),
6159
+ FRAMEWORK_CI_UNEXPECTED: join17(temporary, "unexpected"),
5344
6160
  FRAMEWORK_CI_EXPECTED_READS: JSON.stringify([
5345
6161
  "https://example.invalid/framework-ci-sentinel"
5346
6162
  ])
@@ -5375,7 +6191,7 @@ async function runInstallerPreflight(options) {
5375
6191
  if (status !== 0 || !stdout.includes("framework installer preload preflight passed"))
5376
6192
  throw new Error("Candidate Bun runtime failed installer preflight");
5377
6193
  try {
5378
- await lstat9(join15(temporary, "unexpected"));
6194
+ await lstat10(join17(temporary, "unexpected"));
5379
6195
  throw new Error("Runtime preflight recorded unexpected activity");
5380
6196
  } catch (error) {
5381
6197
  if (errorCode(error) !== "ENOENT")
@@ -5387,8 +6203,8 @@ async function runInstallerPreflight(options) {
5387
6203
  }
5388
6204
 
5389
6205
  // ../../src/installer/installer-extraction.ts
5390
- import { chmod, lstat as lstat10, mkdir as mkdir6, mkdtemp as mkdtemp6, readdir as readdir6, realpath as realpath3 } from "fs/promises";
5391
- import { join as join16, resolve as resolve11, win32 as win322 } from "path";
6206
+ import { chmod, lstat as lstat11, mkdir as mkdir6, mkdtemp as mkdtemp6, readdir as readdir7, realpath as realpath4 } from "fs/promises";
6207
+ import { join as join18, resolve as resolve12, win32 as win322 } from "path";
5392
6208
  async function run(cmd, env) {
5393
6209
  return runInstallerCommand(cmd, env, {
5394
6210
  outputLimit: 8 * 1024 * 1024,
@@ -5396,8 +6212,8 @@ async function run(cmd, env) {
5396
6212
  failureMessage: "Installer preparation command failed"
5397
6213
  });
5398
6214
  }
5399
- async function digest2(path) {
5400
- const info = await lstat10(path);
6215
+ async function digest3(path) {
6216
+ const info = await lstat11(path);
5401
6217
  if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1)
5402
6218
  throw new Error("Invalid extracted file");
5403
6219
  const { size, sha256 } = await hashFileAt(path, info, "Extracted file changed");
@@ -5431,8 +6247,8 @@ async function prepareInstallerExecution(options) {
5431
6247
  const temp = runnerTemp(env);
5432
6248
  if (!temp)
5433
6249
  throw new Error("Missing runner temp directory");
5434
- const parent = await realpath3(temp), sourceInstaller = resolve11(options.installer), sourceArchive = resolve11(options.archive);
5435
- if (!(await lstat10(parent)).isDirectory())
6250
+ const parent = await realpath4(temp), sourceInstaller = resolve12(options.installer), sourceArchive = resolve12(options.archive);
6251
+ if (!(await lstat11(parent)).isDirectory())
5436
6252
  throw new Error("Invalid runner temp directory");
5437
6253
  const verified = await verifyInstallerPayload({
5438
6254
  ...options,
@@ -5440,10 +6256,10 @@ async function prepareInstallerExecution(options) {
5440
6256
  archive: sourceArchive,
5441
6257
  env
5442
6258
  });
5443
- const directory = await mkdtemp6(join16(parent, "framework-installer-"));
6259
+ const directory = await mkdtemp6(join18(parent, "framework-installer-"));
5444
6260
  const imageIo = defaultInstallerImageMountIo(run);
5445
6261
  try {
5446
- const profile = join16(directory, "profile"), incoming = join16(directory, "incoming");
6262
+ const profile = join18(directory, "profile"), incoming = join18(directory, "incoming");
5447
6263
  await mkdir6(profile, { mode: 448 });
5448
6264
  await mkdir6(incoming, { mode: 448 });
5449
6265
  const clean = cleanEnv(env);
@@ -5456,34 +6272,34 @@ async function prepareInstallerExecution(options) {
5456
6272
  env: clean,
5457
6273
  run,
5458
6274
  work: async (mount) => {
5459
- const appName = `${options.appName}.app`, apps = (await readdir6(mount)).filter((name) => name.endsWith(".app"));
6275
+ const appName = `${options.appName}.app`, apps = (await readdir7(mount)).filter((name) => name.endsWith(".app"));
5460
6276
  if (apps.length !== 1 || apps[0] !== appName)
5461
6277
  throw new Error("Unexpected installer application");
5462
- const sourceApp = await realpath3(join16(mount, appName)), mountRoot = await realpath3(mount);
6278
+ const sourceApp = await realpath4(join18(mount, appName)), mountRoot = await realpath4(mount);
5463
6279
  if (!isWithin(mountRoot, sourceApp))
5464
6280
  throw new Error("Installer application escapes image");
5465
- const app = join16(incoming, appName);
6281
+ const app = join18(incoming, appName);
5466
6282
  await run(["/usr/bin/ditto", sourceApp, app], clean);
5467
- const actualApp = await realpath3(app), resources = await realpath3(join16(actualApp, "Contents", "Resources"));
5468
- if (!isWithin(await realpath3(incoming), actualApp) || !isWithin(actualApp, resources))
6283
+ const actualApp = await realpath4(app), resources = await realpath4(join18(actualApp, "Contents", "Resources"));
6284
+ if (!isWithin(await realpath4(incoming), actualApp) || !isWithin(actualApp, resources))
5469
6285
  throw new Error("Copied installer escapes profile");
5470
- const plist = join16(actualApp, "Contents", "Info.plist"), plistInfo = await lstat10(plist);
6286
+ const plist = join18(actualApp, "Contents", "Info.plist"), plistInfo = await lstat11(plist);
5471
6287
  if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
5472
6288
  throw new Error("Invalid installer property list");
5473
6289
  const name = (await run(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], clean)).trim();
5474
6290
  if (!name || name === "." || name === ".." || /[\\/]/.test(name))
5475
6291
  throw new Error("Invalid installer executable");
5476
- const appExecutable = join16(actualApp, "Contents", "MacOS", name);
5477
- const sourceExecutable = join16(sourceApp, "Contents", "MacOS", name);
5478
- if (!isWithin(actualApp, await realpath3(appExecutable)) || !isWithin(sourceApp, await realpath3(sourceExecutable)))
6292
+ const appExecutable = join18(actualApp, "Contents", "MacOS", name);
6293
+ const sourceExecutable = join18(sourceApp, "Contents", "MacOS", name);
6294
+ if (!isWithin(actualApp, await realpath4(appExecutable)) || !isWithin(sourceApp, await realpath4(sourceExecutable)))
5479
6295
  throw new Error("Installer executable escapes application");
5480
6296
  await assertInstallerExecutable(appExecutable, options.platform);
5481
- if (JSON.stringify(await digest2(sourceExecutable)) !== JSON.stringify(await digest2(appExecutable)))
6297
+ if (JSON.stringify(await digest3(sourceExecutable)) !== JSON.stringify(await digest3(appExecutable)))
5482
6298
  throw new Error("Copied installer executable differs");
5483
- const archives = (await readdir6(resources)).filter((value) => value.endsWith(".tar.zst"));
6299
+ const archives = (await readdir7(resources)).filter((value) => value.endsWith(".tar.zst"));
5484
6300
  if (archives.length !== 1)
5485
6301
  throw new Error("Missing installer archive");
5486
- const embedded = await digest2(join16(resources, archives[0]));
6302
+ const embedded = await digest3(join18(resources, archives[0]));
5487
6303
  if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
5488
6304
  throw new Error("Copied installer archive differs");
5489
6305
  return executable;
@@ -5498,9 +6314,9 @@ async function prepareInstallerExecution(options) {
5498
6314
  assertInstallerLayout(options.platform, options.appName, names);
5499
6315
  const find = (name) => findArchiveMember(names, name, options.platform, "Installer member missing or ambiguous");
5500
6316
  if (options.platform === "windows-x64") {
5501
- const subdirectory = join16(incoming, ".installer");
6317
+ const subdirectory = join18(incoming, ".installer");
5502
6318
  await mkdir6(subdirectory);
5503
- executable = join16(incoming, `${options.appName}-Setup.exe`);
6319
+ executable = join18(incoming, `${options.appName}-Setup.exe`);
5504
6320
  await extractArchiveMember({
5505
6321
  tar,
5506
6322
  archive: sourceInstaller,
@@ -5514,11 +6330,11 @@ async function prepareInstallerExecution(options) {
5514
6330
  tar,
5515
6331
  archive: sourceInstaller,
5516
6332
  member: find(`.installer/${options.appName}-Setup.metadata.json`),
5517
- destination: join16(subdirectory, `${options.appName}-Setup.metadata.json`),
6333
+ destination: join18(subdirectory, `${options.appName}-Setup.metadata.json`),
5518
6334
  maximum: 1024 * 1024,
5519
6335
  env: clean
5520
6336
  });
5521
- const embeddedPath = join16(subdirectory, `${options.appName}-Setup.tar.zst`);
6337
+ const embeddedPath = join18(subdirectory, `${options.appName}-Setup.tar.zst`);
5522
6338
  await extractArchiveMember({
5523
6339
  tar,
5524
6340
  archive: sourceInstaller,
@@ -5527,11 +6343,11 @@ async function prepareInstallerExecution(options) {
5527
6343
  maximum: verified.archive.size,
5528
6344
  env: clean
5529
6345
  });
5530
- const embedded = await digest2(embeddedPath);
6346
+ const embedded = await digest3(embeddedPath);
5531
6347
  if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
5532
6348
  throw new Error("Copied installer archive differs");
5533
6349
  } else {
5534
- executable = join16(incoming, "installer");
6350
+ executable = join18(incoming, "installer");
5535
6351
  await extractArchiveMember({
5536
6352
  tar,
5537
6353
  archive: sourceInstaller,
@@ -5541,7 +6357,7 @@ async function prepareInstallerExecution(options) {
5541
6357
  env: clean
5542
6358
  });
5543
6359
  await assertInstallerExecutable(executable, options.platform);
5544
- await assertEmbeddedArchive(executable, (await lstat10(executable)).size, verified.archive);
6360
+ await assertEmbeddedArchive(executable, (await lstat11(executable)).size, verified.archive);
5545
6361
  await chmod(executable, 448);
5546
6362
  }
5547
6363
  }
@@ -5587,10 +6403,10 @@ function assertInstallerRendererObservation(value, offline = false) {
5587
6403
  }
5588
6404
 
5589
6405
  // ../../src/installer/installed-payload.ts
5590
- import { createHash as createHash11 } from "crypto";
5591
- import { lstat as lstat11, open as open5, realpath as realpath4, rm as rm6 } from "fs/promises";
6406
+ import { createHash as createHash14 } from "crypto";
6407
+ import { lstat as lstat12, open as open5, realpath as realpath5, rm as rm6 } from "fs/promises";
5592
6408
  import { once } from "events";
5593
- import { join as join17, resolve as resolve12 } from "path";
6409
+ import { join as join19, resolve as resolve13 } from "path";
5594
6410
  import { createZstdDecompress } from "zlib";
5595
6411
  import { Parser } from "tar";
5596
6412
  function cleanEnv2(parent, forceLocal) {
@@ -5613,7 +6429,7 @@ async function command2(args, env, limit, collect) {
5613
6429
  const errors = (async () => {
5614
6430
  for await (const _part of child.stderr) {}
5615
6431
  })();
5616
- const hash = createHash11("sha256"), chunks = [];
6432
+ const hash = createHash14("sha256"), chunks = [];
5617
6433
  let size = 0;
5618
6434
  try {
5619
6435
  for await (const part of child.stdout) {
@@ -5636,7 +6452,7 @@ async function command2(args, env, limit, collect) {
5636
6452
  }
5637
6453
  }
5638
6454
  async function listArchive(archive, platform, env) {
5639
- const archiveInfo = await lstat11(archive);
6455
+ const archiveInfo = await lstat12(archive);
5640
6456
  if (!archiveInfo.isFile() || archiveInfo.isSymbolicLink() || archiveInfo.size < 1)
5641
6457
  throw new Error("Invalid staged archive");
5642
6458
  const version = await command2(["tar", "--version"], cleanEnv2(env, false), 65536, true);
@@ -5667,7 +6483,7 @@ async function readMembers(archive, limits, collect) {
5667
6483
  failure ??= new Error("Archive member missing or ambiguous");
5668
6484
  return entry.resume();
5669
6485
  }
5670
- const hash = createHash11("sha256"), chunks = [];
6486
+ const hash = createHash14("sha256"), chunks = [];
5671
6487
  const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
5672
6488
  members.set(entry.path, member);
5673
6489
  entry.on("data", (chunk) => {
@@ -5705,14 +6521,14 @@ async function readMembers(archive, limits, collect) {
5705
6521
  return members;
5706
6522
  }
5707
6523
  async function installed(path, root, limit) {
5708
- const info = await lstat11(path);
5709
- if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1 || info.size > limit || !isWithin(root, await realpath4(path)))
6524
+ const info = await lstat12(path);
6525
+ if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1 || info.size > limit || !isWithin(root, await realpath5(path)))
5710
6526
  throw new Error("Invalid installed file");
5711
6527
  const { size, sha256 } = await hashFileAt(path, info, "Installed file changed");
5712
6528
  return { digest: sha256, size };
5713
6529
  }
5714
6530
  async function assertRuntimeBinary(path, platform) {
5715
- const info = await lstat11(path), file = await open5(path, "r");
6531
+ const info = await lstat12(path), file = await open5(path, "r");
5716
6532
  try {
5717
6533
  await assertNativeExecutable(file, info.size, platform, "runtime executable");
5718
6534
  } finally {
@@ -5726,8 +6542,8 @@ async function verifyInstalledPayload(options) {
5726
6542
  const sidecars = assertSidecarNames(options.sidecars ?? [], options.platform).map((name) => sidecarBundlePath(name, options.platform));
5727
6543
  if (!/^\d+\.\d+\.\d+$/.test(options.version) || options.version.length > 64)
5728
6544
  throw new Error("Invalid installed version");
5729
- const profile = await realpath4(options.profile), root = await realpath4(options.installedRoot), archive = resolve12(options.archive);
5730
- if (!(await lstat11(profile)).isDirectory() || !(await lstat11(root)).isDirectory() || !isWithin(profile, root))
6545
+ const profile = await realpath5(options.profile), root = await realpath5(options.installedRoot), archive = resolve13(options.archive);
6546
+ if (!(await lstat12(profile)).isDirectory() || !(await lstat12(root)).isDirectory() || !isWithin(profile, root))
5731
6547
  throw new Error("Installed root escapes isolated profile");
5732
6548
  const { archiveInfo, entries } = await listArchive(archive, options.platform, env);
5733
6549
  assertPayloadLayout({
@@ -5761,7 +6577,7 @@ async function verifyInstalledPayload(options) {
5761
6577
  const member = members.get(path);
5762
6578
  if (!member || member.count !== 1)
5763
6579
  throw new Error("Archive member missing or ambiguous");
5764
- const current = await installed(join17(root, name), root, limit);
6580
+ const current = await installed(join19(root, name), root, limit);
5765
6581
  if (member.size !== current.size || member.digest !== current.digest)
5766
6582
  throw new Error(`Installed file differs from archive: ${name}`);
5767
6583
  if (name === "Resources/version.json") {
@@ -5783,8 +6599,8 @@ async function extractCandidateRuntime(options) {
5783
6599
  const temp = runnerTemp(env);
5784
6600
  if (!temp)
5785
6601
  throw new Error("Missing runner temp directory");
5786
- const tempRoot = await realpath4(temp), profile = await realpath4(options.profile), archive = resolve12(options.archive);
5787
- if (!isWithin(tempRoot, profile) || !(await lstat11(profile)).isDirectory())
6602
+ const tempRoot = await realpath5(temp), profile = await realpath5(options.profile), archive = resolve13(options.archive);
6603
+ if (!isWithin(tempRoot, profile) || !(await lstat12(profile)).isDirectory())
5788
6604
  throw new Error("Runtime profile escapes runner temp");
5789
6605
  const { archiveInfo, tarEnv, entries } = await listArchive(archive, options.platform, env);
5790
6606
  assertPayloadLayout({
@@ -5796,7 +6612,7 @@ async function extractCandidateRuntime(options) {
5796
6612
  const prefix = options.platform === "macos-arm64" ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
5797
6613
  const expected = `${prefix}/bun${suffix}`;
5798
6614
  const member = findArchiveMember(entries, expected, options.platform, "Runtime archive member missing or ambiguous");
5799
- const destination = join17(profile, `candidate-bun${suffix}`), output = await open5(destination, "wx", 448);
6615
+ const destination = join19(profile, `candidate-bun${suffix}`), output = await open5(destination, "wx", 448);
5800
6616
  const spawn = () => Bun.spawn({
5801
6617
  cmd: ["tar", "--zstd", "-xOf", archive, "--", member],
5802
6618
  env: tarEnv,
@@ -5809,7 +6625,7 @@ async function extractCandidateRuntime(options) {
5809
6625
  const child = spawn(), errors = (async () => {
5810
6626
  for await (const _part of child.stderr) {}
5811
6627
  })();
5812
- const hash = createHash11("sha256");
6628
+ const hash = createHash14("sha256");
5813
6629
  let size = 0;
5814
6630
  try {
5815
6631
  for await (const part of child.stdout) {
@@ -5852,8 +6668,8 @@ async function extractCandidateRuntime(options) {
5852
6668
 
5853
6669
  // ../../src/installer/installer-process-cleanup.ts
5854
6670
  import { execFile as execFile2 } from "child_process";
5855
- import { realpath as realpath5 } from "fs/promises";
5856
- import { promisify } from "util";
6671
+ import { realpath as realpath6 } from "fs/promises";
6672
+ import { promisify as promisify2 } from "util";
5857
6673
 
5858
6674
  // ../../src/native/windows-process.ts
5859
6675
  import { dlopen as dlopen2, FFIType as FFIType2, ptr as ptr2 } from "bun:ffi";
@@ -5897,7 +6713,7 @@ function windowsProcessImage(pid, options) {
5897
6713
  }
5898
6714
 
5899
6715
  // ../../src/installer/installer-process-cleanup.ts
5900
- var execute = promisify(execFile2);
6716
+ var execute = promisify2(execFile2);
5901
6717
  async function terminateGuardedWorker(options) {
5902
6718
  const { pid, runtime, platform } = options;
5903
6719
  assertInstallerContext(options.env, platform, process.platform, process.arch);
@@ -5918,7 +6734,7 @@ async function terminateGuardedWorker(options) {
5918
6734
  ])
5919
6735
  if (options.env[name])
5920
6736
  env[name] = options.env[name];
5921
- const expected = await realpath5(runtime);
6737
+ const expected = await realpath6(runtime);
5922
6738
  const actual = await runningExecutable(pid, platform, env);
5923
6739
  if (actual === undefined)
5924
6740
  return;
@@ -5969,7 +6785,7 @@ async function readMacosState(pid, env) {
5969
6785
  }
5970
6786
  async function runningExecutable(pid, platform, env) {
5971
6787
  if (platform === "linux-x64" || platform === "linux-arm64")
5972
- return realpath5(`/proc/${pid}/exe`).catch((error) => {
6788
+ return realpath6(`/proc/${pid}/exe`).catch((error) => {
5973
6789
  if (error.code === "ENOENT")
5974
6790
  return;
5975
6791
  throw error;
@@ -5987,7 +6803,7 @@ async function runningExecutable(pid, platform, env) {
5987
6803
  if (!listed)
5988
6804
  return;
5989
6805
  const state = macosProcess(listed.stdout);
5990
- return state === EXITING || state === undefined ? state : realpath5(state);
6806
+ return state === EXITING || state === undefined ? state : realpath6(state);
5991
6807
  }
5992
6808
  return windowsRunningExecutable(pid);
5993
6809
  }
@@ -5998,12 +6814,12 @@ async function windowsRunningExecutable(pid) {
5998
6814
  } catch (error) {
5999
6815
  throw new Error("Unable to query guarded process executable", { cause: error });
6000
6816
  }
6001
- return image === "missing" ? undefined : realpath5(image);
6817
+ return image === "missing" ? undefined : realpath6(image);
6002
6818
  }
6003
6819
 
6004
6820
  // ../../src/updates/install/update-swap-stage.ts
6005
- import { lstat as lstat17, mkdtemp as mkdtemp8, readFile as readFile8, realpath as realpath7, rm as rm8 } from "fs/promises";
6006
- import { join as join27 } from "path";
6821
+ import { lstat as lstat18, mkdtemp as mkdtemp8, readFile as readFile9, realpath as realpath8, rm as rm8 } from "fs/promises";
6822
+ import { join as join29 } from "path";
6007
6823
 
6008
6824
  // ../../src/updates/install/update-handoff-plan.ts
6009
6825
  import { basename as basename6 } from "path";
@@ -6042,10 +6858,10 @@ function planUpdateHandoff(options) {
6042
6858
  }
6043
6859
 
6044
6860
  // ../../src/updates/install/update-extraction.ts
6045
- import { createHash as createHash12 } from "crypto";
6861
+ import { createHash as createHash15 } from "crypto";
6046
6862
  import { constants as constants4 } from "fs";
6047
- import { lstat as lstat12, mkdir as mkdir7, mkdtemp as mkdtemp7, open as open6, readFile as readFile6, realpath as realpath6, rm as rm7, symlink } from "fs/promises";
6048
- import { isAbsolute as isAbsolute5, join as join18 } from "path";
6863
+ import { lstat as lstat13, mkdir as mkdir7, mkdtemp as mkdtemp7, open as open6, readFile as readFile7, realpath as realpath7, rm as rm7, symlink } from "fs/promises";
6864
+ import { isAbsolute as isAbsolute6, join as join20 } from "path";
6049
6865
  import { Transform } from "stream";
6050
6866
  import { pipeline } from "stream/promises";
6051
6867
  import { createZstdDecompress as createZstdDecompress2 } from "zlib";
@@ -6074,12 +6890,12 @@ async function extractVerifiedUpdate(options) {
6074
6890
  "linux-x64": ["linux", "x64"],
6075
6891
  "linux-arm64": ["linux", "arm64"]
6076
6892
  };
6077
- if (!isVerifiedRelease(descriptor) || !expected[platform] || descriptor.platform !== expected[platform][0] || descriptor.arch !== expected[platform][1] || !isAbsolute5(archive) || !isAbsolute5(options.directory) || !Number.isSafeInteger(maxCompressedBytes) || maxCompressedBytes < 1 || descriptor.asset.size > maxCompressedBytes || !Number.isSafeInteger(maxExpandedBytes) || maxExpandedBytes < 1)
6893
+ if (!isVerifiedRelease(descriptor) || !expected[platform] || descriptor.platform !== expected[platform][0] || descriptor.arch !== expected[platform][1] || !isAbsolute6(archive) || !isAbsolute6(options.directory) || !Number.isSafeInteger(maxCompressedBytes) || maxCompressedBytes < 1 || descriptor.asset.size > maxCompressedBytes || !Number.isSafeInteger(maxExpandedBytes) || maxExpandedBytes < 1)
6078
6894
  throw new Error("Invalid update extraction context");
6079
6895
  assertPortableAppName(appName);
6080
6896
  const sidecars = assertSidecarNames(options.sidecars ?? [], platform);
6081
6897
  const archiveRoot = platform === "macos-arm64" ? `${appName}.app` : appName.replaceAll(" ", "");
6082
- const info = await lstat12(archive);
6898
+ const info = await lstat13(archive);
6083
6899
  if (!info.isFile() || info.isSymbolicLink() || info.size !== descriptor.asset.size)
6084
6900
  throw new Error("Invalid update archive");
6085
6901
  const file = await open6(archive, constants4.O_RDONLY | (constants4.O_NOFOLLOW ?? 0));
@@ -6088,11 +6904,11 @@ async function extractVerifiedUpdate(options) {
6088
6904
  const before = await file.stat();
6089
6905
  if (!before.isFile() || before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size || !await verifyReleaseStream(file.createReadStream({ autoClose: false, start: 0 }), descriptor))
6090
6906
  throw new Error("Update archive verification failed");
6091
- const parent = await realpath6(options.directory);
6092
- if (!(await lstat12(parent)).isDirectory())
6907
+ const parent = await realpath7(options.directory);
6908
+ if (!(await lstat13(parent)).isDirectory())
6093
6909
  throw new Error("Invalid update staging directory");
6094
- directory = await mkdtemp7(join18(parent, "framework-update-extract-"));
6095
- const payloadRoot = join18(directory, "payload"), decompressed = join18(directory, "payload.tar");
6910
+ directory = await mkdtemp7(join20(parent, "framework-update-extract-"));
6911
+ const payloadRoot = join20(directory, "payload"), decompressed = join20(directory, "payload.tar");
6096
6912
  await mkdir7(payloadRoot, { mode: 448 });
6097
6913
  const entries = [], links = [], seen = new Set, fold = platform === "windows-x64";
6098
6914
  let invalid = false;
@@ -6110,7 +6926,7 @@ async function extractVerifiedUpdate(options) {
6110
6926
  done(null, chunk);
6111
6927
  }
6112
6928
  });
6113
- const hash = createHash12("sha256");
6929
+ const hash = createHash15("sha256");
6114
6930
  let compressedBytes = 0;
6115
6931
  const verifyInput = new Transform({
6116
6932
  transform(chunk, _encoding, done) {
@@ -6210,14 +7026,14 @@ async function extractVerifiedUpdate(options) {
6210
7026
  if (invalid)
6211
7027
  throw new Error("Unsafe or unsupported update archive entry");
6212
7028
  if (links.length) {
6213
- const bin = join18(payloadRoot, archiveRoot, "bin"), cef = join18(bin, "cef");
6214
- for (const path of [join18(payloadRoot, archiveRoot), bin, cef]) {
6215
- const value = await lstat12(path);
7029
+ const bin = join20(payloadRoot, archiveRoot, "bin"), cef = join20(bin, "cef");
7030
+ for (const path of [join20(payloadRoot, archiveRoot), bin, cef]) {
7031
+ const value = await lstat13(path);
6216
7032
  if (!value.isDirectory() || value.isSymbolicLink())
6217
7033
  throw new Error("Invalid CEF link directory");
6218
7034
  }
6219
7035
  for (const link of links) {
6220
- const destination = join18(payloadRoot, link.path), target = join18(bin, link.target), value = await lstat12(target);
7036
+ const destination = join20(payloadRoot, link.path), target = join20(bin, link.target), value = await lstat13(target);
6221
7037
  if (!value.isFile() || value.isSymbolicLink())
6222
7038
  throw new Error("Invalid CEF link target");
6223
7039
  await symlink(link.target, destination);
@@ -6225,12 +7041,12 @@ async function extractVerifiedUpdate(options) {
6225
7041
  }
6226
7042
  await rm7(decompressed);
6227
7043
  assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
6228
- const prefix = platform === "macos-arm64" ? join18(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
6229
- const resources = join18(payloadRoot, prefix, "Resources");
7044
+ const prefix = platform === "macos-arm64" ? join20(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
7045
+ const resources = join20(payloadRoot, prefix, "Resources");
6230
7046
  const bin = platform === "macos-arm64" ? "MacOS" : "bin", suffix = platform === "windows-x64" ? ".exe" : "";
6231
7047
  const executables = [
6232
- join18(bin, `launcher${suffix}`),
6233
- join18(bin, `bun${suffix}`),
7048
+ join20(bin, `launcher${suffix}`),
7049
+ join20(bin, `bun${suffix}`),
6234
7050
  ...sidecars.map((name) => sidecarBundlePath(name, platform))
6235
7051
  ];
6236
7052
  const critical = [
@@ -6240,21 +7056,21 @@ async function extractVerifiedUpdate(options) {
6240
7056
  "Resources/app/client/index.html"
6241
7057
  ];
6242
7058
  for (const path of critical) {
6243
- const item = await lstat12(join18(payloadRoot, prefix, path));
7059
+ const item = await lstat13(join20(payloadRoot, prefix, path));
6244
7060
  if (!item.isFile() || item.isSymbolicLink() || item.size < 1 || platform !== "windows-x64" && process.platform !== "win32" && executables.includes(path) && !(item.mode & 64))
6245
7061
  throw new Error("Invalid critical update file");
6246
7062
  }
6247
7063
  for (const name of ["version.json", "build.json"]) {
6248
- const metadata = await lstat12(join18(resources, name));
7064
+ const metadata = await lstat13(join20(resources, name));
6249
7065
  if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size < 1 || metadata.size > 1048576)
6250
7066
  throw new Error("Invalid update metadata");
6251
7067
  }
6252
- if (JSON.parse(await readFile6(join18(resources, "version.json"), "utf8")).version !== descriptor.version)
7068
+ if (JSON.parse(await readFile7(join20(resources, "version.json"), "utf8")).version !== descriptor.version)
6253
7069
  throw new Error("Update version mismatch");
6254
- assertBuildMetadata(JSON.parse(await readFile6(join18(resources, "build.json"), "utf8")), renderer);
7070
+ assertBuildMetadata(JSON.parse(await readFile7(join20(resources, "build.json"), "utf8")), renderer);
6255
7071
  return {
6256
7072
  directory,
6257
- payload: join18(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
7073
+ payload: join20(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
6258
7074
  };
6259
7075
  } catch (error) {
6260
7076
  if (directory)
@@ -6266,19 +7082,19 @@ async function extractVerifiedUpdate(options) {
6266
7082
  }
6267
7083
 
6268
7084
  // ../../src/updates/install/update-swap.ts
6269
- import { createHash as createHash13 } from "crypto";
7085
+ import { createHash as createHash16 } from "crypto";
6270
7086
  import { constants as constants7 } from "fs";
6271
- import { lstat as lstat13, open as open9, readdir as readdir7, readFile as readFile7, readlink as readlink2 } from "fs/promises";
6272
- import { basename as basename8, dirname as dirname6, join as join21 } from "path";
7087
+ import { lstat as lstat14, open as open9, readdir as readdir8, readFile as readFile8, readlink as readlink2 } from "fs/promises";
7088
+ import { basename as basename8, dirname as dirname6, join as join23 } from "path";
6273
7089
 
6274
7090
  // ../../src/updates/update-state-store.ts
6275
7091
  import { randomUUID as randomUUID2 } from "crypto";
6276
7092
  import { constants as constants6 } from "fs";
6277
7093
  import { open as open8, rename, unlink, writeFile as writeFile5 } from "fs/promises";
6278
- import { join as join20 } from "path";
7094
+ import { join as join22 } from "path";
6279
7095
 
6280
7096
  // ../../src/updates/locks/update-lock.ts
6281
- import { basename as basename7, dirname as dirname5, join as join19 } from "path";
7097
+ import { basename as basename7, dirname as dirname5, join as join21 } from "path";
6282
7098
 
6283
7099
  // ../../src/updates/locks/native-file-lock.ts
6284
7100
  import { constants as constants5 } from "fs";
@@ -6446,7 +7262,7 @@ async function tryAcquireWindows(path, mode) {
6446
7262
  function updateLockPath(target) {
6447
7263
  if (!isCanonicalPath(target))
6448
7264
  throw new Error("Invalid update lock target");
6449
- return join19(dirname5(target), `.${basename7(target)}.framework-update.lock`);
7265
+ return join21(dirname5(target), `.${basename7(target)}.framework-update.lock`);
6450
7266
  }
6451
7267
  async function tryAcquireUpdateLock(target) {
6452
7268
  return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
@@ -6511,7 +7327,7 @@ function parseState(value) {
6511
7327
  return Object.freeze(record);
6512
7328
  }
6513
7329
  async function readUpdateStageState(staging) {
6514
- const text = await readSmallStateFile(join20(staging, "state.json"), 4096, "Invalid update staging state");
7330
+ const text = await readSmallStateFile(join22(staging, "state.json"), 4096, "Invalid update staging state");
6515
7331
  return text === undefined ? undefined : parseState(JSON.parse(text));
6516
7332
  }
6517
7333
  async function writeUpdateStageState(staging, state) {
@@ -6520,8 +7336,8 @@ async function writeUpdateStageState(staging, state) {
6520
7336
  async function replaceUpdateStageState(staging, state, durable) {
6521
7337
  if (typeof state.generation !== "string" || !isUuid(state.generation))
6522
7338
  throw new Error("Invalid update staging state");
6523
- const path = join20(staging, "state.json");
6524
- const temporary = join20(staging, `.state-${state.generation}-${randomUUID2()}.tmp`);
7339
+ const path = join22(staging, "state.json");
7340
+ const temporary = join22(staging, `.state-${state.generation}-${randomUUID2()}.tmp`);
6525
7341
  const contents = JSON.stringify(state) + `
6526
7342
  `;
6527
7343
  let renamed = false;
@@ -6559,12 +7375,12 @@ async function withUpdateLock(target, operation) {
6559
7375
  function updateStagingFor(target) {
6560
7376
  if (!isCanonicalPath(target))
6561
7377
  throw new Error("Invalid update target");
6562
- return join21(dirname6(target), `.${basename8(target)}.framework-update`);
7378
+ return join23(dirname6(target), `.${basename8(target)}.framework-update`);
6563
7379
  }
6564
7380
  async function readUpdateTreeVersion(tree) {
6565
- const versionPath = join21(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
7381
+ const versionPath = join23(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
6566
7382
  try {
6567
- const value = JSON.parse(await readFile7(versionPath, "utf8"));
7383
+ const value = JSON.parse(await readFile8(versionPath, "utf8"));
6568
7384
  if (typeof value !== "object" || value === null || typeof value.version !== "string")
6569
7385
  return;
6570
7386
  return value.version;
@@ -6578,7 +7394,7 @@ function updateTreeIdentityFromStat(info) {
6578
7394
  return { device: info.dev.toString(10), inode: info.ino.toString(10) };
6579
7395
  }
6580
7396
  async function readUpdateTreeIdentity(tree) {
6581
- const info = await lstat13(tree, { bigint: true });
7397
+ const info = await lstat14(tree, { bigint: true });
6582
7398
  return updateTreeIdentityFromStat(info);
6583
7399
  }
6584
7400
  function sameUpdateTreeIdentity(left, right) {
@@ -6622,9 +7438,9 @@ async function readTreeFileBytes(file, buffer, length, position) {
6622
7438
  }
6623
7439
  async function readUpdateTreeDigest(tree, options = {}) {
6624
7440
  const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
6625
- const hash = createHash13("sha256");
7441
+ const hash = createHash16("sha256");
6626
7442
  hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
6627
- const root = await lstat13(tree, { bigint: true });
7443
+ const root = await lstat14(tree, { bigint: true });
6628
7444
  if (!root.isDirectory() || root.isSymbolicLink())
6629
7445
  throw new Error("Update tree is not a real directory");
6630
7446
  const rootDevice = root.dev;
@@ -6654,10 +7470,10 @@ async function readUpdateTreeDigest(tree, options = {}) {
6654
7470
  if (before.isSymbolicLink())
6655
7471
  return [{ kind: "symlink", path, relative, before }];
6656
7472
  if (before.isDirectory()) {
6657
- const names = (await limit(() => readdir7(path))).map((name) => ({ name, bytes: Buffer.from(name, "utf8") })).toSorted((left, right) => Buffer.compare(left.bytes, right.bytes)).map(({ name }) => name);
7473
+ const names = (await limit(() => readdir8(path))).map((name) => ({ name, bytes: Buffer.from(name, "utf8") })).toSorted((left, right) => Buffer.compare(left.bytes, right.bytes)).map(({ name }) => name);
6658
7474
  const children = await Promise.all(names.map(async (name) => {
6659
- const childPath = join21(path, name);
6660
- return list(childPath, relative ? `${relative}/${name}` : name, await limit(() => lstat13(childPath, { bigint: true })));
7475
+ const childPath = join23(path, name);
7476
+ return list(childPath, relative ? `${relative}/${name}` : name, await limit(() => lstat14(childPath, { bigint: true })));
6661
7477
  }));
6662
7478
  return [{ kind: "directory", path, relative, before }, ...children.flat()];
6663
7479
  }
@@ -6671,7 +7487,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6671
7487
  return { kind: "none" };
6672
7488
  if (entry.kind === "symlink") {
6673
7489
  const target = Buffer.from(await readlink2(path), "utf8");
6674
- const after = await lstat13(path, { bigint: true });
7490
+ const after = await lstat14(path, { bigint: true });
6675
7491
  if (!sameTreeEntrySnapshot(before, after))
6676
7492
  throw new Error("Update tree changed while reading a symbolic link");
6677
7493
  return { kind: "bytes", bytes: target };
@@ -6690,7 +7506,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6690
7506
  const size = Number(before.size);
6691
7507
  const bytes = Buffer.allocUnsafe(size);
6692
7508
  await readTreeFileBytes(file, bytes, size, 0);
6693
- if (!sameTreeEntrySnapshot(before, await lstat13(path, { bigint: true })))
7509
+ if (!sameTreeEntrySnapshot(before, await lstat14(path, { bigint: true })))
6694
7510
  throw new Error("Update tree changed while reading a file");
6695
7511
  return { kind: "bytes", bytes };
6696
7512
  } finally {
@@ -6759,7 +7575,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6759
7575
  position = nextPosition;
6760
7576
  index = nextIndex;
6761
7577
  }
6762
- if (!sameTreeEntrySnapshot(entry.before, await lstat13(entry.path, { bigint: true })))
7578
+ if (!sameTreeEntrySnapshot(entry.before, await lstat14(entry.path, { bigint: true })))
6763
7579
  throw new Error("Update tree changed while reading a file");
6764
7580
  } finally {
6765
7581
  await file.close();
@@ -6775,11 +7591,11 @@ async function readUpdateTreeDigest(tree, options = {}) {
6775
7591
  await Promise.all(entries.map(async (entry) => {
6776
7592
  if (entry.kind !== "directory" || entry.relative === "")
6777
7593
  return;
6778
- const after = await limit(() => lstat13(entry.path, { bigint: true }));
7594
+ const after = await limit(() => lstat14(entry.path, { bigint: true }));
6779
7595
  if (!sameTreeEntrySnapshot(entry.before, after))
6780
7596
  throw new Error("Update tree changed while reading a directory");
6781
7597
  }));
6782
- const finalRoot = await lstat13(tree, { bigint: true });
7598
+ const finalRoot = await lstat14(tree, { bigint: true });
6783
7599
  if (!sameTreeEntrySnapshot(root, finalRoot))
6784
7600
  throw new Error("Update tree changed while its digest was computed");
6785
7601
  const count = Buffer.allocUnsafe(8);
@@ -6788,7 +7604,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6788
7604
  return hash.digest("hex");
6789
7605
  }
6790
7606
  async function assertDirectory(path) {
6791
- const info = await lstat13(path);
7607
+ const info = await lstat14(path);
6792
7608
  if (!info.isDirectory() || info.isSymbolicLink())
6793
7609
  throw new Error("Update exchange requires real directories");
6794
7610
  }
@@ -6799,8 +7615,8 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
6799
7615
  const { target, staging } = options;
6800
7616
  if (dirname6(staging) !== dirname6(target) || staging === target)
6801
7617
  throw new Error("Invalid update swap context");
6802
- const candidate = join21(staging, "candidate");
6803
- const legacyOld = join21(staging, "old");
7618
+ const candidate = join23(staging, "candidate");
7619
+ const legacyOld = join23(staging, "old");
6804
7620
  if (await pathExists(legacyOld))
6805
7621
  throw new Error("A legacy update tree requires recovery before another swap");
6806
7622
  await assertDirectory(target);
@@ -6829,11 +7645,11 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
6829
7645
  }
6830
7646
 
6831
7647
  // ../../src/updates/retention/retirement-inventory.ts
6832
- import { lstat as lstat15, readdir as readdir9 } from "fs/promises";
6833
- import { basename as basename12, dirname as dirname10, join as join25 } from "path";
7648
+ import { lstat as lstat16, readdir as readdir10 } from "fs/promises";
7649
+ import { basename as basename12, dirname as dirname10, join as join27 } from "path";
6834
7650
 
6835
7651
  // ../../src/updates/retention/update-retention-marker.ts
6836
- import { basename as basename9, dirname as dirname7, join as join22 } from "path";
7652
+ import { basename as basename9, dirname as dirname7, join as join24 } from "path";
6837
7653
  var LOWERCASE_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
6838
7654
  var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
6839
7655
  function assertCanonicalTarget(target) {
@@ -6852,28 +7668,28 @@ function isTreeIdentity(value) {
6852
7668
  function updateRetentionIntentPath(target, generation) {
6853
7669
  assertCanonicalTarget(target);
6854
7670
  assertGeneration(generation);
6855
- return join22(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
7671
+ return join24(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
6856
7672
  }
6857
7673
 
6858
7674
  // ../../src/updates/retention/retention-prune-progress.ts
6859
- import { basename as basename11, dirname as dirname9, join as join24 } from "path";
7675
+ import { basename as basename11, dirname as dirname9, join as join26 } from "path";
6860
7676
 
6861
7677
  // ../../src/updates/retention/retirement-records.ts
6862
- import { lstat as lstat14, readdir as readdir8, writeFile as writeFile6 } from "fs/promises";
6863
- import { basename as basename10, dirname as dirname8, join as join23 } from "path";
7678
+ import { lstat as lstat15, readdir as readdir9, writeFile as writeFile6 } from "fs/promises";
7679
+ import { basename as basename10, dirname as dirname8, join as join25 } from "path";
6864
7680
  function updateRetirementPaths(target, generation) {
6865
7681
  if (!isCanonicalPath(target) || !isUuid(generation))
6866
7682
  throw new Error("Invalid update retirement identity");
6867
7683
  const prefix = `.${basename10(target)}.framework-retired-${generation}`;
6868
- const container = join23(dirname8(target), prefix);
7684
+ const container = join25(dirname8(target), prefix);
6869
7685
  return Object.freeze({
6870
7686
  container,
6871
- tree: join23(container, "tree"),
6872
- healthReceipt: join23(container, "healthy.json"),
7687
+ tree: join25(container, "tree"),
7688
+ healthReceipt: join25(container, "healthy.json"),
6873
7689
  healthTemporaryPrefix: ".healthy-",
6874
- claim: join23(dirname8(target), `${prefix}.claim.json`),
7690
+ claim: join25(dirname8(target), `${prefix}.claim.json`),
6875
7691
  claimTemporaryPrefix: `${prefix}.claim-`,
6876
- cleanupMarker: join23(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
7692
+ cleanupMarker: join25(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
6877
7693
  cleanupMarkerTemporaryPrefix: `.${basename10(target)}.framework-update-cleanup-`
6878
7694
  });
6879
7695
  }
@@ -6924,7 +7740,7 @@ async function readCleanupMarker(path) {
6924
7740
  }
6925
7741
  async function pathInfo(path) {
6926
7742
  try {
6927
- return await lstat14(path);
7743
+ return await lstat15(path);
6928
7744
  } catch (error) {
6929
7745
  if (errorCode(error) === "ENOENT")
6930
7746
  return;
@@ -6972,15 +7788,15 @@ function assertNoUnresolvedRetentionPruneArtifacts(target, names, allowances = {
6972
7788
  async function assertNoUpdateRetentionPruneArtifactsWhileLocked(target) {
6973
7789
  if (!isCanonicalPath(target) || !basename12(target))
6974
7790
  throw new Error("Invalid update retention prune gate target");
6975
- assertNoUnresolvedRetentionPruneArtifacts(target, await readdir9(dirname10(target)), {}, "update retention prune requires recovery before staging");
7791
+ assertNoUnresolvedRetentionPruneArtifacts(target, await readdir10(dirname10(target)), {}, "update retention prune requires recovery before staging");
6976
7792
  }
6977
7793
 
6978
7794
  // ../../src/updates/retention/update-retirement.ts
6979
- import { lstat as lstat16, mkdir as mkdir8, readdir as readdir10, rmdir, unlink as unlink2, writeFile as writeFile7 } from "fs/promises";
6980
- import { basename as basename13, dirname as dirname11, join as join26 } from "path";
7795
+ import { lstat as lstat17, mkdir as mkdir8, readdir as readdir11, rmdir, unlink as unlink2, writeFile as writeFile7 } from "fs/promises";
7796
+ import { basename as basename13, dirname as dirname11, join as join28 } from "path";
6981
7797
  async function reconcileRetirementCleanupMarkerWhileLocked(options) {
6982
7798
  const { target, staging, currentVersion } = options;
6983
- const markerPath = join26(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
7799
+ const markerPath = join28(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
6984
7800
  const markerInfo = await pathInfo(markerPath);
6985
7801
  if (!markerInfo)
6986
7802
  return "none";
@@ -6997,14 +7813,14 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
6997
7813
  const containerInfo = await pathInfo(paths.container);
6998
7814
  if (!containerInfo?.isDirectory() || containerInfo.isSymbolicLink())
6999
7815
  return "recovery-required";
7000
- const containerEntries = await readdir10(paths.container);
7816
+ const containerEntries = await readdir11(paths.container);
7001
7817
  if (containerEntries.length !== 1 || containerEntries[0] !== "tree")
7002
7818
  return "recovery-required";
7003
7819
  const stagingInfo = await pathInfo(staging);
7004
7820
  if (stagingInfo) {
7005
7821
  if (!stagingInfo.isDirectory() || stagingInfo.isSymbolicLink())
7006
7822
  return "recovery-required";
7007
- const stagingEntries = await readdir10(staging);
7823
+ const stagingEntries = await readdir11(staging);
7008
7824
  if (stagingEntries.length !== 0)
7009
7825
  return "recovery-required";
7010
7826
  await rmdir(staging);
@@ -7018,14 +7834,14 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
7018
7834
 
7019
7835
  // ../../src/updates/install/update-swap-stage.ts
7020
7836
  async function assertInstalledVersion(options) {
7021
- const info = await lstat17(options.target);
7022
- if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(options.target) !== options.target)
7837
+ const info = await lstat18(options.target);
7838
+ if (!info.isDirectory() || info.isSymbolicLink() || await realpath8(options.target) !== options.target)
7023
7839
  throw new Error("Invalid update install target");
7024
- const versionFile = join27(options.target, ...options.platform === "macos-arm64" ? ["Contents", "Resources"] : ["Resources"], "version.json");
7025
- const versionInfo = await lstat17(versionFile);
7840
+ const versionFile = join29(options.target, ...options.platform === "macos-arm64" ? ["Contents", "Resources"] : ["Resources"], "version.json");
7841
+ const versionInfo = await lstat18(versionFile);
7026
7842
  if (!versionInfo.isFile() || versionInfo.size > 1024 * 1024)
7027
7843
  throw new Error("Installed update version mismatch");
7028
- if (JSON.parse(await readFile8(versionFile, "utf8")).version !== options.version)
7844
+ if (JSON.parse(await readFile9(versionFile, "utf8")).version !== options.version)
7029
7845
  throw new Error("Installed update version mismatch");
7030
7846
  }
7031
7847
  async function stageUpdateSwap(options) {
@@ -7045,7 +7861,7 @@ async function stageUpdateSwap(options) {
7045
7861
  });
7046
7862
  const staging = updateStagingFor(plan.target);
7047
7863
  const preparing = await mkdtemp8(`${staging}.preparing-`);
7048
- const candidate = join27(staging, "candidate");
7864
+ const candidate = join29(staging, "candidate");
7049
7865
  let published = false;
7050
7866
  try {
7051
7867
  const extracted = await extractVerifiedUpdate({
@@ -7059,12 +7875,12 @@ async function stageUpdateSwap(options) {
7059
7875
  maxExpandedBytes: options.maxExpandedBytes,
7060
7876
  ...options.sidecars === undefined ? {} : { sidecars: options.sidecars }
7061
7877
  });
7062
- renameExclusive(extracted.payload, join27(preparing, "candidate"));
7878
+ renameExclusive(extracted.payload, join29(preparing, "candidate"));
7063
7879
  await rm8(extracted.directory, { recursive: true, force: true });
7064
- const candidateTreeIdentity = await readUpdateTreeIdentity(join27(preparing, "candidate"));
7880
+ const candidateTreeIdentity = await readUpdateTreeIdentity(join29(preparing, "candidate"));
7065
7881
  if (!candidateTreeIdentity)
7066
7882
  throw new Error("Update candidate tree identity could not be read");
7067
- const candidateTreeDigest = await readUpdateTreeDigest(join27(preparing, "candidate"));
7883
+ const candidateTreeDigest = await readUpdateTreeDigest(join29(preparing, "candidate"));
7068
7884
  await writeUpdateStageState(preparing, newUpdateStageState({
7069
7885
  version: plan.version,
7070
7886
  previousVersion: options.currentVersion,
@@ -7083,7 +7899,7 @@ async function stageUpdateSwap(options) {
7083
7899
  });
7084
7900
  let existingInfo;
7085
7901
  try {
7086
- existingInfo = await lstat17(staging);
7902
+ existingInfo = await lstat18(staging);
7087
7903
  } catch (error) {
7088
7904
  if (errorCode(error) === "ENOENT") {
7089
7905
  const retirement = await reconcileRetirementCleanupMarkerWhileLocked({
@@ -7149,11 +7965,11 @@ function isolatedEnv(parent, profile, platform) {
7149
7965
  RUNNER_ENVIRONMENT: "github-hosted",
7150
7966
  HOME: profile,
7151
7967
  USERPROFILE: profile,
7152
- LOCALAPPDATA: join28(profile, "LocalAppData"),
7153
- XDG_DATA_HOME: join28(profile, ".local", "share"),
7154
- TMP: join28(profile, "tmp"),
7155
- TEMP: join28(profile, "tmp"),
7156
- TMPDIR: join28(profile, "tmp"),
7968
+ LOCALAPPDATA: join30(profile, "LocalAppData"),
7969
+ XDG_DATA_HOME: join30(profile, ".local", "share"),
7970
+ TMP: join30(profile, "tmp"),
7971
+ TEMP: join30(profile, "tmp"),
7972
+ TMPDIR: join30(profile, "tmp"),
7157
7973
  ELECTROBUN_INSTALLER_UI_AUTOCLOSE: "1"
7158
7974
  });
7159
7975
  if (platform === "windows-x64")
@@ -7248,15 +8064,15 @@ async function observeInstalledApp(options) {
7248
8064
  await preflightInstallerRuntime({ env: parent, runtime: candidate.path, bootstrap });
7249
8065
  stage("runtime-preflight-passed");
7250
8066
  for (const path of [
7251
- join28(prepared.profile, "LocalAppData"),
7252
- join28(prepared.profile, ".local", "share"),
7253
- join28(prepared.profile, "tmp")
8067
+ join30(prepared.profile, "LocalAppData"),
8068
+ join30(prepared.profile, ".local", "share"),
8069
+ join30(prepared.profile, "tmp")
7254
8070
  ])
7255
8071
  await mkdir9(path, { recursive: true, mode: 448 });
7256
8072
  const mac = options.platform === "macos-arm64", windows = options.platform === "windows-x64";
7257
- const installedRoot = mac ? join28(prepared.incoming, `${options.appName}.app`, "Contents") : join28(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
7258
- const resources = join28(installedRoot, "Resources"), binary = join28(installedRoot, mac ? "MacOS" : "bin"), launcher = join28(binary, windows ? "launcher.exe" : "launcher"), runtime = join28(binary, windows ? "bun.exe" : "bun");
7259
- const worker = join28(resources, "app", "bun", "index.js");
8073
+ const installedRoot = mac ? join30(prepared.incoming, `${options.appName}.app`, "Contents") : join30(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
8074
+ const resources = join30(installedRoot, "Resources"), binary = join30(installedRoot, mac ? "MacOS" : "bin"), launcher = join30(binary, windows ? "launcher.exe" : "launcher"), runtime = join30(binary, windows ? "bun.exe" : "bun");
8075
+ const worker = join30(resources, "app", "bun", "index.js");
7260
8076
  const sidecars = options.sidecars ?? [];
7261
8077
  let foreignHits = 0;
7262
8078
  const sentinel = policy ? Bun.serve({
@@ -7306,8 +8122,8 @@ async function observeInstalledApp(options) {
7306
8122
  if (sentinel && (!(await fetch(foreignOrigin + "/", { signal: AbortSignal.timeout(1000) })).ok || foreignHits !== 1))
7307
8123
  throw new Error("Foreign network sentinel unavailable");
7308
8124
  foreignHits = 0;
7309
- const nonce = randomBytes2(24).toString("hex");
7310
- const ack = join28(run.directory, "ack"), permit = join28(run.directory, "permit"), observation = join28(run.directory, "observation"), unexpected = join28(run.directory, "unexpected"), pidRecord = join28(run.directory, "worker-pid");
8125
+ const nonce = randomBytes3(24).toString("hex");
8126
+ const ack = join30(run.directory, "ack"), permit = join30(run.directory, "permit"), observation = join30(run.directory, "observation"), unexpected = join30(run.directory, "unexpected"), pidRecord = join30(run.directory, "worker-pid");
7311
8127
  const env = {
7312
8128
  ...baseEnv,
7313
8129
  FRAMEWORK_CI_NONCE: nonce,
@@ -7320,13 +8136,13 @@ async function observeInstalledApp(options) {
7320
8136
  };
7321
8137
  let launchRecord, expectedApp;
7322
8138
  if (mac && viaInstaller) {
7323
- const shimDir = join28(run.directory, "launch-shim");
8139
+ const shimDir = join30(run.directory, "launch-shim");
7324
8140
  await mkdir9(shimDir, { mode: 448 });
7325
- const path = join28(shimDir, "open");
8141
+ const path = join30(shimDir, "open");
7326
8142
  await writeFile8(path, shim, { flag: "wx", mode: 448 });
7327
8143
  await chmod2(path, 448);
7328
- expectedApp = join28(await realpath8(prepared.incoming), `${options.appName}.app`);
7329
- launchRecord = join28(run.directory, "launch-record");
8144
+ expectedApp = join30(await realpath9(prepared.incoming), `${options.appName}.app`);
8145
+ launchRecord = join30(run.directory, "launch-record");
7330
8146
  Object.assign(env, {
7331
8147
  PATH: shimDir + delimiter + (env.PATH ?? ""),
7332
8148
  FRAMEWORK_CI_EXPECTED_APP: expectedApp,
@@ -7362,7 +8178,7 @@ async function observeInstalledApp(options) {
7362
8178
  const error = installerErrorName(await Promise.race([installerStderr, Bun.sleep(2000).then(() => "")]));
7363
8179
  throw new Error(`Installer exited unsuccessfully (exit=${installer.exitCode}, signal=${installer.signalCode ?? "none"}, ` + `ready=${await pathExists(worker) && await pathExists(launcher)}, acknowledged=${await pathExists(ack)}, ` + `error=${error ?? "none"})`);
7364
8180
  }
7365
- const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(join28(resources, "version.json"));
8181
+ const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(join30(resources, "version.json"));
7366
8182
  if (installer && shouldLaunchInstalledApp({
7367
8183
  platform: options.platform,
7368
8184
  ready,
@@ -7370,17 +8186,17 @@ async function observeInstalledApp(options) {
7370
8186
  acknowledged: await pathExists(ack),
7371
8187
  installerExit: installer.exitCode
7372
8188
  })) {
7373
- if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile9(launchRecord, "utf8") !== expectedApp + `
8189
+ if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile10(launchRecord, "utf8") !== expectedApp + `
7374
8190
  `)
7375
8191
  throw new Error("Installer launch request mismatch");
7376
8192
  app = spawnApp();
7377
8193
  }
7378
8194
  if (await pathExists(ack) && !granted) {
7379
8195
  stage("worker-acknowledged");
7380
- if (await readFile9(ack, "utf8") !== nonce + `
8196
+ if (await readFile10(ack, "utf8") !== nonce + `
7381
8197
  `)
7382
8198
  throw new Error("Worker guard acknowledgement mismatch");
7383
- const record = await readFile9(pidRecord, "utf8"), match = /^([a-f0-9]{48})\n([1-9]\d{0,9})\n$/.exec(record);
8199
+ const record = await readFile10(pidRecord, "utf8"), match = /^([a-f0-9]{48})\n([1-9]\d{0,9})\n$/.exec(record);
7384
8200
  if (!match || match[1] !== nonce || Number(match[2]) < 2 || Number(match[2]) === process.pid)
7385
8201
  throw new Error("Worker process identity mismatch");
7386
8202
  guardedPid = Number(match[2]);
@@ -7538,7 +8354,7 @@ async function observeInstalledApp(options) {
7538
8354
  await swapAfterExit(target, staged.staging);
7539
8355
  stage("update-swapped");
7540
8356
  await preflightInstallerRuntime({ env: parent, runtime, bootstrap });
7541
- const directory = join28(prepared.directory, "update");
8357
+ const directory = join30(prepared.directory, "update");
7542
8358
  await mkdir9(directory, { mode: 448 });
7543
8359
  const updated = await observeRun({
7544
8360
  directory,
@@ -7587,9 +8403,9 @@ async function qualifyInstallerCommand(options) {
7587
8403
  const parsed = parseReleaseConfig(config), requirements = parsed.requirements(tag), policy = requirements.offlinePolicy, names = requirements.platforms[platform];
7588
8404
  if (!policy || !names || names.length !== 2)
7589
8405
  throw new Error("Installer qualification requires an explicit offline policy and payloads");
7590
- const directory = resolve13(options.directory), destination = join29(directory, `installer-test-${platform}.json`);
8406
+ const directory = resolve14(options.directory), destination = join31(directory, `installer-test-${platform}.json`);
7591
8407
  try {
7592
- await lstat18(destination);
8408
+ await lstat19(destination);
7593
8409
  throw new Error("Installer receipt already exists");
7594
8410
  } catch (error) {
7595
8411
  if (errorCode(error) !== "ENOENT")
@@ -7603,8 +8419,8 @@ async function qualifyInstallerCommand(options) {
7603
8419
  appName: app.appName,
7604
8420
  appId: app.appId,
7605
8421
  version: plan.version,
7606
- installer: join29(directory, names[0]),
7607
- archive: join29(directory, names[1]),
8422
+ installer: join31(directory, names[0]),
8423
+ archive: join31(directory, names[1]),
7608
8424
  expectedReads: parsed.expectedReads,
7609
8425
  offlinePolicy: policy,
7610
8426
  sidecars: parsed.sidecars
@@ -7635,11 +8451,11 @@ async function qualifyInstallerCommand(options) {
7635
8451
  }
7636
8452
 
7637
8453
  // ../../src/installer/installer-upgrade-command.ts
7638
- import { lstat as lstat19, mkdir as mkdir10, rename as rename2, writeFile as writeFile10 } from "fs/promises";
7639
- import { join as join31, resolve as resolve15 } from "path";
8454
+ import { lstat as lstat20, mkdir as mkdir10, rename as rename2, writeFile as writeFile10 } from "fs/promises";
8455
+ import { join as join33, resolve as resolve16 } from "path";
7640
8456
 
7641
8457
  // ../../src/installer/upgrade-asset-download.ts
7642
- import { createHash as createHash14 } from "crypto";
8458
+ import { createHash as createHash17 } from "crypto";
7643
8459
  import { open as open10, unlink as unlink3 } from "fs/promises";
7644
8460
 
7645
8461
  // ../../src/installer/write-all.ts
@@ -7677,7 +8493,7 @@ async function downloadAsset(options) {
7677
8493
  discardStream(response.body);
7678
8494
  throw error;
7679
8495
  }
7680
- const hash = createHash14("sha256");
8496
+ const hash = createHash17("sha256");
7681
8497
  let completed = false;
7682
8498
  try {
7683
8499
  let size = 0;
@@ -7717,7 +8533,7 @@ async function downloadAsset(options) {
7717
8533
  }
7718
8534
 
7719
8535
  // ../../src/updates/feed/update-discovery.ts
7720
- import { createHash as createHash15 } from "crypto";
8536
+ import { createHash as createHash18 } from "crypto";
7721
8537
  var MAX_POINTER_BYTES = 262144;
7722
8538
  var MAX_LEDGER_BYTES2 = 1024 * 1024;
7723
8539
  async function discoverSignedRelease(options) {
@@ -7753,7 +8569,7 @@ async function discoverSignedRelease(options) {
7753
8569
  throw new Error("No qualified channel descriptor is available");
7754
8570
  const { tag } = selected;
7755
8571
  const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
7756
- if (bytes.length !== listed.size || createHash15("sha256").update(bytes).digest("hex") !== listed.sha256)
8572
+ if (bytes.length !== listed.size || createHash18("sha256").update(bytes).digest("hex") !== listed.sha256)
7757
8573
  throw new Error("Channel descriptor differs from its release");
7758
8574
  let signed;
7759
8575
  try {
@@ -7771,8 +8587,8 @@ async function discoverSignedRelease(options) {
7771
8587
  }
7772
8588
 
7773
8589
  // ../../src/updates/install/update-download.ts
7774
- import { mkdtemp as mkdtemp9, open as open11, realpath as realpath9, rm as rm9 } from "fs/promises";
7775
- import { basename as basename14, dirname as dirname13, join as join30, resolve as resolve14 } from "path";
8590
+ import { mkdtemp as mkdtemp9, open as open11, realpath as realpath10, rm as rm9 } from "fs/promises";
8591
+ import { basename as basename14, dirname as dirname13, join as join32, resolve as resolve15 } from "path";
7776
8592
  async function downloadVerifiedRelease(options) {
7777
8593
  const { descriptor, maxBytes } = options;
7778
8594
  const timeout = options.timeoutMs ?? 120000;
@@ -7804,13 +8620,13 @@ async function downloadVerifiedRelease(options) {
7804
8620
  if (length !== null && (!/^\d+$/.test(length) || Number(length) !== descriptor.asset.size)) {
7805
8621
  throw new Error("Release download size mismatch");
7806
8622
  }
7807
- const root = options.createTemporaryDirectory ? await realpath9(resolve14(options.directory)) : resolve14(options.directory);
7808
- const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(join30(root, "framework-update-"));
7809
- const temporaryDirectory = resolve14(allocated);
8623
+ const root = options.createTemporaryDirectory ? await realpath10(resolve15(options.directory)) : resolve15(options.directory);
8624
+ const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(join32(root, "framework-update-"));
8625
+ const temporaryDirectory = resolve15(allocated);
7810
8626
  if (dirname13(temporaryDirectory) !== root || !basename14(temporaryDirectory).startsWith("framework-update-"))
7811
8627
  throw new Error("Invalid update download directory");
7812
8628
  temporary = temporaryDirectory;
7813
- const path = join30(temporary, "archive");
8629
+ const path = join32(temporary, "archive");
7814
8630
  const file = await open11(path, "wx", 384);
7815
8631
  try {
7816
8632
  async function* writeChunks() {
@@ -7913,9 +8729,9 @@ async function qualifyUpgradeCommand(options) {
7913
8729
  const parsed = parseReleaseConfig(config), feed = feedUrl(parsed.feed), requirements = parsed.requirements(tag), names = requirements.platforms[platform];
7914
8730
  if (!requirements.offlinePolicy || !names || names.length !== 2)
7915
8731
  throw new Error("Upgrade qualification requires an explicit offline policy and payloads");
7916
- const directory = resolve15(options.directory), destination = join31(directory, `upgrade-test-${platform}.json`);
8732
+ const directory = resolve16(options.directory), destination = join33(directory, `upgrade-test-${platform}.json`);
7917
8733
  try {
7918
- await lstat19(destination);
8734
+ await lstat20(destination);
7919
8735
  throw new Error("Upgrade receipt already exists");
7920
8736
  } catch (error) {
7921
8737
  if (errorCode(error) !== "ENOENT")
@@ -7936,7 +8752,7 @@ async function qualifyUpgradeCommand(options) {
7936
8752
  const channel = "daily";
7937
8753
  const trust = { ...base, channel };
7938
8754
  const discovery = discoveryName(config, channel, platform);
7939
- const signed = await readJsonFile(join31(directory, discovery), 65536, "staged descriptor");
8755
+ const signed = await readJsonFile(join33(directory, discovery), 65536, "staged descriptor");
7940
8756
  const verified = verifyReleaseDescriptor(signed, trust);
7941
8757
  if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.asset.name !== names[1])
7942
8758
  throw new Error("Untrusted staged descriptor");
@@ -7959,7 +8775,7 @@ async function qualifyUpgradeCommand(options) {
7959
8775
  return null;
7960
8776
  if (previous.tag === tag || !versionLessThan(previous.version, descriptor.version))
7961
8777
  throw new Error("Previous release is not older than this release");
7962
- const work = join31(directory, `upgrade-${platform}`);
8778
+ const work = join33(directory, `upgrade-${platform}`);
7963
8779
  await mkdir10(work, { mode: 448 });
7964
8780
  const downloaded = await downloadVerifiedRelease({
7965
8781
  descriptor: previous,
@@ -7968,12 +8784,12 @@ async function qualifyUpgradeCommand(options) {
7968
8784
  timeoutMs: 600000,
7969
8785
  fetch: fetcher
7970
8786
  });
7971
- const previousArchive = join31(work, previous.asset.name);
8787
+ const previousArchive = join33(work, previous.asset.name);
7972
8788
  await rename2(downloaded.path, previousArchive);
7973
8789
  const installerName = parsed.requirements(previous.tag).platforms[platform]?.[0];
7974
8790
  if (!installerName)
7975
8791
  throw new Error("Previous release has no installer for this platform");
7976
- const previousInstaller = join31(work, installerName);
8792
+ const previousInstaller = join33(work, installerName);
7977
8793
  await downloadAsset({
7978
8794
  feed,
7979
8795
  tag: previous.tag,
@@ -7997,7 +8813,7 @@ async function qualifyUpgradeCommand(options) {
7997
8813
  update: {
7998
8814
  descriptor,
7999
8815
  trust,
8000
- archive: join31(directory, names[1]),
8816
+ archive: join33(directory, names[1]),
8001
8817
  maxCompressedBytes: MAX_COMPRESSED_BYTES2,
8002
8818
  maxExpandedBytes: MAX_EXPANDED_BYTES2
8003
8819
  }
@@ -8052,7 +8868,7 @@ function electrobunArtifacts(appName, platform) {
8052
8868
  }
8053
8869
 
8054
8870
  // src/library/steps.ts
8055
- var selectRetainedStepEffect = (context) => Effect24.gen(function* () {
8871
+ var selectRetainedStepEffect = (context) => Effect25.gen(function* () {
8056
8872
  const output = context.env.GITHUB_OUTPUT;
8057
8873
  if (!output)
8058
8874
  return yield* fail("Expected GITHUB_OUTPUT");
@@ -8064,7 +8880,7 @@ runId=${result.runId}
8064
8880
  ` : `reuse=false
8065
8881
  `));
8066
8882
  });
8067
- var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect24.gen(function* () {
8883
+ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect25.gen(function* () {
8068
8884
  const fs = yield* ReleaseFs;
8069
8885
  const [installerAsset, archiveAsset] = platformAssets(context);
8070
8886
  const [installer, archive] = electrobunArtifacts(context.config.appName, context.platform);
@@ -8073,12 +8889,12 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
8073
8889
  yield* step(() => fs.mkdir(directory, { recursive: true }));
8074
8890
  const packed = yield* scopedTempDirectory("framework-command-pack-");
8075
8891
  const sources = {
8076
- [installerAsset]: join32(artifacts, installer),
8077
- [archiveAsset]: join32(artifacts, archive)
8892
+ [installerAsset]: join34(artifacts, installer),
8893
+ [archiveAsset]: join34(artifacts, archive)
8078
8894
  };
8079
8895
  for (const policy of parsed.commandArtifacts) {
8080
8896
  const name = requirements.commandArtifacts[policy.kind][context.platform];
8081
- sources[name] = join32(packed, name);
8897
+ sources[name] = join34(packed, name);
8082
8898
  yield* step(() => packCommandArtifact({
8083
8899
  source: policy.build,
8084
8900
  archive: sources[name],
@@ -8087,8 +8903,8 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
8087
8903
  }));
8088
8904
  }
8089
8905
  return yield* stagePlatformArtifactsEffect({ ...context, directory, sources });
8090
- }).pipe(Effect24.scoped);
8091
- var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* () {
8906
+ }).pipe(Effect25.scoped);
8907
+ var inspectStagedStepEffect = (context, directory) => Effect25.gen(function* () {
8092
8908
  const fs = yield* ReleaseFs;
8093
8909
  const parsed = parseReleaseConfig(context.config);
8094
8910
  const requirements = parsed.requirements(context.tag);
@@ -8096,10 +8912,10 @@ var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* ()
8096
8912
  const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
8097
8913
  if (entries.length !== assets.length || entries.some((entry) => !entry.isFile() || !assets.includes(entry.name)))
8098
8914
  return yield* fail("Staged platform directory contains unexpected files");
8099
- const [installer, archive] = platformAssets(context).map((name) => join32(directory, name));
8915
+ const [installer, archive] = platformAssets(context).map((name) => join34(directory, name));
8100
8916
  for (const policy of parsed.commandArtifacts)
8101
8917
  yield* step(() => readCommandArtifact({
8102
- archive: join32(directory, requirements.commandArtifacts[policy.kind][context.platform]),
8918
+ archive: join34(directory, requirements.commandArtifacts[policy.kind][context.platform]),
8103
8919
  executable: policy.executable,
8104
8920
  platform: context.platform
8105
8921
  }));
@@ -8115,12 +8931,12 @@ var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* ()
8115
8931
  }))
8116
8932
  };
8117
8933
  });
8118
- var qualifyStepEffect = (context, directory) => Effect24.gen(function* () {
8934
+ var qualifyStepEffect = (context, directory) => Effect25.gen(function* () {
8119
8935
  const mode = stepRenderer(context.env);
8120
8936
  yield* step(() => qualifyCommandArtifactsCommand({ ...context, directory }));
8121
8937
  yield* step(() => qualifyInstallerCommand({ ...context, renderer: mode, directory }));
8122
8938
  });
8123
- var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect24.suspend(() => {
8939
+ var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect25.suspend(() => {
8124
8940
  const renderer = stepRenderer(context.env);
8125
8941
  return step(() => qualifyUpgradeCommand({ ...context, renderer, directory, ...onStage ? { onStage } : {} }));
8126
8942
  });
@@ -8138,17 +8954,17 @@ import {
8138
8954
  mkdir as mkdir11,
8139
8955
  mkdtemp as mkdtemp10,
8140
8956
  open as open12,
8141
- readFile as readFile10,
8142
- realpath as realpath10,
8957
+ readFile as readFile11,
8958
+ realpath as realpath11,
8143
8959
  rm as rm10,
8144
8960
  writeFile as writeFile11
8145
8961
  } from "fs/promises";
8146
- import { dirname as dirname14, join as join33, resolve as resolve16 } from "path";
8147
- import { promisify as promisify2 } from "util";
8962
+ import { dirname as dirname14, join as join35, resolve as resolve17 } from "path";
8963
+ import { promisify as promisify3 } from "util";
8148
8964
  var shasum = /^[a-f0-9]{64}$/;
8149
8965
  var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
8150
8966
  var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
8151
- var exec = promisify2(execFile3);
8967
+ var exec = promisify3(execFile3);
8152
8968
  function requireThat2(condition, message) {
8153
8969
  if (!condition)
8154
8970
  throw new Error(message);
@@ -8271,9 +9087,9 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8271
9087
  const trusted = trustedArtifacts.find((file) => file.name === name);
8272
9088
  return fromProducer && trusted && trusted.size === fromProducer.size && trusted.sha256 === fromProducer.sha256;
8273
9089
  }), "Package producer receipt must describe exactly the protected DEB and AppImage");
8274
- const destination = resolve16(options.output);
8275
- const parent = await realpath10(dirname14(destination));
8276
- const work = await mkdtemp10(join33(parent, ".linux-package-pair-"));
9090
+ const destination = resolve17(options.output);
9091
+ const parent = await realpath11(dirname14(destination));
9092
+ const work = await mkdtemp10(join35(parent, ".linux-package-pair-"));
8277
9093
  try {
8278
9094
  const files = await runReleaseLibrary(provideLibraryPorts()(stageExpectedFilesEffect({
8279
9095
  directory: work,
@@ -8281,11 +9097,11 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8281
9097
  sources
8282
9098
  })));
8283
9099
  requireThat2([...artifacts, archive, runtime].every((asset) => files.some((file) => file.name === asset.name && file.size === asset.size && file.digest === `sha256:${asset.sha256}`)), "Staged package or update archive does not agree with its bound size and digest");
8284
- const deb = join33(work, expected.debName);
8285
- const image = join33(work, expected.appImageName);
9100
+ const deb = join35(work, expected.debName);
9101
+ const image = join35(work, expected.appImageName);
8286
9102
  const version = expected.tag.slice(1);
8287
9103
  parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version);
8288
- await verifyEmbeddedRuntime(image, await readFile10(join33(work, runtime.name)));
9104
+ await verifyEmbeddedRuntime(image, await readFile11(join35(work, runtime.name)));
8289
9105
  const offset = String(runtime.size);
8290
9106
  requireRegularDesktopEntry(await inspect("unsquashfs", [
8291
9107
  "-offset",
@@ -8315,8 +9131,8 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8315
9131
  await mkdir11(destination);
8316
9132
  try {
8317
9133
  for (const name of names)
8318
- await link(join33(work, name), join33(destination, name));
8319
- await writeFile11(join33(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
9134
+ await link(join35(work, name), join35(destination, name));
9135
+ await writeFile11(join35(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
8320
9136
  `, {
8321
9137
  flag: "wx"
8322
9138
  });
@@ -8331,56 +9147,58 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8331
9147
  }
8332
9148
  var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
8333
9149
  // src/library/linux-format-producer.ts
8334
- import { createHash as createHash16 } from "crypto";
8335
- import { createReadStream, createWriteStream } from "fs";
9150
+ import { createHash as createHash19 } from "crypto";
9151
+ import { createReadStream as createReadStream2, createWriteStream } from "fs";
8336
9152
  import {
8337
9153
  chmod as chmod4,
8338
9154
  cp,
8339
- lstat as lstat20,
9155
+ lstat as lstat21,
8340
9156
  lutimes,
8341
9157
  mkdir as mkdir12,
8342
9158
  mkdtemp as mkdtemp11,
8343
9159
  open as open13,
8344
- readdir as readdir11,
9160
+ readdir as readdir12,
8345
9161
  readlink as readlink3,
8346
- realpath as realpath11,
9162
+ realpath as realpath12,
8347
9163
  rm as rm11,
9164
+ symlink as symlink2,
8348
9165
  utimes,
8349
9166
  writeFile as writeFile12
8350
9167
  } from "fs/promises";
8351
- import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute6, join as join34, relative as relative5, resolve as resolve17 } from "path";
9168
+ import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute7, join as join36, relative as relative5, resolve as resolve18 } from "path";
8352
9169
  import { pipeline as pipeline2 } from "stream/promises";
8353
9170
  var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
8354
- var sha256 = /^[a-f0-9]{64}$/;
9171
+ var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
9172
+ var sha2562 = /^[a-f0-9]{64}$/;
8355
9173
  var sum = async (path) => {
8356
- const hash = createHash16("sha256");
8357
- for await (const chunk of createReadStream(path))
9174
+ const hash = createHash19("sha256");
9175
+ for await (const chunk of createReadStream2(path))
8358
9176
  hash.update(chunk);
8359
9177
  return hash.digest("hex");
8360
9178
  };
8361
9179
  var relativeFiles = (value) => value.split("/").every((part) => component.test(part));
8362
9180
  var text2 = (v) => v.length > 0 && v.length <= 250 && !/[\r\n]/.test(v);
8363
- function check(ok, message) {
9181
+ function check2(ok, message) {
8364
9182
  if (!ok)
8365
9183
  throw new Error(message);
8366
9184
  }
8367
9185
  async function exactCopy(pin, to) {
8368
- check(sha256.test(pin.sha256), "Missing protected input digest");
8369
- const before = await lstat20(pin.path);
8370
- check(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
9186
+ check2(sha2562.test(pin.sha256), "Missing protected input digest");
9187
+ const before = await lstat21(pin.path);
9188
+ check2(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
8371
9189
  const input = await open13(pin.path, "r");
8372
9190
  try {
8373
9191
  const after = await input.stat();
8374
- check(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
9192
+ check2(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
8375
9193
  await pipeline2(input.createReadStream({ autoClose: false, start: 0, end: before.size - 1 }), createWriteStream(to, { flags: "wx", mode: 384 }));
8376
9194
  } finally {
8377
9195
  await input.close();
8378
9196
  }
8379
- check((await lstat20(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
9197
+ check2((await lstat21(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
8380
9198
  }
8381
- async function regular(root, path) {
8382
- const file = join34(root, path);
8383
- check((await lstat20(file)).isFile() && await realpath11(file) === file, "Required bundle member is not a regular file");
9199
+ async function regular2(root, path) {
9200
+ const file = join36(root, path);
9201
+ check2((await lstat21(file)).isFile() && await realpath12(file) === file, "Required bundle member is not a regular file");
8384
9202
  return file;
8385
9203
  }
8386
9204
  async function elf(path, appImage = false) {
@@ -8388,38 +9206,38 @@ async function elf(path, appImage = false) {
8388
9206
  try {
8389
9207
  const h = Buffer.alloc(20);
8390
9208
  const { bytesRead } = await input.read(h, 0, h.length, 0);
8391
- check(bytesRead === 20 && h.toString("hex", 0, 6) === "7f454c460201" && h.readUInt16LE(18) === 62 && (!appImage || h.toString("hex", 8, 11) === "414902"), "Expected native Linux x64 executable");
9209
+ check2(bytesRead === 20 && h.toString("hex", 0, 6) === "7f454c460201" && h.readUInt16LE(18) === 62 && (!appImage || h.toString("hex", 8, 11) === "414902"), "Expected native Linux x64 executable");
8392
9210
  } finally {
8393
9211
  await input.close();
8394
9212
  }
8395
9213
  }
8396
9214
  async function normalizeTree(root, dir = root) {
8397
- for (const name of await readdir11(dir)) {
8398
- const file = join34(dir, name);
8399
- const st = await lstat20(file);
9215
+ for (const name of await readdir12(dir)) {
9216
+ const file = join36(dir, name);
9217
+ const st = await lstat21(file);
8400
9218
  if (st.isSymbolicLink()) {
8401
- check(!isAbsolute6(await readlink3(file)), "Absolute bundle symlink");
8402
- const target = relative5(root, await realpath11(file));
8403
- check(target !== ".." && !target.startsWith("../") && !isAbsolute6(target), "Escaping bundle symlink");
9219
+ check2(!isAbsolute7(await readlink3(file)), "Absolute bundle symlink");
9220
+ const target = relative5(root, await realpath12(file));
9221
+ check2(target !== ".." && !target.startsWith("../") && !isAbsolute7(target), "Escaping bundle symlink");
8404
9222
  } else if (st.isDirectory()) {
8405
9223
  await chmod4(file, 493);
8406
9224
  await normalizeTree(root, file);
8407
9225
  } else {
8408
- check(st.isFile(), "Unsupported bundle entry");
9226
+ check2(st.isFile(), "Unsupported bundle entry");
8409
9227
  await chmod4(file, st.mode & 73 ? 493 : 420);
8410
9228
  }
8411
9229
  }
8412
9230
  }
8413
9231
  async function normalizeBuildTimes(directory, epoch) {
8414
- for (const name of (await readdir11(directory)).toSorted()) {
8415
- const path = join34(directory, name);
8416
- const info = await lstat20(path);
9232
+ for (const name of (await readdir12(directory)).toSorted()) {
9233
+ const path = join36(directory, name);
9234
+ const info = await lstat21(path);
8417
9235
  if (info.isSymbolicLink()) {
8418
9236
  await lutimes(path, epoch, epoch);
8419
9237
  } else if (info.isDirectory()) {
8420
9238
  await normalizeBuildTimes(path, epoch);
8421
9239
  } else {
8422
- check(info.isFile(), "Unsupported packaging entry");
9240
+ check2(info.isFile(), "Unsupported packaging entry");
8423
9241
  await utimes(path, epoch, epoch);
8424
9242
  }
8425
9243
  }
@@ -8427,30 +9245,37 @@ async function normalizeBuildTimes(directory, epoch) {
8427
9245
  await utimes(directory, epoch, epoch);
8428
9246
  }
8429
9247
  async function write(root, path, value, mode = 420) {
8430
- const target = join34(root, path);
9248
+ const target = join36(root, path);
8431
9249
  await mkdir12(dirname15(target), { recursive: true });
8432
9250
  await writeFile12(target, value, { flag: "wx", mode });
8433
9251
  await chmod4(target, mode);
8434
9252
  }
8435
9253
  function validatePolicy(policy) {
8436
- check([policy.bundleRoot, policy.artifactStem, policy.desktopId].every((n) => component.test(n)) && /^[a-z0-9][a-z0-9+.-]+$/.test(policy.packageName) && [policy.launcher, policy.icon, ...policy.debSetuid.map((item) => item.path)].every(relativeFiles) && policy.debSetuid.every((item) => sha256.test(item.sha256)) && new Set(policy.debSetuid.map((item) => item.path)).size === policy.debSetuid.length && /^[A-Z][A-Z0-9_]*_LINUX_PACKAGE_FORMAT$/.test(policy.formatEnvironment) && policy.mimeTypes.every((x) => /^x-scheme-handler\/[a-z][a-z0-9+.-]*$/.test(x)) && [policy.name, policy.description, policy.maintainer, policy.homepage].every(text2) && policy.categories.every((x) => /^[A-Za-z0-9]+$/.test(x)) && policy.dependencies.every((x) => /^[a-z0-9][a-z0-9+.-]*(?: \| [a-z0-9][a-z0-9+.-]*)*$/.test(x)), "Invalid app Linux packaging policy");
8437
- check(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
9254
+ const executable = policy.executable ?? policy.packageName;
9255
+ const links = policy.links ?? [];
9256
+ check2([policy.bundleRoot, policy.artifactStem, policy.desktopId].every((n) => component.test(n)) && /^[a-z0-9][a-z0-9+.-]+$/.test(policy.packageName) && typeof executable === "string" && commandName.test(executable) && Array.isArray(links) && links.every((link) => link && typeof link.name === "string" && commandName.test(link.name) && typeof link.target === "string" && relativeFiles(link.target) && link.name !== executable) && new Set(links.map((link) => link.name)).size === links.length && [policy.launcher, policy.icon, ...policy.debSetuid.map((item) => item.path)].every(relativeFiles) && policy.debSetuid.every((item) => sha2562.test(item.sha256)) && new Set(policy.debSetuid.map((item) => item.path)).size === policy.debSetuid.length && /^[A-Z][A-Z0-9_]*_LINUX_PACKAGE_FORMAT$/.test(policy.formatEnvironment) && policy.mimeTypes.every((x) => /^x-scheme-handler\/[a-z][a-z0-9+.-]*$/.test(x)) && [policy.name, policy.description, policy.maintainer, policy.homepage].every(text2) && policy.categories.every((x) => /^[A-Za-z0-9]+$/.test(x)) && policy.dependencies.every((x) => /^[a-z0-9][a-z0-9+.-]*(?: \| [a-z0-9][a-z0-9+.-]*)*$/.test(x)), "Invalid app Linux packaging policy");
9257
+ check2(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
8438
9258
  }
8439
9259
  async function buildLinuxFormats(input, host) {
8440
9260
  const { tag, sourceSha, expectedSourceSha, sourceDateEpoch, policy } = input;
8441
- check(host.os === "linux" && host.arch === "x64", "Requires native Linux x64");
8442
- check(/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) && /^[a-f0-9]{40}$/.test(sourceSha) && sourceSha === expectedSourceSha, "Wrong protected build source or tag");
8443
- check(Number.isSafeInteger(sourceDateEpoch) && sourceDateEpoch > 0 && sourceDateEpoch <= 4294967295, "Expected valid protected SOURCE_DATE_EPOCH");
9261
+ const checkAbort = () => host.signal?.throwIfAborted();
9262
+ checkAbort();
9263
+ check2(host.os === "linux" && host.arch === "x64", "Requires native Linux x64");
9264
+ check2(/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) && /^[a-f0-9]{40}$/.test(sourceSha) && sourceSha === expectedSourceSha, "Wrong protected build source or tag");
9265
+ check2(Number.isSafeInteger(sourceDateEpoch) && sourceDateEpoch > 0 && sourceDateEpoch <= 4294967295, "Expected valid protected SOURCE_DATE_EPOCH");
9266
+ if (input.identity)
9267
+ check2(input.identity.workflowSha === sourceSha && /^[1-9]\d{0,19}$/.test(input.identity.runId) && Number.isSafeInteger(input.identity.runAttempt) && input.identity.runAttempt > 0, "Invalid Linux build workflow identity");
8444
9268
  const env = { SOURCE_DATE_EPOCH: String(sourceDateEpoch), LC_ALL: "C", TZ: "UTC" };
8445
9269
  validatePolicy(policy);
8446
- const requested = resolve17(input.output);
8447
- const parent = await realpath11(dirname15(requested));
8448
- const output = join34(parent, basename16(requested));
8449
- const work = await mkdtemp11(join34(parent, ".linux-formats-"));
9270
+ const requested = resolve18(input.output);
9271
+ const parent = await realpath12(dirname15(requested));
9272
+ const output = join36(parent, basename16(requested));
9273
+ const work = await mkdtemp11(join36(parent, ".linux-formats-"));
9274
+ let outputOwned = false;
8450
9275
  try {
8451
- const archive = join34(work, "payload.tar.zst");
8452
- const tool = join34(work, "appimagetool");
8453
- const runtime = join34(work, "runtime");
9276
+ const archive = join36(work, "payload.tar.zst");
9277
+ const tool = join36(work, "appimagetool");
9278
+ const runtime = join36(work, "runtime");
8454
9279
  for (const [pin, dest] of [
8455
9280
  [input.archive, archive],
8456
9281
  [input.tool, tool],
@@ -8459,47 +9284,58 @@ async function buildLinuxFormats(input, host) {
8459
9284
  await exactCopy(pin, dest);
8460
9285
  await elf(tool, true);
8461
9286
  await elf(runtime, true);
8462
- await host.inspectAppArchive(archive);
8463
- check((await lstat20(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app inspection");
8464
9287
  await chmod4(tool, 448);
8465
- const extracted = join34(work, "extract");
9288
+ const extracted = join36(work, "extract");
8466
9289
  await mkdir12(extracted);
8467
- await host.run("tar", [
8468
- "--zstd",
8469
- "--extract",
8470
- "--file",
8471
- archive,
8472
- "--directory",
8473
- extracted,
8474
- "--no-same-owner",
8475
- "--no-same-permissions"
8476
- ], { env });
8477
- const source = join34(extracted, policy.bundleRoot);
8478
- check((await lstat20(source)).isDirectory() && await realpath11(source) === source, "Wrong extracted app root");
9290
+ if (host.extractVerifiedAppArchive) {
9291
+ await host.extractVerifiedAppArchive(archive, extracted);
9292
+ } else {
9293
+ await host.inspectAppArchive(archive);
9294
+ check2((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app inspection");
9295
+ await host.run("tar", [
9296
+ "--zstd",
9297
+ "--extract",
9298
+ "--file",
9299
+ archive,
9300
+ "--directory",
9301
+ extracted,
9302
+ "--no-same-owner",
9303
+ "--no-same-permissions"
9304
+ ], { env });
9305
+ }
9306
+ check2((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app extraction");
9307
+ checkAbort();
9308
+ const source = join36(extracted, policy.bundleRoot);
9309
+ check2((await lstat21(source)).isDirectory() && await realpath12(source) === source, "Wrong extracted app root");
8479
9310
  await chmod4(source, 493);
8480
9311
  await normalizeTree(source);
8481
- await elf(await regular(source, policy.launcher));
9312
+ await elf(await regular2(source, policy.launcher));
9313
+ for (const link of policy.links ?? []) {
9314
+ const target = await regular2(source, link.target);
9315
+ check2(((await lstat21(target)).mode & 73) !== 0, "CLI link target is not executable");
9316
+ }
8482
9317
  for (const pin of policy.debSetuid) {
8483
- const file = await regular(source, pin.path);
9318
+ const file = await regular2(source, pin.path);
8484
9319
  await elf(file);
8485
- check(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
9320
+ check2(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
8486
9321
  }
8487
- const icon = await regular(source, policy.icon);
8488
- check(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
9322
+ const icon = await regular2(source, policy.icon);
9323
+ check2(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
8489
9324
  const stem = `${policy.artifactStem}-${tag}-linux-x64`;
8490
9325
  const debName = `${stem}.deb`;
8491
9326
  const imageName = `${stem}.AppImage`;
8492
- const dest = join34(work, "result");
9327
+ const dest = join36(work, "result");
8493
9328
  await mkdir12(dest);
8494
9329
  const version = tag.slice(1);
8495
9330
  const installed = `usr/lib/${policy.packageName}`;
9331
+ const executable = policy.executable ?? policy.packageName;
8496
9332
  const desktopFile = `${policy.desktopId}.desktop`;
8497
9333
  const desktop = [
8498
9334
  "[Desktop Entry]",
8499
9335
  "Type=Application",
8500
9336
  `Name=${policy.name}`,
8501
9337
  `Comment=${policy.description}`,
8502
- `Exec=${policy.packageName} %U`,
9338
+ `Exec=${executable} %U`,
8503
9339
  `Icon=${policy.desktopId}`,
8504
9340
  `Categories=${policy.categories.join(";")};`,
8505
9341
  ...policy.mimeTypes.length ? [`MimeType=${policy.mimeTypes.join(";")};`] : [],
@@ -8508,20 +9344,28 @@ async function buildLinuxFormats(input, host) {
8508
9344
  ].join(`
8509
9345
  `);
8510
9346
  for (const format of ["deb", "appimage"]) {
8511
- const tree = join34(work, format);
8512
- await mkdir12(join34(tree, "usr", "lib"), { recursive: true });
8513
- const bundle = join34(tree, installed);
9347
+ checkAbort();
9348
+ const tree = join36(work, format);
9349
+ await mkdir12(join36(tree, "usr", "lib"), { recursive: true });
9350
+ const bundle = join36(tree, installed);
8514
9351
  await cp(source, bundle, { recursive: true, verbatimSymlinks: true });
8515
9352
  await normalizeTree(bundle);
9353
+ const appDirectory = join36(bundle, "Resources", "app");
9354
+ check2((await lstat21(appDirectory)).isDirectory() && await realpath12(appDirectory) === appDirectory, "Expected a real packaged app directory");
9355
+ await write(bundle, "Resources/app/.adea-linux-package", `${format}
9356
+ `);
8516
9357
  await write(tree, `usr/share/applications/${desktopFile}`, desktop);
8517
- const iconDest = join34(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
9358
+ const iconDest = join36(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
8518
9359
  await mkdir12(dirname15(iconDest), { recursive: true });
8519
9360
  await cp(icon, iconDest, { force: false, errorOnExist: true });
8520
9361
  await chmod4(iconDest, 420);
9362
+ await mkdir12(join36(tree, "usr", "bin"), { recursive: true });
9363
+ for (const link of policy.links ?? [])
9364
+ await symlink2(`../lib/${policy.packageName}/${link.target}`, join36(tree, "usr", "bin", link.name));
8521
9365
  if (format === "deb") {
8522
9366
  for (const pin of policy.debSetuid)
8523
- await chmod4(await regular(bundle, pin.path), 2541);
8524
- await write(tree, `usr/bin/${policy.packageName}`, `#!/bin/sh
9367
+ await chmod4(await regular2(bundle, pin.path), 2541);
9368
+ await write(tree, `usr/bin/${executable}`, `#!/bin/sh
8525
9369
  export ${policy.formatEnvironment}=deb
8526
9370
  exec '/${installed}/${policy.launcher}' "$@"
8527
9371
  `, 493);
@@ -8537,9 +9381,15 @@ exec '/${installed}/${policy.launcher}' "$@"
8537
9381
  ].join(`
8538
9382
  `));
8539
9383
  await normalizeBuildTimes(tree, sourceDateEpoch);
8540
- await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join34(dest, debName)], { env });
9384
+ await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join36(dest, debName)], { env });
8541
9385
  } else {
8542
- const rootIcon = join34(tree, `${policy.desktopId}.svg`);
9386
+ await write(tree, `usr/bin/${executable}`, `#!/bin/sh
9387
+ set -eu
9388
+ root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
9389
+ export ${policy.formatEnvironment}=appimage
9390
+ exec "$root/${installed}/${policy.launcher}" "$@"
9391
+ `, 493);
9392
+ const rootIcon = join36(tree, `${policy.desktopId}.svg`);
8543
9393
  await cp(icon, rootIcon, { force: false, errorOnExist: true });
8544
9394
  await chmod4(rootIcon, 420);
8545
9395
  await write(tree, desktopFile, desktop);
@@ -8553,7 +9403,7 @@ exec '/${installed}/${policy.launcher}' "$@"
8553
9403
  ].join(`
8554
9404
  `), 493);
8555
9405
  await normalizeBuildTimes(tree, sourceDateEpoch);
8556
- await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join34(dest, imageName)], {
9406
+ await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join36(dest, imageName)], {
8557
9407
  executable: tool,
8558
9408
  env: { ...env, ARCH: "x86_64", VERSION: version, APPIMAGE_EXTRACT_AND_RUN: "1" }
8559
9409
  });
@@ -8561,9 +9411,9 @@ exec '/${installed}/${policy.launcher}' "$@"
8561
9411
  }
8562
9412
  const artifacts = [];
8563
9413
  for (const name of [debName, imageName]) {
8564
- const path = await regular(dest, name);
8565
- const size = (await lstat20(path)).size;
8566
- check(size > 0, "Empty produced artifact");
9414
+ const path = await regular2(dest, name);
9415
+ const size = (await lstat21(path)).size;
9416
+ check2(size > 0, "Empty produced artifact");
8567
9417
  artifacts.push({ name, size, sha256: await sum(path) });
8568
9418
  }
8569
9419
  const receipt = {
@@ -8571,30 +9421,50 @@ exec '/${installed}/${policy.launcher}' "$@"
8571
9421
  tag,
8572
9422
  sourceSha,
8573
9423
  sourceDateEpoch,
9424
+ ...input.identity,
8574
9425
  platform: "linux-x64",
8575
9426
  updateArchiveSha256: input.archive.sha256,
8576
9427
  artifacts
8577
9428
  };
9429
+ checkAbort();
8578
9430
  await mkdir12(output);
9431
+ outputOwned = true;
8579
9432
  try {
8580
9433
  for (const item of artifacts)
8581
- await cp(join34(dest, item.name), join34(output, basename16(item.name)), {
9434
+ await cp(join36(dest, item.name), join36(output, basename16(item.name)), {
8582
9435
  force: false,
8583
9436
  errorOnExist: true
8584
9437
  });
9438
+ checkAbort();
8585
9439
  await write(output, "linux-format-build.json", JSON.stringify(receipt) + `
8586
9440
  `);
9441
+ checkAbort();
8587
9442
  } catch (error) {
8588
9443
  await rm11(output, { recursive: true, force: true });
9444
+ outputOwned = false;
8589
9445
  throw error;
8590
9446
  }
8591
9447
  return receipt;
8592
9448
  } finally {
8593
- await rm11(work, { recursive: true, force: true });
9449
+ let cleanupComplete = false;
9450
+ try {
9451
+ await rm11(work, { recursive: true, force: true });
9452
+ await host.afterWorkCleanup?.();
9453
+ cleanupComplete = true;
9454
+ } finally {
9455
+ if ((!cleanupComplete || host.signal?.aborted) && outputOwned) {
9456
+ await rm11(output, { recursive: true, force: true });
9457
+ host.signal?.throwIfAborted();
9458
+ }
9459
+ }
8594
9460
  }
8595
9461
  }
8596
9462
  export {
8597
9463
  buildLinuxFormats,
9464
+ compareLinuxReproducibility,
9465
+ createDailyBatchR2Client,
9466
+ createDailyBatchR2Store,
9467
+ createDailyBatchS3Transport,
8598
9468
  createDailyNativeReceipt,
8599
9469
  createGitHubPromotionProvider,
8600
9470
  createGitHubReleasePublisher,
@@ -8602,15 +9472,19 @@ export {
8602
9472
  desktopDailyProfile,
8603
9473
  fileIdentity2 as fileIdentity,
8604
9474
  finalizeReleasePleaseDraft,
9475
+ inspectDailyBatch,
8605
9476
  inspectStagedStep,
8606
9477
  planDailyReleaseMatrix,
8607
9478
  planQualificationRun2 as planQualificationRun,
8608
9479
  planReleaseAssets2 as planReleaseAssets,
9480
+ promoteDailyBatch,
8609
9481
  publishFrameworkPackage,
8610
9482
  publishQualifiedRelease,
8611
9483
  qualifyGitHubRelease,
8612
9484
  qualifyStep,
8613
9485
  qualifyUpgradeStep,
9486
+ readDailyBatch,
9487
+ rollbackDailyBatch,
8614
9488
  runPromotionCommand,
8615
9489
  runReleaseCutCommand,
8616
9490
  runReleasePublishCommand,
@@ -8621,6 +9495,8 @@ export {
8621
9495
  stageLinuxPackagePair,
8622
9496
  stagePlatformArtifacts,
8623
9497
  stageReleaseDescriptors,
9498
+ verifyDailyBatchDescriptor,
9499
+ verifyDailyBatchObject,
8624
9500
  verifyDailyReleaseMatrix,
8625
9501
  verifyImage,
8626
9502
  writeDescriptors