Files
cmux/scripts/sign-cmux-bundle.sh
T
Lawrence Chen b129a8669f Move diff viewer backend boundary to a Rust sidecar (#7804)
* Add Rust diff viewer sidecar

* Harden diff sidecar request handling

* Close sidecar review gaps

* Finish sidecar build and retry integration

* Gate sidecar transport and webview checks

* Remove sidecar setup and localization gaps

* Extract diff sidecar process boundary

* Use stdio for native diff sidecar transport

* Satisfy Swift file length guard

* Make custom scheme test deterministic

* Address sidecar review findings

* Test incremental diff tree source reuse

* Make diff tree streaming linear

* Verify diff correctness and streaming performance

* Fix diff sidecar review regressions

* Harden diff sidecar stdio RPC

* Test bounded large diff rendering

* Bound large diff UI updates

* Harden large diff navigation

* Fix diff sidecar isolation warning

* Test mobile diff drawer close control

* Make mobile diff drawer opaque

* Harden mobile diff drawer dismissal

* Refactor diff viewer bridge ownership

* Preserve diff sidecar pipe ownership

* Load diff sessions lazily through Rust

* Keep Rust diff sessions alive while rendering

* Split diff sidecar helpers from legacy files

* Close diff sessions before page navigation

* Close diff sessions before navigating

* Track active diff sessions through navigation

* Refresh generated diff viewer bundle

* Keep diff source switching responsive

* Open typed diff sessions in place

* Update diff CLI file budget

* Extract typed diff viewer writer

* Build typed diff writer in CLI target

* Expose shared diff shortcut payload

* Share typed diff writer model types

* Allow typed diff fallback input replacement

* Open diff loading shell before asset setup

* Bound typed branch base resolution

* Avoid duplicate diff theme registration

* Test custom-scheme asset fetch decoding

* Decode deflated assets for diff scheme

* Test cancellation of stale diff streams

* Cancel stale diff sessions and cap patch writes

* test: cover diff sidecar review regressions

* fix: bound diff sidecar lifecycle

* test: cover sidecar cancellation cleanup

* fix: clean up cancelled sidecar process groups

* test: require race-free sidecar process groups

* fix: handshake sidecar process group startup

* test: cover cancellation after patch rename

* fix: retain cleanup ownership through registration

* fix: bound sidecar startup and shutdown

* test: cover branch picker repository switches

* fix: close final sidecar lifecycle gaps

* test: cover same-repo branch base changes

* fix: preserve process group identity through shutdown

* Make stale branch picker test state-driven

* Test Last Turn switching and abandoned sidecar sessions

* Keep typed diff sources and manifests recoverable

* Test typed diff selector composition

* Compose typed diff selector state

* Rebuild diff webview assets

* Test orphan cleanup and Last Turn repo switching

* Close typed diff lifecycle gaps

* Test pending cancellation and rotating orphan cleanup

* Bound pending and remote diff resources

* Cap sidecar queue and index temp cleanup

* Bound server sessions and retain patch ownership

* Make patch ownership and HTTP encoding durable

* Test empty branch base selection

* Keep empty branch and pending patch recovery available

* Test branch base survives source switching

* Preserve selected branch base across source switches

* Retain generated patch ownership until lifecycle cleanup

* Serialize token session publication

* Keep concurrent diff sessions independently owned

* Reconcile session cleanup with manifest lifecycle

* Make session publication cancellation safe

* Scope cancellation and close transactions correctly

* Authorize session close by manifest ownership

* Close discarded diff sessions safely

* Cancel superseded diff sessions safely

* Reserve diff session resources atomically

* Protect active diff session patches

* Preserve active typed diff sessions

* Lease active diff sidecar sessions

* Journal diff session resource ownership

* Bound diff session recovery artifacts

* Harden diff sidecar production artifact

* Fix POSIX lock calls on Xcode 26.5

* Fix app-side lease locking on Xcode 26.5

* test: cover typed diff direct page lifecycle

* fix: open typed diff session page directly

* Fix sidecar verification for spaced paths
2026-07-15 22:00:34 -07:00

123 lines
4.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Inside-out codesign a cmux .app bundle for Developer ID + notarization.
#
# Usage:
# scripts/sign-cmux-bundle.sh <app-path> <app-entitlements> <signing-identity>
#
# Example:
# scripts/sign-cmux-bundle.sh \
# "build-universal/Build/Products/Release/cmux NIGHTLY.app" \
# cmux.nightly.entitlements \
# "Developer ID Application: Manaflow, Inc. (7WLXT3NR37)"
#
# Optional env:
# CMUX_HELPER_ENTITLEMENTS (default: cmux-helper.entitlements)
# CMUX_TIMESTAMP set to "none" for un-timestamped local sigs
#
# Signs in the Apple-documented inside-out order:
# 1. CLI helpers under Contents/Resources/bin/* with minimal
# hardened-runtime entitlements (no application-identifier).
# 2. Each nested plugin under Contents/PlugIns/* with --deep.
# 3. Each nested framework under Contents/Frameworks/* with --deep
# (covers Sparkle's XPCServices and Updater.app).
# 4. The main app bundle with the provided app-level entitlements,
# WITHOUT --deep. --deep here would overwrite helper/plugin
# signatures and re-introduce the app-id mismatch that amfi on
# notarized macOS 26 Tahoe rejects with errno 163.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ $# -lt 3 ]]; then
echo "usage: $0 <app-path> <app-entitlements> <signing-identity>" >&2
exit 2
fi
APP_PATH="$1"
APP_ENTITLEMENTS="$2"
IDENTITY="$3"
HELPER_ENTITLEMENTS="${CMUX_HELPER_ENTITLEMENTS:-cmux-helper.entitlements}"
if [[ ! -d "$APP_PATH" ]]; then
echo "error: app bundle not found at $APP_PATH" >&2
exit 1
fi
if [[ ! -f "$APP_ENTITLEMENTS" ]]; then
echo "error: app entitlements not found at $APP_ENTITLEMENTS" >&2
exit 1
fi
if [[ ! -f "$HELPER_ENTITLEMENTS" ]]; then
echo "error: helper entitlements not found at $HELPER_ENTITLEMENTS" >&2
exit 1
fi
if [[ "${CMUX_TIMESTAMP:-}" == "none" ]]; then
TS_FLAG=(--timestamp=none)
else
TS_FLAG=(--timestamp)
fi
COMMON=(--force --options runtime "${TS_FLAG[@]}" --sign "$IDENTITY")
# 1. CLI helpers
for helper in "$APP_PATH/Contents/Resources/bin"/*; do
[[ -f "$helper" && -x "$helper" ]] || continue
echo "==> signing helper $(basename "$helper")"
/usr/bin/codesign "${COMMON[@]}" --entitlements "$HELPER_ENTITLEMENTS" "$helper"
done
# 2. Plugins
if [[ -d "$APP_PATH/Contents/PlugIns" ]]; then
while IFS= read -r -d '' plugin; do
echo "==> signing plugin $(basename "$plugin")"
/usr/bin/codesign "${COMMON[@]}" --deep "$plugin"
done < <(find "$APP_PATH/Contents/PlugIns" -mindepth 1 -maxdepth 1 -print0)
fi
# 3. Frameworks
if [[ -d "$APP_PATH/Contents/Frameworks" ]]; then
"$SCRIPT_DIR/remove-sparkle-sandbox-xpc-services.sh" "$APP_PATH"
while IFS= read -r -d '' framework; do
echo "==> signing framework $(basename "$framework")"
/usr/bin/codesign "${COMMON[@]}" --deep "$framework"
done < <(find "$APP_PATH/Contents/Frameworks" -mindepth 1 -maxdepth 1 -print0)
fi
# 4. Main app bundle (no --deep).
echo "==> signing main bundle"
/usr/bin/codesign "${COMMON[@]}" --entitlements "$APP_ENTITLEMENTS" "$APP_PATH"
echo "==> verifying"
/usr/bin/codesign --verify --deep --strict --verbose=2 "$APP_PATH"
"$SCRIPT_DIR/verify-command-palette-nucleo-ffi-artifact.sh" "$APP_PATH"
"$SCRIPT_DIR/verify-diff-sidecar-artifact.sh" \
"$APP_PATH/Contents/Resources/bin/cmux-diff-sidecar" \
--require-signed
APP_ID="$(/usr/libexec/PlistBuddy -c "Print :com.apple.application-identifier" \
/dev/stdin <<<"$(plutil -convert xml1 -o - "$APP_ENTITLEMENTS")" 2>/dev/null || true)"
if [[ -n "$APP_ID" ]]; then
/usr/bin/codesign -d --entitlements :- "$APP_PATH" 2>&1 | grep -q "$APP_ID" || {
echo "error: signed app missing application-identifier $APP_ID" >&2
exit 1
}
fi
/usr/bin/codesign -d --entitlements :- "$APP_PATH" 2>&1 \
| grep -q "com.apple.developer.web-browser.public-key-credential" || {
echo "error: signed app missing web-browser entitlement" >&2
exit 1
}
# Helpers must NOT carry the main app's application-identifier.
for helper in "$APP_PATH/Contents/Resources/bin"/*; do
[[ -f "$helper" && -x "$helper" ]] || continue
if /usr/bin/codesign -d --entitlements :- "$helper" 2>&1 \
| grep -q "application-identifier"; then
echo "error: helper $(basename "$helper") unexpectedly carries application-identifier" >&2
exit 1
fi
done
echo "==> signing OK: $APP_PATH"