Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(release): name unreadable module archives, fail on a missing bundle, test the marker step

M3gA-Mind2332cb8fdbec
diff --git a/scripts/__tests__/stage-modules.test.mjs b/scripts/__tests__/stage-modules.test.mjs
index 9916f95ade..180414a0b9 100644
--- a/scripts/__tests__/stage-modules.test.mjs
+++ b/scripts/__tests__/stage-modules.test.mjs
@@ -1,5 +1,6 @@
import assert from "node:assert/strict";
-import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
+import { existsSync, mkdtempSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
+import { createHash } from "node:crypto";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createServer } from "node:http";
@@ -15,6 +16,7 @@ import {
hostKeyForTarget,
extractWindowsZip,
keepsArchive,
+ replaceArchiveWithMarker,
} from "../release/stage-modules.mjs";
const HOST_KEYS = [
@@ -113,6 +115,21 @@ test("only macOS bundles replace the archive with its digest marker", () => {
}
});
+test("a macOS entry keeps only the archive's verified digest, in tinybus's marker format", () => {
+ const dir = mkdtempSync(join(tmpdir(), "openhuman-marker-"));
+ const archive = join(dir, "demo-1.0.0-macos-15-arm64.tar.gz");
+ writeFileSync(archive, "archive bytes");
+ writeFileSync(join(dir, "libdemo.dylib"), "library bytes");
+ const sha = createHash("sha256").update(readFileSync(archive)).digest("hex");
+
+ replaceArchiveWithMarker(archive, sha);
+
+ assert.equal(existsSync(archive), false, "the archive must not ship");
+ // tinybus reads `<archive>.sha256`, trims it and compares it to the pin.
+ assert.equal(readFileSync(`${archive}.sha256`, "utf8"), `${sha}\n`);
+ assert.equal(readFileSync(join(dir, "libdemo.dylib"), "utf8"), "library bytes");
+});
+
async function withServer(handler, run) {
const server = createServer(handler);
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
diff --git a/scripts/release/macos-bundled-modules.sh b/scripts/release/macos-bundled-modules.sh
index 9d07f55476..dd5cb1b1ab 100755
--- a/scripts/release/macos-bundled-modules.sh
+++ b/scripts/release/macos-bundled-modules.sh
@@ -62,7 +62,9 @@ case "$cmd" in
;;
check)
ROOT="${2:?check needs <bundled-modules dir>}"
- [ -d "$ROOT" ] || { echo "[sign-check] no bundled modules at $ROOT"; exit 0; }
+ # Every caller stages modules before building the app, and tauri.conf.json
+ # bundles the directory, so its absence is a packaging failure.
+ [ -d "$ROOT" ] || { echo "[sign-check] no bundled modules at $ROOT" >&2; exit 1; }
SCRATCH="$(mktemp -d)"
trap 'rm -rf "$SCRATCH"' EXIT
BAD=0
@@ -95,7 +97,11 @@ case "$cmd" in
while IFS= read -r -d '' archive; do
dest="$SCRATCH/$(basename "$archive")"
mkdir -p "$dest"
- tar -xzf "$archive" -C "$dest"
+ if ! tar -xzf "$archive" -C "$dest"; then
+ echo "[sign-check] cannot extract archive: ${archive#"$ROOT"/}"
+ BAD=1
+ continue
+ fi
check_tree "$dest" "${archive#"$ROOT"/}/"
done < <(find "$ROOT" -name '*.tar.gz' -type f -print0)
if [ "$BAD" -ne 0 ]; then
diff --git a/scripts/release/stage-modules.mjs b/scripts/release/stage-modules.mjs
index 367adc3c84..e49a5baa51 100644
--- a/scripts/release/stage-modules.mjs
+++ b/scripts/release/stage-modules.mjs
@@ -78,6 +78,12 @@ export function keepsArchive(hostKey) {
return !hostKey.startsWith("macos-");
}
+/** Replace a verified `archive` with `<archive>.sha256` holding `sha256`. */
+export function replaceArchiveWithMarker(archive, sha256) {
+ writeFileSync(`${archive}.sha256`, `${sha256}\n`);
+ rmSync(archive);
+}
+
export function bundledAssets(source, hostKey) {
const names = parseAllList(source);
const records = parseRecords(source);
@@ -200,10 +206,7 @@ export async function stageModules({ hostKey = defaultHostKey(), output = OUTPUT
if (librariesUnder(dir).length !== 1) {
throw new Error(`${asset.id}: expected exactly one native library in the release archive`);
}
- if (!keepsArchive(asset.hostKey)) {
- writeFileSync(`${archive}.sha256`, `${actual}\n`);
- rmSync(archive);
- }
+ if (!keepsArchive(asset.hostKey)) replaceArchiveWithMarker(archive, actual);
console.log(`[bundled-modules] staged ${asset.id} ${asset.version} (${asset.hostKey})`);
}
console.log(`[bundled-modules] staged ${assets.length} verified releases for ${hostKey}`);