Repository navigation
fix: turn linger on during a linux system service install - #35169
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix acts at the cause: the install already has root, so it now enables linger instead of telling the user to. The only leftover is the advisory function it replaced, which now has no callers. Not checked: maintainer decision on issue #34691 (the decision record cites it; I can't read GitHub here) Notes
What this change shipsInventory (8 items) — 7 justifiedIntent: keep agent runtimes alive after the service account logs out on a Linux system install — FIX.
[FIRST-PRINCIPLES-REVIEWED] 4de7c29 Description read[DESCRIPTION-READ] 08fc674d9e66991b98a5bd176dc96ef2063eae9528c929d14dba239ea6aa4f7b That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The installer already has root, so it now enables linger itself instead of telling the operator to, and a failure only warns without changing the install outcome. Notes
[DESIGN-REVIEWED] 4de7c29 Description read[DESCRIPTION-READ] f783930d951f208fe58a22d550f0934bb32e6506457357147f84787abd83ebeb 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 |
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: |
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: |
Code change approver recommendation: ApproveWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. The PR replaces the install-time linger warning with a privileged 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 |
|
[operator: bolichen97] |
buluoray
left a comment
There was a problem hiding this comment.
Approve on 59ad081. Linux system install now runs loginctl enable-linger <uid> itself through the existing privilege path, with loginctl from trusted system dirs, skipping when linger is on, no per-user manager, or uid unresolved; a failure only warns and the install still succeeds. Decisive lines: src/kiro_crew/service/linux_install.py:434-469 (enable_service_account_linger), src/kiro_crew/service/controller.py:191-193 (call site, non-fatal print)
59ad081 to
0d1a559
Compare
|
Rebased: main moved in docs/decisions/README.md since this head went green (65bdd09 -> 23b63d2); CI re-running. The branch conflicted there because main and this PR each appended a row to the decision index; both rows are kept. The PR's own change is unchanged apart from a two-line comment in [operator: bolichen97] |
|
|
[operator: bolichen97] Design Review, First Principles Review, GPT 6.1 Review, Opus 5.5 Review, Publish readiness signal and Re-run Sensitive Change Review are red on 0d1a559 before reviewing anything: each failed fetching from the API with |
0d1a559 to
cd4b4a4
Compare
|
Rebased: main moved in docs/decisions/README.md since this head was cut (23b63d2 -> 26e8e9e); CI re-running. GitHub reported the branch as conflicting there because main and this PR each appended a row to the decision index; both rows are kept and the PR's own change is otherwise identical, now cd4b4a4. The reds on 0d1a559 were not this change: most jobs failed uploading artifacts while GitHub's artifact service answered with an HTML error page, and [operator: bolichen97] |
|
Stale-PR cleanup check (2026-11-17): every lane except First Principles Review is fine on c872012, and the branch still merges cleanly with main. The First Principles BLOCK was released by an owner-decision override at a307d2d, but overrides apply to one commit only, so the rebased head needs the same override again from a maintainer (@bolichen97), citing #34691 (comment). The reviewer's side note (the unused |
|
[operator: bolichen97] Thanks for the check. Since then GitHub reports the branch as conflicting with main (main's plain-word status prefixes landed in |
|
Rebased: main moved in src/kiro_crew/service/controller.py and docs/system-specs/modules/cli.md since this head went green (794afbb -> 1308732); CI re-running. GitHub reported the branch as conflicting: main's #38821 turned status emoji into plain words in both files, so the failed-linger line now starts with |
c872012 to
10ef8cb
Compare
10ef8cb to
518a2f5
Compare
|
Rebased: main moved in docs/decisions/README.md, docs/guides/install.md, docs/guides/remote-crew-on-ec2.md and docs/system-specs/modules/cli.md since this head was cut (1308732 -> 3b4e971); CI re-running. The rebase applied cleanly and the PR's own change is unchanged: main touched none of the service code it edits. The only red on the previous head was the CodeQL JavaScript/TypeScript analysis, which failed while uploading its results on a GitHub API rate-limit error, not on any finding, and PR Readiness was red only because of it; the new run replaces it. The related service and doctor tests and the static checks pass on the rebased commit, and the [operator: bolichen97] |
|
[operator: bolichen97] CI on 518a2f5 is red only where main is red or a known Windows flake hit; none of the failing tests reach the service install code this PR changes.
This PR waits for #39479 and #39475 to land; the branch is then rebased onto main and CI re-runs. No change to this PR's code is needed for these reds. |
A system install is chosen so work outlives the login session, but each agent runtime runs under the service account's own user manager, which systemd stops at the account's last logout unless linger is on. The install only printed a warning naming the sudo command to run by hand. The install now runs loginctl enable-linger for the account itself, through the root access it already uses, unless logind reports linger on or the host has no per-user manager for that account. It prints what it did and how to undo it, and only warns, without failing the install, when the call fails. Uninstall leaves linger as it is. The spec, the install guides and a decision record describe the new behaviour.
518a2f5 to
4de7c29
Compare
|
Rebased: main moved in docs/decisions/README.md, docs/guides/remote-and-mobile.md and docs/system-specs/modules/cli.md since the last head (3b4e971 -> 82ee8d2); CI re-running. The previous head was red only in tests that do not reach the service install code, and this rebase picks up main's fixes for four of them: the process-cache ratchet on the subagent tombstone sweep memo (#39479), the Windows poll in the auto-improvement watcher tests (#39545) and the Windows code-channel bar test (#39505, #39618). The fifth, a source-link chip count test that reads shared settings state, still has its fix open in #39475. The PR's own change is identical (the rebase applied cleanly with no edits), and the related service tests pass on the new head. [operator: bolichen97] |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
I reviewed head 4de7c29. On a Linux system service install, the new step turns on linger for the unit's account. It finds loginctl only in fixed system directories, runs it through the install's existing privilege path, and passes the resolved numeric uid. It does nothing when linger is already on, when the uid does not resolve, or when the host has no per-user manager. A root account is refused earlier in the install, so this step never runs for root. A failed call only prints a warning with the command to run, and the install result does not change. The service, controller, AppArmor, headless key, inherited env and facade-mirror suites pass on this head, so nothing blocks.
Problem / Motivation
Goal: A Linux system-service install turns linger on for the account the service runs as, so agent runtimes keep running after that account's last logout.
On Linux,
kirocrew service installwrites a system unit, but every agent runtime it starts runs under the service account's own user manager. systemd stops that manager at the account's last logout unless linger is on, so in-flight runtimes die and later ones start without their memory and fork-count ceilings. The install only printed a warning namingsudo loginctl enable-linger <user>, an extra manual sudo step, although the install already runs with root access (reported on Amazon Linux 2023 while following the remote crew on EC2 guide).Why it matters
A system install is the path people pick so the gateway outlives their SSH or Session Manager session. Without linger that promise holds for the gateway but not for the work it runs: every logout kills agent runtimes, and only an install-time warning says so.
Not a goal
kirocrew doctorreports about linger for pods.What changed (motivation → approach → change)
Observed: a system install leaves linger off, and agent runtimes die at the account's last logout. Root cause: the install only warned, even though it holds the root access the fix needs. Change, following the maintainer decision on the issue:
loginctl enable-linger <uid>itself and printslinger turned on for <user> ..., withsudo loginctl disable-linger <uid>to undo itsudo loginctl enable-linger <uid>to run by hand; the install still succeedsloginctlThe step lives in
service/linux_install.py(enable_service_account_linger) and is called byinstall_service()inservice/controller.pywhere the warning was printed. It reuses the install's own privilege path, resolvesloginctlfrom trusted system directories only, passes the numeric uid because root's name lookup can fail where the uid resolves, and asks the same per-user-manager questionkirocrew doctorasks. It runs on every install, a re-install too, so linger turned off by hand comes back on and the printed line says so;kirocrew service uninstallleaves linger as it is. The CLI spec, the install, remote and EC2 guides, the facade's sudo-scope docstring and a new decision record underdocs/decisions/describe the behaviour.Backwards compatibility
Compatible: the install's outcome, exit code and every earlier step are unchanged, and a host whose account already lingers sees no difference. The install does make one lasting host change it did not make before: with linger on, the account's user manager runs now and from every boot, with that account's other enabled user services and timers, and a re-install turns linger back on after someone turned it off by hand. The printed line names the undo command.
Removes nothing:
linger_warning_for_service_account()stays on thekiro_crew.service.linuxfacade, deliberately, as part of its pre-split surface; the install stops printing its advice only where it now acts instead, or where the uid does not resolve or the host has no per-user manager, so the advice could not help.Tests
test/test_service.py::TestLinuxUnitRendering::test_install_turns_linger_on_unless_it_is_on(linger reported off, and not reported):install_service()runs/usr/bin/loginctl enable-linger 1000once and prints the turned-on line with the undo command.test_a_failed_enable_names_the_command_to_run: a failed call returns the warning with loginctl's message andsudo loginctl enable-linger 1000.test_linger_is_left_alone_when_it_has_nothing_to_do(already on, no per-user manager, no trustedloginctl, unresolved uid): no privileged call and no line to print.test/test_service_controller.py::test_install_systemd_prints_the_linger_outcome: the install prints the turned-on line plainly and the failure afterWarning:. The other install tests stub the step so no test can run a realloginctl.Determinism: the 12 linger tests (
-k lingerover both files) passed 5 runs in a row at-n0and once in a shuffled order (pytest-randomly 5.1.0, seed 3469134).Proof: PROVEN test/test_service.py::TestLinuxUnitRendering::test_install_turns_linger_on_unless_it_is_on[reported-off], test/test_service.py::TestLinuxUnitRendering::test_install_turns_linger_on_unless_it_is_on[not-reported] (head 4de7c29)
Manual verification
The real install ran on a disposable host, base and head (next section). The read-only probe half ran against the live logind of an Amazon Linux 2023 host (systemd 252), the reporter's distribution: for an account that lingers,
loginctl show-user <uid> -p Lingerby numeric uid answersLinger=yesand the step has nothing to do; for a uid logind does not track,show-userfails, the probe reads that as unknown, and the step acts.Real-machine verification
Machine: EC2 m7i.2xlarge, Ubuntu 24.04.5 LTS (systemd 255), x86_64, 8 vCPU / 30 GiB
Before (main 1308732):
kirocrew service install, run by a fresh account with no login session and passwordless sudo ->kirocrew service installed and started.with no linger line; thenloginctl show-user 1002 -p Linger->User ID 1002 is not logged in or lingering, andsystemctl is-active user@1002.service->inactiveAfter (head 10ef8cb): the same command ->
linger turned on for kcrmv, so agent runtimes keep running after its last logout. To turn it off: sudo loginctl disable-linger 1002; thenLinger=yesanduser@1002.serviceactive. A second install prints no linger line, andkirocrew service uninstallleavesLinger=yesCleanup: linger turned off, the throwaway account, its sudo rule, the unit and the build removed (
idfinds no such user, nokirocrew*unit files, the linger directory empty); the instance is a disposable verification host with no inbound access, terminated once idleRelated Issues
Closes #34691
Sibling sweep
Swept: git grep -n "enable-linger" -- src/
Sibling: src/kiro_crew/doctor_checks/services.py:122 -- not affected -- doctor only reports and never changes the host, by design
Sibling: src/kiro_crew/pod/runtime.py:792 -- not affected -- the pod remedy runs without root, so it can only name the command
Sibling: src/kiro_crew/sandbox_cgroup.py:203 -- not affected -- a runtime log line from the unprivileged gateway
Sibling: src/kiro_crew/service/linux_install.py:231 -- not affected -- the SELinux refusal installs nothing; the operator sets up that user unit by hand
Sibling: src/kiro_crew/service/linux_unit.py:263 -- not affected -- the old advisory text, kept as facade surface
Pattern harvest
Not generalizable: one install step told the operator to run a command the installer already had the privilege to run; there is no code shape a rule could match.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement