Skip to content

fix(daemon): preserve macOS launchd ownership during startup - #3952

Merged
afonsojramos merged 3 commits into
v3-betafrom
fix/macos-launch-agent-reconciliation
Sep 16, 2026
Merged

afonsojramos merged 3 commits into
v3-betafrom
fix/macos-launch-agent-reconciliation

Conversation

@afonsojramos

@afonsojramos afonsojramos commented Sep 16, 2026

Copy link
Copy Markdown
Member

Keep macOS daemon startup under launchd ownership. Reuse an unchanged running registration, reload changed or stopped jobs, and report launchctl failures instead of treating them as missing jobs.

Before replacing an unmanaged daemon, wait for both process exit and its original instance-lock inode to be released. A closed listener or unlinked lock file does not prove exit. Apply does not spawn an unmanaged fallback while ownership is unresolved or after launchd has accepted a registration but has not started listening yet.

Validation: focused startup, process/lock-release, and launchctl parsing regressions pass. Full library tests and strict library Clippy pass. An independent review identified the shutdown race now covered by the new regressions.

Live macOS verification passed with the combined local build including #3948 and #3951. The visible Store update/Apply flow restarted Spotify and restored stdlib 1.12.0 after a published older-version fixture. Daemon PID 3060 and its launch-agent plist remained unchanged with responsive health checks. A subsequent macOS protocol URL Apply also preserved that daemon. Delayed startup and shutdown-race paths are covered by regressions, not forced in the live installation.

Reuse an unchanged running launch agent and reload stopped or changed
registrations before replacing an unmanaged daemon. Propagate launchctl
failures so unavailable launchd is not mistaken for a missing job.
Wait for the previous daemon process and instance lock to exit before
loading its launch agent. Keep the old lock inode open through shutdown,
so a closed listener or unlinked pathname cannot falsely signal readiness.

Block unmanaged startup when shutdown or launchd ownership is unresolved,
while preserving the fallback for unsupported supervisors.
Do not start an unmanaged macOS daemon after launchd accepted registration
but has not opened the listener within the readiness window.
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: b199cb72-9ba9-425e-aa73-dcaeea405ed7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@afonsojramos
afonsojramos marked this pull request as ready for review September 16, 2026 23:38
@afonsojramos
afonsojramos merged commit 4870bae into v3-beta Sep 16, 2026
6 checks passed
@afonsojramos
afonsojramos deleted the fix/macos-launch-agent-reconciliation branch September 16, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant