Skip to content

fix(service): address launchd gui/<uid> domain explicitly in install and stop - #17492

Merged
buluoray merged 1 commit into
mainfrom
fix/launchd-gui-domain-install-stop-11017
Oct 9, 2026
Merged

buluoray merged 1 commit into
mainfrom
fix/launchd-gui-domain-install-stop-11017

Conversation

@buluoray

@buluoray buluoray commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On macOS, kirocrew service install puts the gateway agent in the launchd domain that restart, stop and the status probes all address, including when it is run over SSH, and kirocrew stop no longer reports success when launchd refused the stop.

install() used launchctl load -w <plist> and stop() used launchctl unload <plist>. Those legacy verbs act on the caller's own domain. From a desktop session that is gui/<uid>, the domain restart()'s kickstart -k gui/<uid>/<label> and Dev Fleet's probe already name. From SSH it is user/<uid>, so the agent lands where restart cannot reach it, and stop_service() falls through to the port-SIGTERM path, which KeepAlive undoes at once. Separately, stop() returned None and stop_service() returned True for any stop, so a refused unload printed "✅ Stopped kirocrew service".

Why it matters

Anyone running the gateway on a Mac they reach over SSH (the module supports headless flows; see headless_auth_warning) gets an agent that kirocrew restart/stop cannot control, and a CLI that says the stop worked when it did not.

Not a goal

What changed (motivation → approach → change)

Symptom: an install from SSH lands the job where the other verbs do not look, and a refused stop is reported as a stop. Root cause: two write verbs act on whatever domain the caller is in, while every other verb names gui/<uid>. Fix (options 1 and 3 from the issue):

  • install(): launchctl enable gui/<uid>/<label>, then launchctl bootstrap gui/<uid> <plist>. enable takes over the job load -w did of clearing a persistent disabled override, which an older uninstall wrote with unload -w (without it, reinstalling after a legacy uninstall would be refused).
  • No desktop login: there is then no gui/<uid> domain, and launchd answers 125: Domain does not support specified action. On that answer only, install runs enable + bootstrap into user/<uid> instead and logs which domain it used. This keeps the install working where load -w from SSH succeeded before (the owner asked for this fallback). Any other bootstrap refusal still raises ServiceInstallError.
  • Migration: on reinstall, _bootout() boots out an agent an older load -w left behind, searching gui/<uid> then user/<uid>. Because bootout is asynchronous (see pod/launchd.stop), it polls print until the label is gone, for up to 10s, before bootstrapping. Without that wait, bootstrap would hit the label that has not finished unloading.
  • stop(): launchctl bootout <domain>/<label> over the same domains, returning bool. bootout takes the job out of the domain, so KeepAlive has nothing to respawn. The plist and its enabled state stay in place for the next login, so the no-respawn property of unload without -w is kept. A definite "not found", or 125 from a missing domain, means no job there and the next domain is tried; any other refusal is logged and returns False.
  • restart(): kickstart -k on gui/<uid> then user/<uid>, the same order and the same "not found / 125 means try the next domain" rule, so it reaches an agent the no-desktop fallback installed. Any other refusal returns False.
  • uninstall(): the same bootout, then the plist is removed.
  • is_loaded() (new): launchctl print <domain>/<label> over gui/<uid> then user/<uid>. Only "not found" or 125 counts as absent, so a flaky probe never reads as "nothing installed".
  • controller.restart_service() gates on is_loaded() instead of the caller-domain is_active(). From SSH, is_active() misses a gui/<uid> job, so a CLI restart got an empty report and fell to the SIGTERM-by-port + detached-spawn path, starting an unmanaged gateway beside the KeepAlive one. It now kickstarts the service job.
  • controller.stop_service() calls macos.stop() directly and returns its bool, instead of gating on is_active() (which from SSH misses a gui/<uid> job) and returning a hard-coded True.
  • Spec: docs/system-specs/modules/cli.md, launchd section.

Backwards compatibility

