Skip to content

fix: boot out a loaded macos agent on install even without its plist - #35560

Merged
RohanK6 merged 1 commit into
mainfrom
crew/conductor/macos-install-bootout-without-plist
Nov 12, 2026
Merged

RohanK6 merged 1 commit into
mainfrom
crew/conductor/macos-install-bootout-without-plist

Conversation

@RohanK6

@RohanK6 RohanK6 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: kirocrew service install on macOS works again when the old agent is still loaded but its plist is gone.

install() in src/kiro_crew/service/macos.py booted 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 with 5: 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 bootout gets them out.

Not a goal

What changed (motivation → approach → change)

Symptom: launchctl bootstrap fails with 5: Input/output error on 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. _bootout already treats a job that is not loaded in any searched domain as nothing to do (No such process / 125 move on), so a clean install behaves as before.

docs/system-specs/modules/cli.md now 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:
    • "test_install_boots_out_a_loaded_job_whose_plist_is_gone" (new): a job loaded in gui/<uid> with no plist; install succeeds and boots out before bootstrapping.
    • "test_install_fails_on_a_refusal_other_than_an_unavailable_domain": it produced its bootstrap refusal through the plist-less state this PR fixes. It now gets it from a bootout launchd refuses, and asserts the same thing (only 125 falls back to user/<uid>).
  • test/test_service.py::TestMacOSPlistRendering::test_install_writes_plist_and_loads and test/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_SECS to 0, as test/test_service_macos_control.py already does.
  • 825 test/test_service*.py and test/test_host_service_guard.py tests 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.py models 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • 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.

@RohanK6
RohanK6 requested review from a team and KiroCrewCaptain as code owners November 11, 2026 20:29
@RohanK6
RohanK6 requested a review from buluoray November 11, 2026 20:29
@KiroCrewCaptain

KiroCrewCaptain commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: 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 service install path. The sibling functions (uninstall, stop, restart, is_loaded) are unchanged, as the PR says. The cli.md update matches the code, and CI is green.

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 9407be6d2c · 36 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 11, 2026
@RohanK6
RohanK6 force-pushed the crew/conductor/macos-install-bootout-without-plist branch from a04ac24 to dbbb1f2 Compare November 12, 2026 03:04
@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 Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 9407be6

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 9407be6d2c7c2bd9baa2eb4f9dac1e8b3c05a080 false-positive: <reason, 20 to 500 characters>

@RohanK6
RohanK6 force-pushed the crew/conductor/macos-install-bootout-without-plist branch from dbbb1f2 to cb7c19e Compare November 12, 2026 05:16
@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 Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 9407be6d2c7c2bd9baa2eb4f9dac1e8b3c05a080 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 9407be6d2c7c2bd9baa2eb4f9dac1e8b3c05a080 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • On a first install, _bootout now always runs. _ABSENT_MARKERS has "could not find service", but launchctl's error 113 text, "Could not find specified service", does not contain that string. If bootout answers with 113, a clean install logs a "bootout refused" warning and skips the user/<uid> probe. The install itself still succeeds, so this is only noise, but check it on a Mac.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 9407be6d2c7c2bd9baa2eb4f9dac1e8b3c05a080 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The PR deletes one guard, PLIST_PATH.exists(), which stood in for "launchd holds the job". _bootout already asks launchd that directly and skips a domain that answers not-found or 125.

Not checked: real launchd behaviour on macOS when a job is loaded but its plist is gone; the tests model it.

What this change ships

Inventory (4 items) — 4 justified

Intent: a Mac user can reinstall the service when the old agent is still loaded but its plist is gone. FIX (#35559).

  1. service install now boots out a loaded agent even when its plist is missing, so bootstrap no longer fails with 5: Input/output error — justified
  2. The cli.md install section says the reinstall bootout runs whether or not the plist is on disk — justified
  3. The existing refusal-path test now gets its bootstrap refusal from a bootout launchd refuses, not from the plist-less state; the description states this — justified
  4. Two install tests set _BOOTOUT_SETTLE_SECS to 0 because the bootout is now unconditional — justified

[FIRST-PRINCIPLES-REVIEWED] 9407be6

Description read

[DESCRIPTION-READ] 4188746c3fc34d2925131f48c3e90ff71d5a59e064e75509e7aef6f2aa3c930e

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 9407be6

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 9407be6d2c7c2bd9baa2eb4f9dac1e8b3c05a080 false-positive: <reason, 20 to 500 characters>

@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 Nov 12, 2026
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.
@RohanK6
RohanK6 force-pushed the crew/conductor/macos-install-bootout-without-plist branch from cb7c19e to 9407be6 Compare November 12, 2026 12:18
@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 Nov 12, 2026
@RohanK6
RohanK6 enabled auto-merge (squash) November 12, 2026 13:34

@bolichen97 bolichen97 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. 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 makes bootstrap fail with 5: Input/output error.
  • I checked main's _bootout. On a fresh install, each domain answers "not found" or 125 (_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_gone covers the fix. The refusal test now uses a real plist and refuse_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.

@RohanK6
RohanK6 merged commit aa89ac8 into main Nov 12, 2026
105 of 106 checks passed
@RohanK6
RohanK6 deleted the crew/conductor/macos-install-bootout-without-plist branch November 12, 2026 14:05
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 12, 2026
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: service install fails with "5: Input/output error" when the agent is still loaded but its plist is gone

3 participants