@adea-ai/app-framework-release-tools 0.10.0 → 0.11.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/README.md CHANGED
@@ -25,6 +25,8 @@ adea-release <command> [arguments]
25
25
  | `sign-descriptors` | Signs the release descriptors |
26
26
  | `verify-macos-signing` | Checks a macOS build's signature |
27
27
  | `publish` | Publishes a release once |
28
+ | `publish-packages` | Stages a published tag's raw Linux .deb and AppImage |
29
+ | `daily-batch` | Shows, promotes or rolls back a dry-run Daily batch |
28
30
  | `promote` | Promotes a release to another channel |
29
31
  | `finalize` | Waits for the release to complete and finalizes its draft |
30
32
  | `publish-framework-package` | Publishes the framework package to npm |
@@ -35,7 +37,11 @@ The framework's `release-*` bins run the same commands.
35
37
 
36
38
  The caller must obtain the expected repository, source, run and attempt from a protected authority. Local `origin/main` ancestry is advisory: it does not authenticate the remote, rule out local grafts, or establish approval. Pin and independently qualify the builder image and its system tools, then complete the native lifecycle and batch gates before any publication. Historical releases without the tracked manifest need a separately authenticated policy-to-baseline binding; this command does not supply one.
37
39
 
38
- `package-channels <policy.json> <manifest.json> <new-output-dir> [channel ...]` is a dry run. It reads a `framework/package-channels/v1` policy and one exact manifest (a `framework/daily-batch/v1` batch or a published `release.json`) and renders Homebrew, WinGet, APT, pacman, RPM and Flatpak files under `<out>/<channel>/`, with `package-channels.json` listing each channel's asset, install command and the release-page downloads. Channels are planned independently; the command exits 1 when any requested channel failed, after writing the others. It signs, uploads and qualifies nothing. Daily releases get `<token>@daily` casks and `<Id>.Daily` WinGet manifests, and only Stable releases are eligible for public catalogs.
40
+ `package-channels <policy.json> <manifest.json> <new-output-dir> [channel ...]` is a dry run. It reads a `framework/package-channels/v1` policy and one exact manifest (a `framework/daily-batch/v1` batch or a published `release.json`) and renders Homebrew, WinGet, APT, pacman, RPM and Flatpak files under `<out>/<channel>/`, with `package-channels.json` listing each channel's asset, install command and the release-page downloads. Channels are planned independently; the command exits 1 when any requested channel failed, after writing the others. It signs, uploads and qualifies nothing. Daily releases get `<token>@daily` casks and `<Id>.Daily` WinGet manifests, and only Stable releases are eligible for public catalogs. A direct `.exe` WinGet installer is the framework's standalone Setup.exe: its manifest passes `--package-manager=winget` (the policy gives no silent flags), and after a successful install the Setup writes `.package-manager` in `%LOCALAPPDATA%\<appId>\stable\app`, so the in-app updater leaves the install to WinGet. A `.zip` installer (Electrobun's Setup) gets the policy's flags and is not marked.
41
+
42
+ `publish-packages --local <packages-dir> <release-config.json> <out>`, with `RELEASE_TAG` and `SOURCE_SHA` set and the checkout at the tag, stages a tag's Linux packages like `publish --local`: the directory holds only `<archive base>.deb` and `<archive base>.AppImage` files for Linux archives the feed already lists for the tag from the same commit. They are added to release.json and the channel pointers as raw, unsigned files; no descriptor names them and nothing already published is replaced.
43
+
44
+ `daily-batch <show|promote|rollback> --dry-run <store-dir> ...` runs the staged Daily batch protocol (one signed `channels/daily-batch.json` pointer over immutable `batches/sha256-<digest>/` objects) against a local directory store. `promote` takes `<release-config.json> <candidate-dir> <key-id> <signing-key.pem> <trust.json>` and re-verifies a `daily-matrix stage-local` candidate; `rollback` takes `<app-id> <feed-app> <manifest-digest> <key-id> <signing-key.pem> <trust.json>` and moves the pointer back to a batch already in the store. Without `--dry-run` it refuses: live publication waits for durable shared storage and the reader migration.
39
45
 
40
46
  ## License
41
47
 
@@ -179,7 +179,7 @@ function keys(value, required) {
179
179
  return isRecord(value) && hasExactOwnKeys(value, required);
180
180
  }
181
181
  function buildDailyProductConfig(base, policy) {
182
- if (!isRecord(base) || base.dailyReleaseProfile !== undefined || !keys(base.platforms, legacy) || !isRecord(base.descriptors) || !isRecord(policy) || !hasExactOwnKeys(policy, [
182
+ if (!isRecord(base) || base.dailyReleaseProfile !== undefined && base.dailyReleaseProfile !== "desktop-v1" || !keys(base.platforms, legacy) || !isRecord(base.descriptors) || !isRecord(policy) || !hasExactOwnKeys(policy, [
183
183
  "schema",
184
184
  "profile",
185
185
  "appId",
package/dist/cli.js CHANGED
@@ -80,20 +80,26 @@ import { Effect as Effect32 } from "effect";
80
80
  // ../../src/installer/hosted-runner.ts
81
81
  import { isAbsolute } from "path";
82
82
  var JOB_NUMBER = /^[1-9]\d{0,19}$/;
83
- function isHostedRunner(env) {
83
+ function hostedRunnerRefusal(env) {
84
84
  if (env.CI !== "true")
85
- return false;
85
+ return "CI is not true";
86
86
  if (env.GITHUB_ACTIONS === "true")
87
- return env.RUNNER_ENVIRONMENT === "github-hosted";
87
+ return env.RUNNER_ENVIRONMENT === "github-hosted" ? undefined : "RUNNER_ENVIRONMENT is not github-hosted";
88
88
  if (env.FRAMEWORK_DISPOSABLE_RUNNER !== "true")
89
- return false;
89
+ return "FRAMEWORK_DISPOSABLE_RUNNER is not true";
90
90
  if (env.GITLAB_CI === "true")
91
- return JOB_NUMBER.test(env.CI_JOB_ID ?? "");
92
- return env.CIRCLECI === "true" && JOB_NUMBER.test(env.CIRCLE_BUILD_NUM ?? "");
91
+ return JOB_NUMBER.test(env.CI_JOB_ID ?? "") ? undefined : "CI_JOB_ID is not a job number";
92
+ if (env.CIRCLECI !== "true")
93
+ return "neither GITLAB_CI nor CIRCLECI is true";
94
+ return JOB_NUMBER.test(env.CIRCLE_BUILD_NUM ?? "") ? undefined : "CIRCLE_BUILD_NUM is not a job number";
95
+ }
96
+ function isHostedRunner(env) {
97
+ return hostedRunnerRefusal(env) === undefined;
93
98
  }
94
99
  function assertHostedRunner(env, subject) {
95
- if (!isHostedRunner(env))
96
- throw new Error(`${subject} requires a disposable hosted runner`);
100
+ const refusal = hostedRunnerRefusal(env);
101
+ if (refusal !== undefined)
102
+ throw new Error(`${subject} requires a disposable hosted runner (${refusal})`);
97
103
  }
98
104
  function runnerTemp(env) {
99
105
  const path = env.GITHUB_ACTIONS === "true" ? env.RUNNER_TEMP : env.TMPDIR;
@@ -1080,6 +1086,10 @@ import { Cause, Data, Effect, Exit } from "effect";
1080
1086
 
1081
1087
  class ReleaseFailure extends Data.TaggedError("ReleaseFailure") {
1082
1088
  }
1089
+
1090
+ class PublicReleaseError extends Error {
1091
+ name = "PublicReleaseError";
1092
+ }
1083
1093
  var refuse = (reason, message) => Effect.fail(new ReleaseFailure({ reason, message }));
1084
1094
  var fail = (message) => refuse("refused", message);
1085
1095
  var stepFailure = (error) => new ReleaseFailure({
@@ -3718,11 +3728,24 @@ async function promoteDailyBatch(store, candidate, signer, keys) {
3718
3728
  throw new Error("Daily promotion could not be read back");
3719
3729
  return selected;
3720
3730
  }
3731
+ async function readDailyBatchByDigest(store, target, manifestDigest) {
3732
+ if (!app.test(target.appId) || !feedApp.test(target.feedApp) || !hex2.test(manifestDigest))
3733
+ throw new Error("Invalid Daily batch target");
3734
+ const bytes = await readSmall(await store.readObject(`${prefix(target.feedApp, manifestDigest)}/manifest.json`), 262144);
3735
+ if (hash(bytes) !== manifestDigest)
3736
+ throw new Error("Daily batch manifest changed");
3737
+ const manifest = parseManifest(parseJson(bytes));
3738
+ if (manifest.identity.appId !== target.appId || manifest.identity.feedApp !== target.feedApp)
3739
+ throw new Error("Daily batch app mismatch");
3740
+ return Object.freeze({ version: "", sequence: 0, manifestDigest, manifest });
3741
+ }
3721
3742
  async function rollbackDailyBatch(store, current, target, signer, keys) {
3722
3743
  const appId = current.manifest.identity.appId;
3723
3744
  const slug = current.manifest.identity.feedApp;
3724
3745
  if (target.manifest.identity.appId !== appId || target.manifest.identity.feedApp !== slug || !hex2.test(target.manifestDigest))
3725
3746
  throw new Error("Invalid rollback target");
3747
+ if (target.manifestDigest === current.manifestDigest)
3748
+ throw new Error("Rollback target is the current Daily batch");
3726
3749
  const selected = await readDailyBatch(store, { appId, feedApp: slug }, keys);
3727
3750
  if (!selected || selected.version !== current.version)
3728
3751
  throw new Error("Daily pointer changed during rollback");
@@ -5936,6 +5959,72 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
5936
5959
  };
5937
5960
  return yield* writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, updated, release));
5938
5961
  });
5962
+ var linuxPackageFormats = [
5963
+ {
5964
+ extension: ".deb",
5965
+ magic: (head) => head.subarray(0, 8).toString("latin1") === `!<arch>
5966
+ `
5967
+ },
5968
+ {
5969
+ extension: ".AppImage",
5970
+ magic: (head) => head.subarray(0, 4).equals(Buffer.from([127, 69, 76, 70])) && head.subarray(8, 11).equals(Buffer.from([65, 73, 2]))
5971
+ }
5972
+ ];
5973
+ var stageLocalPackagesEffect = (options) => Effect21.gen(function* () {
5974
+ const fs = yield* ReleaseFs;
5975
+ const { tag, sourceSha } = options;
5976
+ const local = localConfig(options.config);
5977
+ const feed = local.feed;
5978
+ const requirements = local.requirements(tag);
5979
+ const allowed = new Map;
5980
+ for (const platform of ["linux-x64", "linux-arm64"])
5981
+ for (const archive of requirements.platforms[platform] ?? [])
5982
+ if (archive.endsWith(".tar.zst"))
5983
+ for (const { extension } of linuxPackageFormats)
5984
+ allowed.set(archive.slice(0, -".tar.zst".length) + extension, archive);
5985
+ const directory = resolve9(options.directory);
5986
+ const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
5987
+ if (!entries.length || entries.some((entry) => !entry.isFile() || !allowed.has(entry.name)))
5988
+ return yield* fail("Staged directory holds files that are not this tag's Linux packages");
5989
+ const names = entries.map((entry) => entry.name).toSorted();
5990
+ const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(join15(directory, name), name), { concurrency: "unbounded" });
5991
+ for (const name of names) {
5992
+ const format = linuxPackageFormats.find(({ extension }) => name.endsWith(extension));
5993
+ const head = Buffer.alloc(16);
5994
+ const file = yield* step(() => fs.open(join15(directory, name), "r"));
5995
+ yield* step(() => file.read(head, 0, 16, 0)).pipe(Effect21.ensuring(Effect21.promise(() => file.close().catch(() => {
5996
+ return;
5997
+ }))));
5998
+ if (!format.magic(head))
5999
+ return yield* fail(`Not a ${format.extension} package: ${name}`);
6000
+ }
6001
+ const [ledger, remote] = yield* Effect21.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
6002
+ const entry = ledger.releases.find((item) => item.tag === tag);
6003
+ if (!entry || !remote || entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt))
6004
+ return yield* fail("The feed has not published this tag; publish its release first");
6005
+ if (entry.sourceSha !== sourceSha)
6006
+ return yield* fail("The feed publishes this tag from another source commit");
6007
+ const merged = [...remote.assets];
6008
+ const uploads = [];
6009
+ for (const artifact of staged) {
6010
+ if (!merged.some((asset) => asset.name === allowed.get(artifact.name)))
6011
+ return yield* fail(`The feed has no ${allowed.get(artifact.name)} for ${artifact.name}`);
6012
+ const existing = merged.find((asset) => asset.name === artifact.name);
6013
+ if (existing) {
6014
+ if (existing.size !== artifact.size || "sha256:" + existing.sha256 !== artifact.digest)
6015
+ return yield* fail(`Immutable asset conflict: ${artifact.name}`);
6016
+ continue;
6017
+ }
6018
+ merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
6019
+ uploads.push({
6020
+ key: feedAssetKey(feed, tag, artifact.name),
6021
+ path: join15(directory, artifact.name),
6022
+ artifact
6023
+ });
6024
+ }
6025
+ const release = { ...remote, assets: merged };
6026
+ return yield* writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, ledger, release));
6027
+ });
5939
6028
  function stablePlatforms(config) {
5940
6029
  const value = isRecord(config) ? config.stablePlatforms : undefined;
5941
6030
  if (value === undefined)
@@ -10367,6 +10456,7 @@ import { basename as basename17, isAbsolute as isAbsolute8, join as join39, reso
10367
10456
  import { promisify as promisify5 } from "util";
10368
10457
 
10369
10458
  // src/library/windows-standalone-bootstrap.ts
10459
+ var WINDOWS_PACKAGE_MANAGER_SWITCH = "--package-manager=winget";
10370
10460
  var windowsBootstrapSource = String.raw`
10371
10461
  #define WIN32_LEAN_AND_MEAN
10372
10462
  #include <windows.h>
@@ -10425,10 +10515,28 @@ static BOOL write_exclusive(const wchar_t *path, const unsigned char *bytes, DWO
10425
10515
  return CloseHandle(file) && ok;
10426
10516
  }
10427
10517
 
10518
+ // Marks the installed app root as package-manager owned. The root must already exist as a real
10519
+ // directory (the inner Setup created it); the marker is replaced, never followed through a link.
10520
+ static BOOL write_package_manager_marker(void) {
10521
+ wchar_t local[MAX_PATH], root[MAX_PATH], marker[MAX_PATH];
10522
+ DWORD n = GetEnvironmentVariableW(L"LOCALAPPDATA", local, MAX_PATH);
10523
+ if (!n || n >= MAX_PATH) return FALSE;
10524
+ int m = swprintf(root, MAX_PATH, L"%ls\\%ls\\stable\\app", local, APP_ID);
10525
+ if (m <= 0 || m >= MAX_PATH || !join_path(marker, root, L".package-manager")) return FALSE;
10526
+ DWORD attributes = GetFileAttributesW(root);
10527
+ if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)
10528
+ || (attributes & FILE_ATTRIBUTE_REPARSE_POINT)) return FALSE;
10529
+ DeleteFileW(marker);
10530
+ static const unsigned char owner[] = "winget\n";
10531
+ return write_exclusive(marker, owner, sizeof owner - 1);
10532
+ }
10533
+
10428
10534
  int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int show) {
10429
10535
  (void)instance; (void)previous; (void)show;
10430
- // No undocumented silent or arbitrary installer arguments are forwarded.
10431
- if (command[0]) {
10536
+ // No undocumented silent or arbitrary installer arguments are forwarded. The only option is
10537
+ // the exact package-manager switch, which is not forwarded either: it marks the install.
10538
+ BOOL package_manager = wcscmp(command, L"${WINDOWS_PACKAGE_MANAGER_SWITCH}") == 0;
10539
+ if (command[0] && !package_manager) {
10432
10540
  MessageBoxW(NULL, L"This installer accepts no command-line options.", APP_NAME, MB_OK | MB_ICONERROR);
10433
10541
  return 2;
10434
10542
  }
@@ -10480,6 +10588,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int
10480
10588
  cleanup:
10481
10589
  DeleteFileW(archive); DeleteFileW(meta); DeleteFileW(child);
10482
10590
  RemoveDirectoryW(hidden); CloseHandle(guard); RemoveDirectoryW(work);
10591
+ if (code == 0 && package_manager && !write_package_manager_marker()) code = 2;
10483
10592
  if (code == 0) return 0;
10484
10593
  fail:
10485
10594
  MessageBoxW(NULL, L"Installation did not complete.", APP_NAME, MB_OK | MB_ICONERROR);
@@ -10620,6 +10729,7 @@ async function buildStandaloneWindowsExe(options) {
10620
10729
  throw new Error("Unexpected pinned Zig compiler version");
10621
10730
  await writeFile14(join39(work, "app.h"), [
10622
10731
  `#define APP_NAME L"${appName}"`,
10732
+ `#define APP_ID L"${appId}"`,
10623
10733
  `#define SETUP_SIZE ${setup.size}u`,
10624
10734
  `#define METADATA_SIZE ${metadata.size}u`,
10625
10735
  `#define ARCHIVE_SIZE ${archive.size}u`
@@ -10821,16 +10931,17 @@ end
10821
10931
  };
10822
10932
  }
10823
10933
  function winget(context, row) {
10824
- keys2(row, "winget", ["identifier", "publisher", "artifact", "silent", "silentWithProgress"], ["nestedInstaller"]);
10934
+ keys2(row, "winget", ["identifier", "publisher", "artifact"], ["nestedInstaller", "silent", "silentWithProgress"]);
10825
10935
  const stableId = text3(row.identifier, "WinGet package identifier", /^[A-Za-z0-9][A-Za-z0-9-]*(\.[A-Za-z0-9][A-Za-z0-9-]*)+$/);
10826
10936
  const publisher = text3(row.publisher, "WinGet publisher");
10827
10937
  const asset = exact2(context, row.artifact, "WinGet", [".exe", ".zip"]);
10828
10938
  const direct = asset.name.endsWith(".exe");
10829
10939
  ensure(direct === (row.nestedInstaller === undefined), direct ? "A direct .exe installer takes no nestedInstaller" : "A .zip installer needs nestedInstaller");
10830
10940
  const nested = direct ? undefined : text3(row.nestedInstaller, "nested executable", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.exe$/i);
10941
+ ensure(!direct || row.silent === undefined && row.silentWithProgress === undefined, "A direct .exe installer takes the package-manager switch, not silent flags");
10831
10942
  const flags = /^[-/][a-zA-Z0-9_-]+(?: [-/][a-zA-Z0-9_-]+)*$/;
10832
- const silent = text3(row.silent, "silent flags", flags);
10833
- const progress = text3(row.silentWithProgress, "silent progress flags", flags);
10943
+ const silent = direct ? WINDOWS_PACKAGE_MANAGER_SWITCH : text3(row.silent, "silent flags", flags);
10944
+ const progress = direct ? WINDOWS_PACKAGE_MANAGER_SWITCH : text3(row.silentWithProgress, "silent progress flags", flags);
10834
10945
  const stable = context.manifest.channel === "stable";
10835
10946
  const id = stable ? stableId : `${stableId}.Daily`;
10836
10947
  const { name, description, homepage, license } = context.common;
@@ -11555,6 +11666,46 @@ var stageDailyBatchEffect = (options) => Effect27.gen(function* () {
11555
11666
  }));
11556
11667
  return { directory, ...manifest };
11557
11668
  }).pipe(Effect27.scoped);
11669
+ var stagedDailyBatchManifestEffect = (options) => Effect27.gen(function* () {
11670
+ const fs = yield* ReleaseFs;
11671
+ const directory = resolve21(options.directory);
11672
+ const recordPath = join41(directory, "candidate.json");
11673
+ const info = yield* step(() => fs.lstat(recordPath));
11674
+ if (!info.isFile() || info.size < 1 || info.size > 262144)
11675
+ return yield* fail("Invalid Daily candidate record");
11676
+ const record = yield* attempt(async () => JSON.parse((await fs.readFile(recordPath)).toString("utf8")));
11677
+ if (!isRecord(record) || record.schema !== "framework/daily-staged-batch/v1" || !isRecord(record.identity))
11678
+ return yield* fail("Invalid Daily candidate record");
11679
+ const { tag, sourceSha, workflowSha, runId, runAttempt } = record.identity;
11680
+ if (typeof tag !== "string" || typeof sourceSha !== "string" || typeof workflowSha !== "string" || typeof runId !== "string" || typeof runAttempt !== "number")
11681
+ return yield* fail("Invalid Daily candidate identity");
11682
+ const identity = { tag, sourceSha, workflowSha, runId, runAttempt };
11683
+ const artifacts = join41(directory, "artifacts");
11684
+ const receipts = join41(directory, "receipts");
11685
+ const verified = yield* verifyDailyReleaseMatrixEffect({
11686
+ config: options.config,
11687
+ identity,
11688
+ artifacts,
11689
+ receipts
11690
+ });
11691
+ if (JSON.stringify({ schema: record.schema, ...verified }) !== JSON.stringify({
11692
+ schema: record.schema,
11693
+ profile: record.profile,
11694
+ appId: record.appId,
11695
+ identity: record.identity,
11696
+ assets: record.assets
11697
+ }))
11698
+ return yield* fail("Daily candidate differs from its verified inputs");
11699
+ const feed = yield* attempt(() => parseReleaseConfig(options.config).feed);
11700
+ const plan = yield* attempt(() => planDailyReleaseMatrix(options.config, tag));
11701
+ const receiptFiles = yield* Effect27.forEach(plan.checks, (check) => fileIdentityEffect(join41(receipts, `${check.name}.json`), `${check.name}.json`));
11702
+ return {
11703
+ schema: "framework/daily-batch/v1",
11704
+ identity: { appId: verified.appId, feedApp: feed.app, ...identity },
11705
+ artifacts: verified.assets.map(({ name, size, digest }) => ({ name, size, digest })),
11706
+ receipts: receiptFiles.map(({ name, size, digest }) => ({ name, size, digest }))
11707
+ };
11708
+ });
11558
11709
 
11559
11710
  // src/cli-runner.ts
11560
11711
  import { Cause as Cause3, Effect as Effect28, Exit as Exit5 } from "effect";
@@ -11564,6 +11715,16 @@ function failureError(cause) {
11564
11715
  return new Error(error.message);
11565
11716
  return error instanceof Error ? error : new Error(String(error));
11566
11717
  }
11718
+ function publicFailureCause(cause) {
11719
+ const error = Cause3.squash(cause);
11720
+ if (!(error instanceof ReleaseFailure))
11721
+ return;
11722
+ if (error.reason === "refused")
11723
+ return error.message;
11724
+ if (error.reason !== "step")
11725
+ return;
11726
+ return error.original instanceof PublicReleaseError ? error.original.message : undefined;
11727
+ }
11567
11728
  var runCommand = (failure, program, options = {}) => Effect28.gen(function* () {
11568
11729
  const { env } = yield* ReleaseConfig;
11569
11730
  const output = yield* ReleaseOutput;
@@ -11572,8 +11733,13 @@ var runCommand = (failure, program, options = {}) => Effect28.gen(function* () {
11572
11733
  return 0;
11573
11734
  if (Cause3.hasInterruptsOnly(exit.cause))
11574
11735
  return 130;
11575
- const error = failureError(exit.cause);
11576
- output.stderr(`${typeof failure === "string" ? failure : failure(error)}
11736
+ if (typeof failure !== "string") {
11737
+ output.stderr(`${failure(failureError(exit.cause))}
11738
+ `);
11739
+ return 1;
11740
+ }
11741
+ const cause = publicFailureCause(exit.cause);
11742
+ output.stderr(`${cause && cause !== failure ? `${failure}: ${cause}` : failure}
11577
11743
  `);
11578
11744
  return 1;
11579
11745
  });
@@ -11989,7 +12155,7 @@ async function verifiedSourceCommit(git, sha) {
11989
12155
  async function verifiedSourceFile(git, rootTree, path) {
11990
12156
  const parts = path.split("/");
11991
12157
  if (path.length > 512 || !parts.length || parts.some((part) => !pathPart.test(part)))
11992
- throw new Error("Invalid source metadata path");
12158
+ throw new PublicReleaseError("Invalid source metadata path");
11993
12159
  let tree = rootTree;
11994
12160
  for (let index = 0;index < parts.length; index++) {
11995
12161
  const bytes = await object3(git, "tree", tree, 8 * 1024 * 1024);
@@ -12010,17 +12176,17 @@ async function verifiedSourceFile(git, rootTree, path) {
12010
12176
  offset = zero + 21;
12011
12177
  }
12012
12178
  if (!found)
12013
- throw new Error("Missing source metadata");
12179
+ throw new PublicReleaseError(`Missing source metadata: ${path}`);
12014
12180
  if (index === parts.length - 1) {
12015
12181
  if (found.mode !== "100644" && found.mode !== "100755")
12016
- throw new Error("Source metadata must be a regular blob");
12182
+ throw new PublicReleaseError(`Source metadata must be a regular blob: ${path}`);
12017
12183
  return object3(git, "blob", found.oid, 262144);
12018
12184
  }
12019
12185
  if (found.mode !== "40000" && found.mode !== "040000")
12020
- throw new Error("Invalid source metadata directory");
12186
+ throw new PublicReleaseError(`Invalid source metadata directory: ${path}`);
12021
12187
  tree = found.oid;
12022
12188
  }
12023
- throw new Error("Missing source metadata");
12189
+ throw new PublicReleaseError(`Missing source metadata: ${path}`);
12024
12190
  }
12025
12191
 
12026
12192
  // src/commands/build-linux-formats.ts
@@ -12229,6 +12395,206 @@ var buildLinuxFormatsCommand = (args) => runCommand("Unable to build Linux forma
12229
12395
  `);
12230
12396
  }));
12231
12397
 
12398
+ // src/commands/daily-batch.ts
12399
+ import { lstat as lstat26, readFile as readFile17 } from "fs/promises";
12400
+ import { resolve as resolve24 } from "path";
12401
+
12402
+ // src/library/daily-batch-directory.ts
12403
+ import { createHash as createHash29, createPrivateKey as createPrivateKey2, createPublicKey as createPublicKey4, randomBytes as randomBytes5, sign as sign2 } from "crypto";
12404
+ import { createReadStream as createReadStream4 } from "fs";
12405
+ import { link as link2, lstat as lstat25, mkdir as mkdir15, readFile as readFile16, rename as rename4, rm as rm17, rmdir as rmdir2, writeFile as writeFile17 } from "fs/promises";
12406
+ import { dirname as dirname19, isAbsolute as isAbsolute11, join as join45, resolve as resolve23 } from "path";
12407
+ var segment2 = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,199}$/;
12408
+ var hash3 = (bytes) => createHash29("sha256").update(bytes).digest("hex");
12409
+ async function regular3(file) {
12410
+ const stat = await lstat25(file);
12411
+ if (!stat.isFile())
12412
+ throw new Error("Daily batch store object is not a regular file");
12413
+ return stat;
12414
+ }
12415
+ var missing = (error) => error?.code === "ENOENT";
12416
+ function createDailyBatchDirectoryStore(root) {
12417
+ if (!isAbsolute11(root))
12418
+ throw new Error("Daily batch store directory must be absolute");
12419
+ const base = resolve23(root);
12420
+ const path = (key) => {
12421
+ const parts = key.split("/");
12422
+ if (key.length > 1024 || parts.length < 2 || !parts.every((part) => segment2.test(part)))
12423
+ throw new Error("Invalid Daily batch store key");
12424
+ return join45(base, ...parts);
12425
+ };
12426
+ return {
12427
+ async putImmutable(key, bytes, size, sha256) {
12428
+ const target = path(key);
12429
+ if (!Number.isSafeInteger(size) || size < 0 || !/^[a-f0-9]{64}$/.test(sha256))
12430
+ throw new Error("Invalid Daily batch object identity");
12431
+ const chunks = [];
12432
+ let length = 0;
12433
+ for await (const chunk of bytes) {
12434
+ length += chunk.byteLength;
12435
+ if (length > size)
12436
+ throw new Error(`Daily batch object too large: ${key}`);
12437
+ chunks.push(chunk);
12438
+ }
12439
+ const body = Buffer.concat(chunks);
12440
+ if (length !== size || hash3(body) !== sha256)
12441
+ throw new Error(`Daily batch object differs from its identity: ${key}`);
12442
+ await mkdir15(dirname19(target), { recursive: true, mode: 448 });
12443
+ const temporary = `${target}.${randomBytes5(8).toString("hex")}.partial`;
12444
+ await writeFile17(temporary, body, { flag: "wx", mode: 384 });
12445
+ let exists = false;
12446
+ try {
12447
+ await link2(temporary, target);
12448
+ } catch (error) {
12449
+ if (error.code !== "EEXIST")
12450
+ throw error;
12451
+ exists = true;
12452
+ } finally {
12453
+ await rm17(temporary, { force: true });
12454
+ }
12455
+ if (exists) {
12456
+ await regular3(target);
12457
+ if (hash3(await readFile16(target)) !== sha256)
12458
+ throw new Error(`Daily batch object already exists with different bytes: ${key}`);
12459
+ }
12460
+ },
12461
+ async readObject(key) {
12462
+ const target = path(key);
12463
+ await regular3(target);
12464
+ return createReadStream4(target);
12465
+ },
12466
+ async readPointer(key) {
12467
+ const target = path(key);
12468
+ try {
12469
+ await regular3(target);
12470
+ const bytes = await readFile16(target);
12471
+ return { version: hash3(bytes), bytes };
12472
+ } catch (error) {
12473
+ if (missing(error))
12474
+ return null;
12475
+ throw error;
12476
+ }
12477
+ },
12478
+ async compareAndSwap(key, expectedVersion, bytes) {
12479
+ const target = path(key);
12480
+ await mkdir15(dirname19(target), { recursive: true, mode: 448 });
12481
+ const lock = `${target}.lock`;
12482
+ try {
12483
+ await mkdir15(lock);
12484
+ } catch (error) {
12485
+ if (error.code === "EEXIST")
12486
+ return false;
12487
+ throw error;
12488
+ }
12489
+ try {
12490
+ let current = null;
12491
+ try {
12492
+ await regular3(target);
12493
+ current = hash3(await readFile16(target));
12494
+ } catch (error) {
12495
+ if (!missing(error))
12496
+ throw error;
12497
+ }
12498
+ if (current !== expectedVersion)
12499
+ return false;
12500
+ const temporary = `${target}.${randomBytes5(8).toString("hex")}.partial`;
12501
+ await writeFile17(temporary, bytes, { flag: "wx", mode: 384 });
12502
+ await rename4(temporary, target);
12503
+ return true;
12504
+ } finally {
12505
+ await rmdir2(lock);
12506
+ }
12507
+ }
12508
+ };
12509
+ }
12510
+ function dailyPointerSignerFromPem(keyId, pem) {
12511
+ const key = createPrivateKey2(pem);
12512
+ if (key.asymmetricKeyType !== "ed25519")
12513
+ throw new Error("Daily pointer key must be Ed25519");
12514
+ return { keyId, sign: async (message) => new Uint8Array(sign2(null, message, key)) };
12515
+ }
12516
+ function parseDailyPointerTrust(value) {
12517
+ if (!value || typeof value !== "object" || Array.isArray(value))
12518
+ throw new Error("Invalid Daily pointer trust");
12519
+ const entries = Object.entries(value);
12520
+ if (!entries.length || entries.length > 16 || !entries.every(([id, key]) => /^[a-z0-9][a-z0-9._-]{0,63}$/.test(id) && typeof key === "string" && Buffer.from(key, "base64").length === 32))
12521
+ throw new Error("Invalid Daily pointer trust");
12522
+ return new Map(entries);
12523
+ }
12524
+
12525
+ // src/commands/daily-batch.ts
12526
+ var usage = [
12527
+ "daily-batch show --dry-run <store-dir> <app-id> <feed-app> <trust.json>",
12528
+ "daily-batch promote --dry-run <store-dir> <release-config.json> <candidate-dir> <key-id> <signing-key.pem> <trust.json>",
12529
+ "daily-batch rollback --dry-run <store-dir> <app-id> <feed-app> <manifest-digest> <key-id> <signing-key.pem> <trust.json>"
12530
+ ].join("; ");
12531
+ var bounded3 = async (path, max, name) => {
12532
+ const stat = await lstat26(path);
12533
+ if (!stat.isFile() || stat.size < 1 || stat.size > max)
12534
+ throw new Error(`Invalid ${name}`);
12535
+ return readFile17(path);
12536
+ };
12537
+ var json2 = async (path, max, name) => JSON.parse((await bounded3(path, max, name)).toString("utf8"));
12538
+ var summary = (snapshot) => snapshot && {
12539
+ sequence: snapshot.sequence,
12540
+ manifestDigest: snapshot.manifestDigest,
12541
+ tag: snapshot.manifest.identity.tag,
12542
+ sourceSha: snapshot.manifest.identity.sourceSha,
12543
+ artifacts: snapshot.manifest.artifacts.length,
12544
+ receipts: snapshot.manifest.receipts.length
12545
+ };
12546
+ async function dailyBatchCommand(args, cwd) {
12547
+ const [action, flag, storeDir, ...operands] = args;
12548
+ if (!action || !["show", "promote", "rollback"].includes(action))
12549
+ throw new Error(`Expected ${usage}`);
12550
+ if (flag !== "--dry-run")
12551
+ throw new Error("Live Daily batch publication is not enabled; pass --dry-run with a local store directory");
12552
+ if (!storeDir)
12553
+ throw new Error(`Expected ${usage}`);
12554
+ const root = resolve24(cwd, storeDir);
12555
+ const rootStat = await lstat26(root);
12556
+ if (!rootStat.isDirectory() || rootStat.isSymbolicLink())
12557
+ throw new Error("The Daily batch store must be an existing real directory");
12558
+ const store = createDailyBatchDirectoryStore(root);
12559
+ const signer = async (keyId, path) => dailyPointerSignerFromPem(keyId, (await bounded3(resolve24(cwd, path), 4096, "Daily pointer signing key")).toString("utf8"));
12560
+ const trust = async (path) => parseDailyPointerTrust(await json2(resolve24(cwd, path), 16384, "Daily pointer trust"));
12561
+ if (action === "show") {
12562
+ const [appId, feedApp, trustPath, ...extra] = operands;
12563
+ if (!appId || !feedApp || !trustPath || extra.length)
12564
+ throw new Error(`Expected ${usage}`);
12565
+ const current = await readDailyBatch(store, { appId, feedApp }, await trust(trustPath));
12566
+ return { action, dryRun: true, store: root, current: summary(current) };
12567
+ }
12568
+ if (action === "promote") {
12569
+ const [configPath, candidateDir, keyId, keyPath, trustPath, ...extra] = operands;
12570
+ if (!configPath || !candidateDir || !keyId || !keyPath || !trustPath || extra.length)
12571
+ throw new Error(`Expected ${usage}`);
12572
+ const config = await json2(resolve24(cwd, configPath), 262144, "release configuration");
12573
+ const directory = resolve24(cwd, candidateDir);
12574
+ const selected = await promoteDailyBatch(store, {
12575
+ verify: () => runReleaseLibrary(provideLibraryPorts()(stagedDailyBatchManifestEffect({ config, directory }))),
12576
+ path: (kind, name) => resolve24(directory, kind, name)
12577
+ }, await signer(keyId, keyPath), await trust(trustPath));
12578
+ return { action, dryRun: true, store: root, current: summary(selected) };
12579
+ }
12580
+ const [appId, feedApp, digest, keyId, keyPath, trustPath, ...extra] = operands;
12581
+ if (!appId || !feedApp || !digest || !keyId || !keyPath || !trustPath || extra.length)
12582
+ throw new Error(`Expected ${usage}`);
12583
+ const keys = await trust(trustPath);
12584
+ const target = { appId, feedApp };
12585
+ const current = await readDailyBatch(store, target, keys);
12586
+ if (!current)
12587
+ throw new Error("No Daily batch is selected; nothing to roll back");
12588
+ await rollbackDailyBatch(store, current, await readDailyBatchByDigest(store, target, digest), await signer(keyId, keyPath), keys);
12589
+ return {
12590
+ action,
12591
+ dryRun: true,
12592
+ store: root,
12593
+ previous: summary(current),
12594
+ current: summary(await readDailyBatch(store, target, keys))
12595
+ };
12596
+ }
12597
+
12232
12598
  // src/commands/build-windows-standalone.ts
12233
12599
  import { basename as basename20 } from "path";
12234
12600
  import { Effect as Effect30 } from "effect";
@@ -12262,8 +12628,8 @@ var buildWindowsStandaloneCommand = (args) => runCommand("Unable to build the st
12262
12628
 
12263
12629
  // src/library/apt/stage-apt-repository.ts
12264
12630
  import { spawnSync as spawnSync3 } from "child_process";
12265
- import { lstat as lstat25, mkdir as mkdir15, readFile as readFile16, readdir as readdir16, rm as rm17, unlink as unlink4, writeFile as writeFile17 } from "fs/promises";
12266
- import { dirname as dirname19, isAbsolute as isAbsolute11, join as join45 } from "path";
12631
+ import { lstat as lstat27, mkdir as mkdir16, readFile as readFile18, readdir as readdir16, rm as rm18, unlink as unlink4, writeFile as writeFile18 } from "fs/promises";
12632
+ import { dirname as dirname20, isAbsolute as isAbsolute12, join as join46 } from "path";
12267
12633
  function cmd(program, options, label) {
12268
12634
  const run = spawnSync3(program, options, { encoding: "utf8", timeout: 60000 });
12269
12635
  if (run.error || run.status !== 0)
@@ -12271,14 +12637,14 @@ function cmd(program, options, label) {
12271
12637
  return run.stdout;
12272
12638
  }
12273
12639
  async function add(path, bytes) {
12274
- await mkdir15(dirname19(path), { recursive: true });
12275
- await writeFile17(path, bytes, { flag: "wx" });
12640
+ await mkdir16(dirname20(path), { recursive: true });
12641
+ await writeFile18(path, bytes, { flag: "wx" });
12276
12642
  }
12277
12643
  async function stageAptRepositoryCommand(args) {
12278
12644
  const [tag, policyPath, inventoryPath, packagePath, output, signingHome, trustedFingerprint] = args;
12279
- if (args.length !== 7 || !tag || !/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) || !policyPath || !inventoryPath || !packagePath || !output || !signingHome || !isAbsolute11(signingHome) || !trustedFingerprint || !/^[A-F0-9]{40}$/.test(trustedFingerprint))
12645
+ if (args.length !== 7 || !tag || !/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) || !policyPath || !inventoryPath || !packagePath || !output || !signingHome || !isAbsolute12(signingHome) || !trustedFingerprint || !/^[A-F0-9]{40}$/.test(trustedFingerprint))
12280
12646
  throw new Error("Expected TAG POLICY VERIFIED_INVENTORY DEB_OR_DIRECTORY NEW_OUTPUT GPG_HOME PINNED_FINGERPRINT");
12281
- const rawPolicy = JSON.parse(await readFile16(policyPath, "utf8"));
12647
+ const rawPolicy = JSON.parse(await readFile18(policyPath, "utf8"));
12282
12648
  if (typeof rawPolicy !== "object" || rawPolicy === null || Array.isArray(rawPolicy))
12283
12649
  throw new Error("Expected APT repository policy");
12284
12650
  const variant = rawPolicy;
@@ -12286,27 +12652,27 @@ async function stageAptRepositoryCommand(args) {
12286
12652
  const policies = multiarch ? variant.packages : [rawPolicy];
12287
12653
  if (!Array.isArray(policies) || policies.length !== (multiarch ? 2 : 1) || policies.some((policy) => !policy || typeof policy !== "object" || !/^[A-Za-z0-9][A-Za-z0-9_.+-]*\.deb$/.test(policy.assetName)))
12288
12654
  throw new Error("Invalid APT release package selection");
12289
- const inventory = JSON.parse(await readFile16(inventoryPath, "utf8"));
12655
+ const inventory = JSON.parse(await readFile18(inventoryPath, "utf8"));
12290
12656
  if (inventory.tag !== tag || !Array.isArray(inventory.assets))
12291
12657
  throw new Error("Verified inventory does not name requested release");
12292
12658
  if (multiarch) {
12293
- if (!(await lstat25(packagePath)).isDirectory())
12659
+ if (!(await lstat27(packagePath)).isDirectory())
12294
12660
  throw new Error("Multiarch APT requires one directory of two ordinary DEBs");
12295
12661
  const entries = await readdir16(packagePath, { withFileTypes: true });
12296
12662
  if (entries.length !== 2 || entries.some((entry) => !entry.isFile() || !policies.some((policy) => entry.name === policy.assetName)))
12297
12663
  throw new Error("Multiarch APT requires exactly the two selected ordinary DEBs");
12298
12664
  }
12299
- await mkdir15(output, { mode: 448 });
12665
+ await mkdir16(output, { mode: 448 });
12300
12666
  try {
12301
12667
  const now = new Date;
12302
12668
  const stagedInputs = [];
12303
12669
  for (const [index, policy] of policies.entries()) {
12304
- const input = multiarch ? join45(packagePath, policy.assetName) : packagePath;
12305
- if (!(await lstat25(input)).isFile())
12670
+ const input = multiarch ? join46(packagePath, policy.assetName) : packagePath;
12671
+ if (!(await lstat27(input)).isFile())
12306
12672
  throw new Error("Expected ordinary Debian package");
12307
- const deb = await readFile16(input);
12308
- const stagedInput = join45(output, `.input-${index}.deb`);
12309
- await writeFile17(stagedInput, deb, { mode: 384, flag: "wx" });
12673
+ const deb = await readFile18(input);
12674
+ const stagedInput = join46(output, `.input-${index}.deb`);
12675
+ await writeFile18(stagedInput, deb, { mode: 384, flag: "wx" });
12310
12676
  const control = cmd("dpkg-deb", ["--field", stagedInput], "Debian control inspection failed");
12311
12677
  stagedInputs.push({ policy, tag, assets: inventory.assets, deb, control, now, stagedInput });
12312
12678
  }
@@ -12315,12 +12681,12 @@ async function stageAptRepositoryCommand(args) {
12315
12681
  const { packagePath: stagedPackagePath, files, release } = stageAptMetadata(single);
12316
12682
  return { files, release, packages: [{ packagePath: stagedPackagePath, deb: single.deb }] };
12317
12683
  })();
12318
- const base = join45(output, "dists", single.policy.suite);
12684
+ const base = join46(output, "dists", single.policy.suite);
12319
12685
  for (const entry of staged.packages)
12320
- await add(join45(output, entry.packagePath), entry.deb);
12686
+ await add(join46(output, entry.packagePath), entry.deb);
12321
12687
  for (const [path, contents] of staged.files)
12322
- await add(join45(base, path), contents);
12323
- await add(join45(base, "Release"), staged.release);
12688
+ await add(join46(base, path), contents);
12689
+ await add(join46(base, "Release"), staged.release);
12324
12690
  const flags = [
12325
12691
  "--batch",
12326
12692
  "--no-tty",
@@ -12337,15 +12703,15 @@ async function stageAptRepositoryCommand(args) {
12337
12703
  ["InRelease", "--clearsign"],
12338
12704
  ["Release.gpg", "--detach-sign"]
12339
12705
  ]) {
12340
- cmd("gpg", [...flags, "--armor", "--output", join45(base, name), mode, join45(base, "Release")], `Could not produce ${name} with the pinned signing identity`);
12706
+ cmd("gpg", [...flags, "--armor", "--output", join46(base, name), mode, join46(base, "Release")], `Could not produce ${name} with the pinned signing identity`);
12341
12707
  }
12342
12708
  for (const { stagedInput } of stagedInputs)
12343
12709
  await unlink4(stagedInput);
12344
- await add(join45(output, "STAGED"), `${tag}
12710
+ await add(join46(output, "STAGED"), `${tag}
12345
12711
  `);
12346
12712
  return { tag, staged: true };
12347
12713
  } catch (error) {
12348
- await rm17(output, { recursive: true, force: true });
12714
+ await rm18(output, { recursive: true, force: true });
12349
12715
  throw error;
12350
12716
  }
12351
12717
  }
@@ -12353,10 +12719,10 @@ async function stageAptRepositoryCommand(args) {
12353
12719
  // src/library/release-retention-cli.ts
12354
12720
  import { constants as constants9 } from "fs";
12355
12721
  import { open as open16 } from "fs/promises";
12356
- import { isAbsolute as isAbsolute12 } from "path";
12722
+ import { isAbsolute as isAbsolute13 } from "path";
12357
12723
 
12358
12724
  // src/library/release-retention.ts
12359
- import { createHash as createHash29 } from "crypto";
12725
+ import { createHash as createHash30 } from "crypto";
12360
12726
  var day = 86400000;
12361
12727
  var safeTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-dev\.(?:0|[1-9]\d*))?$/;
12362
12728
  var safeAsset = /^[a-zA-Z0-9][a-zA-Z0-9._+-]{0,254}$/;
@@ -12384,7 +12750,7 @@ function unique(rows, key, caption) {
12384
12750
  var byKey = (a, b) => a.key.localeCompare(b.key);
12385
12751
  var ordered = (rows, key) => rows.toSorted((a, b) => key(a).localeCompare(key(b)));
12386
12752
  var stable = (value) => JSON.stringify(value);
12387
- var fingerprint = (value) => createHash29("sha256").update(stable(value)).digest("hex");
12753
+ var fingerprint = (value) => createHash30("sha256").update(stable(value)).digest("hex");
12388
12754
  var latestFirst = (a, b) => date(b.publishedAt) - date(a.publishedAt) || a.tag.localeCompare(b.tag);
12389
12755
  function planReleaseRetention(snapshot) {
12390
12756
  const { app } = snapshot;
@@ -12528,7 +12894,7 @@ function assertRetirementPreflight(plan, fresh, approvedDigest) {
12528
12894
 
12529
12895
  // src/library/release-retention-cli.ts
12530
12896
  var document = async (path) => {
12531
- if (!path || !isAbsolute12(path))
12897
+ if (!path || !isAbsolute13(path))
12532
12898
  throw new Error("Expected an absolute evidence file path");
12533
12899
  const file = await open16(path, constants9.O_RDONLY | constants9.O_NOFOLLOW | constants9.O_NONBLOCK);
12534
12900
  try {
@@ -12558,22 +12924,22 @@ if (false) {}
12558
12924
 
12559
12925
  // src/linux-channel-proof-cli.ts
12560
12926
  import { spawnSync as spawnSync4 } from "child_process";
12561
- import { createHash as createHash30 } from "crypto";
12562
- import { createReadStream as createReadStream4 } from "fs";
12927
+ import { createHash as createHash31 } from "crypto";
12928
+ import { createReadStream as createReadStream5 } from "fs";
12563
12929
  import { constants as constants10, createWriteStream as createWriteStream2 } from "fs";
12564
- import { lstat as lstat26, mkdtemp as mkdtemp15, open as open17, readFile as readFile17, realpath as realpath13, rm as rm18 } from "fs/promises";
12930
+ import { lstat as lstat28, mkdtemp as mkdtemp15, open as open17, readFile as readFile19, realpath as realpath13, rm as rm19 } from "fs/promises";
12565
12931
  import { tmpdir as tmpdir8 } from "os";
12566
- import { basename as basename21, join as join46 } from "path";
12932
+ import { basename as basename21, join as join47 } from "path";
12567
12933
  import { pipeline as pipeline3 } from "stream/promises";
12568
12934
  import { pathToFileURL } from "url";
12569
12935
  function check4(ok, message) {
12570
12936
  if (!ok)
12571
12937
  throw new Error(message);
12572
12938
  }
12573
- async function hash3(path) {
12574
- check4((await lstat26(path)).isFile(), "artifact must be a regular file");
12575
- const digest = createHash30("sha256");
12576
- for await (const chunk of createReadStream4(path))
12939
+ async function hash4(path) {
12940
+ check4((await lstat28(path)).isFile(), "artifact must be a regular file");
12941
+ const digest = createHash31("sha256");
12942
+ for await (const chunk of createReadStream5(path))
12577
12943
  digest.update(chunk);
12578
12944
  return digest.digest("hex");
12579
12945
  }
@@ -12606,11 +12972,11 @@ async function verifyRpmStage(stage) {
12606
12972
  }
12607
12973
  for (const artifact of [stage.payload, stage.rpm]) {
12608
12974
  check4(/^[0-9a-f]{64}$/.test(artifact.sha256), "expected SHA-256");
12609
- check4(await hash3(artifact.path) === artifact.sha256, "staged artifact digest mismatch");
12975
+ check4(await hash4(artifact.path) === artifact.sha256, "staged artifact digest mismatch");
12610
12976
  }
12611
12977
  const repo = await realpath13(stage.repository);
12612
12978
  const keyUrl = pathToFileURL(await realpath13(stage.publicKey)).href;
12613
- const config = options(await readFile17(stage.repoFile, "utf8"), stage.repoId);
12979
+ const config = options(await readFile19(stage.repoFile, "utf8"), stage.repoId);
12614
12980
  check4(config.get("baseurl") === pathToFileURL(repo).href, "expected the local repository");
12615
12981
  check4(config.get("gpgkey") === keyUrl, "expected the configured QA public key");
12616
12982
  for (const flag of ["pkg_gpgcheck", "repo_gpgcheck"]) {
@@ -12620,10 +12986,10 @@ async function verifyRpmStage(stage) {
12620
12986
  check4([...config.keys()].every((key) => allowed.has(key)), "unexpected repository options");
12621
12987
  for (const path of [
12622
12988
  stage.publicKey,
12623
- join46(repo, "repodata/repomd.xml"),
12624
- join46(repo, "repodata/repomd.xml.asc")
12989
+ join47(repo, "repodata/repomd.xml"),
12990
+ join47(repo, "repodata/repomd.xml.asc")
12625
12991
  ]) {
12626
- check4((await lstat26(path)).isFile(), "expected regular key and signed metadata files");
12992
+ check4((await lstat28(path)).isFile(), "expected regular key and signed metadata files");
12627
12993
  }
12628
12994
  const result = spawnSync4("rpm", ["-qp", "--queryformat", "%{NAME}|%{VERSION}|%{ARCH}", await realpath13(stage.rpm.path)], { encoding: "utf8", timeout: 1e4 });
12629
12995
  check4(result.error?.code !== "ENOENT", "rpm is required for RPM header verification");
@@ -12633,12 +12999,12 @@ async function verifyRpmStage(stage) {
12633
12999
  async function verifySignedRpmStage(stage, fingerprint) {
12634
13000
  check4(/^[A-F0-9]{40}$/.test(fingerprint), "expected an independently trusted full primary fingerprint");
12635
13001
  await verifyRpmStage(stage);
12636
- const root = await mkdtemp15(join46(tmpdir8(), "rpm-signature-proof-"));
12637
- const rpm = join46(root, "package.rpm");
12638
- const key = join46(root, "key.asc");
12639
- const metadata = join46(root, "repomd.xml");
12640
- const signature = join46(root, "repomd.xml.asc");
12641
- const originalMetadata = join46(stage.repository, "repodata/repomd.xml");
13002
+ const root = await mkdtemp15(join47(tmpdir8(), "rpm-signature-proof-"));
13003
+ const rpm = join47(root, "package.rpm");
13004
+ const key = join47(root, "key.asc");
13005
+ const metadata = join47(root, "repomd.xml");
13006
+ const signature = join47(root, "repomd.xml.asc");
13007
+ const originalMetadata = join47(stage.repository, "repodata/repomd.xml");
12642
13008
  const originalSignature = `${originalMetadata}.asc`;
12643
13009
  const snapshot = async (source, target, max) => {
12644
13010
  const file = await open17(source, constants10.O_RDONLY | constants10.O_NOFOLLOW);
@@ -12666,7 +13032,7 @@ async function verifySignedRpmStage(stage, fingerprint) {
12666
13032
  await snapshot(stage.publicKey, key, 1024 * 1024);
12667
13033
  await snapshot(originalMetadata, metadata, 8 * 1024 * 1024);
12668
13034
  await snapshot(originalSignature, signature, 1024 * 1024);
12669
- check4(await hash3(rpm) === stage.rpm.sha256, "RPM changed before signature verification");
13035
+ check4(await hash4(rpm) === stage.rpm.sha256, "RPM changed before signature verification");
12670
13036
  const gpg = ["--no-options", "--batch", "--homedir", root, "--no-auto-key-retrieve"];
12671
13037
  const list = command("gpg", [...gpg, "--with-colons", "--fingerprint", "--show-keys", key]);
12672
13038
  const lines = list.split(`
@@ -12679,7 +13045,7 @@ async function verifySignedRpmStage(stage, fingerprint) {
12679
13045
  const signatures = verified.split(`
12680
13046
  `).filter((line) => line.startsWith("[GNUPG:] VALIDSIG "));
12681
13047
  check4(signatures.length === 1 && signatures[0].split(" ").at(-1) === fingerprint, "metadata signer does not match pinned primary fingerprint");
12682
- const db = join46(root, "rpmdb");
13048
+ const db = join47(root, "rpmdb");
12683
13049
  command("rpm", ["--dbpath", db, "--initdb"]);
12684
13050
  command("rpmkeys", ["--dbpath", db, "--import", key]);
12685
13051
  command("rpmkeys", ["--dbpath", db, "--define", "_pkgverify_level all", "--checksig", rpm]);
@@ -12693,10 +13059,10 @@ async function verifySignedRpmStage(stage, fingerprint) {
12693
13059
  ]);
12694
13060
  const rpmIdentity = identity.split("|");
12695
13061
  check4(rpmIdentity.length === 5 && rpmIdentity[0] === stage.packageName && /^[0-9]+$/.test(rpmIdentity[1]) && rpmIdentity[2] === stage.version && /^[A-Za-z0-9][A-Za-z0-9._+~^]*$/.test(rpmIdentity[3]) && rpmIdentity[4] === stage.architecture, "signed RPM header does not match the requested package");
12696
- const rpmSha256 = await hash3(rpm);
12697
- const metadataSha256 = await hash3(metadata);
12698
- const signatureSha256 = await hash3(signature);
12699
- check4(await hash3(stage.rpm.path) === rpmSha256 && await hash3(originalMetadata) === metadataSha256 && await hash3(originalSignature) === signatureSha256, "signed inputs changed during verification");
13062
+ const rpmSha256 = await hash4(rpm);
13063
+ const metadataSha256 = await hash4(metadata);
13064
+ const signatureSha256 = await hash4(signature);
13065
+ check4(await hash4(stage.rpm.path) === rpmSha256 && await hash4(originalMetadata) === metadataSha256 && await hash4(originalSignature) === signatureSha256, "signed inputs changed during verification");
12700
13066
  return {
12701
13067
  kind: "rpm-signature-proof",
12702
13068
  sourceSha: stage.sourceSha,
@@ -12707,7 +13073,7 @@ async function verifySignedRpmStage(stage, fingerprint) {
12707
13073
  signatureSha256
12708
13074
  };
12709
13075
  } finally {
12710
- await rm18(root, { recursive: true, force: true });
13076
+ await rm19(root, { recursive: true, force: true });
12711
13077
  }
12712
13078
  }
12713
13079
  var systemTalkDenied2 = /^(org\.freedesktop\.(Flatpak|DBus|systemd1)|org\.gtk\.GDBus)(\.|$)/;
@@ -12736,14 +13102,14 @@ function verifyFlatpakCapabilities(policy, result) {
12736
13102
 
12737
13103
  // src/linux-rpm-metadata-proof.ts
12738
13104
  import { spawnSync as spawnSync5 } from "child_process";
12739
- import { createHash as createHash31 } from "crypto";
13105
+ import { createHash as createHash32 } from "crypto";
12740
13106
  import { constants as constants11 } from "fs";
12741
- import { lstat as lstat27, open as open18, realpath as realpath14 } from "fs/promises";
12742
- import { isAbsolute as isAbsolute13, join as join47, relative as relative7, resolve as resolve23 } from "path";
13107
+ import { lstat as lstat29, open as open18, realpath as realpath14 } from "fs/promises";
13108
+ import { isAbsolute as isAbsolute14, join as join48, relative as relative7, resolve as resolve25 } from "path";
12743
13109
  import { gunzipSync as gunzipSync2 } from "zlib";
12744
13110
  var maxCompressed = 16 * 1024 * 1024;
12745
13111
  var maxOpen = 32 * 1024 * 1024;
12746
- var digest5 = (bytes) => createHash31("sha256").update(bytes).digest("hex");
13112
+ var digest5 = (bytes) => createHash32("sha256").update(bytes).digest("hex");
12747
13113
  function ensure2(ok, reason) {
12748
13114
  if (!ok)
12749
13115
  throw new Error(reason);
@@ -12831,7 +13197,7 @@ async function digestRegular(path, expectedSize) {
12831
13197
  try {
12832
13198
  const stat = await file.stat();
12833
13199
  ensure2(stat.isFile() && stat.size === expectedSize && stat.size > 0 && stat.size <= 4 * 1024 * 1024 * 1024, "Invalid RPM file");
12834
- const hash = createHash31("sha256");
13200
+ const hash = createHash32("sha256");
12835
13201
  let size = 0;
12836
13202
  for await (const chunk of file.createReadStream({ autoClose: false })) {
12837
13203
  size += chunk.length;
@@ -12845,13 +13211,13 @@ async function digestRegular(path, expectedSize) {
12845
13211
  }
12846
13212
  }
12847
13213
  async function contained(repo, href) {
12848
- ensure2(!isAbsolute13(href) && href.length <= 1024, "Invalid repository path");
13214
+ ensure2(!isAbsolute14(href) && href.length <= 1024, "Invalid repository path");
12849
13215
  const parts = href.split("/");
12850
13216
  ensure2(parts.every((part) => /^[A-Za-z0-9][A-Za-z0-9._+-]*$/.test(part)), "Invalid repository path");
12851
13217
  let current = repo;
12852
13218
  for (let i = 0;i < parts.length; i++) {
12853
- current = join47(current, parts[i]);
12854
- const info = await lstat27(current);
13219
+ current = join48(current, parts[i]);
13220
+ const info = await lstat29(current);
12855
13221
  ensure2(i === parts.length - 1 ? info.isFile() : info.isDirectory(), "Unsafe repository path");
12856
13222
  }
12857
13223
  ensure2(await realpath14(current) === current, "Repository path resolves outside its location");
@@ -12889,10 +13255,10 @@ async function verifyRpmRepository(stage, fingerprint) {
12889
13255
  plain = zstd.stdout;
12890
13256
  }
12891
13257
  ensure2(plain.length === record.openSize && digest5(plain) === openHash, "Uncompressed primary metadata checksum mismatch");
12892
- const rpmPath = resolve23(stage.rpm.path);
13258
+ const rpmPath = resolve25(stage.rpm.path);
12893
13259
  const rpmHref = relative7(repo, rpmPath);
12894
13260
  ensure2(!rpmHref.startsWith("../") && rpmHref !== "" && await contained(repo, rpmHref) === rpmPath, "RPM must be a regular file inside the local repository");
12895
- const rpmStat = await lstat27(rpmPath);
13261
+ const rpmStat = await lstat29(rpmPath);
12896
13262
  parseXml("primary", plain, [...proof.rpmIdentity, rpmHref, proof.rpmSha256, String(rpmStat.size)]);
12897
13263
  ensure2(await digestRegular(rpmPath, rpmStat.size) === proof.rpmSha256, "RPM changed during repository verification");
12898
13264
  return {
@@ -12905,8 +13271,8 @@ async function verifyRpmRepository(stage, fingerprint) {
12905
13271
  }
12906
13272
 
12907
13273
  // src/library/arch-publish.ts
12908
- import { createHash as createHash32 } from "crypto";
12909
- import { join as join48 } from "path";
13274
+ import { createHash as createHash33 } from "crypto";
13275
+ import { join as join49 } from "path";
12910
13276
  import { tmpdir as tmpdir9 } from "os";
12911
13277
  import { Effect as Effect31 } from "effect";
12912
13278
 
@@ -13148,7 +13514,7 @@ var readLicense = (url) => Effect31.gen(function* () {
13148
13514
  return yield* fail("Release license is unavailable");
13149
13515
  }
13150
13516
  const bytes = yield* step(() => readReleaseBytes(response, MAX_LICENSE_BYTES));
13151
- const sha256 = yield* step(async () => createHash32("sha256").update(bytes).digest("hex"));
13517
+ const sha256 = yield* step(async () => createHash33("sha256").update(bytes).digest("hex"));
13152
13518
  return { url, sha256 };
13153
13519
  });
13154
13520
  var git2 = (args) => Effect31.gen(function* () {
@@ -13190,7 +13556,7 @@ var verifyArchRelease = (options) => Effect31.gen(function* () {
13190
13556
  if (!listed)
13191
13557
  return yield* fail(`Missing signed descriptor: ${descriptorPolicy.name}`);
13192
13558
  const bytes = yield* feedBytes(options.feed, `${options.tag}/${descriptorPolicy.name}`, 65536);
13193
- if (!bytes || bytes.length !== listed.size || createHash32("sha256").update(bytes).digest("hex") !== listed.sha256)
13559
+ if (!bytes || bytes.length !== listed.size || createHash33("sha256").update(bytes).digest("hex") !== listed.sha256)
13194
13560
  return yield* fail(`Signed descriptor differs from its release: ${descriptorPolicy.name}`);
13195
13561
  const json = yield* step(async () => {
13196
13562
  try {
@@ -13262,7 +13628,7 @@ var publishArchPackageEffect = (options) => Effect31.gen(function* () {
13262
13628
  const directory = options.printDirectory;
13263
13629
  yield* step(() => fs.mkdir(directory, { recursive: true }));
13264
13630
  for (const [name, contents] of Object.entries({ ...files, ...repositoryFiles }))
13265
- yield* step(() => fs.writeFile(join48(directory, name), contents, { mode: 420 }));
13631
+ yield* step(() => fs.writeFile(join49(directory, name), contents, { mode: 420 }));
13266
13632
  }
13267
13633
  const base = { pkgname: policy.pkgname, pkgver: rendered.pkgver, pkgrel };
13268
13634
  if (options.dryRun)
@@ -13275,14 +13641,14 @@ var publishArchPackageEffect = (options) => Effect31.gen(function* () {
13275
13641
  if (!key.includes("PRIVATE KEY"))
13276
13642
  return yield* fail("AUR_SSH_PRIVATE_KEY_B64 is not a private key");
13277
13643
  return yield* Effect31.gen(function* () {
13278
- const work = yield* step(() => fs.mkdtemp(join48(tmpdir9(), "arch-package-")));
13644
+ const work = yield* step(() => fs.mkdtemp(join49(tmpdir9(), "arch-package-")));
13279
13645
  yield* Effect31.addFinalizer(() => Effect31.promise(() => fs.rm(work, { recursive: true, force: true }).then(() => {
13280
13646
  return;
13281
13647
  }, () => {
13282
13648
  return;
13283
13649
  })));
13284
- const keyFile = join48(work, "aur_id_ed25519");
13285
- const knownHosts = join48(work, "aur_known_hosts");
13650
+ const keyFile = join49(work, "aur_id_ed25519");
13651
+ const knownHosts = join49(work, "aur_known_hosts");
13286
13652
  yield* step(() => fs.mkdir(work, { recursive: true, mode: 448 }));
13287
13653
  yield* step(() => fs.writeFile(keyFile, key.endsWith(`
13288
13654
  `) ? key : `${key}
@@ -13290,7 +13656,7 @@ var publishArchPackageEffect = (options) => Effect31.gen(function* () {
13290
13656
  yield* step(() => fs.writeFile(knownHosts, `${AUR_HOST_KEY}
13291
13657
  `, { mode: 420 }));
13292
13658
  const ssh = `ssh -i "${keyFile}" -o IdentitiesOnly=yes -o UserKnownHostsFile="${knownHosts}" -o StrictHostKeyChecking=yes`;
13293
- const checkout = join48(work, policy.pkgname);
13659
+ const checkout = join49(work, policy.pkgname);
13294
13660
  yield* git2([
13295
13661
  "-c",
13296
13662
  `core.sshCommand=${ssh}`,
@@ -13303,7 +13669,7 @@ var publishArchPackageEffect = (options) => Effect31.gen(function* () {
13303
13669
  checkout
13304
13670
  ]);
13305
13671
  for (const [name, contents] of Object.entries(files))
13306
- yield* step(() => fs.writeFile(join48(checkout, name), contents, { mode: 420 }));
13672
+ yield* step(() => fs.writeFile(join49(checkout, name), contents, { mode: 420 }));
13307
13673
  yield* git2(["-C", checkout, "add", "--", ...Object.keys(files)]);
13308
13674
  const staged = yield* gitExit(["-C", checkout, "diff", "--cached", "--quiet"]);
13309
13675
  if (staged === 0)
@@ -13381,6 +13747,22 @@ var publish = (argv) => {
13381
13747
  yield* print({ tag: result.tag, runId: result.runId, runAttempt: result.runAttempt });
13382
13748
  }), { requireGitHubActions: !local });
13383
13749
  };
13750
+ var publishPackages = (argv) => {
13751
+ const [local, args] = localFlag(argv);
13752
+ return runCommand((error) => `Unable to stage the Linux packages: ${redactedErrorMessage(error)}`, Effect32.gen(function* () {
13753
+ const [directory, configPath, out, ...extra] = args;
13754
+ if (!local || !directory || !configPath || !out || extra.length)
13755
+ return yield* invalid("Expected --local <packages-dir> <release-config.json> <out>");
13756
+ const config = yield* readReleaseConfig(configPath);
13757
+ const { env } = yield* ReleaseConfig;
13758
+ const { RELEASE_TAG: tag, SOURCE_SHA: sourceSha } = env;
13759
+ if (!tag || !sourceSha)
13760
+ return yield* invalid("Missing local release identity");
13761
+ yield* localTagProvenanceEffect({ config, tag, sourceSha });
13762
+ const plan = yield* Effect32.uninterruptible(stageLocalPackagesEffect({ config, directory, out, tag, sourceSha }));
13763
+ return yield* print({ tag, objects: plan.objects.length });
13764
+ }));
13765
+ };
13384
13766
  var cut = (argv) => {
13385
13767
  const [local, args] = localFlag(argv);
13386
13768
  return runCommand((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`, Effect32.gen(function* () {
@@ -13459,7 +13841,7 @@ var planAssets = (args) => runCommand("Unable to plan release assets; check rele
13459
13841
  const { env } = yield* ReleaseConfig;
13460
13842
  yield* print(yield* planReleaseAssetsEffect({ env, config, tag }));
13461
13843
  }));
13462
- var sign2 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.", Effect32.gen(function* () {
13844
+ var sign3 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.", Effect32.gen(function* () {
13463
13845
  const [identityPath, artifactPath, feed, ...extra] = args;
13464
13846
  const { env } = yield* ReleaseConfig;
13465
13847
  if (!identityPath || !artifactPath || !feed || extra.length || !env.ADEA_RELEASE_SIGNING_KEY)
@@ -13663,6 +14045,10 @@ var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; chec
13663
14045
  const result = action === "verify" ? yield* verifyDailyReleaseMatrixEffect(options) : yield* stageDailyBatchEffect({ ...options, parent });
13664
14046
  return yield* print(result);
13665
14047
  }));
14048
+ var dailyBatch = (args) => runCommand((error) => `Unable to run the Daily batch command: ${redactedErrorMessage(error)}`, Effect32.gen(function* () {
14049
+ const { cwd } = yield* ReleaseConfig;
14050
+ yield* print(yield* step(() => dailyBatchCommand(args, cwd)));
14051
+ }));
13666
14052
  var prepareStableCatalog2 = (args) => runCommand((error) => `Unable to prepare Stable catalog: ${redactedErrorMessage(error)}`, Effect32.gen(function* () {
13667
14053
  yield* print(yield* step(() => prepareStableCatalogCommand(args)));
13668
14054
  }));
@@ -13710,6 +14096,7 @@ var commands = {
13710
14096
  "build-linux-formats": buildLinuxFormatsCommand,
13711
14097
  "build-windows-standalone": buildWindowsStandaloneCommand,
13712
14098
  cut,
14099
+ "daily-batch": dailyBatch,
13713
14100
  "daily-matrix": dailyMatrix,
13714
14101
  finalize,
13715
14102
  "linux-channel-proof": linuxChannelProof,
@@ -13720,8 +14107,9 @@ var commands = {
13720
14107
  promote,
13721
14108
  publish,
13722
14109
  "publish-arch": publishArch,
14110
+ "publish-packages": publishPackages,
13723
14111
  "publish-framework-package": publishFramework,
13724
- sign: sign2,
14112
+ sign: sign3,
13725
14113
  "sign-descriptors": signDescriptors,
13726
14114
  "stage-apt-repository": stageAptRepository,
13727
14115
  step: releaseStep,
package/dist/index.js CHANGED
@@ -794,6 +794,10 @@ import { Cause, Data, Effect, Exit } from "effect";
794
794
 
795
795
  class ReleaseFailure extends Data.TaggedError("ReleaseFailure") {
796
796
  }
797
+
798
+ class PublicReleaseError extends Error {
799
+ name = "PublicReleaseError";
800
+ }
797
801
  var refuse = (reason, message) => Effect.fail(new ReleaseFailure({ reason, message }));
798
802
  var fail = (message) => refuse("refused", message);
799
803
  var stepFailure = (error) => new ReleaseFailure({
@@ -1904,20 +1908,26 @@ import { join as join2, resolve } from "path";
1904
1908
  // ../../src/installer/hosted-runner.ts
1905
1909
  import { isAbsolute } from "path";
1906
1910
  var JOB_NUMBER = /^[1-9]\d{0,19}$/;
1907
- function isHostedRunner(env) {
1911
+ function hostedRunnerRefusal(env) {
1908
1912
  if (env.CI !== "true")
1909
- return false;
1913
+ return "CI is not true";
1910
1914
  if (env.GITHUB_ACTIONS === "true")
1911
- return env.RUNNER_ENVIRONMENT === "github-hosted";
1915
+ return env.RUNNER_ENVIRONMENT === "github-hosted" ? undefined : "RUNNER_ENVIRONMENT is not github-hosted";
1912
1916
  if (env.FRAMEWORK_DISPOSABLE_RUNNER !== "true")
1913
- return false;
1917
+ return "FRAMEWORK_DISPOSABLE_RUNNER is not true";
1914
1918
  if (env.GITLAB_CI === "true")
1915
- return JOB_NUMBER.test(env.CI_JOB_ID ?? "");
1916
- return env.CIRCLECI === "true" && JOB_NUMBER.test(env.CIRCLE_BUILD_NUM ?? "");
1919
+ return JOB_NUMBER.test(env.CI_JOB_ID ?? "") ? undefined : "CI_JOB_ID is not a job number";
1920
+ if (env.CIRCLECI !== "true")
1921
+ return "neither GITLAB_CI nor CIRCLECI is true";
1922
+ return JOB_NUMBER.test(env.CIRCLE_BUILD_NUM ?? "") ? undefined : "CIRCLE_BUILD_NUM is not a job number";
1923
+ }
1924
+ function isHostedRunner(env) {
1925
+ return hostedRunnerRefusal(env) === undefined;
1917
1926
  }
1918
1927
  function assertHostedRunner(env, subject) {
1919
- if (!isHostedRunner(env))
1920
- throw new Error(`${subject} requires a disposable hosted runner`);
1928
+ const refusal = hostedRunnerRefusal(env);
1929
+ if (refusal !== undefined)
1930
+ throw new Error(`${subject} requires a disposable hosted runner (${refusal})`);
1921
1931
  }
1922
1932
  function runnerTemp(env) {
1923
1933
  const path = env.GITHUB_ACTIONS === "true" ? env.RUNNER_TEMP : env.TMPDIR;
@@ -3576,11 +3586,24 @@ async function promoteDailyBatch(store, candidate, signer, keys) {
3576
3586
  throw new Error("Daily promotion could not be read back");
3577
3587
  return selected;
3578
3588
  }
3589
+ async function readDailyBatchByDigest(store, target, manifestDigest) {
3590
+ if (!app.test(target.appId) || !feedApp.test(target.feedApp) || !hex2.test(manifestDigest))
3591
+ throw new Error("Invalid Daily batch target");
3592
+ const bytes = await readSmall(await store.readObject(`${prefix(target.feedApp, manifestDigest)}/manifest.json`), 262144);
3593
+ if (hash(bytes) !== manifestDigest)
3594
+ throw new Error("Daily batch manifest changed");
3595
+ const manifest = parseManifest(parseJson(bytes));
3596
+ if (manifest.identity.appId !== target.appId || manifest.identity.feedApp !== target.feedApp)
3597
+ throw new Error("Daily batch app mismatch");
3598
+ return Object.freeze({ version: "", sequence: 0, manifestDigest, manifest });
3599
+ }
3579
3600
  async function rollbackDailyBatch(store, current, target, signer, keys) {
3580
3601
  const appId = current.manifest.identity.appId;
3581
3602
  const slug = current.manifest.identity.feedApp;
3582
3603
  if (target.manifest.identity.appId !== appId || target.manifest.identity.feedApp !== slug || !hex2.test(target.manifestDigest))
3583
3604
  throw new Error("Invalid rollback target");
3605
+ if (target.manifestDigest === current.manifestDigest)
3606
+ throw new Error("Rollback target is the current Daily batch");
3584
3607
  const selected = await readDailyBatch(store, { appId, feedApp: slug }, keys);
3585
3608
  if (!selected || selected.version !== current.version)
3586
3609
  throw new Error("Daily pointer changed during rollback");
@@ -5794,6 +5817,72 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
5794
5817
  };
5795
5818
  return yield* writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, updated, release));
5796
5819
  });
5820
+ var linuxPackageFormats = [
5821
+ {
5822
+ extension: ".deb",
5823
+ magic: (head) => head.subarray(0, 8).toString("latin1") === `!<arch>
5824
+ `
5825
+ },
5826
+ {
5827
+ extension: ".AppImage",
5828
+ magic: (head) => head.subarray(0, 4).equals(Buffer.from([127, 69, 76, 70])) && head.subarray(8, 11).equals(Buffer.from([65, 73, 2]))
5829
+ }
5830
+ ];
5831
+ var stageLocalPackagesEffect = (options) => Effect21.gen(function* () {
5832
+ const fs = yield* ReleaseFs;
5833
+ const { tag, sourceSha } = options;
5834
+ const local = localConfig(options.config);
5835
+ const feed = local.feed;
5836
+ const requirements = local.requirements(tag);
5837
+ const allowed = new Map;
5838
+ for (const platform of ["linux-x64", "linux-arm64"])
5839
+ for (const archive of requirements.platforms[platform] ?? [])
5840
+ if (archive.endsWith(".tar.zst"))
5841
+ for (const { extension } of linuxPackageFormats)
5842
+ allowed.set(archive.slice(0, -".tar.zst".length) + extension, archive);
5843
+ const directory = resolve9(options.directory);
5844
+ const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
5845
+ if (!entries.length || entries.some((entry) => !entry.isFile() || !allowed.has(entry.name)))
5846
+ return yield* fail("Staged directory holds files that are not this tag's Linux packages");
5847
+ const names = entries.map((entry) => entry.name).toSorted();
5848
+ const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(join14(directory, name), name), { concurrency: "unbounded" });
5849
+ for (const name of names) {
5850
+ const format = linuxPackageFormats.find(({ extension }) => name.endsWith(extension));
5851
+ const head = Buffer.alloc(16);
5852
+ const file = yield* step(() => fs.open(join14(directory, name), "r"));
5853
+ yield* step(() => file.read(head, 0, 16, 0)).pipe(Effect21.ensuring(Effect21.promise(() => file.close().catch(() => {
5854
+ return;
5855
+ }))));
5856
+ if (!format.magic(head))
5857
+ return yield* fail(`Not a ${format.extension} package: ${name}`);
5858
+ }
5859
+ const [ledger, remote] = yield* Effect21.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
5860
+ const entry = ledger.releases.find((item) => item.tag === tag);
5861
+ if (!entry || !remote || entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt))
5862
+ return yield* fail("The feed has not published this tag; publish its release first");
5863
+ if (entry.sourceSha !== sourceSha)
5864
+ return yield* fail("The feed publishes this tag from another source commit");
5865
+ const merged = [...remote.assets];
5866
+ const uploads = [];
5867
+ for (const artifact of staged) {
5868
+ if (!merged.some((asset) => asset.name === allowed.get(artifact.name)))
5869
+ return yield* fail(`The feed has no ${allowed.get(artifact.name)} for ${artifact.name}`);
5870
+ const existing = merged.find((asset) => asset.name === artifact.name);
5871
+ if (existing) {
5872
+ if (existing.size !== artifact.size || "sha256:" + existing.sha256 !== artifact.digest)
5873
+ return yield* fail(`Immutable asset conflict: ${artifact.name}`);
5874
+ continue;
5875
+ }
5876
+ merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
5877
+ uploads.push({
5878
+ key: feedAssetKey(feed, tag, artifact.name),
5879
+ path: join14(directory, artifact.name),
5880
+ artifact
5881
+ });
5882
+ }
5883
+ const release = { ...remote, assets: merged };
5884
+ return yield* writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, ledger, release));
5885
+ });
5797
5886
  function stablePlatforms(config) {
5798
5887
  const value = isRecord(config) ? config.stablePlatforms : undefined;
5799
5888
  if (value === undefined)
@@ -10257,6 +10346,7 @@ import { basename as basename17, isAbsolute as isAbsolute8, join as join38, reso
10257
10346
  import { promisify as promisify5 } from "util";
10258
10347
 
10259
10348
  // src/library/windows-standalone-bootstrap.ts
10349
+ var WINDOWS_PACKAGE_MANAGER_SWITCH = "--package-manager=winget";
10260
10350
  var windowsBootstrapSource = String.raw`
10261
10351
  #define WIN32_LEAN_AND_MEAN
10262
10352
  #include <windows.h>
@@ -10315,10 +10405,28 @@ static BOOL write_exclusive(const wchar_t *path, const unsigned char *bytes, DWO
10315
10405
  return CloseHandle(file) && ok;
10316
10406
  }
10317
10407
 
10408
+ // Marks the installed app root as package-manager owned. The root must already exist as a real
10409
+ // directory (the inner Setup created it); the marker is replaced, never followed through a link.
10410
+ static BOOL write_package_manager_marker(void) {
10411
+ wchar_t local[MAX_PATH], root[MAX_PATH], marker[MAX_PATH];
10412
+ DWORD n = GetEnvironmentVariableW(L"LOCALAPPDATA", local, MAX_PATH);
10413
+ if (!n || n >= MAX_PATH) return FALSE;
10414
+ int m = swprintf(root, MAX_PATH, L"%ls\\%ls\\stable\\app", local, APP_ID);
10415
+ if (m <= 0 || m >= MAX_PATH || !join_path(marker, root, L".package-manager")) return FALSE;
10416
+ DWORD attributes = GetFileAttributesW(root);
10417
+ if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)
10418
+ || (attributes & FILE_ATTRIBUTE_REPARSE_POINT)) return FALSE;
10419
+ DeleteFileW(marker);
10420
+ static const unsigned char owner[] = "winget\n";
10421
+ return write_exclusive(marker, owner, sizeof owner - 1);
10422
+ }
10423
+
10318
10424
  int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int show) {
10319
10425
  (void)instance; (void)previous; (void)show;
10320
- // No undocumented silent or arbitrary installer arguments are forwarded.
10321
- if (command[0]) {
10426
+ // No undocumented silent or arbitrary installer arguments are forwarded. The only option is
10427
+ // the exact package-manager switch, which is not forwarded either: it marks the install.
10428
+ BOOL package_manager = wcscmp(command, L"${WINDOWS_PACKAGE_MANAGER_SWITCH}") == 0;
10429
+ if (command[0] && !package_manager) {
10322
10430
  MessageBoxW(NULL, L"This installer accepts no command-line options.", APP_NAME, MB_OK | MB_ICONERROR);
10323
10431
  return 2;
10324
10432
  }
@@ -10370,6 +10478,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int
10370
10478
  cleanup:
10371
10479
  DeleteFileW(archive); DeleteFileW(meta); DeleteFileW(child);
10372
10480
  RemoveDirectoryW(hidden); CloseHandle(guard); RemoveDirectoryW(work);
10481
+ if (code == 0 && package_manager && !write_package_manager_marker()) code = 2;
10373
10482
  if (code == 0) return 0;
10374
10483
  fail:
10375
10484
  MessageBoxW(NULL, L"Installation did not complete.", APP_NAME, MB_OK | MB_ICONERROR);
@@ -10510,6 +10619,7 @@ async function buildStandaloneWindowsExe(options) {
10510
10619
  throw new Error("Unexpected pinned Zig compiler version");
10511
10620
  await writeFile14(join38(work, "app.h"), [
10512
10621
  `#define APP_NAME L"${appName}"`,
10622
+ `#define APP_ID L"${appId}"`,
10513
10623
  `#define SETUP_SIZE ${setup.size}u`,
10514
10624
  `#define METADATA_SIZE ${metadata.size}u`,
10515
10625
  `#define ARCHIVE_SIZE ${archive.size}u`
@@ -10711,16 +10821,17 @@ end
10711
10821
  };
10712
10822
  }
10713
10823
  function winget(context, row) {
10714
- keys2(row, "winget", ["identifier", "publisher", "artifact", "silent", "silentWithProgress"], ["nestedInstaller"]);
10824
+ keys2(row, "winget", ["identifier", "publisher", "artifact"], ["nestedInstaller", "silent", "silentWithProgress"]);
10715
10825
  const stableId = text3(row.identifier, "WinGet package identifier", /^[A-Za-z0-9][A-Za-z0-9-]*(\.[A-Za-z0-9][A-Za-z0-9-]*)+$/);
10716
10826
  const publisher = text3(row.publisher, "WinGet publisher");
10717
10827
  const asset = exact2(context, row.artifact, "WinGet", [".exe", ".zip"]);
10718
10828
  const direct = asset.name.endsWith(".exe");
10719
10829
  ensure(direct === (row.nestedInstaller === undefined), direct ? "A direct .exe installer takes no nestedInstaller" : "A .zip installer needs nestedInstaller");
10720
10830
  const nested = direct ? undefined : text3(row.nestedInstaller, "nested executable", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.exe$/i);
10831
+ ensure(!direct || row.silent === undefined && row.silentWithProgress === undefined, "A direct .exe installer takes the package-manager switch, not silent flags");
10721
10832
  const flags = /^[-/][a-zA-Z0-9_-]+(?: [-/][a-zA-Z0-9_-]+)*$/;
10722
- const silent = text3(row.silent, "silent flags", flags);
10723
- const progress = text3(row.silentWithProgress, "silent progress flags", flags);
10833
+ const silent = direct ? WINDOWS_PACKAGE_MANAGER_SWITCH : text3(row.silent, "silent flags", flags);
10834
+ const progress = direct ? WINDOWS_PACKAGE_MANAGER_SWITCH : text3(row.silentWithProgress, "silent progress flags", flags);
10724
10835
  const stable = context.manifest.channel === "stable";
10725
10836
  const id = stable ? stableId : `${stableId}.Daily`;
10726
10837
  const { name, description, homepage, license } = context.common;
@@ -1 +1 @@
1
- {"version":"0.10.0","commit":"15725353a83f706e8e7cb1340e7da4a7a5e4f0bd"}
1
+ {"version":"0.11.0","commit":"b696526dddf88edf23ec5bf0bf3ac136cb63d67e"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/app-framework-release-tools",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Host-side release tooling for @adea-ai/app-framework apps, on Effect: the release CLIs and the framework package publish. Installing it never adds Effect to the framework itself.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {