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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(desktop): back off longer when stapler loses Apple's ticket service (#3034)
Call Whiteab42db738bbe
diff --git a/desktop/scripts/macos_signing.py b/desktop/scripts/macos_signing.pyindex 3165b9ef5..46d9ce920 100644--- a/desktop/scripts/macos_signing.py+++ b/desktop/scripts/macos_signing.py@@ -93,9 +93,12 @@ TIMESTAMP_UNAVAILABLE = "timestamp service is not available"TIMESTAMP_ATTEMPTS = 3# stapler fetches and checks tickets through Apple's CloudKit service; a dropped# connection there fails the action with an NSURLErrorDomain error and Error 68.+# Such drops can last longer than a few seconds: in gh-v3.2.3rc12 an Accepted DMG+# failed all three of the former 15 s-spaced attempts within 52 s. Back off over+# about five minutes before giving up; only the network error is retried.STAPLER_NETWORK_ERROR = "NSURLErrorDomain"-STAPLER_ATTEMPTS = 3-STAPLER_RETRY_SECONDS = 15+STAPLER_RETRY_DELAYS_SECONDS = (15, 30, 60, 90, 120)+STAPLER_ATTEMPTS = len(STAPLER_RETRY_DELAYS_SECONDS) + 1class SigningError(RuntimeError):@@ -430,8 +433,13 @@ def stapler(action: str, path: Path) -> None:except SigningError as error:if STAPLER_NETWORK_ERROR not in str(error) or attempt == STAPLER_ATTEMPTS:raise- print(f"stapler {action} {path.name} lost its connection to Apple; retrying ({attempt}/{STAPLER_ATTEMPTS})", flush=True)- time.sleep(STAPLER_RETRY_SECONDS)+ delay = STAPLER_RETRY_DELAYS_SECONDS[attempt - 1]+ print(+ f"stapler {action} {path.name} lost its connection to Apple; "+ f"retrying in {delay} s ({attempt}/{STAPLER_ATTEMPTS})",+ flush=True,+ )+ time.sleep(delay)def assess(path: Path, *, kind: str) -> None:diff --git a/tests/test_desktop_macos_signing.py b/tests/test_desktop_macos_signing.pyindex fd811c7f5..ac480939d 100644--- a/tests/test_desktop_macos_signing.py+++ b/tests/test_desktop_macos_signing.py@@ -191,3 +191,54 @@ def test_an_unreviewed_runtime_executable_stops_signing_before_any_codesign(tmp_node_executable=tmp_path / "tools/bin/node",identity=COMPLETE["APPLE_SIGNING_IDENTITY"],)+++def _stapler_run(outcomes, calls):+ def fake_run(command, *, redacted=None, capture=False):+ calls.append(command)+ outcome = outcomes.pop(0)+ if outcome is not None:+ raise signing.SigningError(f"{redacted} exited 68\n{outcome}")+ return fake_run+++NETWORK_LOST = 'error is Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."'+++def test_stapler_rides_out_a_lasting_cloudkit_connection_drop(tmp_path, monkeypatch):+ calls: list[list[str]] = []+ sleeps: list[float] = []+ # Three drops in a row, as gh-v3.2.3rc12 hit, then the ticket arrives.+ monkeypatch.setattr(signing, "run", _stapler_run([NETWORK_LOST, NETWORK_LOST, NETWORK_LOST, None], calls))+ monkeypatch.setattr(signing.time, "sleep", sleeps.append)++ signing.stapler("staple", tmp_path / "Avibe.dmg")++ assert len(calls) == 4+ assert all(command[:3] == ["xcrun", "stapler", "staple"] for command in calls)+ assert sleeps == list(signing.STAPLER_RETRY_DELAYS_SECONDS[:3])+++def test_stapler_gives_up_after_its_backoff_and_reports_the_last_error(tmp_path, monkeypatch):+ calls: list[list[str]] = []+ sleeps: list[float] = []+ monkeypatch.setattr(signing, "run", _stapler_run([NETWORK_LOST] * signing.STAPLER_ATTEMPTS, calls))+ monkeypatch.setattr(signing.time, "sleep", sleeps.append)++ with pytest.raises(signing.SigningError, match="NSURLErrorDomain"):+ signing.stapler("validate", tmp_path / "Avibe.app")++ assert len(calls) == signing.STAPLER_ATTEMPTS+ assert sleeps == list(signing.STAPLER_RETRY_DELAYS_SECONDS)+ assert sum(sleeps) >= 300+++def test_stapler_does_not_retry_a_failure_that_is_not_a_network_drop(tmp_path, monkeypatch):+ calls: list[list[str]] = []+ monkeypatch.setattr(signing, "run", _stapler_run(["Could not validate ticket"], calls))+ monkeypatch.setattr(signing.time, "sleep", lambda _seconds: pytest.fail("a non-network failure must not wait"))++ with pytest.raises(signing.SigningError, match="Could not validate ticket"):+ signing.stapler("staple", tmp_path / "Avibe.dmg")++ assert len(calls) == 1