@adea-ai/app-framework-release-tools 0.4.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
@@ -17,6 +17,11 @@ var __export = (target, all) => {
17
17
  // src/index.ts
18
18
  var exports_src = {};
19
19
  __export(exports_src, {
20
+ buildLinuxFormats: () => buildLinuxFormats,
21
+ compareLinuxReproducibility: () => compareLinuxReproducibility,
22
+ createDailyBatchR2Client: () => createDailyBatchR2Client,
23
+ createDailyBatchR2Store: () => createDailyBatchR2Store,
24
+ createDailyBatchS3Transport: () => createDailyBatchS3Transport,
20
25
  createDailyNativeReceipt: () => createDailyNativeReceipt,
21
26
  createGitHubPromotionProvider: () => createGitHubPromotionProvider,
22
27
  createGitHubReleasePublisher: () => createGitHubReleasePublisher,
@@ -24,15 +29,19 @@ __export(exports_src, {
24
29
  desktopDailyProfile: () => desktopDailyProfile,
25
30
  fileIdentity: () => fileIdentity2,
26
31
  finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
32
+ inspectDailyBatch: () => inspectDailyBatch,
27
33
  inspectStagedStep: () => inspectStagedStep,
28
34
  planDailyReleaseMatrix: () => planDailyReleaseMatrix,
29
35
  planQualificationRun: () => planQualificationRun2,
30
36
  planReleaseAssets: () => planReleaseAssets2,
37
+ promoteDailyBatch: () => promoteDailyBatch,
31
38
  publishFrameworkPackage: () => publishFrameworkPackage,
32
39
  publishQualifiedRelease: () => publishQualifiedRelease,
33
40
  qualifyGitHubRelease: () => qualifyGitHubRelease,
34
41
  qualifyStep: () => qualifyStep,
35
42
  qualifyUpgradeStep: () => qualifyUpgradeStep,
43
+ readDailyBatch: () => readDailyBatch,
44
+ rollbackDailyBatch: () => rollbackDailyBatch,
36
45
  runPromotionCommand: () => runPromotionCommand,
37
46
  runReleaseCutCommand: () => runReleaseCutCommand,
38
47
  runReleasePublishCommand: () => runReleasePublishCommand,
@@ -43,6 +52,8 @@ __export(exports_src, {
43
52
  stageLinuxPackagePair: () => stageLinuxPackagePair,
44
53
  stagePlatformArtifacts: () => stagePlatformArtifacts,
45
54
  stageReleaseDescriptors: () => stageReleaseDescriptors,
55
+ verifyDailyBatchDescriptor: () => verifyDailyBatchDescriptor,
56
+ verifyDailyBatchObject: () => verifyDailyBatchObject,
46
57
  verifyDailyReleaseMatrix: () => verifyDailyReleaseMatrix,
47
58
  verifyImage: () => verifyImage,
48
59
  writeDescriptors: () => writeDescriptors
@@ -175,7 +186,7 @@ function parseArchPackage(value) {
175
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");
176
187
  assert(policy.channel === undefined || policy.channel === "stable" || policy.channel === "daily", "Invalid Arch package channel");
177
188
  const repository = policy.repository;
178
- 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");
179
190
  return {
180
191
  pkgname: policy.pkgname,
181
192
  pkgdesc: policy.pkgdesc,
@@ -239,7 +250,8 @@ function parseArchPackage(value) {
239
250
  repository: {
240
251
  name: repository.name,
241
252
  base: repository.base,
242
- publicKey: repository.publicKey
253
+ publicKey: repository.publicKey,
254
+ ...typeof repository.keyFingerprint === "string" ? { keyFingerprint: repository.keyFingerprint } : {}
243
255
  }
244
256
  }
245
257
  };
@@ -799,15 +811,122 @@ async function runReleaseEffect(effect) {
799
811
  }
800
812
 
801
813
  // src/release-ports.ts
802
- import { execFile, spawnSync } from "child_process";
814
+ import { execFile, spawn, spawnSync } from "child_process";
803
815
  import { createPrivateKey } from "crypto";
804
816
  import * as fsp from "fs/promises";
805
817
  import { Context, Effect as Effect2 } from "effect";
818
+ import { promisify } from "util";
806
819
  import { Effect as Effect3, Fiber, Option } from "effect";
807
820
 
808
821
  class ReleaseGit extends Context.Service()("ReleaseTools/Git") {
809
822
  }
810
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
+
811
930
  class ReleaseGitHub extends Context.Service()("ReleaseTools/GitHub") {
812
931
  }
813
932
 
@@ -3144,6 +3263,424 @@ var stageReleaseDescriptorsEffect = (options) => Effect15.gen(function* () {
3144
3263
  });
3145
3264
  var writeDescriptors = (directory, signed) => runReleaseLibrary(provideLibraryPorts()(writeDescriptorsEffect(directory, signed)));
3146
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
+
3147
3684
  // src/library/daily-matrix.ts
3148
3685
  import { join as join7 } from "path";
3149
3686
  import { Effect as Effect16 } from "effect";
@@ -3344,10 +3881,136 @@ var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
3344
3881
  function verifyDailyReleaseMatrix(options) {
3345
3882
  return runReleaseLibrary(provideLibraryPorts()(verifyDailyReleaseMatrixEffect(options)));
3346
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() {}
3347
4010
  // src/library/daily-native-receipt.ts
3348
- import { join as join8 } from "path";
3349
- import { Effect as Effect17 } from "effect";
3350
- 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* () {
3351
4014
  const { config, identity, artifacts, checkName, report } = options;
3352
4015
  yield* attempt(() => assertDailyIdentity(identity));
3353
4016
  const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
@@ -3361,7 +4024,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function*
3361
4024
  const dir = yield* step(() => fs.lstat(artifacts));
3362
4025
  if (!dir.isDirectory() || dir.isSymbolicLink())
3363
4026
  return yield* fail("Expected real native artifact directory");
3364
- 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));
3365
4028
  const evidence = yield* attempt(() => validateDailyNativeEvidence(report, "framework/daily-native-job/v1", {
3366
4029
  appId: matrix.appId,
3367
4030
  identity,
@@ -3379,7 +4042,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function*
3379
4042
  const { baselineAsset, baselineOrigin } = evidence.observations.upgrade;
3380
4043
  const proofFiles = baselineOrigin.kind === "private-from-verified-payload" ? [baselineAsset, baselineOrigin.payload] : [baselineAsset];
3381
4044
  for (const expected of proofFiles) {
3382
- const observed = yield* fileIdentityEffect(join8(baselineDirectory, expected.name), expected.name);
4045
+ const observed = yield* fileIdentityEffect(join9(baselineDirectory, expected.name), expected.name);
3383
4046
  if (observed.size !== expected.size || observed.digest !== expected.digest)
3384
4047
  return yield* fail("Daily desktop baseline installer or prior payload differs from native observations");
3385
4048
  }
@@ -3402,6 +4065,160 @@ function createDailyNativeReceipt(options) {
3402
4065
  arch: process.arch
3403
4066
  })));
3404
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
+ }
3405
4222
  // src/library/macos-dmg.ts
3406
4223
  import { execFileSync } from "child_process";
3407
4224
  import {
@@ -3413,8 +4230,8 @@ import {
3413
4230
  rmSync,
3414
4231
  symlinkSync
3415
4232
  } from "fs";
3416
- import { basename as basename4, dirname, join as join9, resolve as resolve6 } from "path";
3417
- 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";
3418
4235
 
3419
4236
  // ../../src/release/macos-dmg.ts
3420
4237
  var MIB = 1024 * 1024;
@@ -3445,7 +4262,7 @@ function treeSize(root) {
3445
4262
  logicalBytes += info.size;
3446
4263
  else if (info.isDirectory())
3447
4264
  for (const name of readdirSync(path))
3448
- pending.push(join9(path, name));
4265
+ pending.push(join11(path, name));
3449
4266
  else if (!info.isSymbolicLink())
3450
4267
  throw new Error("Unsupported disk image entry");
3451
4268
  if (!Number.isSafeInteger(logicalBytes))
@@ -3453,29 +4270,29 @@ function treeSize(root) {
3453
4270
  }
3454
4271
  return { logicalBytes, entries };
3455
4272
  }
3456
- var verifyImageEffect = (image) => Effect18.gen(function* () {
4273
+ var verifyImageEffect = (image) => Effect19.gen(function* () {
3457
4274
  const host = yield* MacosHost;
3458
4275
  for (let tries = 1;; tries++) {
3459
- 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)));
3460
4277
  if (verified)
3461
4278
  return;
3462
4279
  host.wait(5000 * 2 ** (tries - 1));
3463
4280
  }
3464
4281
  });
3465
- var createMacosDmgEffect = (options) => Effect18.gen(function* () {
4282
+ var createMacosDmgEffect = (options) => Effect19.gen(function* () {
3466
4283
  const host = yield* MacosHost;
3467
4284
  if (host.platform !== "darwin")
3468
4285
  return yield* fail("Disk image creation requires macOS");
3469
4286
  assertPortableAppName(options.appName);
3470
- const app = resolve6(options.appPath), output = resolve6(options.outputPath);
4287
+ const app = resolve7(options.appPath), output = resolve7(options.outputPath);
3471
4288
  const info = yield* attempt(() => lstatSync(app));
3472
4289
  if (!app.endsWith(".app") || !info.isDirectory() || info.isSymbolicLink() || !output.endsWith(".dmg"))
3473
4290
  return yield* fail("Invalid disk image paths");
3474
- const staging = yield* Effect18.acquireRelease(attempt(() => mkdtempSync(join9(dirname(output), ".framework-dmg-"))), (path) => Effect18.sync(() => rmSync(path, { recursive: true, force: true })));
3475
- 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");
3476
4293
  yield* attempt(() => mkdirSync(payload));
3477
- yield* attempt(() => host.run("/usr/bin/ditto", [app, join9(payload, basename4(app))]));
3478
- 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")));
3479
4296
  const capacityMiB = yield* attempt(() => dmgCapacityMiB(treeSize(payload)));
3480
4297
  yield* attempt(() => host.run("/usr/bin/hdiutil", [
3481
4298
  "create",
@@ -3492,36 +4309,36 @@ var createMacosDmgEffect = (options) => Effect18.gen(function* () {
3492
4309
  yield* verifyImageEffect(image);
3493
4310
  yield* attempt(() => linkSync(image, output));
3494
4311
  return { capacityMiB };
3495
- }).pipe(Effect18.scoped);
4312
+ }).pipe(Effect19.scoped);
3496
4313
  function verifyImage(image, io = liveHost) {
3497
- runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect18.provideService(MacosHost, {
4314
+ runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect19.provideService(MacosHost, {
3498
4315
  run: (command, args) => io.run(command, args),
3499
4316
  wait: (milliseconds) => io.wait(milliseconds),
3500
4317
  platform: process.platform
3501
4318
  })));
3502
4319
  }
3503
4320
  function createMacosDmg(options) {
3504
- return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect18.provideService(MacosHost, liveHost)));
4321
+ return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect19.provideService(MacosHost, liveHost)));
3505
4322
  }
3506
4323
  // src/library/qualification-run.ts
3507
- import { Effect as Effect21 } from "effect";
4324
+ import { Effect as Effect22 } from "effect";
3508
4325
 
3509
4326
  // src/library/local-release.ts
3510
- import { createHash as createHash8 } from "crypto";
4327
+ import { createHash as createHash11 } from "crypto";
3511
4328
  import { constants as constants3 } from "fs";
3512
- import { dirname as dirname2, join as join11, resolve as resolve8 } from "path";
3513
- 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";
3514
4331
 
3515
4332
  // ../../src/native/native-rename.ts
3516
4333
  import { randomUUID } from "crypto";
3517
- 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";
3518
4335
  import { dlopen, FFIType, ptr } from "bun:ffi";
3519
- import { join as join10 } from "path";
4336
+ import { join as join12 } from "path";
3520
4337
 
3521
4338
  // ../../src/native/canonical-path.ts
3522
- import { isAbsolute as isAbsolute2, resolve as resolve7 } from "path";
4339
+ import { isAbsolute as isAbsolute3, resolve as resolve8 } from "path";
3523
4340
  function isCanonicalPath(value) {
3524
- 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");
3525
4342
  }
3526
4343
 
3527
4344
  // ../../src/native/native-rename.ts
@@ -3595,8 +4412,8 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
3595
4412
  if (!isCanonicalPath(parent))
3596
4413
  throw new Error("Invalid directory exchange probe parent");
3597
4414
  const id = randomUUID();
3598
- const first = join10(parent, `.framework-exchange-probe-${id}-a`);
3599
- 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`);
3600
4417
  const marker = "exchange-probe";
3601
4418
  const firstValue = `${id}:first`;
3602
4419
  const secondValue = `${id}:second`;
@@ -3607,12 +4424,12 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
3607
4424
  firstCreated = true;
3608
4425
  await mkdir3(second, { mode: 448 });
3609
4426
  secondCreated = true;
3610
- await writeFile3(join10(first, marker), firstValue, { flag: "wx", mode: 384 });
3611
- 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 });
3612
4429
  exchange(first, second);
3613
4430
  const [firstAfter, secondAfter] = await Promise.all([
3614
- readFile5(join10(first, marker), "utf8"),
3615
- readFile5(join10(second, marker), "utf8")
4431
+ readFile6(join12(first, marker), "utf8"),
4432
+ readFile6(join12(second, marker), "utf8")
3616
4433
  ]);
3617
4434
  if (firstAfter !== secondValue || secondAfter !== firstValue)
3618
4435
  throw new Error("Directory exchange did not exchange both probe trees");
@@ -3677,8 +4494,8 @@ function createFeedReleaseCutProvider(options) {
3677
4494
  }
3678
4495
 
3679
4496
  // src/library/feed-state.ts
3680
- import { createHash as createHash7 } from "crypto";
3681
- import { Effect as Effect19 } from "effect";
4497
+ import { createHash as createHash10 } from "crypto";
4498
+ import { Effect as Effect20 } from "effect";
3682
4499
 
3683
4500
  // ../../src/shared/discard-stream.ts
3684
4501
  function discardStream(stream) {
@@ -3838,11 +4655,11 @@ var json = (bytes) => {
3838
4655
  throw new Error("Invalid release feed response");
3839
4656
  }
3840
4657
  };
3841
- var feedObject = (feed, path, maximum) => Effect19.gen(function* () {
4658
+ var feedObject = (feed, path, maximum) => Effect20.gen(function* () {
3842
4659
  const { fetch: fetch2 } = yield* ReleaseFetch;
3843
4660
  return yield* step(() => readFeedObject(feed, path, fetch2, maximum));
3844
4661
  });
3845
- var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
4662
+ var readFeedLedgerEffect = (feed) => Effect20.gen(function* () {
3846
4663
  const bytes = yield* feedObject(feed, "index.json", MAX_LEDGER_BYTES);
3847
4664
  const ledger = bytes ? yield* attempt(() => parseReleaseLedger(json(bytes), feed.app)) : null;
3848
4665
  if (ledger && ledger.releases.length > 0)
@@ -3854,7 +4671,7 @@ var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
3854
4671
  }
3855
4672
  return ledger ?? { schema: 1, app: feed.app, releases: [] };
3856
4673
  });
3857
- var readFeedReleaseEffect = (feed, tag) => Effect19.gen(function* () {
4674
+ var readFeedReleaseEffect = (feed, tag) => Effect20.gen(function* () {
3858
4675
  const bytes = yield* feedObject(feed, `${tag}/release.json`, MAX_RELEASE_BYTES);
3859
4676
  if (!bytes)
3860
4677
  return null;
@@ -3904,10 +4721,10 @@ class ReleaseFeedSnapshotChanged extends Error {
3904
4721
  var snapshotChanged = step(async () => {
3905
4722
  throw new ReleaseFeedSnapshotChanged;
3906
4723
  });
3907
- var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
4724
+ var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
3908
4725
  const { config, feed, tag } = options;
3909
4726
  const { fetch: fetcher } = yield* ReleaseFetch;
3910
- 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));
3911
4728
  if (options.expectedLedger && JSON.stringify(ledger) !== JSON.stringify(options.expectedLedger))
3912
4729
  return yield* snapshotChanged;
3913
4730
  const release = yield* readFeedReleaseEffect(feed, tag);
@@ -3925,7 +4742,7 @@ var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
3925
4742
  if (!listed)
3926
4743
  return yield* fail(`Missing signed descriptor: ${policy.name}`);
3927
4744
  const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
3928
- 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)
3929
4746
  return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
3930
4747
  const verified = verifyReleaseDescriptor(json(bytes), {
3931
4748
  appId: policy.appId,
@@ -3970,13 +4787,13 @@ var timestamp2 = (value) => {
3970
4787
  throw new Error("Invalid release clock");
3971
4788
  return new Date(value).toISOString();
3972
4789
  };
3973
- var exactFiles = (directory, names) => Effect20.gen(function* () {
4790
+ var exactFiles = (directory, names) => Effect21.gen(function* () {
3974
4791
  const fs = yield* ReleaseFs;
3975
4792
  const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
3976
4793
  if (entries.length !== names.length || entries.some((entry) => !entry.isFile() || !names.includes(entry.name)))
3977
4794
  return yield* fail("Staged directory does not hold exactly the platform release files");
3978
4795
  });
3979
- var promised2 = Effect20.gen(function* () {
4796
+ var promised2 = Effect21.gen(function* () {
3980
4797
  const fs = yield* ReleaseFs;
3981
4798
  const { fetch: fetch2 } = yield* ReleaseFetch;
3982
4799
  const { run: git } = yield* ReleaseGit;
@@ -3986,7 +4803,7 @@ var promised2 = Effect20.gen(function* () {
3986
4803
  run: (effect) => runReleaseLibrary(provideLibraryPorts({ fs, fetch: fetch2, git })(effect))
3987
4804
  };
3988
4805
  });
3989
- var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
4806
+ var runLocalReleaseCutEffect = (options) => Effect21.gen(function* () {
3990
4807
  const { kind, platform } = options;
3991
4808
  const parsed = parseReleaseConfig(options.config);
3992
4809
  const provenance = yield* resolveLocalProvenanceEffect({
@@ -4011,7 +4828,7 @@ var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
4011
4828
  }));
4012
4829
  return { ...result, version: result.tag.slice(1), platform };
4013
4830
  });
4014
- var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
4831
+ var localTagProvenanceEffect = (options) => Effect21.gen(function* () {
4015
4832
  const parsed = parseReleaseConfig(options.config);
4016
4833
  parsed.requirements(options.tag);
4017
4834
  const provenance = yield* resolveLocalProvenanceEffect({
@@ -4022,16 +4839,16 @@ var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
4022
4839
  return yield* fail("Release tag does not belong to the source version");
4023
4840
  return { repository: provenance.repository };
4024
4841
  });
4025
- var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
4842
+ var stageLocalDescriptorsEffect = (options) => Effect21.gen(function* () {
4026
4843
  const { tag, platform } = options;
4027
4844
  const local = localConfig(options.config);
4028
4845
  if (!/^[1-9]\d{0,19}$/.test(options.runId) || !isGitSha(options.sourceSha))
4029
4846
  return yield* fail("Invalid local release identity");
4030
4847
  const publicKey = configuredSigningKey(local.config, options.keyId, options.privateKey);
4031
4848
  const payloads = platformPayloads(local.requirements(tag), platform);
4032
- const directory = resolve8(options.directory);
4849
+ const directory = resolve9(options.directory);
4033
4850
  yield* exactFiles(directory, payloads);
4034
- 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" });
4035
4852
  const signed = signDiscoveryDescriptors({
4036
4853
  policies: discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform),
4037
4854
  assets,
@@ -4049,7 +4866,7 @@ var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
4049
4866
  privateKey: options.privateKey
4050
4867
  });
4051
4868
  for (const asset of assets)
4052
- 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))
4053
4870
  return yield* fail("Staged payload changed before signing");
4054
4871
  yield* writeDescriptorsEffect(directory, signed);
4055
4872
  return signed.map((value) => value.name);
@@ -4069,22 +4886,22 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
4069
4886
  var describe = (key, bytes, cacheControl) => ({
4070
4887
  key,
4071
4888
  size: bytes.length,
4072
- sha256: createHash8("sha256").update(bytes).digest("hex"),
4889
+ sha256: createHash11("sha256").update(bytes).digest("hex"),
4073
4890
  contentType: "application/json",
4074
4891
  cacheControl
4075
4892
  });
4076
- var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* () {
4893
+ var writeStagedTree = (out, feed, assets, documents) => Effect21.gen(function* () {
4077
4894
  const fs = yield* ReleaseFs;
4078
- const root = resolve8(out);
4079
- 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)));
4080
4897
  if (exists)
4081
4898
  return yield* fail("Release output directory already exists");
4082
4899
  yield* step(() => fs.mkdir(dirname2(root), { recursive: true, mode: 448 }));
4083
- const staging = yield* step(() => fs.mkdtemp(join11(dirname2(root), ".release-staging-")));
4084
- 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* () {
4085
4902
  const objects = [];
4086
4903
  for (const { key, path, artifact } of assets) {
4087
- const target = join11(staging, key);
4904
+ const target = join13(staging, key);
4088
4905
  yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
4089
4906
  yield* step(() => fs.copyFile(path, target, constants3.COPYFILE_EXCL));
4090
4907
  if (JSON.stringify(yield* fileIdentityEffect(target, artifact.name)) !== JSON.stringify(artifact))
@@ -4098,13 +4915,13 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4098
4915
  });
4099
4916
  }
4100
4917
  for (const { key, bytes } of documents) {
4101
- const target = join11(staging, key);
4918
+ const target = join13(staging, key);
4102
4919
  yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
4103
4920
  yield* step(() => fs.writeFile(target, bytes, { flag: "wx", mode: 384 }));
4104
4921
  objects.push(describe(key, bytes, MUTABLE));
4105
4922
  }
4106
4923
  const plan = { schema: 1, base: feed.base, objects };
4107
- 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 }));
4108
4925
  yield* attempt(() => renameExclusive(staging, root));
4109
4926
  return plan;
4110
4927
  }));
@@ -4112,10 +4929,10 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4112
4929
  return exit.value;
4113
4930
  const error = Cause2.squash(exit.cause);
4114
4931
  const original = error instanceof ReleaseFailure ? error.original ?? error : error;
4115
- 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 })));
4116
4933
  if (Exit3.isFailure(cleanup)) {
4117
4934
  const cleanupError = Cause2.squash(cleanup.cause);
4118
- return yield* Effect20.fail(new ReleaseFailure({
4935
+ return yield* Effect21.fail(new ReleaseFailure({
4119
4936
  reason: "cleanup",
4120
4937
  message: "Release staging failed and its private temporary tree could not be removed",
4121
4938
  original: new AggregateError([
@@ -4124,8 +4941,8 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4124
4941
  ], "Release staging failed and its private temporary tree could not be removed", { cause: original })
4125
4942
  }));
4126
4943
  }
4127
- return yield* Effect20.failCause(exit.cause);
4128
- }).pipe(Effect20.uninterruptible);
4944
+ return yield* Effect21.failCause(exit.cause);
4945
+ }).pipe(Effect21.uninterruptible);
4129
4946
  function releaseDocuments(feed, ledger, release) {
4130
4947
  return [
4131
4948
  { key: feedReleaseKey(feed, release.tag), bytes: jsonBytes(release) },
@@ -4142,23 +4959,23 @@ function releaseDocuments(feed, ledger, release) {
4142
4959
  }))
4143
4960
  ];
4144
4961
  }
4145
- var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
4962
+ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
4146
4963
  const fs = yield* ReleaseFs;
4147
4964
  const { tag, sourceSha, platform } = options;
4148
4965
  const local = localConfig(options.config);
4149
4966
  const feed = local.feed, now = timestamp2(options.now);
4150
4967
  const payloads = platformPayloads(local.requirements(tag), platform);
4151
4968
  const policies = discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform);
4152
- const directory = resolve8(options.directory);
4969
+ const directory = resolve9(options.directory);
4153
4970
  const names = [...payloads, ...policies.map((policy) => policy.name)];
4154
4971
  yield* exactFiles(directory, names);
4155
- 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" });
4156
4973
  for (const policy of policies) {
4157
4974
  const artifact = staged.find((asset) => asset.name === policy.name);
4158
4975
  if (artifact.size > 65536)
4159
4976
  return yield* fail("Signed descriptor is too large");
4160
- const bytes = yield* step(() => fs.readFile(join11(directory, policy.name)));
4161
- 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)
4162
4979
  return yield* fail("Signed descriptor changed");
4163
4980
  let parsed;
4164
4981
  try {
@@ -4179,7 +4996,7 @@ var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
4179
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)
4180
4997
  return yield* fail(`Untrusted signed descriptor: ${policy.name}`);
4181
4998
  }
4182
- 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" });
4183
5000
  const entry = ledger.releases.find((item) => item.tag === tag);
4184
5001
  if (Boolean(entry) !== Boolean(remote) || entry && remote && (entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt)))
4185
5002
  return yield* fail("Inconsistent feed release; reconcile publication before retrying");
@@ -4197,7 +5014,7 @@ var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
4197
5014
  merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
4198
5015
  uploads.push({
4199
5016
  key: feedAssetKey(feed, tag, artifact.name),
4200
- path: join11(directory, artifact.name),
5017
+ path: join13(directory, artifact.name),
4201
5018
  artifact
4202
5019
  });
4203
5020
  }
@@ -4230,7 +5047,7 @@ function stablePlatforms(config) {
4230
5047
  throw new Error("Invalid stablePlatforms in the release configuration");
4231
5048
  return value;
4232
5049
  }
4233
- var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
5050
+ var verifyLocalReleaseEffect = (options) => Effect21.gen(function* () {
4234
5051
  const local = localConfig(options.config);
4235
5052
  const { release, platforms } = yield* verifyFeedReleaseEffect({
4236
5053
  config: local.config,
@@ -4246,7 +5063,7 @@ var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
4246
5063
  missing: Object.keys(platformTargets).filter((platform) => !platforms.includes(platform))
4247
5064
  };
4248
5065
  });
4249
- var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
5066
+ var runLocalPromotionEffect = (options) => Effect21.gen(function* () {
4250
5067
  const local = localConfig(options.config);
4251
5068
  const feed = local.feed;
4252
5069
  const required = stablePlatforms(local.config);
@@ -4304,7 +5121,7 @@ var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
4304
5121
  const verification = qualified.get(selected.tag);
4305
5122
  const absent = Object.keys(platformTargets).filter((name) => !verification?.platforms.includes(name));
4306
5123
  const entry = ledger.releases.find((item) => item.tag === selected.tag);
4307
- 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)], {
4308
5125
  concurrency: "unbounded"
4309
5126
  }));
4310
5127
  if (!entry || !remote || !verification || entry.kind === "dev" || JSON.stringify(currentLedger) !== JSON.stringify(ledger) || JSON.stringify(remote) !== JSON.stringify(verification.release))
@@ -4343,7 +5160,7 @@ var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
4343
5160
 
4344
5161
  // src/library/qualification-run.ts
4345
5162
  var REFUSAL = "Qualification requires a GitHub release-assets run, a GitLab tag pipeline or a CircleCI tag workflow";
4346
- var tagRun = (options) => Effect21.gen(function* () {
5163
+ var tagRun = (options) => Effect22.gen(function* () {
4347
5164
  const { tag, sha, runId } = options;
4348
5165
  if (options.tagName !== tag || !isGitSha(sha) || !/^[1-9]\d{0,19}$/.test(runId ?? "") || !/^v\d+\.\d+\.\d+$/.test(tag) || tag.length > 65)
4349
5166
  return yield* fail(REFUSAL);
@@ -4357,7 +5174,7 @@ var tagRun = (options) => Effect21.gen(function* () {
4357
5174
  runAttempt: 1
4358
5175
  };
4359
5176
  });
4360
- var planQualificationRunEffect = (options) => Effect21.gen(function* () {
5177
+ var planQualificationRunEffect = (options) => Effect22.gen(function* () {
4361
5178
  const { env, config, tag } = options;
4362
5179
  if (env.GITHUB_ACTIONS === "true") {
4363
5180
  const plan = yield* planReleaseAssetsEffect({ env, config, tag });
@@ -4390,8 +5207,8 @@ var planQualificationRun2 = (options) => runReleaseLibrary(provideLibraryPorts({
4390
5207
  ...options.git ? { git: options.git } : {}
4391
5208
  })(planQualificationRunEffect(options)));
4392
5209
  // src/library/retained-build.ts
4393
- import { Effect as Effect22 } from "effect";
4394
- var id = (value) => Effect22.gen(function* () {
5210
+ import { Effect as Effect23 } from "effect";
5211
+ var id = (value) => Effect23.gen(function* () {
4395
5212
  if (typeof value === "number" && !Number.isSafeInteger(value))
4396
5213
  return yield* fail("Invalid GitHub identity");
4397
5214
  const text = String(value);
@@ -4399,7 +5216,7 @@ var id = (value) => Effect22.gen(function* () {
4399
5216
  return yield* fail("Invalid GitHub identity");
4400
5217
  return text;
4401
5218
  });
4402
- var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
5219
+ var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
4403
5220
  const { env, config, tag, platform } = options;
4404
5221
  if (!["macos-arm64", "windows-x64", "linux-x64"].includes(platform) || !isRecord(config) || typeof config.appName !== "string" || env.RELEASE_TAG !== tag)
4405
5222
  return yield* fail("Invalid retained build context");
@@ -4517,12 +5334,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
4517
5334
  });
4518
5335
  var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
4519
5336
  // src/library/staging.ts
4520
- import { createHash as createHash9 } from "crypto";
4521
- import { join as join12, resolve as resolve9 } from "path";
4522
- import { Effect as Effect23 } from "effect";
4523
- 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({
4524
5341
  try: async (signal) => {
4525
- const hash = createHash9("sha256");
5342
+ const hash = createHash12("sha256");
4526
5343
  let copied = 0;
4527
5344
  for await (const chunk of input.createReadStream({
4528
5345
  autoClose: false
@@ -4549,14 +5366,14 @@ var copyHashed = (input, output, size) => Effect23.tryPromise({
4549
5366
  original: error
4550
5367
  })
4551
5368
  });
4552
- var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
5369
+ var stageExpectedFilesEffect = (options) => Effect24.gen(function* () {
4553
5370
  const fs = yield* ReleaseFs;
4554
5371
  const { expected } = options;
4555
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)))
4556
5373
  return yield* fail("Staging sources do not match expected filenames");
4557
- const directory = resolve9(options.directory);
5374
+ const directory = resolve10(options.directory);
4558
5375
  const created = [];
4559
- const stage = Effect23.forEach(expected, (name) => Effect23.gen(function* () {
5376
+ const stage = Effect24.forEach(expected, (name) => Effect24.gen(function* () {
4560
5377
  const sourcePath = options.sources[name];
4561
5378
  if (typeof sourcePath !== "string" || !sourcePath)
4562
5379
  return yield* fail("Invalid staging source");
@@ -4567,7 +5384,7 @@ var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
4567
5384
  const before = yield* step(() => input.stat());
4568
5385
  if (!before.isFile() || before.dev !== sourceInfo.dev || before.ino !== sourceInfo.ino || before.size !== sourceInfo.size)
4569
5386
  return yield* fail("Staging source changed");
4570
- const target = join12(directory, name);
5387
+ const target = join14(directory, name);
4571
5388
  const output = yield* scopedHandle(() => fs.open(target, "wx"));
4572
5389
  created.push(target);
4573
5390
  const copied = yield* copyHashed(input, output, before.size);
@@ -4576,10 +5393,10 @@ var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
4576
5393
  if (copied.size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.dev !== before.dev || after.ino !== before.ino)
4577
5394
  return yield* fail("Staging source changed");
4578
5395
  return { name, size: copied.size, digest: copied.digest };
4579
- }).pipe(Effect23.scoped), { concurrency: 1 });
4580
- 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(() => {}))))));
4581
5398
  });
4582
- var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
5399
+ var stagePlatformArtifactsEffect = (options) => Effect24.gen(function* () {
4583
5400
  const requirements = parseReleaseConfig(options.config).requirements(options.tag);
4584
5401
  const expected = platformPayloads(requirements, options.platform);
4585
5402
  if (!expected.length || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
@@ -4588,13 +5405,13 @@ var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
4588
5405
  });
4589
5406
  var stagePlatformArtifacts = (options) => runReleaseLibrary(provideLibraryPorts()(stagePlatformArtifactsEffect(options)));
4590
5407
  // src/library/steps.ts
4591
- import { join as join32 } from "path";
4592
- import { Effect as Effect24 } from "effect";
5408
+ import { join as join34 } from "path";
5409
+ import { Effect as Effect25 } from "effect";
4593
5410
 
4594
5411
  // ../../src/installer/installer-archive-members.ts
4595
- import { createHash as createHash10 } from "crypto";
4596
- import { lstat as lstat6, open as open4 } from "fs/promises";
4597
- 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";
4598
5415
 
4599
5416
  // ../../src/installer/native-executable.ts
4600
5417
  async function assertNativeExecutable(file, size, platform, what) {
@@ -4618,7 +5435,7 @@ async function assertNativeExecutable(file, size, platform, what) {
4618
5435
  var EMBEDDED_ARCHIVE_MARKER = Buffer.from("ELECTROBUN_ARCHIVE_V1");
4619
5436
  function isWithin(root, path) {
4620
5437
  const rel = relative3(root, path);
4621
- return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !isAbsolute3(rel);
5438
+ return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !isAbsolute4(rel);
4622
5439
  }
4623
5440
  function normalizeArchiveMember(name) {
4624
5441
  return name.replace(/^\.\//, "").replaceAll("\\", "/");
@@ -4634,7 +5451,7 @@ function findArchiveMember(entries, expected, platform, message) {
4634
5451
  return found[0];
4635
5452
  }
4636
5453
  async function assertArchiveUnchanged(archive, before, message) {
4637
- const after = await lstat6(archive);
5454
+ const after = await lstat7(archive);
4638
5455
  if (!after.isFile() || after.isSymbolicLink() || !sameFile(after, before))
4639
5456
  throw new Error(message);
4640
5457
  }
@@ -4680,7 +5497,7 @@ async function extractArchiveMember(options) {
4680
5497
  }
4681
5498
  }
4682
5499
  async function assertInstallerExecutable(path, platform) {
4683
- const info = await lstat6(path);
5500
+ const info = await lstat7(path);
4684
5501
  if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
4685
5502
  throw new Error("Invalid installer executable");
4686
5503
  const file = await open4(path, "r");
@@ -4699,7 +5516,7 @@ async function assertEmbeddedArchive(path, size, archive) {
4699
5516
  const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
4700
5517
  if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
4701
5518
  throw new Error("Installer archive marker is missing");
4702
- const hash = createHash10("sha256");
5519
+ const hash = createHash13("sha256");
4703
5520
  let read = 0;
4704
5521
  for await (const chunk of file.createReadStream({
4705
5522
  start: position + marker.length,
@@ -4716,23 +5533,23 @@ async function assertEmbeddedArchive(path, size, archive) {
4716
5533
  }
4717
5534
 
4718
5535
  // ../../src/installer/installer-identity.ts
4719
- 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";
4720
5537
  import { tmpdir as tmpdir4 } from "os";
4721
- 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";
4722
5539
 
4723
5540
  // ../../src/installer/installer-image-mount.ts
4724
- import { lstat as lstat7, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir4, rm as rm4, stat } from "fs/promises";
4725
- 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";
4726
5543
  var FAILED_ATTACH_PROBES = 5;
4727
5544
  var FAILED_ATTACH_PROBE_INTERVAL_MS = 500;
4728
5545
  async function containsMountAt(path, expectedDevice) {
4729
- const info = await lstat7(path);
5546
+ const info = await lstat8(path);
4730
5547
  if (!info.isDirectory() || info.isSymbolicLink())
4731
5548
  return false;
4732
5549
  if (info.dev !== expectedDevice)
4733
5550
  return true;
4734
- for (const name of await readdir4(path)) {
4735
- 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);
4736
5553
  if (!childInfo.isDirectory() || childInfo.isSymbolicLink())
4737
5554
  continue;
4738
5555
  if (childInfo.dev !== info.dev || await containsMountAt(child, info.dev))
@@ -4926,8 +5743,8 @@ async function withInstallerImageRetries(options) {
4926
5743
  };
4927
5744
  const priorErrors = () => failedAttempts.map((attempt) => attempt.error);
4928
5745
  for (let attempt = 1;attempt <= maximumAttempts; attempt++) {
4929
- const directory = await mkdtemp3(join13(options.parent, options.prefix));
4930
- const mount = join13(directory, "mount");
5746
+ const directory = await mkdtemp3(join15(options.parent, options.prefix));
5747
+ const mount = join15(directory, "mount");
4931
5748
  const io = options.createIo?.(directory, mount) ?? defaultInstallerImageMountIo(options.run);
4932
5749
  let lifecycleStarted = false;
4933
5750
  try {
@@ -5095,7 +5912,7 @@ async function runInstallerCommand(args, env, options) {
5095
5912
 
5096
5913
  // ../../src/installer/installer-identity.ts
5097
5914
  async function identity(path) {
5098
- const info = await lstat8(path);
5915
+ const info = await lstat9(path);
5099
5916
  if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || !Number.isSafeInteger(info.size))
5100
5917
  throw new Error("Invalid installer artifact");
5101
5918
  const { size, sha256 } = await hashFileAt(path, info, "Installer artifact changed");
@@ -5122,12 +5939,12 @@ async function verifyInstallerPayload(options) {
5122
5939
  else
5123
5940
  assertInstallerContext(parent, options.platform, process.platform, process.arch);
5124
5941
  assertPortableAppName(options.appName);
5125
- const installerPath = resolve10(options.installer), archivePath = resolve10(options.archive);
5942
+ const installerPath = resolve11(options.installer), archivePath = resolve11(options.archive);
5126
5943
  const before = { installer: await identity(installerPath), archive: await identity(archivePath) };
5127
5944
  if (!Number.isSafeInteger(before.archive.size + 256 * 1024 * 1024))
5128
5945
  throw new Error("Installer archive exceeds bound");
5129
5946
  const env = environment(parent);
5130
- const temporary = await mkdtemp4(join14(tmpdir4(), "framework-installer-inspect-"));
5947
+ const temporary = await mkdtemp4(join16(tmpdir4(), "framework-installer-inspect-"));
5131
5948
  const cleanupIo = defaultInstallerImageMountIo(command);
5132
5949
  try {
5133
5950
  if (options.platform === "macos-arm64") {
@@ -5138,24 +5955,24 @@ async function verifyInstallerPayload(options) {
5138
5955
  env,
5139
5956
  run: command,
5140
5957
  work: async (mount) => {
5141
- const apps = (await readdir5(mount)).filter((name) => name.endsWith(".app"));
5958
+ const apps = (await readdir6(mount)).filter((name) => name.endsWith(".app"));
5142
5959
  if (apps.length !== 1)
5143
5960
  throw new Error("Installer application is missing or ambiguous");
5144
- const resources = join14(mount, apps[0], "Contents", "Resources");
5145
- 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);
5146
5963
  if (!isWithin(actualRoot, actualApp) || !isWithin(actualApp, actualResources))
5147
5964
  throw new Error("Installer resources escape mounted image");
5148
- const plist = join14(actualApp, "Contents", "Info.plist"), plistInfo = await lstat8(plist);
5965
+ const plist = join16(actualApp, "Contents", "Info.plist"), plistInfo = await lstat9(plist);
5149
5966
  if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
5150
5967
  throw new Error("Invalid installer property list");
5151
5968
  const executable = (await command(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], env)).trim();
5152
5969
  if (!executable || executable === "." || executable === ".." || /[\\/]/.test(executable))
5153
5970
  throw new Error("Invalid installer executable name");
5154
- await assertInstallerExecutable(join14(actualApp, "Contents", "MacOS", executable), options.platform);
5155
- 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"));
5156
5973
  if (archives.length !== 1)
5157
5974
  throw new Error("Installer archive is missing or ambiguous");
5158
- const embedded = await identity(join14(actualResources, archives[0]));
5975
+ const embedded = await identity(join16(actualResources, archives[0]));
5159
5976
  if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
5160
5977
  throw new Error("Installer archive differs from release archive");
5161
5978
  }
@@ -5173,7 +5990,7 @@ async function verifyInstallerPayload(options) {
5173
5990
  const matches = names.filter((name) => candidates.includes(normalizeArchiveMember(name)));
5174
5991
  if (matches.length !== 1)
5175
5992
  throw new Error("Installer archive is missing or ambiguous");
5176
- const extracted = join14(temporary, "member");
5993
+ const extracted = join16(temporary, "member");
5177
5994
  const count = await extractArchiveMember({
5178
5995
  tar,
5179
5996
  archive: installerPath,
@@ -5184,7 +6001,7 @@ async function verifyInstallerPayload(options) {
5184
6001
  });
5185
6002
  if (options.platform === "windows-x64") {
5186
6003
  const setup = findArchiveMember(names, `${options.appName}-Setup.exe`, options.platform, "Installer executable is missing or ambiguous");
5187
- const executable = join14(temporary, "setup.exe");
6004
+ const executable = join16(temporary, "setup.exe");
5188
6005
  await extractArchiveMember({
5189
6006
  tar,
5190
6007
  archive: installerPath,
@@ -5220,19 +6037,19 @@ async function verifyInstallerPayload(options) {
5220
6037
  }
5221
6038
 
5222
6039
  // ../../src/installer/installer-qualification-command.ts
5223
- import { lstat as lstat18, writeFile as writeFile9 } from "fs/promises";
5224
- 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";
5225
6042
 
5226
6043
  // ../../src/installer/installer-observation.ts
5227
- import { randomBytes as randomBytes2 } from "crypto";
5228
- 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";
5229
6046
  import { createServer } from "net";
5230
- import { delimiter, dirname as dirname12, join as join28 } from "path";
6047
+ import { delimiter, dirname as dirname12, join as join30 } from "path";
5231
6048
 
5232
6049
  // ../../src/installer/installer-ci-bootstrap.ts
5233
- import { randomBytes } from "crypto";
5234
- import { lstat as lstat9, mkdir as mkdir5, mkdtemp as mkdtemp5, realpath as realpath2, rm as rm5, writeFile as writeFile4 } from "fs/promises";
5235
- 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";
5236
6053
  import { fileURLToPath } from "url";
5237
6054
  var bootstrapModules = [
5238
6055
  "app/value-guards.js",
@@ -5255,27 +6072,27 @@ async function prepareInstallerCiBootstrap(env = process.env) {
5255
6072
  const temp = runnerTemp(env);
5256
6073
  if (!isHostedRunner(env) || !temp)
5257
6074
  throw new Error("Installer bootstrap requires a disposable hosted runner");
5258
- const parent = await realpath2(temp);
5259
- if (/\s/.test(parent) || !(await lstat9(parent)).isDirectory())
6075
+ const parent = await realpath3(temp);
6076
+ if (/\s/.test(parent) || !(await lstat10(parent)).isDirectory())
5260
6077
  throw new Error("Runner temp cannot represent a Bun preload path");
5261
6078
  const source = dirname4(dirname4(fileURLToPath(import.meta.url)));
5262
- const directory = await mkdtemp5(join15(parent, "framework-ci-"));
6079
+ const directory = await mkdtemp5(join17(parent, "framework-ci-"));
5263
6080
  try {
5264
6081
  for (const name of bootstrapModules) {
5265
- const contents = await readBoundedFile(join15(source, name), 2 * 1024 * 1024, "installer bootstrap module");
5266
- await mkdir5(dirname4(join15(directory, name)), { recursive: true, mode: 448 });
5267
- 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 });
5268
6085
  }
5269
- await writeFile4(join15(directory, "package.json"), `{"type":"module"}
6086
+ await writeFile4(join17(directory, "package.json"), `{"type":"module"}
5270
6087
  `, {
5271
6088
  flag: "wx",
5272
6089
  mode: 384
5273
6090
  });
5274
- const worker = join15(directory, "installer/installer-ci-worker.js");
6091
+ const worker = join17(directory, "installer/installer-ci-worker.js");
5275
6092
  return {
5276
6093
  directory,
5277
6094
  worker,
5278
- preflight: join15(directory, "installer/installer-ci-preflight.js"),
6095
+ preflight: join17(directory, "installer/installer-ci-preflight.js"),
5279
6096
  bunOptions: `--preload=${worker}`
5280
6097
  };
5281
6098
  } catch (error) {
@@ -5286,11 +6103,11 @@ async function prepareInstallerCiBootstrap(env = process.env) {
5286
6103
  async function preflightInstallerRuntime(options) {
5287
6104
  const { env, runtime, bootstrap } = options;
5288
6105
  const temp = runnerTemp(env);
5289
- if (!isHostedRunner(env) || !temp || !isAbsolute4(runtime))
6106
+ if (!isHostedRunner(env) || !temp || !isAbsolute5(runtime))
5290
6107
  throw new Error("Runtime preflight requires a disposable hosted runner");
5291
- const tempRoot = await realpath2(temp), bootstrapRoot = await realpath2(bootstrap.directory);
6108
+ const tempRoot = await realpath3(temp), bootstrapRoot = await realpath3(bootstrap.directory);
5292
6109
  const relativeBootstrap = relative4(tempRoot, bootstrapRoot);
5293
- 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}`)
5294
6111
  throw new Error("Invalid installer bootstrap location");
5295
6112
  await runInstallerPreflight({
5296
6113
  env,
@@ -5303,14 +6120,14 @@ async function preflightInstallerRuntime(options) {
5303
6120
  async function runInstallerPreflight(options) {
5304
6121
  const { env, runtime, worker, preflight } = options;
5305
6122
  for (const path of [worker, preflight]) {
5306
- const item = await lstat9(path);
6123
+ const item = await lstat10(path);
5307
6124
  if (!item.isFile() || item.isSymbolicLink())
5308
6125
  throw new Error("Invalid installer bootstrap module");
5309
6126
  }
5310
- const info = await lstat9(runtime);
6127
+ const info = await lstat10(runtime);
5311
6128
  if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
5312
6129
  throw new Error("Invalid candidate Bun runtime");
5313
- const temporary = await mkdtemp5(join15(options.parent, "framework-preflight-"));
6130
+ const temporary = await mkdtemp5(join17(options.parent, "framework-preflight-"));
5314
6131
  try {
5315
6132
  const clean = {};
5316
6133
  for (const key of [
@@ -5327,7 +6144,7 @@ async function runInstallerPreflight(options) {
5327
6144
  ])
5328
6145
  if (env[key])
5329
6146
  clean[key] = env[key];
5330
- const nonce = randomBytes(24).toString("hex");
6147
+ const nonce = randomBytes2(24).toString("hex");
5331
6148
  Object.assign(clean, {
5332
6149
  CI: "true",
5333
6150
  GITHUB_ACTIONS: "true",
@@ -5335,11 +6152,11 @@ async function runInstallerPreflight(options) {
5335
6152
  BUN_OPTIONS: `--preload=${worker}`,
5336
6153
  FRAMEWORK_CI_WORKER_ENTRY: preflight,
5337
6154
  FRAMEWORK_CI_NONCE: nonce,
5338
- FRAMEWORK_CI_ACK: join15(temporary, "ack"),
5339
- FRAMEWORK_CI_PERMIT: join15(temporary, "permit"),
6155
+ FRAMEWORK_CI_ACK: join17(temporary, "ack"),
6156
+ FRAMEWORK_CI_PERMIT: join17(temporary, "permit"),
5340
6157
  FRAMEWORK_CI_ORIGIN: "http://127.0.0.1:48999",
5341
- FRAMEWORK_CI_OBSERVATION: join15(temporary, "observation"),
5342
- FRAMEWORK_CI_UNEXPECTED: join15(temporary, "unexpected"),
6158
+ FRAMEWORK_CI_OBSERVATION: join17(temporary, "observation"),
6159
+ FRAMEWORK_CI_UNEXPECTED: join17(temporary, "unexpected"),
5343
6160
  FRAMEWORK_CI_EXPECTED_READS: JSON.stringify([
5344
6161
  "https://example.invalid/framework-ci-sentinel"
5345
6162
  ])
@@ -5374,7 +6191,7 @@ async function runInstallerPreflight(options) {
5374
6191
  if (status !== 0 || !stdout.includes("framework installer preload preflight passed"))
5375
6192
  throw new Error("Candidate Bun runtime failed installer preflight");
5376
6193
  try {
5377
- await lstat9(join15(temporary, "unexpected"));
6194
+ await lstat10(join17(temporary, "unexpected"));
5378
6195
  throw new Error("Runtime preflight recorded unexpected activity");
5379
6196
  } catch (error) {
5380
6197
  if (errorCode(error) !== "ENOENT")
@@ -5386,8 +6203,8 @@ async function runInstallerPreflight(options) {
5386
6203
  }
5387
6204
 
5388
6205
  // ../../src/installer/installer-extraction.ts
5389
- import { chmod, lstat as lstat10, mkdir as mkdir6, mkdtemp as mkdtemp6, readdir as readdir6, realpath as realpath3 } from "fs/promises";
5390
- 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";
5391
6208
  async function run(cmd, env) {
5392
6209
  return runInstallerCommand(cmd, env, {
5393
6210
  outputLimit: 8 * 1024 * 1024,
@@ -5395,8 +6212,8 @@ async function run(cmd, env) {
5395
6212
  failureMessage: "Installer preparation command failed"
5396
6213
  });
5397
6214
  }
5398
- async function digest2(path) {
5399
- const info = await lstat10(path);
6215
+ async function digest3(path) {
6216
+ const info = await lstat11(path);
5400
6217
  if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1)
5401
6218
  throw new Error("Invalid extracted file");
5402
6219
  const { size, sha256 } = await hashFileAt(path, info, "Extracted file changed");
@@ -5430,8 +6247,8 @@ async function prepareInstallerExecution(options) {
5430
6247
  const temp = runnerTemp(env);
5431
6248
  if (!temp)
5432
6249
  throw new Error("Missing runner temp directory");
5433
- const parent = await realpath3(temp), sourceInstaller = resolve11(options.installer), sourceArchive = resolve11(options.archive);
5434
- 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())
5435
6252
  throw new Error("Invalid runner temp directory");
5436
6253
  const verified = await verifyInstallerPayload({
5437
6254
  ...options,
@@ -5439,10 +6256,10 @@ async function prepareInstallerExecution(options) {
5439
6256
  archive: sourceArchive,
5440
6257
  env
5441
6258
  });
5442
- const directory = await mkdtemp6(join16(parent, "framework-installer-"));
6259
+ const directory = await mkdtemp6(join18(parent, "framework-installer-"));
5443
6260
  const imageIo = defaultInstallerImageMountIo(run);
5444
6261
  try {
5445
- const profile = join16(directory, "profile"), incoming = join16(directory, "incoming");
6262
+ const profile = join18(directory, "profile"), incoming = join18(directory, "incoming");
5446
6263
  await mkdir6(profile, { mode: 448 });
5447
6264
  await mkdir6(incoming, { mode: 448 });
5448
6265
  const clean = cleanEnv(env);
@@ -5455,34 +6272,34 @@ async function prepareInstallerExecution(options) {
5455
6272
  env: clean,
5456
6273
  run,
5457
6274
  work: async (mount) => {
5458
- 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"));
5459
6276
  if (apps.length !== 1 || apps[0] !== appName)
5460
6277
  throw new Error("Unexpected installer application");
5461
- const sourceApp = await realpath3(join16(mount, appName)), mountRoot = await realpath3(mount);
6278
+ const sourceApp = await realpath4(join18(mount, appName)), mountRoot = await realpath4(mount);
5462
6279
  if (!isWithin(mountRoot, sourceApp))
5463
6280
  throw new Error("Installer application escapes image");
5464
- const app = join16(incoming, appName);
6281
+ const app = join18(incoming, appName);
5465
6282
  await run(["/usr/bin/ditto", sourceApp, app], clean);
5466
- const actualApp = await realpath3(app), resources = await realpath3(join16(actualApp, "Contents", "Resources"));
5467
- 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))
5468
6285
  throw new Error("Copied installer escapes profile");
5469
- const plist = join16(actualApp, "Contents", "Info.plist"), plistInfo = await lstat10(plist);
6286
+ const plist = join18(actualApp, "Contents", "Info.plist"), plistInfo = await lstat11(plist);
5470
6287
  if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
5471
6288
  throw new Error("Invalid installer property list");
5472
6289
  const name = (await run(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], clean)).trim();
5473
6290
  if (!name || name === "." || name === ".." || /[\\/]/.test(name))
5474
6291
  throw new Error("Invalid installer executable");
5475
- const appExecutable = join16(actualApp, "Contents", "MacOS", name);
5476
- const sourceExecutable = join16(sourceApp, "Contents", "MacOS", name);
5477
- 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)))
5478
6295
  throw new Error("Installer executable escapes application");
5479
6296
  await assertInstallerExecutable(appExecutable, options.platform);
5480
- if (JSON.stringify(await digest2(sourceExecutable)) !== JSON.stringify(await digest2(appExecutable)))
6297
+ if (JSON.stringify(await digest3(sourceExecutable)) !== JSON.stringify(await digest3(appExecutable)))
5481
6298
  throw new Error("Copied installer executable differs");
5482
- const archives = (await readdir6(resources)).filter((value) => value.endsWith(".tar.zst"));
6299
+ const archives = (await readdir7(resources)).filter((value) => value.endsWith(".tar.zst"));
5483
6300
  if (archives.length !== 1)
5484
6301
  throw new Error("Missing installer archive");
5485
- const embedded = await digest2(join16(resources, archives[0]));
6302
+ const embedded = await digest3(join18(resources, archives[0]));
5486
6303
  if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
5487
6304
  throw new Error("Copied installer archive differs");
5488
6305
  return executable;
@@ -5497,9 +6314,9 @@ async function prepareInstallerExecution(options) {
5497
6314
  assertInstallerLayout(options.platform, options.appName, names);
5498
6315
  const find = (name) => findArchiveMember(names, name, options.platform, "Installer member missing or ambiguous");
5499
6316
  if (options.platform === "windows-x64") {
5500
- const subdirectory = join16(incoming, ".installer");
6317
+ const subdirectory = join18(incoming, ".installer");
5501
6318
  await mkdir6(subdirectory);
5502
- executable = join16(incoming, `${options.appName}-Setup.exe`);
6319
+ executable = join18(incoming, `${options.appName}-Setup.exe`);
5503
6320
  await extractArchiveMember({
5504
6321
  tar,
5505
6322
  archive: sourceInstaller,
@@ -5513,11 +6330,11 @@ async function prepareInstallerExecution(options) {
5513
6330
  tar,
5514
6331
  archive: sourceInstaller,
5515
6332
  member: find(`.installer/${options.appName}-Setup.metadata.json`),
5516
- destination: join16(subdirectory, `${options.appName}-Setup.metadata.json`),
6333
+ destination: join18(subdirectory, `${options.appName}-Setup.metadata.json`),
5517
6334
  maximum: 1024 * 1024,
5518
6335
  env: clean
5519
6336
  });
5520
- const embeddedPath = join16(subdirectory, `${options.appName}-Setup.tar.zst`);
6337
+ const embeddedPath = join18(subdirectory, `${options.appName}-Setup.tar.zst`);
5521
6338
  await extractArchiveMember({
5522
6339
  tar,
5523
6340
  archive: sourceInstaller,
@@ -5526,11 +6343,11 @@ async function prepareInstallerExecution(options) {
5526
6343
  maximum: verified.archive.size,
5527
6344
  env: clean
5528
6345
  });
5529
- const embedded = await digest2(embeddedPath);
6346
+ const embedded = await digest3(embeddedPath);
5530
6347
  if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
5531
6348
  throw new Error("Copied installer archive differs");
5532
6349
  } else {
5533
- executable = join16(incoming, "installer");
6350
+ executable = join18(incoming, "installer");
5534
6351
  await extractArchiveMember({
5535
6352
  tar,
5536
6353
  archive: sourceInstaller,
@@ -5540,7 +6357,7 @@ async function prepareInstallerExecution(options) {
5540
6357
  env: clean
5541
6358
  });
5542
6359
  await assertInstallerExecutable(executable, options.platform);
5543
- await assertEmbeddedArchive(executable, (await lstat10(executable)).size, verified.archive);
6360
+ await assertEmbeddedArchive(executable, (await lstat11(executable)).size, verified.archive);
5544
6361
  await chmod(executable, 448);
5545
6362
  }
5546
6363
  }
@@ -5586,10 +6403,10 @@ function assertInstallerRendererObservation(value, offline = false) {
5586
6403
  }
5587
6404
 
5588
6405
  // ../../src/installer/installed-payload.ts
5589
- import { createHash as createHash11 } from "crypto";
5590
- 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";
5591
6408
  import { once } from "events";
5592
- import { join as join17, resolve as resolve12 } from "path";
6409
+ import { join as join19, resolve as resolve13 } from "path";
5593
6410
  import { createZstdDecompress } from "zlib";
5594
6411
  import { Parser } from "tar";
5595
6412
  function cleanEnv2(parent, forceLocal) {
@@ -5612,7 +6429,7 @@ async function command2(args, env, limit, collect) {
5612
6429
  const errors = (async () => {
5613
6430
  for await (const _part of child.stderr) {}
5614
6431
  })();
5615
- const hash = createHash11("sha256"), chunks = [];
6432
+ const hash = createHash14("sha256"), chunks = [];
5616
6433
  let size = 0;
5617
6434
  try {
5618
6435
  for await (const part of child.stdout) {
@@ -5635,7 +6452,7 @@ async function command2(args, env, limit, collect) {
5635
6452
  }
5636
6453
  }
5637
6454
  async function listArchive(archive, platform, env) {
5638
- const archiveInfo = await lstat11(archive);
6455
+ const archiveInfo = await lstat12(archive);
5639
6456
  if (!archiveInfo.isFile() || archiveInfo.isSymbolicLink() || archiveInfo.size < 1)
5640
6457
  throw new Error("Invalid staged archive");
5641
6458
  const version = await command2(["tar", "--version"], cleanEnv2(env, false), 65536, true);
@@ -5666,7 +6483,7 @@ async function readMembers(archive, limits, collect) {
5666
6483
  failure ??= new Error("Archive member missing or ambiguous");
5667
6484
  return entry.resume();
5668
6485
  }
5669
- const hash = createHash11("sha256"), chunks = [];
6486
+ const hash = createHash14("sha256"), chunks = [];
5670
6487
  const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
5671
6488
  members.set(entry.path, member);
5672
6489
  entry.on("data", (chunk) => {
@@ -5704,14 +6521,14 @@ async function readMembers(archive, limits, collect) {
5704
6521
  return members;
5705
6522
  }
5706
6523
  async function installed(path, root, limit) {
5707
- const info = await lstat11(path);
5708
- 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)))
5709
6526
  throw new Error("Invalid installed file");
5710
6527
  const { size, sha256 } = await hashFileAt(path, info, "Installed file changed");
5711
6528
  return { digest: sha256, size };
5712
6529
  }
5713
6530
  async function assertRuntimeBinary(path, platform) {
5714
- const info = await lstat11(path), file = await open5(path, "r");
6531
+ const info = await lstat12(path), file = await open5(path, "r");
5715
6532
  try {
5716
6533
  await assertNativeExecutable(file, info.size, platform, "runtime executable");
5717
6534
  } finally {
@@ -5725,8 +6542,8 @@ async function verifyInstalledPayload(options) {
5725
6542
  const sidecars = assertSidecarNames(options.sidecars ?? [], options.platform).map((name) => sidecarBundlePath(name, options.platform));
5726
6543
  if (!/^\d+\.\d+\.\d+$/.test(options.version) || options.version.length > 64)
5727
6544
  throw new Error("Invalid installed version");
5728
- const profile = await realpath4(options.profile), root = await realpath4(options.installedRoot), archive = resolve12(options.archive);
5729
- 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))
5730
6547
  throw new Error("Installed root escapes isolated profile");
5731
6548
  const { archiveInfo, entries } = await listArchive(archive, options.platform, env);
5732
6549
  assertPayloadLayout({
@@ -5760,7 +6577,7 @@ async function verifyInstalledPayload(options) {
5760
6577
  const member = members.get(path);
5761
6578
  if (!member || member.count !== 1)
5762
6579
  throw new Error("Archive member missing or ambiguous");
5763
- const current = await installed(join17(root, name), root, limit);
6580
+ const current = await installed(join19(root, name), root, limit);
5764
6581
  if (member.size !== current.size || member.digest !== current.digest)
5765
6582
  throw new Error(`Installed file differs from archive: ${name}`);
5766
6583
  if (name === "Resources/version.json") {
@@ -5782,8 +6599,8 @@ async function extractCandidateRuntime(options) {
5782
6599
  const temp = runnerTemp(env);
5783
6600
  if (!temp)
5784
6601
  throw new Error("Missing runner temp directory");
5785
- const tempRoot = await realpath4(temp), profile = await realpath4(options.profile), archive = resolve12(options.archive);
5786
- 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())
5787
6604
  throw new Error("Runtime profile escapes runner temp");
5788
6605
  const { archiveInfo, tarEnv, entries } = await listArchive(archive, options.platform, env);
5789
6606
  assertPayloadLayout({
@@ -5795,7 +6612,7 @@ async function extractCandidateRuntime(options) {
5795
6612
  const prefix = options.platform === "macos-arm64" ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
5796
6613
  const expected = `${prefix}/bun${suffix}`;
5797
6614
  const member = findArchiveMember(entries, expected, options.platform, "Runtime archive member missing or ambiguous");
5798
- 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);
5799
6616
  const spawn = () => Bun.spawn({
5800
6617
  cmd: ["tar", "--zstd", "-xOf", archive, "--", member],
5801
6618
  env: tarEnv,
@@ -5808,7 +6625,7 @@ async function extractCandidateRuntime(options) {
5808
6625
  const child = spawn(), errors = (async () => {
5809
6626
  for await (const _part of child.stderr) {}
5810
6627
  })();
5811
- const hash = createHash11("sha256");
6628
+ const hash = createHash14("sha256");
5812
6629
  let size = 0;
5813
6630
  try {
5814
6631
  for await (const part of child.stdout) {
@@ -5851,8 +6668,8 @@ async function extractCandidateRuntime(options) {
5851
6668
 
5852
6669
  // ../../src/installer/installer-process-cleanup.ts
5853
6670
  import { execFile as execFile2 } from "child_process";
5854
- import { realpath as realpath5 } from "fs/promises";
5855
- import { promisify } from "util";
6671
+ import { realpath as realpath6 } from "fs/promises";
6672
+ import { promisify as promisify2 } from "util";
5856
6673
 
5857
6674
  // ../../src/native/windows-process.ts
5858
6675
  import { dlopen as dlopen2, FFIType as FFIType2, ptr as ptr2 } from "bun:ffi";
@@ -5896,7 +6713,7 @@ function windowsProcessImage(pid, options) {
5896
6713
  }
5897
6714
 
5898
6715
  // ../../src/installer/installer-process-cleanup.ts
5899
- var execute = promisify(execFile2);
6716
+ var execute = promisify2(execFile2);
5900
6717
  async function terminateGuardedWorker(options) {
5901
6718
  const { pid, runtime, platform } = options;
5902
6719
  assertInstallerContext(options.env, platform, process.platform, process.arch);
@@ -5917,7 +6734,7 @@ async function terminateGuardedWorker(options) {
5917
6734
  ])
5918
6735
  if (options.env[name])
5919
6736
  env[name] = options.env[name];
5920
- const expected = await realpath5(runtime);
6737
+ const expected = await realpath6(runtime);
5921
6738
  const actual = await runningExecutable(pid, platform, env);
5922
6739
  if (actual === undefined)
5923
6740
  return;
@@ -5968,7 +6785,7 @@ async function readMacosState(pid, env) {
5968
6785
  }
5969
6786
  async function runningExecutable(pid, platform, env) {
5970
6787
  if (platform === "linux-x64" || platform === "linux-arm64")
5971
- return realpath5(`/proc/${pid}/exe`).catch((error) => {
6788
+ return realpath6(`/proc/${pid}/exe`).catch((error) => {
5972
6789
  if (error.code === "ENOENT")
5973
6790
  return;
5974
6791
  throw error;
@@ -5986,7 +6803,7 @@ async function runningExecutable(pid, platform, env) {
5986
6803
  if (!listed)
5987
6804
  return;
5988
6805
  const state = macosProcess(listed.stdout);
5989
- return state === EXITING || state === undefined ? state : realpath5(state);
6806
+ return state === EXITING || state === undefined ? state : realpath6(state);
5990
6807
  }
5991
6808
  return windowsRunningExecutable(pid);
5992
6809
  }
@@ -5997,12 +6814,12 @@ async function windowsRunningExecutable(pid) {
5997
6814
  } catch (error) {
5998
6815
  throw new Error("Unable to query guarded process executable", { cause: error });
5999
6816
  }
6000
- return image === "missing" ? undefined : realpath5(image);
6817
+ return image === "missing" ? undefined : realpath6(image);
6001
6818
  }
6002
6819
 
6003
6820
  // ../../src/updates/install/update-swap-stage.ts
6004
- import { lstat as lstat17, mkdtemp as mkdtemp8, readFile as readFile8, realpath as realpath7, rm as rm8 } from "fs/promises";
6005
- 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";
6006
6823
 
6007
6824
  // ../../src/updates/install/update-handoff-plan.ts
6008
6825
  import { basename as basename6 } from "path";
@@ -6041,10 +6858,10 @@ function planUpdateHandoff(options) {
6041
6858
  }
6042
6859
 
6043
6860
  // ../../src/updates/install/update-extraction.ts
6044
- import { createHash as createHash12 } from "crypto";
6861
+ import { createHash as createHash15 } from "crypto";
6045
6862
  import { constants as constants4 } from "fs";
6046
- 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";
6047
- 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";
6048
6865
  import { Transform } from "stream";
6049
6866
  import { pipeline } from "stream/promises";
6050
6867
  import { createZstdDecompress as createZstdDecompress2 } from "zlib";
@@ -6073,12 +6890,12 @@ async function extractVerifiedUpdate(options) {
6073
6890
  "linux-x64": ["linux", "x64"],
6074
6891
  "linux-arm64": ["linux", "arm64"]
6075
6892
  };
6076
- 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)
6077
6894
  throw new Error("Invalid update extraction context");
6078
6895
  assertPortableAppName(appName);
6079
6896
  const sidecars = assertSidecarNames(options.sidecars ?? [], platform);
6080
6897
  const archiveRoot = platform === "macos-arm64" ? `${appName}.app` : appName.replaceAll(" ", "");
6081
- const info = await lstat12(archive);
6898
+ const info = await lstat13(archive);
6082
6899
  if (!info.isFile() || info.isSymbolicLink() || info.size !== descriptor.asset.size)
6083
6900
  throw new Error("Invalid update archive");
6084
6901
  const file = await open6(archive, constants4.O_RDONLY | (constants4.O_NOFOLLOW ?? 0));
@@ -6087,11 +6904,11 @@ async function extractVerifiedUpdate(options) {
6087
6904
  const before = await file.stat();
6088
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))
6089
6906
  throw new Error("Update archive verification failed");
6090
- const parent = await realpath6(options.directory);
6091
- if (!(await lstat12(parent)).isDirectory())
6907
+ const parent = await realpath7(options.directory);
6908
+ if (!(await lstat13(parent)).isDirectory())
6092
6909
  throw new Error("Invalid update staging directory");
6093
- directory = await mkdtemp7(join18(parent, "framework-update-extract-"));
6094
- 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");
6095
6912
  await mkdir7(payloadRoot, { mode: 448 });
6096
6913
  const entries = [], links = [], seen = new Set, fold = platform === "windows-x64";
6097
6914
  let invalid = false;
@@ -6109,7 +6926,7 @@ async function extractVerifiedUpdate(options) {
6109
6926
  done(null, chunk);
6110
6927
  }
6111
6928
  });
6112
- const hash = createHash12("sha256");
6929
+ const hash = createHash15("sha256");
6113
6930
  let compressedBytes = 0;
6114
6931
  const verifyInput = new Transform({
6115
6932
  transform(chunk, _encoding, done) {
@@ -6209,14 +7026,14 @@ async function extractVerifiedUpdate(options) {
6209
7026
  if (invalid)
6210
7027
  throw new Error("Unsafe or unsupported update archive entry");
6211
7028
  if (links.length) {
6212
- const bin = join18(payloadRoot, archiveRoot, "bin"), cef = join18(bin, "cef");
6213
- for (const path of [join18(payloadRoot, archiveRoot), bin, cef]) {
6214
- 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);
6215
7032
  if (!value.isDirectory() || value.isSymbolicLink())
6216
7033
  throw new Error("Invalid CEF link directory");
6217
7034
  }
6218
7035
  for (const link of links) {
6219
- 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);
6220
7037
  if (!value.isFile() || value.isSymbolicLink())
6221
7038
  throw new Error("Invalid CEF link target");
6222
7039
  await symlink(link.target, destination);
@@ -6224,12 +7041,12 @@ async function extractVerifiedUpdate(options) {
6224
7041
  }
6225
7042
  await rm7(decompressed);
6226
7043
  assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
6227
- const prefix = platform === "macos-arm64" ? join18(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
6228
- 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");
6229
7046
  const bin = platform === "macos-arm64" ? "MacOS" : "bin", suffix = platform === "windows-x64" ? ".exe" : "";
6230
7047
  const executables = [
6231
- join18(bin, `launcher${suffix}`),
6232
- join18(bin, `bun${suffix}`),
7048
+ join20(bin, `launcher${suffix}`),
7049
+ join20(bin, `bun${suffix}`),
6233
7050
  ...sidecars.map((name) => sidecarBundlePath(name, platform))
6234
7051
  ];
6235
7052
  const critical = [
@@ -6239,21 +7056,21 @@ async function extractVerifiedUpdate(options) {
6239
7056
  "Resources/app/client/index.html"
6240
7057
  ];
6241
7058
  for (const path of critical) {
6242
- const item = await lstat12(join18(payloadRoot, prefix, path));
7059
+ const item = await lstat13(join20(payloadRoot, prefix, path));
6243
7060
  if (!item.isFile() || item.isSymbolicLink() || item.size < 1 || platform !== "windows-x64" && process.platform !== "win32" && executables.includes(path) && !(item.mode & 64))
6244
7061
  throw new Error("Invalid critical update file");
6245
7062
  }
6246
7063
  for (const name of ["version.json", "build.json"]) {
6247
- const metadata = await lstat12(join18(resources, name));
7064
+ const metadata = await lstat13(join20(resources, name));
6248
7065
  if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size < 1 || metadata.size > 1048576)
6249
7066
  throw new Error("Invalid update metadata");
6250
7067
  }
6251
- 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)
6252
7069
  throw new Error("Update version mismatch");
6253
- assertBuildMetadata(JSON.parse(await readFile6(join18(resources, "build.json"), "utf8")), renderer);
7070
+ assertBuildMetadata(JSON.parse(await readFile7(join20(resources, "build.json"), "utf8")), renderer);
6254
7071
  return {
6255
7072
  directory,
6256
- payload: join18(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
7073
+ payload: join20(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
6257
7074
  };
6258
7075
  } catch (error) {
6259
7076
  if (directory)
@@ -6265,19 +7082,19 @@ async function extractVerifiedUpdate(options) {
6265
7082
  }
6266
7083
 
6267
7084
  // ../../src/updates/install/update-swap.ts
6268
- import { createHash as createHash13 } from "crypto";
7085
+ import { createHash as createHash16 } from "crypto";
6269
7086
  import { constants as constants7 } from "fs";
6270
- import { lstat as lstat13, open as open9, readdir as readdir7, readFile as readFile7, readlink as readlink2 } from "fs/promises";
6271
- 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";
6272
7089
 
6273
7090
  // ../../src/updates/update-state-store.ts
6274
7091
  import { randomUUID as randomUUID2 } from "crypto";
6275
7092
  import { constants as constants6 } from "fs";
6276
7093
  import { open as open8, rename, unlink, writeFile as writeFile5 } from "fs/promises";
6277
- import { join as join20 } from "path";
7094
+ import { join as join22 } from "path";
6278
7095
 
6279
7096
  // ../../src/updates/locks/update-lock.ts
6280
- 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";
6281
7098
 
6282
7099
  // ../../src/updates/locks/native-file-lock.ts
6283
7100
  import { constants as constants5 } from "fs";
@@ -6445,7 +7262,7 @@ async function tryAcquireWindows(path, mode) {
6445
7262
  function updateLockPath(target) {
6446
7263
  if (!isCanonicalPath(target))
6447
7264
  throw new Error("Invalid update lock target");
6448
- return join19(dirname5(target), `.${basename7(target)}.framework-update.lock`);
7265
+ return join21(dirname5(target), `.${basename7(target)}.framework-update.lock`);
6449
7266
  }
6450
7267
  async function tryAcquireUpdateLock(target) {
6451
7268
  return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
@@ -6510,7 +7327,7 @@ function parseState(value) {
6510
7327
  return Object.freeze(record);
6511
7328
  }
6512
7329
  async function readUpdateStageState(staging) {
6513
- 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");
6514
7331
  return text === undefined ? undefined : parseState(JSON.parse(text));
6515
7332
  }
6516
7333
  async function writeUpdateStageState(staging, state) {
@@ -6519,8 +7336,8 @@ async function writeUpdateStageState(staging, state) {
6519
7336
  async function replaceUpdateStageState(staging, state, durable) {
6520
7337
  if (typeof state.generation !== "string" || !isUuid(state.generation))
6521
7338
  throw new Error("Invalid update staging state");
6522
- const path = join20(staging, "state.json");
6523
- 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`);
6524
7341
  const contents = JSON.stringify(state) + `
6525
7342
  `;
6526
7343
  let renamed = false;
@@ -6558,12 +7375,12 @@ async function withUpdateLock(target, operation) {
6558
7375
  function updateStagingFor(target) {
6559
7376
  if (!isCanonicalPath(target))
6560
7377
  throw new Error("Invalid update target");
6561
- return join21(dirname6(target), `.${basename8(target)}.framework-update`);
7378
+ return join23(dirname6(target), `.${basename8(target)}.framework-update`);
6562
7379
  }
6563
7380
  async function readUpdateTreeVersion(tree) {
6564
- 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");
6565
7382
  try {
6566
- const value = JSON.parse(await readFile7(versionPath, "utf8"));
7383
+ const value = JSON.parse(await readFile8(versionPath, "utf8"));
6567
7384
  if (typeof value !== "object" || value === null || typeof value.version !== "string")
6568
7385
  return;
6569
7386
  return value.version;
@@ -6577,7 +7394,7 @@ function updateTreeIdentityFromStat(info) {
6577
7394
  return { device: info.dev.toString(10), inode: info.ino.toString(10) };
6578
7395
  }
6579
7396
  async function readUpdateTreeIdentity(tree) {
6580
- const info = await lstat13(tree, { bigint: true });
7397
+ const info = await lstat14(tree, { bigint: true });
6581
7398
  return updateTreeIdentityFromStat(info);
6582
7399
  }
6583
7400
  function sameUpdateTreeIdentity(left, right) {
@@ -6621,9 +7438,9 @@ async function readTreeFileBytes(file, buffer, length, position) {
6621
7438
  }
6622
7439
  async function readUpdateTreeDigest(tree, options = {}) {
6623
7440
  const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
6624
- const hash = createHash13("sha256");
7441
+ const hash = createHash16("sha256");
6625
7442
  hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
6626
- const root = await lstat13(tree, { bigint: true });
7443
+ const root = await lstat14(tree, { bigint: true });
6627
7444
  if (!root.isDirectory() || root.isSymbolicLink())
6628
7445
  throw new Error("Update tree is not a real directory");
6629
7446
  const rootDevice = root.dev;
@@ -6653,10 +7470,10 @@ async function readUpdateTreeDigest(tree, options = {}) {
6653
7470
  if (before.isSymbolicLink())
6654
7471
  return [{ kind: "symlink", path, relative, before }];
6655
7472
  if (before.isDirectory()) {
6656
- 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);
6657
7474
  const children = await Promise.all(names.map(async (name) => {
6658
- const childPath = join21(path, name);
6659
- 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 })));
6660
7477
  }));
6661
7478
  return [{ kind: "directory", path, relative, before }, ...children.flat()];
6662
7479
  }
@@ -6670,7 +7487,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6670
7487
  return { kind: "none" };
6671
7488
  if (entry.kind === "symlink") {
6672
7489
  const target = Buffer.from(await readlink2(path), "utf8");
6673
- const after = await lstat13(path, { bigint: true });
7490
+ const after = await lstat14(path, { bigint: true });
6674
7491
  if (!sameTreeEntrySnapshot(before, after))
6675
7492
  throw new Error("Update tree changed while reading a symbolic link");
6676
7493
  return { kind: "bytes", bytes: target };
@@ -6689,7 +7506,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6689
7506
  const size = Number(before.size);
6690
7507
  const bytes = Buffer.allocUnsafe(size);
6691
7508
  await readTreeFileBytes(file, bytes, size, 0);
6692
- if (!sameTreeEntrySnapshot(before, await lstat13(path, { bigint: true })))
7509
+ if (!sameTreeEntrySnapshot(before, await lstat14(path, { bigint: true })))
6693
7510
  throw new Error("Update tree changed while reading a file");
6694
7511
  return { kind: "bytes", bytes };
6695
7512
  } finally {
@@ -6758,7 +7575,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6758
7575
  position = nextPosition;
6759
7576
  index = nextIndex;
6760
7577
  }
6761
- if (!sameTreeEntrySnapshot(entry.before, await lstat13(entry.path, { bigint: true })))
7578
+ if (!sameTreeEntrySnapshot(entry.before, await lstat14(entry.path, { bigint: true })))
6762
7579
  throw new Error("Update tree changed while reading a file");
6763
7580
  } finally {
6764
7581
  await file.close();
@@ -6774,11 +7591,11 @@ async function readUpdateTreeDigest(tree, options = {}) {
6774
7591
  await Promise.all(entries.map(async (entry) => {
6775
7592
  if (entry.kind !== "directory" || entry.relative === "")
6776
7593
  return;
6777
- const after = await limit(() => lstat13(entry.path, { bigint: true }));
7594
+ const after = await limit(() => lstat14(entry.path, { bigint: true }));
6778
7595
  if (!sameTreeEntrySnapshot(entry.before, after))
6779
7596
  throw new Error("Update tree changed while reading a directory");
6780
7597
  }));
6781
- const finalRoot = await lstat13(tree, { bigint: true });
7598
+ const finalRoot = await lstat14(tree, { bigint: true });
6782
7599
  if (!sameTreeEntrySnapshot(root, finalRoot))
6783
7600
  throw new Error("Update tree changed while its digest was computed");
6784
7601
  const count = Buffer.allocUnsafe(8);
@@ -6787,7 +7604,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6787
7604
  return hash.digest("hex");
6788
7605
  }
6789
7606
  async function assertDirectory(path) {
6790
- const info = await lstat13(path);
7607
+ const info = await lstat14(path);
6791
7608
  if (!info.isDirectory() || info.isSymbolicLink())
6792
7609
  throw new Error("Update exchange requires real directories");
6793
7610
  }
@@ -6798,8 +7615,8 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
6798
7615
  const { target, staging } = options;
6799
7616
  if (dirname6(staging) !== dirname6(target) || staging === target)
6800
7617
  throw new Error("Invalid update swap context");
6801
- const candidate = join21(staging, "candidate");
6802
- const legacyOld = join21(staging, "old");
7618
+ const candidate = join23(staging, "candidate");
7619
+ const legacyOld = join23(staging, "old");
6803
7620
  if (await pathExists(legacyOld))
6804
7621
  throw new Error("A legacy update tree requires recovery before another swap");
6805
7622
  await assertDirectory(target);
@@ -6828,11 +7645,11 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
6828
7645
  }
6829
7646
 
6830
7647
  // ../../src/updates/retention/retirement-inventory.ts
6831
- import { lstat as lstat15, readdir as readdir9 } from "fs/promises";
6832
- 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";
6833
7650
 
6834
7651
  // ../../src/updates/retention/update-retention-marker.ts
6835
- 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";
6836
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}$/;
6837
7654
  var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
6838
7655
  function assertCanonicalTarget(target) {
@@ -6851,28 +7668,28 @@ function isTreeIdentity(value) {
6851
7668
  function updateRetentionIntentPath(target, generation) {
6852
7669
  assertCanonicalTarget(target);
6853
7670
  assertGeneration(generation);
6854
- return join22(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
7671
+ return join24(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
6855
7672
  }
6856
7673
 
6857
7674
  // ../../src/updates/retention/retention-prune-progress.ts
6858
- 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";
6859
7676
 
6860
7677
  // ../../src/updates/retention/retirement-records.ts
6861
- import { lstat as lstat14, readdir as readdir8, writeFile as writeFile6 } from "fs/promises";
6862
- 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";
6863
7680
  function updateRetirementPaths(target, generation) {
6864
7681
  if (!isCanonicalPath(target) || !isUuid(generation))
6865
7682
  throw new Error("Invalid update retirement identity");
6866
7683
  const prefix = `.${basename10(target)}.framework-retired-${generation}`;
6867
- const container = join23(dirname8(target), prefix);
7684
+ const container = join25(dirname8(target), prefix);
6868
7685
  return Object.freeze({
6869
7686
  container,
6870
- tree: join23(container, "tree"),
6871
- healthReceipt: join23(container, "healthy.json"),
7687
+ tree: join25(container, "tree"),
7688
+ healthReceipt: join25(container, "healthy.json"),
6872
7689
  healthTemporaryPrefix: ".healthy-",
6873
- claim: join23(dirname8(target), `${prefix}.claim.json`),
7690
+ claim: join25(dirname8(target), `${prefix}.claim.json`),
6874
7691
  claimTemporaryPrefix: `${prefix}.claim-`,
6875
- cleanupMarker: join23(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
7692
+ cleanupMarker: join25(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
6876
7693
  cleanupMarkerTemporaryPrefix: `.${basename10(target)}.framework-update-cleanup-`
6877
7694
  });
6878
7695
  }
@@ -6923,7 +7740,7 @@ async function readCleanupMarker(path) {
6923
7740
  }
6924
7741
  async function pathInfo(path) {
6925
7742
  try {
6926
- return await lstat14(path);
7743
+ return await lstat15(path);
6927
7744
  } catch (error) {
6928
7745
  if (errorCode(error) === "ENOENT")
6929
7746
  return;
@@ -6971,15 +7788,15 @@ function assertNoUnresolvedRetentionPruneArtifacts(target, names, allowances = {
6971
7788
  async function assertNoUpdateRetentionPruneArtifactsWhileLocked(target) {
6972
7789
  if (!isCanonicalPath(target) || !basename12(target))
6973
7790
  throw new Error("Invalid update retention prune gate target");
6974
- 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");
6975
7792
  }
6976
7793
 
6977
7794
  // ../../src/updates/retention/update-retirement.ts
6978
- import { lstat as lstat16, mkdir as mkdir8, readdir as readdir10, rmdir, unlink as unlink2, writeFile as writeFile7 } from "fs/promises";
6979
- 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";
6980
7797
  async function reconcileRetirementCleanupMarkerWhileLocked(options) {
6981
7798
  const { target, staging, currentVersion } = options;
6982
- const markerPath = join26(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
7799
+ const markerPath = join28(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
6983
7800
  const markerInfo = await pathInfo(markerPath);
6984
7801
  if (!markerInfo)
6985
7802
  return "none";
@@ -6996,14 +7813,14 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
6996
7813
  const containerInfo = await pathInfo(paths.container);
6997
7814
  if (!containerInfo?.isDirectory() || containerInfo.isSymbolicLink())
6998
7815
  return "recovery-required";
6999
- const containerEntries = await readdir10(paths.container);
7816
+ const containerEntries = await readdir11(paths.container);
7000
7817
  if (containerEntries.length !== 1 || containerEntries[0] !== "tree")
7001
7818
  return "recovery-required";
7002
7819
  const stagingInfo = await pathInfo(staging);
7003
7820
  if (stagingInfo) {
7004
7821
  if (!stagingInfo.isDirectory() || stagingInfo.isSymbolicLink())
7005
7822
  return "recovery-required";
7006
- const stagingEntries = await readdir10(staging);
7823
+ const stagingEntries = await readdir11(staging);
7007
7824
  if (stagingEntries.length !== 0)
7008
7825
  return "recovery-required";
7009
7826
  await rmdir(staging);
@@ -7017,14 +7834,14 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
7017
7834
 
7018
7835
  // ../../src/updates/install/update-swap-stage.ts
7019
7836
  async function assertInstalledVersion(options) {
7020
- const info = await lstat17(options.target);
7021
- 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)
7022
7839
  throw new Error("Invalid update install target");
7023
- const versionFile = join27(options.target, ...options.platform === "macos-arm64" ? ["Contents", "Resources"] : ["Resources"], "version.json");
7024
- 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);
7025
7842
  if (!versionInfo.isFile() || versionInfo.size > 1024 * 1024)
7026
7843
  throw new Error("Installed update version mismatch");
7027
- if (JSON.parse(await readFile8(versionFile, "utf8")).version !== options.version)
7844
+ if (JSON.parse(await readFile9(versionFile, "utf8")).version !== options.version)
7028
7845
  throw new Error("Installed update version mismatch");
7029
7846
  }
7030
7847
  async function stageUpdateSwap(options) {
@@ -7044,7 +7861,7 @@ async function stageUpdateSwap(options) {
7044
7861
  });
7045
7862
  const staging = updateStagingFor(plan.target);
7046
7863
  const preparing = await mkdtemp8(`${staging}.preparing-`);
7047
- const candidate = join27(staging, "candidate");
7864
+ const candidate = join29(staging, "candidate");
7048
7865
  let published = false;
7049
7866
  try {
7050
7867
  const extracted = await extractVerifiedUpdate({
@@ -7058,12 +7875,12 @@ async function stageUpdateSwap(options) {
7058
7875
  maxExpandedBytes: options.maxExpandedBytes,
7059
7876
  ...options.sidecars === undefined ? {} : { sidecars: options.sidecars }
7060
7877
  });
7061
- renameExclusive(extracted.payload, join27(preparing, "candidate"));
7878
+ renameExclusive(extracted.payload, join29(preparing, "candidate"));
7062
7879
  await rm8(extracted.directory, { recursive: true, force: true });
7063
- const candidateTreeIdentity = await readUpdateTreeIdentity(join27(preparing, "candidate"));
7880
+ const candidateTreeIdentity = await readUpdateTreeIdentity(join29(preparing, "candidate"));
7064
7881
  if (!candidateTreeIdentity)
7065
7882
  throw new Error("Update candidate tree identity could not be read");
7066
- const candidateTreeDigest = await readUpdateTreeDigest(join27(preparing, "candidate"));
7883
+ const candidateTreeDigest = await readUpdateTreeDigest(join29(preparing, "candidate"));
7067
7884
  await writeUpdateStageState(preparing, newUpdateStageState({
7068
7885
  version: plan.version,
7069
7886
  previousVersion: options.currentVersion,
@@ -7082,7 +7899,7 @@ async function stageUpdateSwap(options) {
7082
7899
  });
7083
7900
  let existingInfo;
7084
7901
  try {
7085
- existingInfo = await lstat17(staging);
7902
+ existingInfo = await lstat18(staging);
7086
7903
  } catch (error) {
7087
7904
  if (errorCode(error) === "ENOENT") {
7088
7905
  const retirement = await reconcileRetirementCleanupMarkerWhileLocked({
@@ -7148,11 +7965,11 @@ function isolatedEnv(parent, profile, platform) {
7148
7965
  RUNNER_ENVIRONMENT: "github-hosted",
7149
7966
  HOME: profile,
7150
7967
  USERPROFILE: profile,
7151
- LOCALAPPDATA: join28(profile, "LocalAppData"),
7152
- XDG_DATA_HOME: join28(profile, ".local", "share"),
7153
- TMP: join28(profile, "tmp"),
7154
- TEMP: join28(profile, "tmp"),
7155
- 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"),
7156
7973
  ELECTROBUN_INSTALLER_UI_AUTOCLOSE: "1"
7157
7974
  });
7158
7975
  if (platform === "windows-x64")
@@ -7247,15 +8064,15 @@ async function observeInstalledApp(options) {
7247
8064
  await preflightInstallerRuntime({ env: parent, runtime: candidate.path, bootstrap });
7248
8065
  stage("runtime-preflight-passed");
7249
8066
  for (const path of [
7250
- join28(prepared.profile, "LocalAppData"),
7251
- join28(prepared.profile, ".local", "share"),
7252
- join28(prepared.profile, "tmp")
8067
+ join30(prepared.profile, "LocalAppData"),
8068
+ join30(prepared.profile, ".local", "share"),
8069
+ join30(prepared.profile, "tmp")
7253
8070
  ])
7254
8071
  await mkdir9(path, { recursive: true, mode: 448 });
7255
8072
  const mac = options.platform === "macos-arm64", windows = options.platform === "windows-x64";
7256
- const installedRoot = mac ? join28(prepared.incoming, `${options.appName}.app`, "Contents") : join28(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
7257
- 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");
7258
- 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");
7259
8076
  const sidecars = options.sidecars ?? [];
7260
8077
  let foreignHits = 0;
7261
8078
  const sentinel = policy ? Bun.serve({
@@ -7305,8 +8122,8 @@ async function observeInstalledApp(options) {
7305
8122
  if (sentinel && (!(await fetch(foreignOrigin + "/", { signal: AbortSignal.timeout(1000) })).ok || foreignHits !== 1))
7306
8123
  throw new Error("Foreign network sentinel unavailable");
7307
8124
  foreignHits = 0;
7308
- const nonce = randomBytes2(24).toString("hex");
7309
- 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");
7310
8127
  const env = {
7311
8128
  ...baseEnv,
7312
8129
  FRAMEWORK_CI_NONCE: nonce,
@@ -7319,13 +8136,13 @@ async function observeInstalledApp(options) {
7319
8136
  };
7320
8137
  let launchRecord, expectedApp;
7321
8138
  if (mac && viaInstaller) {
7322
- const shimDir = join28(run.directory, "launch-shim");
8139
+ const shimDir = join30(run.directory, "launch-shim");
7323
8140
  await mkdir9(shimDir, { mode: 448 });
7324
- const path = join28(shimDir, "open");
8141
+ const path = join30(shimDir, "open");
7325
8142
  await writeFile8(path, shim, { flag: "wx", mode: 448 });
7326
8143
  await chmod2(path, 448);
7327
- expectedApp = join28(await realpath8(prepared.incoming), `${options.appName}.app`);
7328
- launchRecord = join28(run.directory, "launch-record");
8144
+ expectedApp = join30(await realpath9(prepared.incoming), `${options.appName}.app`);
8145
+ launchRecord = join30(run.directory, "launch-record");
7329
8146
  Object.assign(env, {
7330
8147
  PATH: shimDir + delimiter + (env.PATH ?? ""),
7331
8148
  FRAMEWORK_CI_EXPECTED_APP: expectedApp,
@@ -7361,7 +8178,7 @@ async function observeInstalledApp(options) {
7361
8178
  const error = installerErrorName(await Promise.race([installerStderr, Bun.sleep(2000).then(() => "")]));
7362
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"})`);
7363
8180
  }
7364
- 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"));
7365
8182
  if (installer && shouldLaunchInstalledApp({
7366
8183
  platform: options.platform,
7367
8184
  ready,
@@ -7369,17 +8186,17 @@ async function observeInstalledApp(options) {
7369
8186
  acknowledged: await pathExists(ack),
7370
8187
  installerExit: installer.exitCode
7371
8188
  })) {
7372
- if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile9(launchRecord, "utf8") !== expectedApp + `
8189
+ if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile10(launchRecord, "utf8") !== expectedApp + `
7373
8190
  `)
7374
8191
  throw new Error("Installer launch request mismatch");
7375
8192
  app = spawnApp();
7376
8193
  }
7377
8194
  if (await pathExists(ack) && !granted) {
7378
8195
  stage("worker-acknowledged");
7379
- if (await readFile9(ack, "utf8") !== nonce + `
8196
+ if (await readFile10(ack, "utf8") !== nonce + `
7380
8197
  `)
7381
8198
  throw new Error("Worker guard acknowledgement mismatch");
7382
- 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);
7383
8200
  if (!match || match[1] !== nonce || Number(match[2]) < 2 || Number(match[2]) === process.pid)
7384
8201
  throw new Error("Worker process identity mismatch");
7385
8202
  guardedPid = Number(match[2]);
@@ -7537,7 +8354,7 @@ async function observeInstalledApp(options) {
7537
8354
  await swapAfterExit(target, staged.staging);
7538
8355
  stage("update-swapped");
7539
8356
  await preflightInstallerRuntime({ env: parent, runtime, bootstrap });
7540
- const directory = join28(prepared.directory, "update");
8357
+ const directory = join30(prepared.directory, "update");
7541
8358
  await mkdir9(directory, { mode: 448 });
7542
8359
  const updated = await observeRun({
7543
8360
  directory,
@@ -7586,9 +8403,9 @@ async function qualifyInstallerCommand(options) {
7586
8403
  const parsed = parseReleaseConfig(config), requirements = parsed.requirements(tag), policy = requirements.offlinePolicy, names = requirements.platforms[platform];
7587
8404
  if (!policy || !names || names.length !== 2)
7588
8405
  throw new Error("Installer qualification requires an explicit offline policy and payloads");
7589
- 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`);
7590
8407
  try {
7591
- await lstat18(destination);
8408
+ await lstat19(destination);
7592
8409
  throw new Error("Installer receipt already exists");
7593
8410
  } catch (error) {
7594
8411
  if (errorCode(error) !== "ENOENT")
@@ -7602,8 +8419,8 @@ async function qualifyInstallerCommand(options) {
7602
8419
  appName: app.appName,
7603
8420
  appId: app.appId,
7604
8421
  version: plan.version,
7605
- installer: join29(directory, names[0]),
7606
- archive: join29(directory, names[1]),
8422
+ installer: join31(directory, names[0]),
8423
+ archive: join31(directory, names[1]),
7607
8424
  expectedReads: parsed.expectedReads,
7608
8425
  offlinePolicy: policy,
7609
8426
  sidecars: parsed.sidecars
@@ -7634,11 +8451,11 @@ async function qualifyInstallerCommand(options) {
7634
8451
  }
7635
8452
 
7636
8453
  // ../../src/installer/installer-upgrade-command.ts
7637
- import { lstat as lstat19, mkdir as mkdir10, rename as rename2, writeFile as writeFile10 } from "fs/promises";
7638
- 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";
7639
8456
 
7640
8457
  // ../../src/installer/upgrade-asset-download.ts
7641
- import { createHash as createHash14 } from "crypto";
8458
+ import { createHash as createHash17 } from "crypto";
7642
8459
  import { open as open10, unlink as unlink3 } from "fs/promises";
7643
8460
 
7644
8461
  // ../../src/installer/write-all.ts
@@ -7676,7 +8493,7 @@ async function downloadAsset(options) {
7676
8493
  discardStream(response.body);
7677
8494
  throw error;
7678
8495
  }
7679
- const hash = createHash14("sha256");
8496
+ const hash = createHash17("sha256");
7680
8497
  let completed = false;
7681
8498
  try {
7682
8499
  let size = 0;
@@ -7716,7 +8533,7 @@ async function downloadAsset(options) {
7716
8533
  }
7717
8534
 
7718
8535
  // ../../src/updates/feed/update-discovery.ts
7719
- import { createHash as createHash15 } from "crypto";
8536
+ import { createHash as createHash18 } from "crypto";
7720
8537
  var MAX_POINTER_BYTES = 262144;
7721
8538
  var MAX_LEDGER_BYTES2 = 1024 * 1024;
7722
8539
  async function discoverSignedRelease(options) {
@@ -7752,7 +8569,7 @@ async function discoverSignedRelease(options) {
7752
8569
  throw new Error("No qualified channel descriptor is available");
7753
8570
  const { tag } = selected;
7754
8571
  const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
7755
- 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)
7756
8573
  throw new Error("Channel descriptor differs from its release");
7757
8574
  let signed;
7758
8575
  try {
@@ -7770,8 +8587,8 @@ async function discoverSignedRelease(options) {
7770
8587
  }
7771
8588
 
7772
8589
  // ../../src/updates/install/update-download.ts
7773
- import { mkdtemp as mkdtemp9, open as open11, realpath as realpath9, rm as rm9 } from "fs/promises";
7774
- 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";
7775
8592
  async function downloadVerifiedRelease(options) {
7776
8593
  const { descriptor, maxBytes } = options;
7777
8594
  const timeout = options.timeoutMs ?? 120000;
@@ -7803,13 +8620,13 @@ async function downloadVerifiedRelease(options) {
7803
8620
  if (length !== null && (!/^\d+$/.test(length) || Number(length) !== descriptor.asset.size)) {
7804
8621
  throw new Error("Release download size mismatch");
7805
8622
  }
7806
- const root = options.createTemporaryDirectory ? await realpath9(resolve14(options.directory)) : resolve14(options.directory);
7807
- const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(join30(root, "framework-update-"));
7808
- 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);
7809
8626
  if (dirname13(temporaryDirectory) !== root || !basename14(temporaryDirectory).startsWith("framework-update-"))
7810
8627
  throw new Error("Invalid update download directory");
7811
8628
  temporary = temporaryDirectory;
7812
- const path = join30(temporary, "archive");
8629
+ const path = join32(temporary, "archive");
7813
8630
  const file = await open11(path, "wx", 384);
7814
8631
  try {
7815
8632
  async function* writeChunks() {
@@ -7912,9 +8729,9 @@ async function qualifyUpgradeCommand(options) {
7912
8729
  const parsed = parseReleaseConfig(config), feed = feedUrl(parsed.feed), requirements = parsed.requirements(tag), names = requirements.platforms[platform];
7913
8730
  if (!requirements.offlinePolicy || !names || names.length !== 2)
7914
8731
  throw new Error("Upgrade qualification requires an explicit offline policy and payloads");
7915
- 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`);
7916
8733
  try {
7917
- await lstat19(destination);
8734
+ await lstat20(destination);
7918
8735
  throw new Error("Upgrade receipt already exists");
7919
8736
  } catch (error) {
7920
8737
  if (errorCode(error) !== "ENOENT")
@@ -7935,7 +8752,7 @@ async function qualifyUpgradeCommand(options) {
7935
8752
  const channel = "daily";
7936
8753
  const trust = { ...base, channel };
7937
8754
  const discovery = discoveryName(config, channel, platform);
7938
- const signed = await readJsonFile(join31(directory, discovery), 65536, "staged descriptor");
8755
+ const signed = await readJsonFile(join33(directory, discovery), 65536, "staged descriptor");
7939
8756
  const verified = verifyReleaseDescriptor(signed, trust);
7940
8757
  if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.asset.name !== names[1])
7941
8758
  throw new Error("Untrusted staged descriptor");
@@ -7958,7 +8775,7 @@ async function qualifyUpgradeCommand(options) {
7958
8775
  return null;
7959
8776
  if (previous.tag === tag || !versionLessThan(previous.version, descriptor.version))
7960
8777
  throw new Error("Previous release is not older than this release");
7961
- const work = join31(directory, `upgrade-${platform}`);
8778
+ const work = join33(directory, `upgrade-${platform}`);
7962
8779
  await mkdir10(work, { mode: 448 });
7963
8780
  const downloaded = await downloadVerifiedRelease({
7964
8781
  descriptor: previous,
@@ -7967,12 +8784,12 @@ async function qualifyUpgradeCommand(options) {
7967
8784
  timeoutMs: 600000,
7968
8785
  fetch: fetcher
7969
8786
  });
7970
- const previousArchive = join31(work, previous.asset.name);
8787
+ const previousArchive = join33(work, previous.asset.name);
7971
8788
  await rename2(downloaded.path, previousArchive);
7972
8789
  const installerName = parsed.requirements(previous.tag).platforms[platform]?.[0];
7973
8790
  if (!installerName)
7974
8791
  throw new Error("Previous release has no installer for this platform");
7975
- const previousInstaller = join31(work, installerName);
8792
+ const previousInstaller = join33(work, installerName);
7976
8793
  await downloadAsset({
7977
8794
  feed,
7978
8795
  tag: previous.tag,
@@ -7996,7 +8813,7 @@ async function qualifyUpgradeCommand(options) {
7996
8813
  update: {
7997
8814
  descriptor,
7998
8815
  trust,
7999
- archive: join31(directory, names[1]),
8816
+ archive: join33(directory, names[1]),
8000
8817
  maxCompressedBytes: MAX_COMPRESSED_BYTES2,
8001
8818
  maxExpandedBytes: MAX_EXPANDED_BYTES2
8002
8819
  }
@@ -8051,7 +8868,7 @@ function electrobunArtifacts(appName, platform) {
8051
8868
  }
8052
8869
 
8053
8870
  // src/library/steps.ts
8054
- var selectRetainedStepEffect = (context) => Effect24.gen(function* () {
8871
+ var selectRetainedStepEffect = (context) => Effect25.gen(function* () {
8055
8872
  const output = context.env.GITHUB_OUTPUT;
8056
8873
  if (!output)
8057
8874
  return yield* fail("Expected GITHUB_OUTPUT");
@@ -8063,7 +8880,7 @@ runId=${result.runId}
8063
8880
  ` : `reuse=false
8064
8881
  `));
8065
8882
  });
8066
- var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect24.gen(function* () {
8883
+ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect25.gen(function* () {
8067
8884
  const fs = yield* ReleaseFs;
8068
8885
  const [installerAsset, archiveAsset] = platformAssets(context);
8069
8886
  const [installer, archive] = electrobunArtifacts(context.config.appName, context.platform);
@@ -8072,12 +8889,12 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
8072
8889
  yield* step(() => fs.mkdir(directory, { recursive: true }));
8073
8890
  const packed = yield* scopedTempDirectory("framework-command-pack-");
8074
8891
  const sources = {
8075
- [installerAsset]: join32(artifacts, installer),
8076
- [archiveAsset]: join32(artifacts, archive)
8892
+ [installerAsset]: join34(artifacts, installer),
8893
+ [archiveAsset]: join34(artifacts, archive)
8077
8894
  };
8078
8895
  for (const policy of parsed.commandArtifacts) {
8079
8896
  const name = requirements.commandArtifacts[policy.kind][context.platform];
8080
- sources[name] = join32(packed, name);
8897
+ sources[name] = join34(packed, name);
8081
8898
  yield* step(() => packCommandArtifact({
8082
8899
  source: policy.build,
8083
8900
  archive: sources[name],
@@ -8086,8 +8903,8 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
8086
8903
  }));
8087
8904
  }
8088
8905
  return yield* stagePlatformArtifactsEffect({ ...context, directory, sources });
8089
- }).pipe(Effect24.scoped);
8090
- var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* () {
8906
+ }).pipe(Effect25.scoped);
8907
+ var inspectStagedStepEffect = (context, directory) => Effect25.gen(function* () {
8091
8908
  const fs = yield* ReleaseFs;
8092
8909
  const parsed = parseReleaseConfig(context.config);
8093
8910
  const requirements = parsed.requirements(context.tag);
@@ -8095,10 +8912,10 @@ var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* ()
8095
8912
  const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
8096
8913
  if (entries.length !== assets.length || entries.some((entry) => !entry.isFile() || !assets.includes(entry.name)))
8097
8914
  return yield* fail("Staged platform directory contains unexpected files");
8098
- const [installer, archive] = platformAssets(context).map((name) => join32(directory, name));
8915
+ const [installer, archive] = platformAssets(context).map((name) => join34(directory, name));
8099
8916
  for (const policy of parsed.commandArtifacts)
8100
8917
  yield* step(() => readCommandArtifact({
8101
- archive: join32(directory, requirements.commandArtifacts[policy.kind][context.platform]),
8918
+ archive: join34(directory, requirements.commandArtifacts[policy.kind][context.platform]),
8102
8919
  executable: policy.executable,
8103
8920
  platform: context.platform
8104
8921
  }));
@@ -8114,12 +8931,12 @@ var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* ()
8114
8931
  }))
8115
8932
  };
8116
8933
  });
8117
- var qualifyStepEffect = (context, directory) => Effect24.gen(function* () {
8934
+ var qualifyStepEffect = (context, directory) => Effect25.gen(function* () {
8118
8935
  const mode = stepRenderer(context.env);
8119
8936
  yield* step(() => qualifyCommandArtifactsCommand({ ...context, directory }));
8120
8937
  yield* step(() => qualifyInstallerCommand({ ...context, renderer: mode, directory }));
8121
8938
  });
8122
- var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect24.suspend(() => {
8939
+ var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect25.suspend(() => {
8123
8940
  const renderer = stepRenderer(context.env);
8124
8941
  return step(() => qualifyUpgradeCommand({ ...context, renderer, directory, ...onStage ? { onStage } : {} }));
8125
8942
  });
@@ -8137,17 +8954,17 @@ import {
8137
8954
  mkdir as mkdir11,
8138
8955
  mkdtemp as mkdtemp10,
8139
8956
  open as open12,
8140
- readFile as readFile10,
8141
- realpath as realpath10,
8957
+ readFile as readFile11,
8958
+ realpath as realpath11,
8142
8959
  rm as rm10,
8143
8960
  writeFile as writeFile11
8144
8961
  } from "fs/promises";
8145
- import { dirname as dirname14, join as join33, resolve as resolve16 } from "path";
8146
- 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";
8147
8964
  var shasum = /^[a-f0-9]{64}$/;
8148
8965
  var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
8149
8966
  var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
8150
- var exec = promisify2(execFile3);
8967
+ var exec = promisify3(execFile3);
8151
8968
  function requireThat2(condition, message) {
8152
8969
  if (!condition)
8153
8970
  throw new Error(message);
@@ -8270,9 +9087,9 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8270
9087
  const trusted = trustedArtifacts.find((file) => file.name === name);
8271
9088
  return fromProducer && trusted && trusted.size === fromProducer.size && trusted.sha256 === fromProducer.sha256;
8272
9089
  }), "Package producer receipt must describe exactly the protected DEB and AppImage");
8273
- const destination = resolve16(options.output);
8274
- const parent = await realpath10(dirname14(destination));
8275
- 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-"));
8276
9093
  try {
8277
9094
  const files = await runReleaseLibrary(provideLibraryPorts()(stageExpectedFilesEffect({
8278
9095
  directory: work,
@@ -8280,11 +9097,11 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8280
9097
  sources
8281
9098
  })));
8282
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");
8283
- const deb = join33(work, expected.debName);
8284
- const image = join33(work, expected.appImageName);
9100
+ const deb = join35(work, expected.debName);
9101
+ const image = join35(work, expected.appImageName);
8285
9102
  const version = expected.tag.slice(1);
8286
9103
  parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version);
8287
- await verifyEmbeddedRuntime(image, await readFile10(join33(work, runtime.name)));
9104
+ await verifyEmbeddedRuntime(image, await readFile11(join35(work, runtime.name)));
8288
9105
  const offset = String(runtime.size);
8289
9106
  requireRegularDesktopEntry(await inspect("unsquashfs", [
8290
9107
  "-offset",
@@ -8314,8 +9131,8 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8314
9131
  await mkdir11(destination);
8315
9132
  try {
8316
9133
  for (const name of names)
8317
- await link(join33(work, name), join33(destination, name));
8318
- 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) + `
8319
9136
  `, {
8320
9137
  flag: "wx"
8321
9138
  });
@@ -8329,7 +9146,325 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8329
9146
  }
8330
9147
  }
8331
9148
  var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
9149
+ // src/library/linux-format-producer.ts
9150
+ import { createHash as createHash19 } from "crypto";
9151
+ import { createReadStream as createReadStream2, createWriteStream } from "fs";
9152
+ import {
9153
+ chmod as chmod4,
9154
+ cp,
9155
+ lstat as lstat21,
9156
+ lutimes,
9157
+ mkdir as mkdir12,
9158
+ mkdtemp as mkdtemp11,
9159
+ open as open13,
9160
+ readdir as readdir12,
9161
+ readlink as readlink3,
9162
+ realpath as realpath12,
9163
+ rm as rm11,
9164
+ symlink as symlink2,
9165
+ utimes,
9166
+ writeFile as writeFile12
9167
+ } from "fs/promises";
9168
+ import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute7, join as join36, relative as relative5, resolve as resolve18 } from "path";
9169
+ import { pipeline as pipeline2 } from "stream/promises";
9170
+ var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
9171
+ var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
9172
+ var sha2562 = /^[a-f0-9]{64}$/;
9173
+ var sum = async (path) => {
9174
+ const hash = createHash19("sha256");
9175
+ for await (const chunk of createReadStream2(path))
9176
+ hash.update(chunk);
9177
+ return hash.digest("hex");
9178
+ };
9179
+ var relativeFiles = (value) => value.split("/").every((part) => component.test(part));
9180
+ var text2 = (v) => v.length > 0 && v.length <= 250 && !/[\r\n]/.test(v);
9181
+ function check2(ok, message) {
9182
+ if (!ok)
9183
+ throw new Error(message);
9184
+ }
9185
+ async function exactCopy(pin, to) {
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");
9189
+ const input = await open13(pin.path, "r");
9190
+ try {
9191
+ const after = await input.stat();
9192
+ check2(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
9193
+ await pipeline2(input.createReadStream({ autoClose: false, start: 0, end: before.size - 1 }), createWriteStream(to, { flags: "wx", mode: 384 }));
9194
+ } finally {
9195
+ await input.close();
9196
+ }
9197
+ check2((await lstat21(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
9198
+ }
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");
9202
+ return file;
9203
+ }
9204
+ async function elf(path, appImage = false) {
9205
+ const input = await open13(path, "r");
9206
+ try {
9207
+ const h = Buffer.alloc(20);
9208
+ const { bytesRead } = await input.read(h, 0, h.length, 0);
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");
9210
+ } finally {
9211
+ await input.close();
9212
+ }
9213
+ }
9214
+ async function normalizeTree(root, dir = root) {
9215
+ for (const name of await readdir12(dir)) {
9216
+ const file = join36(dir, name);
9217
+ const st = await lstat21(file);
9218
+ if (st.isSymbolicLink()) {
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");
9222
+ } else if (st.isDirectory()) {
9223
+ await chmod4(file, 493);
9224
+ await normalizeTree(root, file);
9225
+ } else {
9226
+ check2(st.isFile(), "Unsupported bundle entry");
9227
+ await chmod4(file, st.mode & 73 ? 493 : 420);
9228
+ }
9229
+ }
9230
+ }
9231
+ async function normalizeBuildTimes(directory, epoch) {
9232
+ for (const name of (await readdir12(directory)).toSorted()) {
9233
+ const path = join36(directory, name);
9234
+ const info = await lstat21(path);
9235
+ if (info.isSymbolicLink()) {
9236
+ await lutimes(path, epoch, epoch);
9237
+ } else if (info.isDirectory()) {
9238
+ await normalizeBuildTimes(path, epoch);
9239
+ } else {
9240
+ check2(info.isFile(), "Unsupported packaging entry");
9241
+ await utimes(path, epoch, epoch);
9242
+ }
9243
+ }
9244
+ await chmod4(directory, 493);
9245
+ await utimes(directory, epoch, epoch);
9246
+ }
9247
+ async function write(root, path, value, mode = 420) {
9248
+ const target = join36(root, path);
9249
+ await mkdir12(dirname15(target), { recursive: true });
9250
+ await writeFile12(target, value, { flag: "wx", mode });
9251
+ await chmod4(target, mode);
9252
+ }
9253
+ function validatePolicy(policy) {
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");
9258
+ }
9259
+ async function buildLinuxFormats(input, host) {
9260
+ const { tag, sourceSha, expectedSourceSha, sourceDateEpoch, policy } = input;
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");
9268
+ const env = { SOURCE_DATE_EPOCH: String(sourceDateEpoch), LC_ALL: "C", TZ: "UTC" };
9269
+ validatePolicy(policy);
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;
9275
+ try {
9276
+ const archive = join36(work, "payload.tar.zst");
9277
+ const tool = join36(work, "appimagetool");
9278
+ const runtime = join36(work, "runtime");
9279
+ for (const [pin, dest] of [
9280
+ [input.archive, archive],
9281
+ [input.tool, tool],
9282
+ [input.runtime, runtime]
9283
+ ])
9284
+ await exactCopy(pin, dest);
9285
+ await elf(tool, true);
9286
+ await elf(runtime, true);
9287
+ await chmod4(tool, 448);
9288
+ const extracted = join36(work, "extract");
9289
+ await mkdir12(extracted);
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");
9310
+ await chmod4(source, 493);
9311
+ await normalizeTree(source);
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
+ }
9317
+ for (const pin of policy.debSetuid) {
9318
+ const file = await regular2(source, pin.path);
9319
+ await elf(file);
9320
+ check2(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
9321
+ }
9322
+ const icon = await regular2(source, policy.icon);
9323
+ check2(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
9324
+ const stem = `${policy.artifactStem}-${tag}-linux-x64`;
9325
+ const debName = `${stem}.deb`;
9326
+ const imageName = `${stem}.AppImage`;
9327
+ const dest = join36(work, "result");
9328
+ await mkdir12(dest);
9329
+ const version = tag.slice(1);
9330
+ const installed = `usr/lib/${policy.packageName}`;
9331
+ const executable = policy.executable ?? policy.packageName;
9332
+ const desktopFile = `${policy.desktopId}.desktop`;
9333
+ const desktop = [
9334
+ "[Desktop Entry]",
9335
+ "Type=Application",
9336
+ `Name=${policy.name}`,
9337
+ `Comment=${policy.description}`,
9338
+ `Exec=${executable} %U`,
9339
+ `Icon=${policy.desktopId}`,
9340
+ `Categories=${policy.categories.join(";")};`,
9341
+ ...policy.mimeTypes.length ? [`MimeType=${policy.mimeTypes.join(";")};`] : [],
9342
+ "Terminal=false",
9343
+ ""
9344
+ ].join(`
9345
+ `);
9346
+ for (const format of ["deb", "appimage"]) {
9347
+ checkAbort();
9348
+ const tree = join36(work, format);
9349
+ await mkdir12(join36(tree, "usr", "lib"), { recursive: true });
9350
+ const bundle = join36(tree, installed);
9351
+ await cp(source, bundle, { recursive: true, verbatimSymlinks: true });
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
+ `);
9357
+ await write(tree, `usr/share/applications/${desktopFile}`, desktop);
9358
+ const iconDest = join36(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
9359
+ await mkdir12(dirname15(iconDest), { recursive: true });
9360
+ await cp(icon, iconDest, { force: false, errorOnExist: true });
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));
9365
+ if (format === "deb") {
9366
+ for (const pin of policy.debSetuid)
9367
+ await chmod4(await regular2(bundle, pin.path), 2541);
9368
+ await write(tree, `usr/bin/${executable}`, `#!/bin/sh
9369
+ export ${policy.formatEnvironment}=deb
9370
+ exec '/${installed}/${policy.launcher}' "$@"
9371
+ `, 493);
9372
+ await write(tree, "DEBIAN/control", [
9373
+ `Package: ${policy.packageName}`,
9374
+ `Version: ${version}`,
9375
+ "Architecture: amd64",
9376
+ `Maintainer: ${policy.maintainer}`,
9377
+ `Description: ${policy.description}`,
9378
+ `Homepage: ${policy.homepage}`,
9379
+ ...policy.dependencies.length ? [`Depends: ${policy.dependencies.join(", ")}`] : [],
9380
+ ""
9381
+ ].join(`
9382
+ `));
9383
+ await normalizeBuildTimes(tree, sourceDateEpoch);
9384
+ await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join36(dest, debName)], { env });
9385
+ } else {
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`);
9393
+ await cp(icon, rootIcon, { force: false, errorOnExist: true });
9394
+ await chmod4(rootIcon, 420);
9395
+ await write(tree, desktopFile, desktop);
9396
+ await write(tree, "AppRun", [
9397
+ "#!/bin/sh",
9398
+ "set -eu",
9399
+ 'root=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)',
9400
+ `export ${policy.formatEnvironment}=appimage`,
9401
+ `exec "$root/${installed}/${policy.launcher}" "$@"`,
9402
+ ""
9403
+ ].join(`
9404
+ `), 493);
9405
+ await normalizeBuildTimes(tree, sourceDateEpoch);
9406
+ await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join36(dest, imageName)], {
9407
+ executable: tool,
9408
+ env: { ...env, ARCH: "x86_64", VERSION: version, APPIMAGE_EXTRACT_AND_RUN: "1" }
9409
+ });
9410
+ }
9411
+ }
9412
+ const artifacts = [];
9413
+ for (const name of [debName, imageName]) {
9414
+ const path = await regular2(dest, name);
9415
+ const size = (await lstat21(path)).size;
9416
+ check2(size > 0, "Empty produced artifact");
9417
+ artifacts.push({ name, size, sha256: await sum(path) });
9418
+ }
9419
+ const receipt = {
9420
+ schema: "linux-package-formats/v1",
9421
+ tag,
9422
+ sourceSha,
9423
+ sourceDateEpoch,
9424
+ ...input.identity,
9425
+ platform: "linux-x64",
9426
+ updateArchiveSha256: input.archive.sha256,
9427
+ artifacts
9428
+ };
9429
+ checkAbort();
9430
+ await mkdir12(output);
9431
+ outputOwned = true;
9432
+ try {
9433
+ for (const item of artifacts)
9434
+ await cp(join36(dest, item.name), join36(output, basename16(item.name)), {
9435
+ force: false,
9436
+ errorOnExist: true
9437
+ });
9438
+ checkAbort();
9439
+ await write(output, "linux-format-build.json", JSON.stringify(receipt) + `
9440
+ `);
9441
+ checkAbort();
9442
+ } catch (error) {
9443
+ await rm11(output, { recursive: true, force: true });
9444
+ outputOwned = false;
9445
+ throw error;
9446
+ }
9447
+ return receipt;
9448
+ } finally {
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
+ }
9460
+ }
9461
+ }
8332
9462
  export {
9463
+ buildLinuxFormats,
9464
+ compareLinuxReproducibility,
9465
+ createDailyBatchR2Client,
9466
+ createDailyBatchR2Store,
9467
+ createDailyBatchS3Transport,
8333
9468
  createDailyNativeReceipt,
8334
9469
  createGitHubPromotionProvider,
8335
9470
  createGitHubReleasePublisher,
@@ -8337,15 +9472,19 @@ export {
8337
9472
  desktopDailyProfile,
8338
9473
  fileIdentity2 as fileIdentity,
8339
9474
  finalizeReleasePleaseDraft,
9475
+ inspectDailyBatch,
8340
9476
  inspectStagedStep,
8341
9477
  planDailyReleaseMatrix,
8342
9478
  planQualificationRun2 as planQualificationRun,
8343
9479
  planReleaseAssets2 as planReleaseAssets,
9480
+ promoteDailyBatch,
8344
9481
  publishFrameworkPackage,
8345
9482
  publishQualifiedRelease,
8346
9483
  qualifyGitHubRelease,
8347
9484
  qualifyStep,
8348
9485
  qualifyUpgradeStep,
9486
+ readDailyBatch,
9487
+ rollbackDailyBatch,
8349
9488
  runPromotionCommand,
8350
9489
  runReleaseCutCommand,
8351
9490
  runReleasePublishCommand,
@@ -8356,6 +9495,8 @@ export {
8356
9495
  stageLinuxPackagePair,
8357
9496
  stagePlatformArtifacts,
8358
9497
  stageReleaseDescriptors,
9498
+ verifyDailyBatchDescriptor,
9499
+ verifyDailyBatchObject,
8359
9500
  verifyDailyReleaseMatrix,
8360
9501
  verifyImage,
8361
9502
  writeDescriptors