Repository navigation
fix: boot out a loaded macos agent on install even without its plist - #35560
Conversation
Code change approver recommendation: ApproveWhy: the decider estimates a 6% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. This fixes reinstall on macOS when the old agent is still loaded but its plist is gone. install() now always calls _bootout(wait=True) instead of only when PLIST_PATH exists. When nothing is loaded, _bootout skips a domain that answers not-found, "No such process" or 125; any other refusal logs a warning and install still bootstraps, as before when the plist was present. So a clean first install behaves as before. The new test would fail on main: the launchctl stand-in refuses a bootstrap over a label that is still loaded. The reworked refusal test still checks the same thing (only 125 falls back to user/). Two stub tests set the settle time to 0 because the bootout now always runs. The only caller is the CLI An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
a04ac24 to
dbbb1f2
Compare
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
dbbb1f2 to
cb7c19e
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. Asking launchd directly fixes the root cause, which was using the plist on disk as a stand-in for a loaded job, and a clean first install still ends in the same bootstrap. Notes
[DESIGN-REVIEWED] 9407be6 Description read[DESCRIPTION-READ] 7309a7fb3434924b24ddafc70e54ca3117534d70988ecd18c415e913a7511655 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The PR deletes one guard, Not checked: real launchd behaviour on macOS when a job is loaded but its plist is gone; the tests model it. What this change shipsInventory (4 items) — 4 justifiedIntent: a Mac user can reinstall the service when the old agent is still loaded but its plist is gone. FIX (#35559).
[FIRST-PRINCIPLES-REVIEWED] 9407be6 Description read[DESCRIPTION-READ] 4188746c3fc34d2925131f48c3e90ff71d5a59e064e75509e7aef6f2aa3c930e That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
kirocrew service install on macOS booted the old agent out only when its plist existed. A job that is still loaded with no plist (an uninstall whose bootout launchd refused deletes the plist anyway, or the file was removed by hand) was left in place, and the bootstrap that followed failed with "5: Input/output error". Re-running install never recovered; only a manual launchctl bootout did. Boot out unconditionally before writing the plist. _bootout already treats a job that is not loaded as nothing to do, so a clean install behaves as before.
cb7c19e to
9407be6
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approving. I read the full diff at 9407be6.
install()now calls_bootout(wait=True)whether or not the plist exists, so a job left loaded with no plist no longer makesbootstrapfail with5: Input/output error.- I checked main's
_bootout. On a fresh install, each domain answers "not found" or125(_service_absent/_domain_unavailable), so it returns False with no settle wait and no raise.install()ignores that return value. A first install behaves as before. test_install_boots_out_a_loaded_job_whose_plist_is_gonecovers the fix. The refusal test now uses a real plist andrefuse_bootout, so it still checks the refused-bootstrap path.- No regex. No new refusal.
Not checked: I ran no tests locally and relied on CI. The cancelled GPT 6.1 Review run has a newer success on this head.
Problem / Motivation
Goal:
kirocrew service installon macOS works again when the old agent is still loaded but its plist is gone.install()insrc/kiro_crew/service/macos.pybooted the old agent out only when its plist existed. The agent can stay loaded with no plist:uninstall()removes the plist even when launchd refused the bootout, and a user can delete the file by hand. The bootstrap that followed then failed with5: Input/output error, and re-running install failed the same way every time.Why it matters
A Mac user in this state cannot reinstall the service at all, and the error names no cause; only a hand-run
launchctl bootoutgets them out.Not a goal
uninstall,stop,restartoris_loadeddo when the plist is missing.service statusprobing the caller's domain (tracked in macOS: service status/is_active probe launchd with legacylaunchctl list <label>, which fails for a gui-domain agent — a running gateway reports "not loaded (no entry)" #11002 / fix(service): probe launchd by domain target on macOS #11016).What changed (motivation → approach → change)
Symptom:
launchctl bootstrapfails with5: Input/output erroron install. Root cause:if PLIST_PATH.exists(): _bootout(wait=True)skips the bootout for a job that is loaded without its file, and bootstrap refuses a label already held. Change: call_bootout(wait=True)unconditionally before writing the plist._bootoutalready treats a job that is not loaded in any searched domain as nothing to do (No such process/125move on), so a clean install behaves as before.docs/system-specs/modules/cli.mdnow says the reinstall bootout runs whether or not the plist is on disk.Backwards compatibility
Compatible: a first install and a reinstall with the plist present run the same launchctl verbs as before; only the plist-less case now boots out first.
Removes nothing: no key, path or record is taken away.
Tests
test/test_service_macos_launchd_domain.py:gui/<uid>with no plist; install succeeds and boots out before bootstrapping.125falls back touser/<uid>).test/test_service.py::TestMacOSPlistRendering::test_install_writes_plist_and_loadsandtest/test_host_service_guard.py::TestLaunchdRedirect::test_install_writes_the_launcher_into_tmp_not_the_real_home: their stubs answer every launchctl verb rc 0, so the now-unconditional bootout never reads as settled; both pin_BOOTOUT_SETTLE_SECSto 0, astest/test_service_macos_control.pyalready does.test/test_service*.pyandtest/test_host_service_guard.pytests pass.Proof: PROVEN test/test_service_macos_launchd_domain.py::test_install_boots_out_a_loaded_job_whose_plist_is_gone (head 9407be6)
Manual verification
Not done: needs a Mac with the agent loaded and its plist removed. The launchctl stand-in in
test_service_macos_launchd_domain.pymodels launchd's refusal of a bootstrap over a held label.Related Issues
Fixes #35559
Sibling sweep
Swept: grep -n "PLIST_PATH.exists" src/kiro_crew/service/.py src/kiro_crew/.py
Sibling: src/kiro_crew/service/macos.py:install -- changed here
Sibling: src/kiro_crew/service/macos.py:uninstall -- not affected -- it already reports the domain that still holds the job, and test_uninstall_with_nothing_installed_only_asks_launchd pins that it boots nothing out without a plist
Sibling: src/kiro_crew/service/macos.py:stop -- not affected -- documented to return False when the plist is absent
Sibling: src/kiro_crew/service/macos.py:is_loaded -- not affected -- documented plist gate; _loaded_domain is the plist-free probe
Sibling: src/kiro_crew/service/macos.py:restart -- not affected -- documented to return False when the plist is absent
Sibling: src/kiro_crew/service/gateway_identity.py -- not affected -- reads the plist, does not gate a bootout
Sibling: src/kiro_crew/service/controller.py -- not affected -- reads the plist, does not gate a bootout
Sibling: src/kiro_crew/cli_server.py -- not affected -- reads the plist, does not gate a bootout
Pattern harvest
Not generalizable: one install step used the plist as a stand-in for "launchd holds the job", which every other bootout path asks launchd directly.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.