Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(release): retry transient stapler validation failures
vastsa2bbab2524a3a
diff --git a/apps/desktop/test/macos-release-verification.test.mjs b/apps/desktop/test/macos-release-verification.test.mjsindex 1b5b706b2..167532e23 100644--- a/apps/desktop/test/macos-release-verification.test.mjs+++ b/apps/desktop/test/macos-release-verification.test.mjs@@ -47,7 +47,12 @@ async function writeDmgFixture(release) {*/async function writeXcrunNotaryFixture(bin,- { status = "Accepted", submitExit = 0, stapleFailures = 0 } = {},+ {+ status = "Accepted",+ submitExit = 0,+ stapleFailures = 0,+ validateFailures = 0,+ } = {},) {await mkdir(bin, { recursive: true });const xcrun = `#!/usr/bin/env bash@@ -76,6 +81,18 @@ case "$1 $2" infiexit 0;;+ "stapler validate")+ count_file="$NOTARY_LOG.validates"+ count=0+ if [[ -f "$count_file" ]]; then count="$(cat "$count_file")"; fi+ count=$((count + 1))+ echo "$count" > "$count_file"+ if (( count <= ${validateFailures} )); then+ echo 'CloudKit query failed: The network connection was lost' >&2+ exit 68+ fi+ exit 0+ ;;esacexit 0`;@@ -91,7 +108,7 @@ function runNotarize(release, bin, log, extraEnv = {}) {...NOTARY_ENV,PATH: `${bin}:${process.env.PATH}`,NOTARY_LOG: log,- STAPLE_DELAY_SECONDS: "1",+ STAPLE_DELAY_SECONDS: "0",...extraEnv,},});@@ -140,6 +157,50 @@ test("stapling retries only after Apple accepts the DMG", async (t) => {);});+test("DMG validation retries a temporary CloudKit connection failure", async (t) => {+ const root = await mkdtemp(join(tmpdir(), "pi-desktop-macos-dmg-validate-retry-"));+ t.after(() => rm(root, { recursive: true, force: true }));++ const release = join(root, "release");+ const bin = join(root, "bin");+ const log = join(root, "xcrun.log");+ await writeDmgFixture(release);+ await writeXcrunNotaryFixture(bin, { validateFailures: 1 });++ const result = runNotarize(release, bin, log);++ assert.equal(result.status, 0, `${result.stdout}\n${result.stderr}`);+ assert.match(result.stderr, /stapler validate attempt 1\/6 failed/);+ const calls = (await readFile(log, "utf8")).trim().split("\n");+ assert.equal(+ calls.filter((line) => line.startsWith("stapler validate")).length,+ 2,+ "validation retries once and then succeeds",+ );+});++test("DMG validation fails closed after the configured retry limit", async (t) => {+ const root = await mkdtemp(join(tmpdir(), "pi-desktop-macos-dmg-validate-fail-"));+ t.after(() => rm(root, { recursive: true, force: true }));++ const release = join(root, "release");+ const bin = join(root, "bin");+ const log = join(root, "xcrun.log");+ await writeDmgFixture(release);+ await writeXcrunNotaryFixture(bin, { validateFailures: 2 });++ const result = runNotarize(release, bin, log, { STAPLE_ATTEMPTS: "2" });++ assert.equal(result.status, 68);+ assert.match(result.stderr, /stapler validate attempt 1\/2 failed/);+ const calls = (await readFile(log, "utf8")).trim().split("\n");+ assert.equal(+ calls.filter((line) => line.startsWith("stapler validate")).length,+ 2,+ "validation stops after the configured bound",+ );+});+test("a rejected DMG is never stapled and the Apple log is fetched", async (t) => {const root = await mkdtemp(join(tmpdir(), "pi-desktop-macos-dmg-rejected-"));t.after(() => rm(root, { recursive: true, force: true }));@@ -233,7 +294,7 @@ test("macOS release verification requires a notarized Developer ID app and DMG",);await writeFile(join(bin, "xcrun"),- "#!/usr/bin/env bash\nprintf '%s\\n' \"$*\" >> \"$STAPLER_LOG\"\n[[ \"$1 $2\" == 'stapler validate' ]]\n",+ "#!/usr/bin/env bash\nprintf '%s\\n' \"$*\" >> \"$STAPLER_LOG\"\nif [[ \"$1 $2\" == 'stapler validate' ]]; then\n count_file=\"$STAPLER_LOG.validates\"\n count=0\n if [[ -f \"$count_file\" ]]; then count=\"$(cat \"$count_file\")\"; fi\n count=$((count + 1))\n echo \"$count\" > \"$count_file\"\n if (( count == 1 )); then echo 'CloudKit query failed: The network connection was lost' >&2; exit 68; fi\n exit 0\nfi\nexit 1\n",);await Promise.all(["codesign", "spctl", "xcrun"].map((name) => chmod(join(bin, name), 0o755)),@@ -248,6 +309,8 @@ test("macOS release verification requires a notarized Developer ID app and DMG",MAC_SIGNING_IDENTITY: SIGNING_IDENTITY_NAME,PATH: `${bin}:${process.env.PATH}`,STAPLER_LOG: staplerLog,+ STAPLE_ATTEMPTS: "2",+ STAPLE_DELAY_SECONDS: "0",},});@@ -257,7 +320,7 @@ test("macOS release verification requires a notarized Developer ID app and DMG",assert.match(result.stdout, /host-core sidecar/);assert.equal(await readFile(staplerLog, "utf8"),- `stapler validate ${app}\nstapler validate ${dmg}\n`,+ `stapler validate ${app}\nstapler validate ${app}\nstapler validate ${dmg}\n`,);});diff --git a/apps/desktop/test/macos-signing-watchdog.test.mjs b/apps/desktop/test/macos-signing-watchdog.test.mjsindex 44823d571..16707099f 100644--- a/apps/desktop/test/macos-signing-watchdog.test.mjs+++ b/apps/desktop/test/macos-signing-watchdog.test.mjs@@ -340,7 +340,7 @@ test(},);-test("the app stapler shim retries only stapler staple and preserves arguments", async (t) => {+test("the app stapler shim retries stapling and validation while preserving arguments", async (t) => {const root = await makeTempDir(t);const fakeBin = join(root, "fakebin");const callLog = join(root, "xcrun-calls.log");@@ -352,8 +352,22 @@ test("the app stapler shim retries only stapler staple and preserves arguments",printf '<%s>\\n' "$@" >> "$PI_TEST_XCRUN_LOG"printf 'call\\n' >> "$PI_TEST_XCRUN_INVOCATIONS"if [[ "$1 $2" == "stapler staple" ]]; then- PI_TEST_CALLS="$(wc -l < "$PI_TEST_XCRUN_INVOCATIONS" | tr -d ' ')"- if (( PI_TEST_CALLS <= PI_TEST_XCRUN_FAILURES )); then+ PI_TEST_OPERATION="staple"+ PI_TEST_FAILURE_LIMIT="$PI_TEST_XCRUN_STAPLE_FAILURES"+elif [[ "$1 $2" == "stapler validate" ]]; then+ PI_TEST_OPERATION="validate"+ PI_TEST_FAILURE_LIMIT="$PI_TEST_XCRUN_VALIDATE_FAILURES"+else+ PI_TEST_OPERATION=""+ PI_TEST_FAILURE_LIMIT="0"+fi+if [[ -n "$PI_TEST_OPERATION" ]]; then+ PI_TEST_COUNT_FILE="$PI_TEST_XCRUN_INVOCATIONS.$PI_TEST_OPERATION"+ PI_TEST_CALLS=0+ if [[ -f "$PI_TEST_COUNT_FILE" ]]; then PI_TEST_CALLS="$(cat "$PI_TEST_COUNT_FILE")"; fi+ PI_TEST_CALLS=$((PI_TEST_CALLS + 1))+ echo "$PI_TEST_CALLS" > "$PI_TEST_COUNT_FILE"+ if (( PI_TEST_CALLS <= PI_TEST_FAILURE_LIMIT )); thenecho "The network connection was lost." >&2exit 68fi@@ -372,7 +386,7 @@ exit 0"--","bash","-c",- 'xcrun "$@"',+ 'xcrun "$@" && xcrun stapler validate "/tmp/PI Desktop.app"',"bash","stapler","staple",@@ -383,7 +397,8 @@ exit 0PATH: `${fakeBin}:${process.env.PATH}`,PI_TEST_XCRUN_LOG: callLog,PI_TEST_XCRUN_INVOCATIONS: invocationLog,- PI_TEST_XCRUN_FAILURES: "2",+ PI_TEST_XCRUN_STAPLE_FAILURES: "2",+ PI_TEST_XCRUN_VALIDATE_FAILURES: "1",PI_STAPLER_MAX_ATTEMPTS: "3",PI_STAPLER_RETRY_DELAY_SECONDS: "0",},@@ -394,14 +409,15 @@ exit 0assert.match(stdout, /stapler-shim=on/);assert.match(stderr, /stapler staple attempt 1\/3 failed/);assert.match(stderr, /stapler staple attempt 2\/3 failed/);+ assert.match(stderr, /stapler validate attempt 1\/3 failed/);assert.equal((await readFile(callLog, "utf8")).split("\n").filter(Boolean).length,- 9,- "three attempts must each preserve the three xcrun arguments",+ 15,+ "five attempts must each preserve the three xcrun arguments",);assert.equal((await readFile(invocationLog, "utf8")).trim().split("\n").length,- 3,+ 5,);assert.ok(stdout.includes("[sign] fake xcrun completed"));});diff --git a/docs/adr/0289-signed-macos-github-releases.md b/docs/adr/0289-signed-macos-github-releases.mdindex 5b083eb6d..437585b1e 100644--- a/docs/adr/0289-signed-macos-github-releases.md+++ b/docs/adr/0289-signed-macos-github-releases.md@@ -28,10 +28,11 @@ for the official `vastsa/PI-Desktop` release lane.the final DMG is submitted separately (`xcrun notarytool submit --wait`) andmust return `status: Accepted` before `xcrun stapler staple` may run; therun then verifies the app as `Notarized Developer ID` and both stapled- tickets before upload. The app's exact `xcrun stapler staple` call is- retried at most six times with a 10-second delay by the signing watchdog;- all other `xcrun` calls pass through. The DMG stapler has the same bounded- retry policy. Retries only occur after Apple accepts the matching+ tickets before upload. The signing shim retries only `xcrun stapler staple`+ and `xcrun stapler validate`, at most six times with a 10-second delay;+ all other `xcrun` calls pass through. The DMG notarization and release+ verification scripts use the same bounded retry for stapling and ticket+ validation. Retries only occur after Apple accepts the matchingnotarization submission. Missing signing or notarization secrets fail the job;unsigned macOS artifacts must not be published from a tag.2. The signing certificate isdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex ce55354e9..722365d63 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -1512,10 +1512,11 @@ identify the platform validation still needed.`codesign --verify --deep --strict --verbose=2`,`spctl --assess --type execute --verbose=4`, and `xcrun stapler validate`against the app, including `Contents/Resources/bin/pi-desktop-host-core`.- 4) Confirm the app stapler shim retries only `xcrun stapler staple` up to six- total attempts after the app submission is accepted, then confirm the- workflow's DMG step reported an Apple notary status of `Accepted` and run- `xcrun stapler validate` against the matching DMG.+ 4) Confirm the app stapler shim retries `xcrun stapler staple` and+ `xcrun stapler validate` up to six total attempts after the app submission+ is accepted, then confirm the workflow's DMG step reported an Apple notary+ status of `Accepted` and stapled and validated the matching DMG. A transient+ CloudKit lookup failure during validation is retried within the same bound.5) Download the DMG on a clean macOS profile, move the app to`/Applications`, and open it without clearing `com.apple.quarantine`.- **Expected**: Each macOS app passes signature integrity, Gatekeeper reports@@ -1524,7 +1525,7 @@ identify the platform validation still needed.no ticket and fails `stapler staple` with error 65, so a tag build must neverreach that state. The app opens normally; no `xattr` quarantine-removalcommand or Security & Privacy override is required. Missing secrets, a- rejected submission, or an exhausted staple retry fail the job.+ rejected submission, or exhausted staple or validation retries fail the job.- **Specs linked**: `06-delivery/06-release-runbook.md`,`05-security/01-security.md`, ADR 0289- **Acceptance**: Quality, Securitydiff --git a/docs/spec/06-delivery/06-release-runbook.md b/docs/spec/06-delivery/06-release-runbook.mdindex b6be09c16..107b3ffea 100644--- a/docs/spec/06-delivery/06-release-runbook.md+++ b/docs/spec/06-delivery/06-release-runbook.md@@ -243,14 +243,15 @@ tickets before any artifact upload. The per-architecture `latest-mac.yml` filesare renamed before upload; the publish job merges them into one feed afterdownloading both artifacts.-For the app ticket, the signing watchdog injects a temporary `xcrun` shim when-`PI_STAPLER_MAX_ATTEMPTS` is set. It retries only the exact `stapler staple`-operation, at most six total attempts with a 10-second delay; `notarytool` and-all other `xcrun` commands pass through unchanged. electron-notarize reaches-that command only after Apple accepts the app submission. The DMG script has-its own bounded retry after its separate submission is accepted. Both retry-paths fail the job if their limit is exhausted, and artifact verification-still requires valid stapled tickets on the app and DMG.+For app and DMG tickets, the release path retries the exact `stapler staple`+and `stapler validate` operations, at most six total attempts with a+10-second delay. The signing watchdog injects the temporary `xcrun` shim for+app packaging when `PI_STAPLER_MAX_ATTEMPTS` is set; the DMG notarization and+release verification scripts call the same shim directly. `notarytool` and+all other `xcrun` commands pass through unchanged. Stapling and validation run+only after Apple accepts the matching submission. Retries fail the job if the+limit is exhausted, and artifact verification still requires valid stapled+tickets on the app and DMG.The shared electron-builder configuration applies the architecture-labelledpattern at the macOS platform level for ZIPs and overrides it at the DMG target@@ -352,7 +353,7 @@ hide in that gap, and the macOS lanes now expose all three:| Per-file signing | `codesign --force --sign <identity> --timestamp --entitlements ... <file>` runs serially, deepest file first, the app bundle last | `DEBUG=electron-osx-sign*` prints `Signing... <file>` and `Executing... <file> codesign ...`; the codesign shim times every invocation. If a keychain ever refuses to hand the key to a wrapped `codesign`, `PI_SIGNING_NO_CODESIGN_SHIM=1` runs the phase without the shim || Silent retry | A failing pass is retried up to three more times with a 5s/10s/15s backoff and no log line | The watchdog's `codesign-calls` and `failures` lines expose repeated passes || App notarization | `@electron/notarize` zips the app, uploads it, and waits for Apple's queue (`mac.notarize=true`) | `DEBUG=electron-notarize*` prints `zipping application to`, `attempting to upload file to Apple`, `notarization success`, then electron-builder prints `notarization successful` |-| App ticket stapling | `xcrun stapler staple` attaches the accepted app ticket; the watchdog retries only this exact command up to six attempts with a 10-second delay | `stapler-shim=on` appears in the watchdog header and each failed attempt is reported |+| App ticket stapling and validation | `xcrun stapler staple` attaches the accepted app ticket and `xcrun stapler validate` verifies it; the release path retries either exact operation up to six attempts with a 10-second delay | `stapler-shim=on` appears in the watchdog header and each failed attempt is reported || DMG notarization | The DMG carries its own signature, so the next step submits it again with `xcrun notarytool submit --wait` | The same watchdog keeps that wait observable and bounded |`scripts/macos-signing-watchdog.mjs` wraps both long phases. It forwards every@@ -372,8 +373,8 @@ block. The knobs:| `PI_SIGNING_TIMEOUT_SECONDS` | 2400 (CI: 1800 packaging, 1200 DMG) | Hard limit for the wrapped phase: diagnostics are dumped, the process group is killed, and the step exits 124 instead of hanging || `PI_SIGNING_STALL_SECONDS` | 300 | Silence with no codesign activity for this long triggers one diagnostics dump; the phase keeps running, because Apple's notarization queue is a legitimate wait || `PI_SIGNING_HEARTBEAT_SECONDS` | 60 | Heartbeat interval while the child produces no output |-| `PI_STAPLER_MAX_ATTEMPTS` | unset (no stapler shim) | When set for signed app packaging, enables at most six attempts for `xcrun stapler staple` |-| `PI_STAPLER_RETRY_DELAY_SECONDS` | 10 | Delay between failed app stapler attempts (maximum 60 seconds) |+| `PI_STAPLER_MAX_ATTEMPTS` | unset for app packaging; release validation scripts default to 6 | Enables bounded retries for `xcrun stapler staple` and `xcrun stapler validate` |+| `PI_STAPLER_RETRY_DELAY_SECONDS` | 10 | Delay between failed stapler attempts (maximum 60 seconds) || `DEBUG` | `electron-osx-sign*,electron-notarize*` | Namespaces that expose walking, per-file signing, and notarization progress |`DEBUG` lists only the two namespaces that sanitize their own command lines,@@ -424,12 +425,14 @@ artifact per submission and electron-builder only covers the app:| Artifact | Submitted by | Ticket ||---|---|---|-| `PI-Desktop.app` (inside the ZIP) | electron-builder `-c.mac.notarize=true` | stapled by electron-builder through the watchdog's bounded `xcrun stapler staple` retry shim |-| `PI-Desktop-<version>-<arch>.dmg` | `scripts/notarize-and-staple-macos-release-dmg.sh` (`notarytool submit --wait`) | stapled by the same script after `status: Accepted` |+| `PI-Desktop.app` (inside the ZIP) | electron-builder `-c.mac.notarize=true` | stapled and validated by electron-builder through the watchdog's bounded stapler retry shim |+| `PI-Desktop-<version>-<arch>.dmg` | `scripts/notarize-and-staple-macos-release-dmg.sh` (`notarytool submit --wait`) | stapled and validated by the same script after `status: Accepted` |A DMG that was never submitted has no ticket, so stapling it fails with`Could not find base64 encoded ticket ... Error 65`. Stapler retries are only-allowed after Apple returns `Accepted`.+allowed after Apple returns `Accepted`. Ticket validation also retries+transient Apple ticket-lookup failures, but still fails closed when the+configured attempt limit is exhausted.Run after every signed release build:diff --git a/scripts/README.md b/scripts/README.mdindex f40e1f748..b0af877d0 100644--- a/scripts/README.md+++ b/scripts/README.md@@ -23,7 +23,7 @@ disagrees, so a green `check:release-docs` is a precondition, not a substitute.| Script | Alias | Purpose ||---|---|---|| `notarize-and-staple-macos-release-dmg.sh` | `scripts/notarize-and-staple-macos-release-dmg.sh [release-dir]` | Submit the single DMG a native macOS job produced to Apple's notary service (`xcrun notarytool submit --wait`), require `status: Accepted`, then attach and validate the ticket (`xcrun stapler staple` / `validate`); run by the Release workflow when `sign_macos` is set. electron-builder only notarizes the `.app`, so the DMG needs this separate submission |-| `macos-stapler-retry-shim.sh` | injected by `macos-signing-watchdog.mjs` when `PI_STAPLER_MAX_ATTEMPTS` is set | Retry only `xcrun stapler staple` up to the configured bound; all other `xcrun` commands pass through unchanged |+| `macos-stapler-retry-shim.sh` | injected by `macos-signing-watchdog.mjs` when `PI_STAPLER_MAX_ATTEMPTS` is set; also called by the DMG notarization and release verification scripts | Retry `xcrun stapler staple` and `xcrun stapler validate` up to the configured bound; all other `xcrun` commands pass through unchanged || `verify-macos-release.sh` | `scripts/verify-macos-release.sh [release-dir]` | Fail unless the one `PI-Desktop.app` and DMG under the release directory are Developer ID-signed, notarized, and stapled; run by the Release workflow after stapling || `macos-signing-diagnostics.sh` | `scripts/macos-signing-diagnostics.sh [--require-identity]` | Print the non-secret signing baseline before packaging (system, `codesign`, keychain identities/list/default, Xcode notary tools, Apple timestamp reachability). Informational by default, because the Developer ID identity is imported from `CSC_LINK` during packaging; `--require-identity` makes a missing Developer ID fatal || `macos-bundle-inventory.mjs` | `node scripts/macos-bundle-inventory.mjs <app-or-release-dir>` | Count what the signing phase has to touch: entries, Mach-O binaries, `.dylib`/`.node`/frameworks/nested bundles, per-directory cost, and the largest binaries (`signing-candidates`). Informational; run after every macOS package build |diff --git a/scripts/macos-signing-watchdog.mjs b/scripts/macos-signing-watchdog.mjsindex 439ab05fa..e2a9b7fbd 100644--- a/scripts/macos-signing-watchdog.mjs+++ b/scripts/macos-signing-watchdog.mjs@@ -19,8 +19,9 @@* - every child line is forwarded live with a `[sign] ` prefix (redacted),* - `codesign` is wrapped by scripts/macos-codesign-shim.sh so each call is* timed through $PI_CODESIGN_LOG (see --codesign-log),- * - when PI_STAPLER_MAX_ATTEMPTS is set, `xcrun stapler staple` is wrapped- * with bounded retries; every other xcrun invocation passes through,+ * - when PI_STAPLER_MAX_ATTEMPTS is set, `xcrun stapler staple` and+ * `xcrun stapler validate` are wrapped with bounded retries; every other+ * xcrun invocation passes through,* - a heartbeat reports phase/idle time/active codesign while output is* silent, plus a bounded stall diagnostic dump,* - a hard timeout terminates the whole process group and exits 124,diff --git a/scripts/macos-stapler-retry-shim.sh b/scripts/macos-stapler-retry-shim.shindex c4d9fe7a2..80476051b 100644--- a/scripts/macos-stapler-retry-shim.sh+++ b/scripts/macos-stapler-retry-shim.sh@@ -1,12 +1,14 @@#!/bin/bash-# Retry only the stapling operation after the caller has an accepted ticket.-# electron-notarize invokes this command only after notarytool reports Accepted.+# Retry stapler operations after the caller has an accepted ticket. Validation+# uses the same bounded retry because Apple's ticket lookup can lose its+# CloudKit connection after a successful staple.set -uPI_STAPLER_REAL_XCRUN="${PI_XCRUN_REAL:-/usr/bin/xcrun}"+PI_STAPLER_OPERATION="${2:-}"-if [[ "${1:-}" != "stapler" || "${2:-}" != "staple" || -z "${PI_STAPLER_MAX_ATTEMPTS:-}" ]]; then+if [[ "${1:-}" != "stapler" || ( "$PI_STAPLER_OPERATION" != "staple" && "$PI_STAPLER_OPERATION" != "validate" ) || -z "${PI_STAPLER_MAX_ATTEMPTS:-}" ]]; thenexec "$PI_STAPLER_REAL_XCRUN" "$@"fi@@ -32,7 +34,7 @@ for ((attempt = 1; attempt <= PI_STAPLER_ATTEMPTS; attempt += 1)); dofiif (( attempt < PI_STAPLER_ATTEMPTS )); then- echo "warning: stapler staple attempt $attempt/$PI_STAPLER_ATTEMPTS failed; retrying in ${PI_STAPLER_DELAY}s." >&2+ echo "warning: stapler $PI_STAPLER_OPERATION attempt $attempt/$PI_STAPLER_ATTEMPTS failed; retrying in ${PI_STAPLER_DELAY}s." >&2sleep "$PI_STAPLER_DELAY"fidonediff --git a/scripts/notarize-and-staple-macos-release-dmg.sh b/scripts/notarize-and-staple-macos-release-dmg.shindex 811062029..5bc60c067 100755--- a/scripts/notarize-and-staple-macos-release-dmg.sh+++ b/scripts/notarize-and-staple-macos-release-dmg.sh@@ -22,12 +22,13 @@set -euo pipefailRELEASE_DIR="${1:-apps/desktop/release}"+SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"EXPECTED_TEAM_ID="DUV63RKYTW"# The ticket can take a moment to reach the stapler after Apple accepts, but a# retry is only legal once the submission returned Accepted. Overridable so# tests do not sleep for real.-STAPLE_ATTEMPTS="${STAPLE_ATTEMPTS:-6}"-STAPLE_DELAY_SECONDS="${STAPLE_DELAY_SECONDS:-10}"+STAPLE_ATTEMPTS="${PI_STAPLER_MAX_ATTEMPTS:-${STAPLE_ATTEMPTS:-6}}"+STAPLE_DELAY_SECONDS="${PI_STAPLER_RETRY_DELAY_SECONDS:-${STAPLE_DELAY_SECONDS:-10}}"if [[ -z "${APPLE_ID:-}" || -z "${APPLE_APP_SPECIFIC_PASSWORD:-}" || -z "${APPLE_TEAM_ID:-}" ]]; thenecho "error: APPLE_ID / APPLE_APP_SPECIFIC_PASSWORD / APPLE_TEAM_ID are required to notarize the DMG." >&2@@ -124,6 +125,9 @@ if [[ "$stapled" != "true" ]]; thenfiecho "==> Validating the stapled ticket on $DMG"-xcrun stapler validate "$DMG"+PI_XCRUN_REAL="$(command -v xcrun)" \+PI_STAPLER_MAX_ATTEMPTS="$STAPLE_ATTEMPTS" \+PI_STAPLER_RETRY_DELAY_SECONDS="$STAPLE_DELAY_SECONDS" \+ bash "$SCRIPT_DIR/macos-stapler-retry-shim.sh" stapler validate "$DMG"echo "==> Staple validation passed: $DMG (status=Accepted)"diff --git a/scripts/verify-macos-release.sh b/scripts/verify-macos-release.shindex a99b388ff..ee32cf664 100755--- a/scripts/verify-macos-release.sh+++ b/scripts/verify-macos-release.sh@@ -5,12 +5,23 @@set -euo pipefailRELEASE_DIR="${1:-apps/desktop/release}"+SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"PRODUCT_NAME="PI-Desktop"# Accepts either the bare common name ("XingYu Liu (DUV63RKYTW)") or the full# certificate label ("Developer ID Application: XingYu Liu (DUV63RKYTW)").IDENTITY_NAME="${MAC_SIGNING_IDENTITY:-XingYu Liu (DUV63RKYTW)}"IDENTITY_NAME="${IDENTITY_NAME#Developer ID Application: }"EXPECTED_IDENTITY="Developer ID Application: ${IDENTITY_NAME}"+STAPLE_ATTEMPTS="${PI_STAPLER_MAX_ATTEMPTS:-${STAPLE_ATTEMPTS:-6}}"+STAPLE_DELAY_SECONDS="${PI_STAPLER_RETRY_DELAY_SECONDS:-${STAPLE_DELAY_SECONDS:-10}}"++validate_stapled_ticket() {+ local artifact="$1"+ PI_XCRUN_REAL="$(command -v xcrun)" \+ PI_STAPLER_MAX_ATTEMPTS="$STAPLE_ATTEMPTS" \+ PI_STAPLER_RETRY_DELAY_SECONDS="$STAPLE_DELAY_SECONDS" \+ bash "$SCRIPT_DIR/macos-stapler-retry-shim.sh" stapler validate "$artifact"+}if [[ ! -d "$RELEASE_DIR" ]]; thenecho "error: release directory does not exist: $RELEASE_DIR" >&2@@ -66,7 +77,7 @@ if [[ "$ASSESSMENT" != *"source=Notarized Developer ID"* ]]; thenfiecho "==> Validating stapled notarization tickets"-xcrun stapler validate "$APP"-xcrun stapler validate "$DMG"+validate_stapled_ticket "$APP"+validate_stapled_ticket "$DMG"echo "==> macOS release verification passed: $APP and $DMG"