Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(desktop): verify legacy macOS load commands (#3109)

Maxbc6cd410ccb2
diff --git a/.github/workflows/desktop-package.yml b/.github/workflows/desktop-package.yml
index 115950da8..d9f62f0e6 100644
--- a/.github/workflows/desktop-package.yml
+++ b/.github/workflows/desktop-package.yml
@@ -282,11 +282,11 @@ jobs:
set -euo pipefail
app="target/release/bundle/macos/Avibe.app"
executable="$(plutil -extract CFBundleExecutable raw -o - "$app/Contents/Info.plist")"
+ # The app keeps Tauri's existing 10.13 floor; the Cua Driver requires macOS 13.
python ../scripts/desktop_release.py verify-macos-build-version \
- --binary "$app/Contents/MacOS/$executable" \
- --binary "$app/Contents/Helpers/cua-driver" \
- --minimum-sdk 26.0 \
- --maximum-deployment-target 11.0
+ --binary "$app/Contents/MacOS/$executable=11.0" \
+ --binary "$app/Contents/Helpers/cua-driver=13.0" \
+ --minimum-sdk 26.0
- name: Save Rust build cache
if: ${{ !inputs.release_tag && steps.rust-cache.outputs.cache-hit != 'true' }}
diff --git a/.github/workflows/desktop-shell.yml b/.github/workflows/desktop-shell.yml
index bc35c09e3..daa572d38 100644
--- a/.github/workflows/desktop-shell.yml
+++ b/.github/workflows/desktop-shell.yml
@@ -145,6 +145,5 @@ jobs:
if: runner.os == 'macOS'
run: >
python ../scripts/desktop_release.py verify-macos-build-version
- --binary target/debug/avibe-desktop
+ --binary target/debug/avibe-desktop=11.0
--minimum-sdk 26.0
- --maximum-deployment-target 11.0
diff --git a/scripts/desktop_release.py b/scripts/desktop_release.py
index 70acf57cf..790ba1438 100644
--- a/scripts/desktop_release.py
+++ b/scripts/desktop_release.py
@@ -85,22 +85,22 @@ def _numeric_version(value: str) -> tuple[int, ...]:
return parts
-def parse_macos_build_versions(output: str) -> list[tuple[str, str]]:
- records: list[tuple[str, str]] = []
+def parse_macos_build_versions(output: str) -> list[tuple[str, str, str]]:
+ records: list[tuple[str, str, str]] = []
command: str | None = None
- minos: str | None = None
+ deployment_target: str | None = None
sdk: str | None = None
def finish_command() -> None:
- nonlocal command, minos, sdk
- if command == "LC_BUILD_VERSION":
- if minos is None or sdk is None:
- raise ValueError("Incomplete LC_BUILD_VERSION command")
- _numeric_version(minos)
+ nonlocal command, deployment_target, sdk
+ if command in {"LC_BUILD_VERSION", "LC_VERSION_MIN_MACOSX"}:
+ if deployment_target is None or sdk is None:
+ raise ValueError(f"Incomplete {command} command")
+ _numeric_version(deployment_target)
_numeric_version(sdk)
- records.append((minos, sdk))
+ records.append((command, deployment_target, sdk))
command = None
- minos = None
+ deployment_target = None
sdk = None
for line in output.splitlines():
@@ -111,24 +111,43 @@ def parse_macos_build_versions(output: str) -> list[tuple[str, str]]:
command = fields[1]
elif command == "LC_BUILD_VERSION" and len(fields) == 2:
if fields[0] == "minos":
- minos = fields[1]
+ deployment_target = fields[1]
+ elif fields[0] == "sdk":
+ sdk = fields[1]
+ elif command == "LC_VERSION_MIN_MACOSX" and len(fields) == 2:
+ if fields[0] == "version":
+ deployment_target = fields[1]
elif fields[0] == "sdk":
sdk = fields[1]
finish_command()
if not records:
- raise ValueError("Mach-O binary has no LC_BUILD_VERSION command")
+ raise ValueError(
+ "Mach-O binary has no LC_BUILD_VERSION or LC_VERSION_MIN_MACOSX command"
+ )
return records
+def parse_macos_binary_spec(spec: str) -> tuple[Path, str]:
+ try:
+ binary, maximum_deployment_target = spec.rsplit("=", 1)
+ except ValueError as exc:
+ raise ValueError(
+ f"Invalid macOS binary spec {spec!r}; expected PATH=MAX_DEPLOYMENT_TARGET"
+ ) from exc
+ if not binary:
+ raise ValueError(f"Invalid macOS binary spec {spec!r}: path is empty")
+ _numeric_version(maximum_deployment_target)
+ return Path(binary), maximum_deployment_target
+
+
def verify_macos_build_versions(
- binaries: list[Path],
+ binaries: list[tuple[Path, str]],
*,
minimum_sdk: str,
- maximum_deployment_target: str,
) -> None:
minimum_sdk_value = _numeric_version(minimum_sdk)
- maximum_deployment_target_value = _numeric_version(maximum_deployment_target)
- for binary in binaries:
+ for binary, maximum_deployment_target in binaries:
+ maximum_deployment_target_value = _numeric_version(maximum_deployment_target)
if binary.is_symlink() or not binary.is_file():
raise ValueError(f"Missing or invalid Mach-O binary: {binary}")
architectures = subprocess.check_output(
@@ -148,22 +167,23 @@ def verify_macos_build_versions(
if len(records) != 1:
raise ValueError(
f"{binary} [{architecture}]: expected exactly one "
- f"LC_BUILD_VERSION command, got {len(records)}"
+ "LC_BUILD_VERSION or LC_VERSION_MIN_MACOSX command, "
+ f"got {len(records)}"
)
- minos, sdk = records[0]
+ command, deployment_target, sdk = records[0]
print(
f"{binary} [{architecture}]: "
- f"LC_BUILD_VERSION minos {minos}, sdk {sdk}"
+ f"{command} deployment target {deployment_target}, sdk {sdk}"
)
if _numeric_version(sdk) < minimum_sdk_value:
raise ValueError(
- f"{binary} [{architecture}]: expected LC_BUILD_VERSION sdk >= "
+ f"{binary} [{architecture}]: expected {command} sdk >= "
f"{minimum_sdk}, got {sdk}"
)
- if _numeric_version(minos) > maximum_deployment_target_value:
+ if _numeric_version(deployment_target) > maximum_deployment_target_value:
raise ValueError(
- f"{binary} [{architecture}]: expected LC_BUILD_VERSION minos <= "
- f"{maximum_deployment_target}, got {minos}"
+ f"{binary} [{architecture}]: expected {command} deployment "
+ f"target <= {maximum_deployment_target}, got {deployment_target}"
)
@@ -551,9 +571,13 @@ def main() -> None:
resolver.add_argument("--tag", required=True)
resolver.add_argument("--output", type=Path, required=True)
build_version = sub.add_parser("verify-macos-build-version")
- build_version.add_argument("--binary", action="append", type=Path, required=True)
+ build_version.add_argument(
+ "--binary",
+ action="append",
+ required=True,
+ metavar="PATH=MAX_DEPLOYMENT_TARGET",
+ )
build_version.add_argument("--minimum-sdk", default="26.0")
- build_version.add_argument("--maximum-deployment-target", default="11.0")
prep = sub.add_parser("prepare")
prep.add_argument("--version", required=True)
prep.add_argument("--tag", default="")
@@ -596,9 +620,8 @@ def main() -> None:
stream.write("".join(f"{key}={value}\n" for key, value in resolve(args["tag"]).items()))
elif command == "verify-macos-build-version":
verify_macos_build_versions(
- args["binary"],
+ [parse_macos_binary_spec(spec) for spec in args["binary"]],
minimum_sdk=args["minimum_sdk"],
- maximum_deployment_target=args["maximum_deployment_target"],
)
elif command == "prepare":
prepare(**args)
diff --git a/tests/test_desktop_release.py b/tests/test_desktop_release.py
index c8e1d02f3..70c4c8a5b 100644
--- a/tests/test_desktop_release.py
+++ b/tests/test_desktop_release.py
@@ -510,7 +510,36 @@ def test_manual_record_names_the_layers_it_produced(tmp_path, profile, layers):
assert (work / "manual" / "Avibe_3.1.2-dev.1_aarch64-apple-darwin.SIGNATURE").read_text() == layers
-def test_macos_build_version_parser_requires_the_pinned_sdk_and_caps_deployment_target(
+def test_macos_build_version_parser_supports_both_platform_commands():
+ def build_version(minos="11.0", sdk="26.5"):
+ return f"""
+Load command 9
+ cmd LC_BUILD_VERSION
+ cmdsize 32
+ platform 1
+ minos {minos}
+ sdk {sdk}
+ ntools 1
+"""
+
+ def version_min(version="10.13", sdk="26.5"):
+ return f"""
+Load command 9
+ cmd LC_VERSION_MIN_MACOSX
+ cmdsize 16
+ version {version}
+ sdk {sdk}
+"""
+
+ assert release.parse_macos_build_versions(build_version()) == [
+ ("LC_BUILD_VERSION", "11.0", "26.5")
+ ]
+ assert release.parse_macos_build_versions(version_min()) == [
+ ("LC_VERSION_MIN_MACOSX", "10.13", "26.5")
+ ]
+
+
+def test_macos_build_version_verifier_checks_each_binary_ceiling(
tmp_path, monkeypatch, capsys
):
binary = tmp_path / "avibe-desktop"
@@ -527,7 +556,16 @@ Load command 9
ntools 1
"""
- def verify(output, architectures="x86_64"):
+ def version_min(version="10.13", sdk="26.5"):
+ return f"""
+Load command 9
+ cmd LC_VERSION_MIN_MACOSX
+ cmdsize 16
+ version {version}
+ sdk {sdk}
+"""
+
+ def verify(output, maximum_deployment_target, architectures="x86_64"):
def check_output(command, **kwargs):
if command[:2] == ["lipo", "-archs"]:
return architectures
@@ -536,21 +574,31 @@ Load command 9
monkeypatch.setattr(release.subprocess, "check_output", check_output)
release.verify_macos_build_versions(
- [binary],
+ [(binary, maximum_deployment_target)],
minimum_sdk="26.0",
- maximum_deployment_target="11.0",
)
- verify(build_version(minos="10.13"))
- assert f"{binary} [x86_64]: LC_BUILD_VERSION minos 10.13, sdk 26.5" in capsys.readouterr().out
- verify(build_version(minos="11.0"), architectures="arm64")
- assert f"{binary} [arm64]: LC_BUILD_VERSION minos 11.0, sdk 26.5" in capsys.readouterr().out
+ verify(version_min(), "11.0")
+ assert (
+ f"{binary} [x86_64]: LC_VERSION_MIN_MACOSX deployment target 10.13, sdk 26.5"
+ in capsys.readouterr().out
+ )
+ verify(build_version(minos="13.0"), "13.0", architectures="arm64")
+ assert (
+ f"{binary} [arm64]: LC_BUILD_VERSION deployment target 13.0, sdk 26.5"
+ in capsys.readouterr().out
+ )
for output, message in (
(build_version(sdk="15.5"), "sdk >= 26.0"),
- (build_version(minos="13.0"), "minos <= 11.0"),
+ (build_version(minos="14.0"), "deployment target <= 13.0"),
):
with pytest.raises(ValueError, match=message):
- verify(output)
+ verify(output, "13.0")
+
+ with pytest.raises(ValueError, match="no LC_BUILD_VERSION or LC_VERSION_MIN_MACOSX"):
+ verify("Load command 1\n cmd LC_SYMTAB\n", "11.0")
+ with pytest.raises(ValueError, match="expected exactly one"):
+ verify(f"{build_version()}\n{version_min()}", "11.0")
def test_macos_desktop_builds_pin_xcode_and_check_link_metadata():
@@ -602,13 +650,16 @@ def test_macos_desktop_builds_pin_xcode_and_check_link_metadata():
)
assert "verify-macos-build-version" in check["run"]
assert "--minimum-sdk 26.0" in check["run"]
- assert "--maximum-deployment-target 11.0" in check["run"]
+ assert "target/debug/avibe-desktop=11.0" in check["run"] or (
+ "Contents/MacOS/$executable=11.0" in check["run"]
+ )
package_check = next(
item
for item in package["steps"]
if item.get("name") == "Verify macOS SDK and deployment target ceiling"
)
- assert "Contents/Helpers/cua-driver" in package_check["run"]
+ assert 'Contents/MacOS/$executable=11.0' in package_check["run"]
+ assert "Contents/Helpers/cua-driver=13.0" in package_check["run"]
def test_workflow_signs_every_macos_layer_before_recording():