Repository navigation
Description
Feature Description
A tool meant to sit in your request path all day has to come back by itself after the machine
restarts. If it does not, the user's next agent session either fails or — worse — silently
bypasses Cortex, and they lose a day of data without noticing.
This is currently one checkbox inside the macOS install issue (#944) and one inside the Linux
install issue (#945), which is how it ends up verified by neither. It also cannot be covered by
the release smoke tests (#956, #957): CI runners do not reboot, so this is deliberate manual
verification on real machines.
Proposed Solution
Verify on macOS (launchd) and Linux (systemd):
- Service auto-starts after a clean reboot, with no user action — Linux: through lingering, before any login (Ubuntu, Debian). macOS: at the desktop login, so at boot with automatic login (macOS)
- Service auto-starts after an unclean shutdown or hard power cycle
- macOS: comes back after logout then login, and after a reboot where the user has not yet
logged in — state which of those launchd actually guarantees for agui/$uiddomain — both: it stops at logout and starts at the next login; after a reboot it starts only at the first desktop login (macOS) - Linux: comes back under user systemd, and state what happens without
enable-linger— it then starts at login and stops when the last session ends (docs) -
agentop service statusreports healthy after reboot, and the proxy is listening — checked after every reboot in the Ubuntu, Debian and macOS runs linked above - The agent works after reboot without re-running
enable— the settings patch and CA
trust both survive - Persisted sessions and metrics are intact after reboot, not truncated or corrupted (feature: persist sessions #901)
- A session interrupted mid-request by a reboot leaves readable data, not a corrupt store
- Document what a user should expect after a reboot and how to tell it worked (docs: troubleshooting guide for the laptop install #960)
Additional Context
Part of the Cortex v0.9.0 release, P0. Complements #944 and #945 — those cover install, upgrade
and uninstall mechanics; this covers the machine restarting underneath a working install.
Manual verification by design. Record the platforms and OS versions actually tested.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew/ToDo
Activity
Alan-Cha commentedon Oct 15, 2026
Ran the Linux half of this manually against a real VM ([email protected], Ubuntu,main-latest), using a new script:scripts/dev/verify-reboot-lingering.sh, submitted in #1409.Why a script instead of just doing it by hand: this needs a real reboot with nobody logged in, which neither
ci.yaml's agentop leg norrelease-smoke-linux.yamlcan exercise — both enable systemd lingering themselves beforeinstall.shruns, so Cortex's own "turn lingering on and remember that I did" branch never fires there, and GitHub-hosted runners can't be rebooted anyway.What it checked, and the results:
Fresh install claims lingering. Starting from
Linger=no, installing Cortex turned lingering on and wrote thelinger-enabled-by-agentopmarker recording that it did so. ✅Survives a real reboot, timed. 5 real reboot cycles, each timed via monotonic clocks on both ends (
ActiveEnterTimestampMonotonicfor the user manager +cortex.service,/proc/uptimeat first successfulhealthz) — no wall-clock skew to account for. Boot-to-healthy:Lingering-ownership edge cases (uninstall shouldn't clobber a preference it didn't set):
Host was restored to its original
Linger=nobaseline afterward.This covers the Linux reboot-survival half of this issue. Not covered here: the macOS equivalent, unclean shutdown/power-cycle (vs. a clean reboot), and session/metrics persistence across the restart — happy to pick those up separately if useful.Ran the Linux half of this manually against a real VM (Ubuntu 26.10, aarch64, systemd 261,
main-latest), usingscripts/dev/verify-reboot-lingering.shfrom #1409.Why a script instead of doing it by hand: this needs a real reboot with nobody logged in. Neither
ci.yaml's agentop leg norrelease-smoke-linux.yamlcan do that. Both enable systemd lingering themselves beforeinstall.shruns, so Cortex's own "turn lingering on and remember that I did" branch never fires there, and GitHub-hosted runners can't be rebooted anyway.What it checked, and the results:
Fresh install claims lingering. Starting from
Linger=no, installing Cortex turned lingering on and wrote thelinger-enabled-by-agentopmarker recording that it did. ✅Survives a real reboot, through lingering. 5 real reboots. For each one, the script compared when
[email protected]andcortex.servicebecame active with when the boot's first login session opened, both on the since-boot clock as the host recorded them. It stayed off the host for 30 s after each reboot so the two times are far apart:On every boot, Cortex was up 23.6–28.9 s before anyone logged in, so lingering started it. ✅ The first summary line is the figure to quote. The second is when the script's health probe first got an answer, which can't happen before the 30 s wait ends.
Lingering-ownership edge cases (uninstall shouldn't undo a preference it didn't set):
The host was restored to its original
Linger=nobaseline afterwards.This covers the Linux reboot-survival half of this issue. Not covered here: the macOS equivalent, unclean shutdown or power loss (as opposed to a clean reboot), and session/metrics persistence across the restart. Happy to pick those up separately if useful.
Test: Prove the reboot came up through lingering, not a login (#964)
Test: Add a real-reboot verification script for Linux lingering (ross…
Alan-Cha commentedon Nov 9, 2026
Linux, second platform: Debian 13, systemd 257 (run 2026-10-27)
Same script as the Ubuntu run above (
scripts/dev/verify-reboot-lingering.sh, #1409), installingmain-latest, on a minimal Debian 13.7 arm64 VM (netinst, "SSH server" only). systemd 256 and 257 log the user manager's own session without saying it is one, so this run also exercises the script's handling of that: the class lookup from huang195's review on #1409.5 real reboots:
cortex.serviceactiveBoot to
cortex.serviceactive: min 1.95 s, median 1.97 s, max 1.97 s (n=5). On every boot Cortex was up about 22.6 s before anyone logged in, so lingering started it. On the last boot the journal's first session line is the manager's, at 1.92 s (New session 1 of user alan.). The script asked logind, gotmanager, skipped it, and found the real first login at 24.67 s.All three lingering-ownership checks passed: install claimed lingering, uninstall turned it back off, and a pre-existing preference was neither claimed nor touched. The VM was restored to
Linger=noafterwards.Found on the first attempt: without polkit, Cortex can't turn lingering on. A minimal Debian install doesn't include polkit, and without it logind refuses a regular user's
loginctl enable-lingerwith "Access denied". Setup still finished and reported Cortex healthy, so Cortex would have stopped at every logout, with a warning that didn't say why. Filed as #1521 and fixed in #1522 (merged): the warning now names polkit and gives the commands that fix it. The run above was done withpolkitdinstalled.Not covered here or in the Ubuntu run: an unclean shutdown or power cut, macOS, and sessions and metrics across a reboot.
Alan-Cha commentedon Nov 11, 2026
macOS: macOS 26.6.2 (25G83), arm64 (UTM VM on an Apple Silicon host, run 2026-11-08 to 11-10)
Cortex v0.9.5, installed with
curl | shlike a user. (main-latest's assets were returning intermittent 504s from GitHub at the time, so this is the latest stable release instead.)How it was measured, and why it's simpler than Linux. Cortex on macOS is a per-user launch agent, loaded into the user's desktop session (
gui/<uid>). An SSH login doesn't create that session, so SSH can't start Cortex, which part 2 below shows directly. So, unlike the Linux script, checking over SSH doesn't disturb what's being measured. Times are process start times read on the host: launchd (pid 1) for boot, the user's Dock for the desktop login, and Cortex's launchd job (the supervisor) and its child (the proxy).kern.boottimeisn't usable for this on macOS: it moves forward by however long the machine slept.1. Automatic login on: 5 reboots (
shutdown -r now), nobody touching the VM:agentop service statusSeconds after boot. launchd started Cortex's job once per boot (
runs = 1), about 7 s after the automatic login.2. Automatic login off.
gui/501domain, Cortex's job not loaded, no Cortex process, nothing on/healthz. That's across 4 SSH logins as the same user in those 3 minutes./healthzanswered 2 s later.What launchd guarantees here (the macOS checklist item): Cortex runs exactly while the user has a desktop session.
On a laptop, the agents Cortex serves run in the same desktop session, so they and Cortex start and stop together.
Not covered yet on macOS: an unclean shutdown or power cut, an agent working after a reboot without re-running
enable, sessions and metrics across a reboot, and a request cut off by a reboot.