No install that succeeded before should now fail (checked against source only, not on a real Mac). A desktop install still lands in gui/<uid>. An SSH install with someone logged in at the desktop now lands in gui/<uid> instead of user/<uid>. An SSH install with nobody at the desktop falls back to user/<uid>, the domain load -w used, and restart, stop, uninstall and reinstall all reach it there. Remaining gap: is_active() / status() still read the caller's domain, so from a desktop session they do not see a fallback user/<uid> job; #11016 covers those probes. Writer sweep: the only callers of macos.install() / macos.stop() / macos.restart() are in service/controller.py. install_service already catches ServiceInstallError and prints it.

Reader: src/kiro_crew/service/controller.py:stop_service -- entry: chat|release (CLI kirocrew stop) -- calls macos.stop() and passes its bool through; test_stop_service_propagates_the_launchd_answer, test_kirocrew_stop_from_ssh_boots_out_the_gui_job
Reader: src/kiro_crew/cli_server.py:_stop -- entry: release (CLI) -- already branches on stop_service()'s bool; a False takes the existing non-service path
Reader: src/kiro_crew/service/macos.py:restart -- entry: release -- tries gui/<uid> then user/<uid>; test_install_from_ssh_lands_where_restart_and_stop_address_it, test_install_without_a_desktop_session_falls_back_to_the_user_domain
Reader: src/kiro_crew/service/controller.py:restart_service -- entry: release (CLI restart command) -- gates on macos.is_loaded(); test_kirocrew_restart_from_ssh_kickstarts_the_service_job, test_kirocrew_restart_with_nothing_loaded_leaves_it_to_the_foreground_path
Reader: src/kiro_crew/service/macos.py:is_active/status -- entry: release -- untouched; they read the caller's domain until #11016, and is_service_active() still uses is_active()

Tests

All run with launchctl stubbed. This host is Linux, so the narrowest honest check is the argv the module builds, run against a stateful launchctl stand-in. The stand-in models the one behaviour at issue: load/unload act on the caller's domain, while bootstrap/bootout/print/kickstart name one. It also models a persistent disabled override and the asynchronous bootout, and with no desktop login it answers 125 for every gui/<uid> verb.

New test/test_service_macos_launchd_domain.py (20 tests):

  • an install from SSH lands in gui/<uid>, after which restart() and stop() both succeed; kirocrew stop from SSH boots out the gui/<uid> job, and reports no stop when nothing is loaded; a CLI restart from SSH kickstarts the service job with and without a desktop session, and leaves a not-loaded agent to the foreground path;
  • an install with no desktop session falls back to user/<uid>, logs it, and restart() and stop() then reach it; reinstall and uninstall reach that job too; a bootstrap refusal other than 125 raises and does not fall back;
  • reinstall migrates a legacy load -w job from gui/<uid> and from user/<uid>, waits for the async bootout, and clears a legacy disabled override;
  • stop() returns False for a refused bootout and for nothing loaded, finds a legacy user/<uid> job, leaves the plist enabled, and never calls stop/disable/-w;
  • uninstall() boots out by domain; stop_service() passes on True and False.

