Repository navigation
feat(service): prefer systemd user units - #10813
hugoncosta wants to merge 2 commits into
Conversation
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: Both reds are mechanical and come from this PR's own diff, not from the design. The Brand Name Gate fails on one added line in If you'd prefer I don't touch this PR, add the |
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes: fresh Linux installs are now session-bound and no longer survive logout or reboot
The brand-gate and gap-list reds are already covered in the earlier comment. This review is only about the new default.
Where
src/kiro_crew/service/linux.py:669: when no unit exists yet, the code setsuser_scope = _user_manager_available(). That probe (linux.py:418-426) returns False only underSUDO_USERor euid 0. Otherwise it returns whethersystemctl --user show-environmentexits 0, and that passes in any ordinary SSH or desktop login.linux.py:683then writesrender_unit(user_scope=True). That unit hasWantedBy=default.target(linux.py:308) and noEnvironmentFile=(linux.py:257).- Neither
linux.install()norcontroller.install_service()(controller.py:120-131) readsLinger=, turns it on, or warns about it.
Failure scenario
An operator SSHes into a VPS and runs kirocrew service install, as remote-and-mobile.md describes. The install succeeds and prints the user unit path. Linger is off by default, so when the last session closes, logind stops user@UID.service and the gateway goes down with it. The dashboard, Slack and cron all stop. Restart=always can't help, because the user manager itself has exited. After a reboot the gateway stays down until that user logs in again.
What this changes
Main promises "survives SSH disconnects, restarts on crash, and starts on boot" (docs/system-specs/modules/cli.md:1355-1356 on main) and "Boot survival via WantedBy=multi-user.target (no linger needed" (cli.md:1413). Main's own user-unit remedy listed loginctl enable-linger <account> as a required step (service/linux.py:580 on main).
The PR mentions linger only in the docs (docs/guides/install.md:659, cli.md:1304). The CLI never mentions it. The only remaining way to get the system unit is implicit: run under sudo, which install.md now says not to do. Existing system-unit installs keep their scope, so the change affects fresh installs and uninstall-then-reinstall.
Smallest fix direction
- After a user-scope install, check
loginctl show-user <user> -p Linger. If it isno, print a clear warning with the exactsudo loginctl enable-linger <user>command, or offer to run it. - Add an explicit, documented way to choose the system unit for always-on hosts, for example a
--systemflag. - State the default change as breaking in the PR description so the release notes carry it. After the rebase, main's
README.md:223("boot-persistent service", added after your merge base) also needs the same update.
From a full open-PR audit against origin/main c66f95b (2026-09-25); findings were checked by independent reviewers reading the code. Reply here if this is wrong.
|
Triage: needs a rebase. main now covers part of this PR (PARTIALLY_COVERED) I read the full diff ( Already on main (merged PRs)
Not on main, so this part is still open
Still open from the earlier review
Recommendation: REBASE onto main using #13964's scope-aware verbs, then CONTINUE-DEVELOPMENT on the default change and the linger handling. |
|
Thank you @hugoncosta for pushing on least-privilege installs. We are closing this PR: much of it has since landed in #13964 (scope-aware status, stop, restart and uninstall for user units) and #15851 (linger checks). The remaining part, making a user unit the default, would make fresh installs stop at logout and not start at boot unless linger is on, which breaks the documented always-on behaviour. If you would like to continue, an explicit opt-in (for example a --user flag that checks or enables linger) against current main would be a welcome fresh PR. The branch is left untouched, so you can reopen this PR at any time, or open a fresh one on current main, if you want to pick it back up. |
Problem / Motivation
On Linux,
kirocrew service installused a machine-wide systemd unit even when the current user had a working systemd user manager. This unnecessarily requires sudo for a per-user application and might be a turn-off for some sysadmins that do not want certain users to have sudo.Why it matters
A user unit provides a least-privilege default and lets users install and control KiroCrew without root access. Hosts without a usable user manager still need the existing system-level fallback.
What changed (motivation → approach → change)
Fresh Linux installations now:
~/.config/systemd/user/kirocrew.servicewhensystemctl --useris available./etc/systemd/system/kirocrew.serviceotherwise.systemctl --userandjournalctl --userfor user-unit lifecycle and logs.User=,Group=, and the/etc/kirocrewenvironment file.Documentation and CLI guidance were updated accordingly. This does not introduce migration machinery, configuration options, or unrelated service-management changes.
RFC: N/A — no matching non-draft RFC currently exists on
mainfor this default change.Tests
Added or updated coverage for:
Verification performed:
git diff --checkpassed.Manual verification
CLI output was smoke-tested and a live systemd integration was performed on a machine without sudo.
Related Issues
N/A — no issue linked.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement