fix(server): wait for launchd bootout safely #18252
main fromrefs/pull/18252/head·opened View on GitHubProblem#
On macOS 15, launchctl bootout --wait <service-target> exits with usage code 64 without stopping the launch agent. Install, update, restart, and uninstall can then continue with the old job still holding the label.
Fixes #11995.
Replaces #12005 after its requested modern-model refresh; GitHub would not reopen the closed PR after the branch was updated.
Change#
- use the supported
launchctl bootout <service-target>form - poll
launchctl print <service-target>until launchd confirms the exact label is absent - bound shutdown verification to the existing 120-second stop timeout
- treat only confirmed not-loaded / no-such-process responses as idempotent success
- fail closed on permission, domain, unexpected-output, and timeout failures
- update the focused boot-service tests for install, repair, update recovery, timeout, and uninstall behavior
Verification#
vp test run apps/server/src/cloud/bootService.test.ts— 60 passedvp run --filter t3 typecheck— passed (existing Effect suggestions only)vp lint apps/server/src/cloud/bootService.ts apps/server/src/cloud/bootService.test.ts --report-unused-disable-directives— passedvp fmt --check apps/server/src/cloud/bootService.ts apps/server/src/cloud/bootService.test.ts— passed- independent Codex autoreview — scoped clean, no verified P0–P2 findings
The current candidate was refreshed against current main, independently reviewed, and updated with OpenAI GPT-6.1 Sol (high reasoning) in the Codex CLI harness. The original commits predate this refresh; this attribution describes the current review and update pass.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This production change introduces a new launchd shutdown state machine with polling, timeout handling, and fail-closed behavior across installation, update, restart, and uninstall paths. The scope and tests are focused, but the lifecycle gating and changed failure semantics warrant human review.
Notes:
- Diff unchanged. Approvability was decided on eligibility alone.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
juliusmarminge added labelsmacroscope-review
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
4353ba0d-d82e-4d10-8b99-8d7706ab192a
📥 Commits
-
Reviewing files that changed from the base of the PR and between ed0f7b908b2e7b3a22e6fd82a73794c2fe6ee06e and 44d60dab452a82462916589e092a3dc15f1a1eff.
📒 Files selected for processing (2)
-
apps/server/src/cloud/bootService.test.tsapps/server/src/cloud/bootService.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
Walkthrough#
Launchd stop and uninstall now run
bootoutwithout--wait, then polllaunchctl printto verify absence. Bootout and verification share a timeout. Tests cover recognized absence responses, polling, command failures, and timeout behavior.Changes#
Launchd stop verification
Layer / File(s) Summary Define launchd stop operations
apps/server/src/cloud/bootService.tsBootServiceStepadds a launchd bootout operation with explicit absence-verification data. Stop and uninstall use plainbootout; the accepted absence messages include missing-service and missing-domain responses.Run and verify launchd bootout
apps/server/src/cloud/bootService.tsThe dedicated runner polls launchctl printuntil absence is confirmed. Bootout and polling use one timeout. Unexpected results and timed-out commands return command errors. The generic runner no longer ignores nonzero results for optional steps.Test verification outcomes
apps/server/src/cloud/bootService.test.tsThe test harness supports per-command results, delays, synchronization, and timeout capture. Tests cover confirmed absence, polling, errors, timeouts, and install, restart, and uninstall behavior. Priority: ➖ Normal
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)#
sequenceDiagram participant BootService participant launchctl participant launchd BootService->>launchctl: Run bootout for service target launchctl->>launchd: Request service bootout launchd-->>launchctl: Return bootout result BootService->>launchctl: Run print to verify absence launchctl->>launchd: Query service target launchd-->>launchctl: Return service status launchctl-->>BootService: Return print result BootService->>launchctl: Repeat print while service remains loadedSuggested reviewers:
t3dotgg
Merge Risk | ⚪ Minimal · up to
44d60-
Merge Risk: ⚪ Minimal · up to
44d60The changed stop flow verifies that the agent is absent before proceeding, with bounded waiting and failure handling. No concrete issue currently prevents merging.
-
Security Architecture Review
-
Security architecture risk: 🔵 Low · up to
44d60The change strengthens shutdown verification without expanding privileges. Remaining uncertainty concerns actual macOS response formats and overlapping maintenance commands, rather than a demonstrated new attack path.
Retained concerns No architecture-level concerns identified.
-
Security review details
-
Security Blast Radius
- inferred — The directly affected scope is the existing host user's T3 background service and its startup configuration, not an individual project. The inspected changes retain the host-derived UID and fixed label; they do not add a caller-selected user target or a higher-privilege management operation.
Trust Boundaries and Controls
- observed — Absence acceptance requires complete, nonzero, non-timeout output matching configured service/domain messages. Signal exits, truncation, invalid UTF-8, unrelated labels, and extra error text cannot establish absence. A recognized bootout “No such process” response still requires a separate absence probe. Missing-domain acceptance is limited to uninstall.
Resilience and Maintainability Implications
- observed — Unverifiable shutdown prevents subsequent activation or plist deletion. Simulated tests assert this terminal-state behavior and the shared timeout. Process execution is scoped and returns an explicit timeout result when requested, so timeout cannot masquerade as confirmed absence. These fixtures establish code behavior, not actual macOS diagnostic compatibility.
- inferred — The ordering guarantee is per lifecycle operation, not a demonstrated cross-process transaction. Existing durable writes use temporary files, synchronization, and rename for each file separately; state and plist replacement are not one atomic transaction. Inspected CLI management paths provide no cross-process serialization guarantee. These limitations were not shown to be introduced or materially worsened by this PR.
-
-
-
-
Pre-merge checks |
4-
✅ Passed checks (4 passed)
-
Check name Status Explanation Title check The title clearly and concisely describes the main change: safely waiting for launchd bootout completion. Description check The description clearly covers the problem, implementation, scope, and focused verification results. It references issue #11995, although it does not include explicit maintainer approval or an exempti…Linked Issues check Issue #11995requires a supported macOS 15 bootout form and a wait until the exact service label is absent before bootstrap.bootService.tsnow useslaunchctl bootout <service-target>and polls `l…Out of Scope Changes check The pull request changes only apps/server/src/cloud/bootService.tsand its focused test file. The command-operation type, strict launchd error handling, timeout propagation, and test-harness updates…
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.-
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
Note
Written by
gpt-6.1-solon behalf of MariaThanks for addressing the launchd shutdown failure. At 540 changed lines from an unvouched contributor, this exceeds what we can take over under our limited review capacity. Right now we are only taking focused bug fixes from outside contributors. Please keep the macOS failure documented in #11995 and request reconsideration with a smaller replacement that preserves shutdown verification.
maria-rcks closed this
@maria-rcks Have you agents go further than mere numbers....
I only filed a PR because the linked issue asked me to....
Fix this...
@juliusmarminge I filed a PR because of your comment on the original issue...if someone wants to take it over then great...but having to babysit and re-open NEW PRs because someone's autobot is too aggressive without reading anything related is really annoying.
@t3dotgg Please teach your junior staff to be a bit more thorough. Follow the breadcrumbs.
Sign in to join this conversation.
Codex Review Summary#
This comment shows the latest Codex review activity on this pull request.
44d60daℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.