Red on base (the file run against origin/main's service/macos.py and service/controller.py): 16 failed, 4 passed. The four that pass are guards for behaviour base already had: the disabled override cleared by load -w, kirocrew stop reporting no stop with nothing loaded, a CLI restart with nothing loaded taking the foreground path, and a no-desktop reinstall/uninstall, which load -w/unload already handled in the caller's user/<uid> domain.

Mutation matrix (each one applied alone; every one turns at least one named test red):

Mutation Reddens
drop enable ..._clears_a_disabled_override_left_by_legacy_uninstall
no settle wait in install ..._migrates_a_legacy_load_w_job[gui,user], ..._waits_for_the_async_bootout_...
search gui/<uid> only ..._migrates_a_legacy_load_w_job[user], test_stop_still_finds_a_legacy_user_domain_job
controller hard-codes True test_stop_service_propagates_the_launchd_answer[False]
restore the is_active() gate in stop_service test_kirocrew_stop_from_ssh_boots_out_the_gui_job and others
absent counts as stopped test_stop_with_nothing_loaded_is_not_a_stop
install back to load -w 6 install tests
remove the user/<uid> install fallback test_install_without_a_desktop_session_falls_back_to_the_user_domain
fall back on any bootstrap refusal test_install_fails_on_a_refusal_other_than_an_unavailable_domain
bootout treats 125 as a refusal test_install_without_a_desktop_session_falls_back_to_the_user_domain, test_reinstall_and_uninstall_without_a_desktop_session_reach_the_user_job
restart tries gui/<uid> only test_install_without_a_desktop_session_falls_back_to_the_user_domain
restart_service gated on is_active() again test_kirocrew_restart_from_ssh_kickstarts_the_service_job[desktop]
is_loaded() probes gui/<uid> only test_kirocrew_restart_from_ssh_kickstarts_the_service_job[no-desktop]

Updated in test/test_service.py: tests that pinned the old load/unload argv, or a stop() mock without a return value, now pin bootstrap/bootout and the bool, and the three restart_service launchd pins patch is_loaded. Runs: test/test_service_macos_launchd_domain.py 20 passed; test/test_service.py 442 passed.

Overlap with #11016, measured with git merge-tree --write-tree HEAD pr/11016: macos.py and test_service.py auto-merge. The two cli.md conflicts (lines ~239 and ~1466) are identical to the ones git merge-tree origin/main pr/11016 already reports, so this PR adds none.

Manual verification

Not run on a real Mac, because this host cannot run launchd. Still to check on macOS:

  • From an SSH session while logged in at the desktop: kirocrew service install, then launchctl print gui/$(id -u)/dev.kirocrew.gateway (rc 0), kirocrew restart, kirocrew stop (agent gone and not respawned).
  • From SSH with nobody logged in at the desktop: kirocrew service install succeeds and logs the user/<uid> fallback, launchctl print user/$(id -u)/dev.kirocrew.gateway (rc 0), then kirocrew restart and kirocrew stop both succeed. Also capture what launchctl bootout gui/$(id -u)/dev.kirocrew.gateway answers in that state: the stand-in assumes 125.

Related Issues

Closes #11017
Related: #11016 (read-only probes; no shared hunks)

Pattern harvest

Rule candidate: review-prompt
Pattern: a launchctl verb that addresses the caller's domain implicitly (load, unload, list <label>) in a module where other verbs name gui/<uid> explicitly.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@buluoray
buluoray requested a review from a team as a code owner October 6, 2026 19:13
@buluoray
buluoray requested a review from CrysisDeu October 6, 2026 19:13
@buluoray
buluoray force-pushed the fix/launchd-gui-domain-install-stop-11017 branch 2 times, most recently from 0166018 to 4de4344 Compare October 6, 2026 19:46
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ human override accepted

@buluoray overrode this lane for ac69d5147e2f93602ff0d45db327879197ed8202 via /ai-review override (this commit only).

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ human override accepted

@buluoray overrode this lane for ac69d5147e2f93602ff0d45db327879197ed8202 via /ai-review override (this commit only).

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed ac69d5147e2f93602ff0d45db327879197ed8202 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] ac69d51

Verdict parsed from the review's SHA-scoped output markers for commit ac69d5147e2f93602ff0d45db327879197ed8202.

False positive or not applicable? A repository writer can comment:
/ai-review override fable ac69d5147e2f93602ff0d45db327879197ed8202: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of ac69d5147e2f93602ff0d45db327879197ed8202 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] ac69d51

False positive or not applicable? A repository writer can comment:
/ai-review override gpt ac69d5147e2f93602ff0d45db327879197ed8202: <one-sentence reason>

@buluoray
buluoray force-pushed the fix/launchd-gui-domain-install-stop-11017 branch from 4de4344 to 4bae3c3 Compare October 6, 2026 22:30
@buluoray

buluoray commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Disposition of the Design Review and First Principles Review BLOCKs on 4de4344820, addressed in 4bae3c3c2f:

Design: stop_service() gated on the caller-domain is_active() — agreed, real defect. stop_service() on launchd no longer consults is_active(); it calls macos.stop(), which searches gui/<uid> then user/<uid> and returns False when nothing is loaded or launchd refused the bootout. New test test_kirocrew_stop_from_ssh_boots_out_the_gui_job drives the controller from a user/<uid> caller session (the fake launchctl list reads the caller's domain, so is_active() is False) and asserts the gui job is booted out. Re-adding the gate reddens 5 named tests (measured). is_active() itself is untouched so this does not overlap #11016; restart_service()'s gate is the same is_active() and is fixed by #11016.

First Principles item 7: duplicated helpers — agreed. service/macos.py no longer defines _ABSENT_MARKERS, _absent or _gui_domain; it uses pod.launchd._service_absent and pod.launchd.domain().

Both: no real-Mac run / unverified bootout not-loaded wording — not clearable from this Linux host. Verification remains a stateful launchctl stand-in. A real-Mac run (desktop install/restart/stop/reinstall; SSH install then kirocrew stop with no respawn; posted bootout output for a not-loaded label) is needed from someone with a Mac.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 7, 2026
@buluoray
buluoray force-pushed the fix/launchd-gui-domain-install-stop-11017 branch from 4bae3c3 to fac8f4a Compare October 8, 2026 13:57
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision ac69d5147e2f93602ff0d45db327879197ed8202 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 8, 2026
@buluoray
buluoray force-pushed the fix/launchd-gui-domain-install-stop-11017 branch from fac8f4a to 8ea30cc Compare October 8, 2026 21:18
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 8, 2026
@buluoray
buluoray force-pushed the fix/launchd-gui-domain-install-stop-11017 branch from 8ea30cc to f30c8a5 Compare October 8, 2026 21:58
@buluoray

buluoray commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Disposition of the reviews on 8ea30cc, fixed in f30c8a5 (one push, rebased onto main):

  • Opus: _bootout stops at gui/ with no desktop (fixed). A 125 answer from the missing gui domain was read as a refusal, so stop, uninstall and reinstall never reached the user/ fallback job. _bootout now treats 125 like "not found" and moves on to the next domain. The stand-in launchctl now answers 125 for every gui/ verb when there is no desktop, and test_reinstall_and_uninstall_without_a_desktop_session_reach_the_user_job fails without the fix.
  • Opus and Design: restart() cannot reach a user/ job (fixed). restart() now runs kickstart -k on gui/ and then user/, the same domains install can bootstrap into. Any other refusal still returns False. The fallback test now asserts that restart succeeds through the user-domain kickstart, and removing the second domain makes it fail.
  • Design and First Principles: the description contradicts the user/ fallback. The code is correct; the PR description is out of date. The owner ruled that the fallback must be added, because without it an SSH install with nobody at the desktop fails where load -w used to succeed. The description's Not a goal and Breaking sections, which promise a failure, need rewriting to describe the fallback. I have not edited the body; that edit is left to the conductor.
  • First Principles item 5: duplicate settle poll (not changed). pod.launchd.stop is tied to a PodConfig pod: it deletes that pod's plist and builds its own failure. Sharing one settle loop would mean refactoring pod code, which is outside this PR.
  • GPT (stale, fac8f4a): "every verb" overclaims (fixed). cli.md and the install() docstring now say that is_active and status still read the caller's domain.

Tests: 17 passed in test/test_service_macos_launchd_domain.py and 442 passed in test/test_service.py. Behaviour was checked against the stand-in launchctl only, not on a real Mac.

@buluoray

buluoray commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Description updated at the owner's request: the owner asked for SSH installs on a Mac with no desktop login to keep working, so this PR now falls back to user/<uid> when gui/<uid> is unavailable, and restart/stop/uninstall search both domains. The Not a goal and Backwards compatibility sections now describe that fallback instead of a failing install. The Goal line is unchanged.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@buluoray
buluoray force-pushed the fix/launchd-gui-domain-install-stop-11017 branch from f30c8a5 to ac69d51 Compare October 8, 2026 22:48
@buluoray

buluoray commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Disposition of the reviews on f30c8a5, fixed in ac69d51 (one push, rebased onto main):

  • Design and First Principles item 6: restart_service() still gated on is_active() (fixed). Confirmed at controller.py:351. Over SSH, the launchctl list probe reads the caller's domain and misses the gui/<uid> job, so the CLI's restart command got an empty report and fell through to SIGTERM-by-port plus a detached spawn beside the KeepAlive job. A new macos.is_loaded() probes launchctl print <domain>/<label> on gui/<uid> and then user/<uid>, and restart_service() now gates on it; only "not found" or 125 counts as absent. New tests: test_kirocrew_restart_from_ssh_kickstarts_the_service_job[desktop,no-desktop] and ..._with_nothing_loaded_leaves_it_to_the_foreground_path. Restoring the is_active() gate fails [desktop]; making is_loaded() probe gui/<uid> only fails [no-desktop]. The three existing restart_service pins in test/test_service.py now patch is_loaded. is_active(), status() and is_service_active() are unchanged (fix(service): probe launchd by domain target on macOS #11016 covers them).
  • First Principles item 2: the fallback relies on launchd answering 125 (not changed). That needs a real-Mac run, already listed under Manual verification, and is left to the owner.

Tests: test/test_service_macos_launchd_domain.py 20 passed and test/test_service.py 442 passed, against a launchctl stand-in only.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 8, 2026
@buluoray

buluoray commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

/ai-review override design ac69d51: the only open finding is the request for a run on a real Mac. The code was verified against source and a stateful launchctl stand-in (install, stop, uninstall and restart across gui/ and user/, with tests that redden on each reverted guard). An SSH install with no desktop login now falls back to user/, so no install that worked before can fail. No Mac is available on this host; the owner ruled this override acceptable on that basis.

@buluoray

buluoray commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

/ai-review override first-principles ac69d51: item 2 is the same real-Mac evidence request (owner ruled the override acceptable; no Mac on this host). Item 6 is stale: the PR body was updated after this verdict and now declares the restart_service() gate on macos.is_loaded(), and the Goal line stands.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@buluoray marked the design AI finding as false positive, not applicable, or explicitly accepted for ac69d5147e2f93602ff0d45db327879197ed8202.

the only open finding is the request for a run on a real Mac. The code was verified against source and a stateful launchctl stand-in (install, stop, uninstall and restart across gui/ and user/, with tests that redden on each reverted guard). An SSH install with no desktop login now falls back to user/, so no install that worked before can fail. No Mac is available on this host; the owner ruled this override acceptable on that basis.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@buluoray marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for ac69d5147e2f93602ff0d45db327879197ed8202.

item 2 is the same real-Mac evidence request (owner ruled the override acceptable; no Mac on this host). Item 6 is stale: the PR body was updated after this verdict and now declares the restart_service() gate on macos.is_loaded(), and the Goal line stands.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 8, 2026

@CrysisDeu CrysisDeu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at ac69d51. Read the full diff plus the owning spec; nothing blocking. Non-blocking notes, worth a follow-up or a quick fix before merge:

  • [MINOR] src/kiro_crew/service/macos.py (_bootout, return True after the first domain that accepts) -- the module now explicitly models the agent living in gui/<uid> OR user/<uid>, but a job can exist in BOTH: after the no-desktop fallback bootstraps into user/<uid>, the plist is still in ~/Library/LaunchAgents, so the next desktop login loads it into gui/<uid> as well (two gateways, one label; the second loses the port bind and KeepAlive loops it). stop()/uninstall()/reinstall then boot out only the first hit and return True while the user/<uid> instance keeps running; restart() likewise kickstarts only the first. Sweep every domain in _bootout (and restart) rather than returning on the first acceptance -- it is the same loop, and is_loaded() already probes both. The dual-domain state was equally reachable with the old load -w from SSH, so this is not a regression, but the PR is the one introducing the two-domain model and should close it (or at least name it in cli.md).
  • [NIT] src/kiro_crew/service/macos.py (_domain_unavailable) -- matches only rc 125 / "125: domain does not support". The stand-in encodes that same assumption for every gui/ verb (print, bootout, kickstart), but on a real Mac with nobody logged in launchctl print gui/<uid>/<label> can answer "Could not find domain for gui/" instead. If it does, is_loaded() reads "loaded" (fail-closed by design), restart() returns False without trying user/<uid>, and _bootout logs a refusal. Cheap hardening: add "could not find domain" to the absent/unavailable test. (The need for a real-Mac transcript is already recorded and overridden by the owner; this is a one-line mitigation, not a repeat of that ask.)
  • [NIT] src/kiro_crew/service/macos.py (_uid) duplicates the getattr(os, "getuid", lambda: -1) guard that pod.launchd.domain() already carries; _legacy_domains() could derive user/<uid> from domain().split("/", 1)[1] and drop the helper.

@buluoray
buluoray merged commit 1a0dd2e into main Oct 9, 2026
115 of 118 checks passed
@buluoray
buluoray deleted the fix/launchd-gui-domain-install-stop-11017 branch October 9, 2026 05:27
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 9, 2026
iamwhatever pushed a commit that referenced this pull request Oct 19, 2026
is_active() and status() used `launchctl list <label>`, which reads only
the caller's domain and can exit non-zero with empty output for a
serving gui/<uid> agent, so `kirocrew service status` called a running
gateway "not loaded". Both now probe `launchctl print <domain>/<label>`
over gui/<uid> then user/<uid>, the same domains install, stop and
restart address since #17492. status() renders a terse summary (domain,
state, pid, non-zero last exit, plist path).

Adds darwin-only tests that bootstrap throwaway agents into the real
gui/<uid> domain and read running, never-started, exited and absent
states back through the module.

Closes #11002

Co-authored-by: Di Wu <dwu96@users.noreply.github.com>
iamwhatever pushed a commit that referenced this pull request Oct 19, 2026
is_active() and status() used `launchctl list <label>`, which reads only
the caller's domain and can exit non-zero with empty output for a
serving gui/<uid> agent, so `kirocrew service status` called a running
gateway "not loaded". Both now probe `launchctl print <domain>/<label>`
over gui/<uid> then user/<uid>, the same domains install, stop and
restart address since #17492. status() renders a terse summary (domain,
state, pid, non-zero last exit, plist path). `service status` exits on
a new is_up() (state = running), so a crash-looping agent exits 1 as on
Linux, while is_active() keeps loaded-counts-as-active for reach.

Closes #11002

Co-authored-by: Di Wu <dwu96@users.noreply.github.com>
iamwhatever pushed a commit that referenced this pull request Oct 19, 2026
is_active() and status() used `launchctl list <label>`, which reads only
the caller's domain and can exit non-zero with empty output for a
serving gui/<uid> agent, so `kirocrew service status` called a running
gateway "not loaded". Both now probe `launchctl print <domain>/<label>`
over gui/<uid> then user/<uid>, the same domains install, stop and
restart address since #17492. status() renders a terse summary (domain,
state, pid, non-zero last exit, plist path). `service status` exits on
a new is_up() (state = running), so a crash-looping agent exits 1 as on
Linux, while is_active() keeps loaded-counts-as-active for reach.

Closes #11002

Co-authored-by: Di Wu <dwu96@users.noreply.github.com>
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.

macOS: install() and stop() address launchd domain-implicitly (load -w / unload), diverging from the gui/<uid> target every other verb addresses

2 participants