Skip to content

[WRONG BRANCH] fix(service): treat launchctl 125 on the GUI domain as an unreachable domain (#7697) - #7710

Closed
chenyb999-zhcn wants to merge 1 commit into
lidge-jun:mainfrom
chenyb999-zhcn:fix/launchd-headless-125-7697
Closed

chenyb999-zhcn wants to merge 1 commit into
lidge-jun:mainfrom
chenyb999-zhcn:fix/launchd-headless-125-7697

Conversation

@chenyb999-zhcn

@chenyb999-zhcn chenyb999-zhcn commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #7697

On a headless Mac (screen sharing / SSH only, no window server logged in), launchctl print gui/<uid>/… answers Could not print domain: 125 — "Domain does not support specified action". The service-manager probe treated any non-112/113/0 exit as "could not ask", so ownership came back unknown and every Codex write delegated nothing and refused.

Like 112, the 125 for a gui/<uid> domain is a label-independent answer about the domain itself — an unreachable GUI domain cannot be holding our job. The probe now counts gui/* 125 as an unreachable domain (proven-absent when nothing is staged on disk, present-registration-absent when the plist is there), while a 125 from the user/<uid> domain still fails closed as unknown.

  • src/service-manager-probe.ts: recognize LAUNCHCTL_DOMAIN_UNSUPPORTED_ACTION = 125 in the gui/ domain loop.
  • tests/codex-integration/codex-service-manager-probe.test.ts: four regression tests — GUI 125 + user 113 with and without a staged plist, GUI 125 + loaded user domain, and user-domain 125 still unknown.

Verification

  • bun test tests/codex-integration/codex-service-manager-probe.test.ts — 118 pass / 1 skip / 0 fail.
  • bun run typecheck — clean.
  • Repro-first: the three unknown-expecting scratch repro tests from the issue failed on the pristine tree and pass with the fix; they were then merged into the existing suite.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (N/A — probe-internal behavior.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (Probe remains read-only; only launchctl print is issued.)

Summary by CodeRabbit

  • Bug Fixes
    • Improved macOS service detection when the GUI service domain is unavailable. The app now continues checking the user service domain, helping it correctly distinguish absent services, installed services, and registered services.
    • An unavailable user service domain is still reported as an unknown status rather than as an absent service.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

…omain answer

On a headless macOS session launchctl print gui/<uid>/<label> exits 125
("Domain does not support specified action") before ever looking at the
label. The probe returned unknown at that point, skipping the user-domain
query and the plist checks, so absence could never be proven and every
admission-gated write was fenced on a machine with nothing installed.

125 from the gui/ domain is now counted like 112 - a label-independent
answer about the domain - and the probe continues to the user domain and
the on-disk definition checks. A user-domain 125 stays unknown: the
fallback must be able to answer, so its failure is a failure to ask.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 9f0d40a and 4d7bacf.

Files selected for processing: 2
  • src/service-manager-probe.ts
  • tests/codex-integration/codex-service-manager-probe.test.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

The launchd probe now continues to the user-domain query when the GUI-domain query exits with status 125. It uses the user-domain response and plist state to determine whether the service is absent or present. A user-domain status 125 still produces an unknown result.

Changes: Headless launchd probe

Layer / File(s) Summary
Handle GUI-domain status 125
src/service-manager-probe.ts
Lines 223–234 define status 125 as an unsupported GUI-domain action. Lines 372–382 continue to the user-domain query only for GUI-domain status 125. Lines 394–400 include that response when determining absence from an unstaged plist.
Verify domain and plist outcomes
tests/codex-integration/codex-service-manager-probe.test.ts
Lines 245–299 test GUI-domain status 125 followed by user-domain statuses 113 and 0, staged and absent plists, and a user-domain status 125.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 4d7ba

The change appears ready to merge after normal checks; no specific issue requiring a fix was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: handling launchctl exit status 125 on the GUI domain as an unreachable domain. It matches the implementation and stated objective.
Linked Issues check Passed Issue #7697 requires the probe to treat exit 125 as an unreachable response only for gui/<uid>, continue to user/<uid>, preserve plist and registration checks, and keep user-domain failures unknow…
Out of Scope Changes check Passed The whole-PR diff changes only src/service-manager-probe.ts and its focused regression test file. The source change is limited to the linked issue's GUI-domain exit-125 handling and related comments…
Full details: Linked Issues check

Explanation

Issue #7697 requires the probe to treat exit 125 as an unreachable response only for gui/&lt;uid&gt;, continue to user/&lt;uid&gt;, preserve plist and registration checks, and keep user-domain failures unknown. src/service-manager-probe.ts adds LAUNCHCTL_DOMAIN_UNSUPPORTED_ACTION = 125 and increments unreachableDomains only when domain.startsWith("gui/"); the existing timeout and spawn-failure checks still return unknown before status handling. The added tests in tests/codex-integration/codex-service-manager-probe.test.ts verify GUI 125 with user 113 returns absent without a plist, preserves a staged plist with absent registration, detects a loaded user-domain job, and keeps user-domain 125 as unknown.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff changes only src/service-manager-probe.ts and its focused regression test file. The source change is limited to the linked issue's GUI-domain exit-125 handling and related comments. The four tests directly cover the required behavior and the negative user-domain case. No unrelated production behavior, cleanup, or documentation change is present.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 25, 2026
@github-actions github-actions Bot changed the title fix(service): treat launchctl 125 on the GUI domain as an unreachable domain (#7697) [WRONG BRANCH] fix(service): treat launchctl 125 on the GUI domain as an unreachable domain (#7697) Oct 25, 2026
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.
  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.
@chenyb999-zhcn Tick the boxes once required local validation has passed with commands, results, and any full-suite exception documented, your branch is on the latest dev commit, and every correct Codex and CodeRabbit finding is resolved.

@lidge-jun

Copy link
Copy Markdown
Owner

Release decision (v2.93.0 dev-merge, maintainer triage lane): CARRIED to dev as #7745. This PR targets main, which only moves by release promotion, so it cannot merge as is. Your commit is cherry-picked unchanged with authorship kept, and the PR carries Co-authored-by. Closing this one in favour of #7745.

#7745 is not merging for 2.93.0. Review asked for native macOS evidence that launchctl print gui/<uid>/<label> cannot exit 125 while a GUI-domain job is still loaded, because the probe gates Codex write admission. The exact checks are listed in #7745 (#7745 (comment)). If you can run them on a Mac, posting the outputs there is the fastest way to get it landed. Thank you for the precise report and the regression tests.

@lidge-jun lidge-jun closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Headless GUI launchctl exit 125 prevents service-manager absence proof

2 participants