Repository navigation
test-kernel keeps its kernels' modules from the boot-time clean-up; ref-sleep needs them; a helper for trials run directly - #141
Conversation
…und missing when it is gone kernel-modules-hook's linux-modules-cleanup.service moves away, at every boot, each tree in /usr/lib/modules that is neither the running kernel's nor a package's: every test kernel's. On the Mac four deep-sleep runs were made with a kernel that had none of its modules, while list and boot said all was well. install, in every mode and before anything is unpacked: where that unit is, a drop-in whose command is the unit's own plus one more way to be left alone (a release that is a line of a state file here), systemd reloaded, and the drop-in looked for in what systemd shows. A unit whose command isn't the one the tool knows, a drop-in that can't be written or isn't shown: the install fails, and the drop-in is one more thing a failed run takes back (or puts back as it was). remove takes it away with the last test kernel, if its text is still the tool's. boot refuses a kernel whose tree has no modules.dep; list says MODULES MISSING, and how the unit and the drop-in stand; check <name> holds one kernel against all of it, exit 0 only if everything is in place. install also fails if depmod leaves no modules.dep. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…driver, as preconditions Both modes: /lib/modules/<release>/modules.dep has to be there. A test kernel whose tree was moved away since its install runs with what its initramfs had and nothing else, and nothing in its boot says so. --upstream: "no device is bound to apple_sep" is a failed precondition of its own, which --xart-writable-ok doesn't cover: the option is for a bound driver whose store is writable, not for a driver that isn't there. On the Mac four runs passed the check that way, with a kernel that had lost its modules. The store's line then says only that nothing shows how it is open, and go looks once more, before the write, that a device is still bound. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
… two new preconditions, as tested Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
… runs itself outside a safe boot; CLAUDE.md Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
The module protection check can pass while systemd uses a different cleanup command. The direct installer and trial runner also need to report failures reliably.
Approach — Preserving registered module trees at cleanup time and checking the running kernel before sleep address the failure observed on the Mac.
Reviewed changes — I reviewed the cleanup drop-in lifecycle, sleep preconditions, direct helper and polkit rule, and their documentation and fixtures.
test-kernelmanages the cleanup exemption and checks installed modules, images, and GRUB entries.ref-sleeprequires the running release’s modules in both modes and anapple_sepbinding in upstream mode.- Direct trials add a passwordless helper for timed sleep, boot selection, diagnostics, and loader restoration.
Both Python fixture suites and Bash syntax checks for the direct scripts passed. Live sleep, GRUB, and polkit behavior were outside the fixture run.
gpt-6.2-sol | 𝕏
…ld run; one lock across install, remove, boot and unselect (Pullfrog on #141) The reading. install and check looked for the drop-in's line in what systemctl cat lists, which is the backing files: a drop-in that sorts later can put the package's command back, or add a second, and every file is still there to list. Now it is the manager's effective command that counts: systemctl show -p ExecStart after the daemon-reload has to be the drop-in's command and no other, with NeedDaemonReload no, and list, check and boot's warning go by the same reading. Whether the unit is there is LoadState, so a systemctl that fails is not a system without the unit. The form the property has was read on this Mac, where the tool's rendering of the drop-in's line equals what systemd shows for the unit as loaded. The lock. A remove of the last kernel could take the drop-in away under an install that had verified it and not yet written its record. install, remove, boot and unselect take flock on /run/test-kernel.lock before their first check and hold it to their last line, a failed install's taking-back included; a second one ends at once, saying so. list and check take none. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…the lock, as tested (Pullfrog on #141) Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…irst failed step; go's status is 0 only for a shown wake; a second experimental kernel by name (Pullfrog on #141) install-direct.sh: its transcript is a new file in /var/log/sleep-drain (checked root-owned and not a link), no chown by path, no temp file in /tmp; each required step's failure ends it with that step's status, and a failed loader swap takes the selection back; a NAME argument (s2rpr, s2rcf), and the loader left alone when the live file already is the bundle. sleep-test: go returns 3 when the write returned 0 with no "back from sleep" line after it; the experimental kernels are a fixed list of names (s2rpr, the PR; s2rcf, its author's test/t6000-s2r-commit-fixes), and arm takes one of them. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
The direct installer can report that the next boot is ready after loader verification fails. A runtime mask can also cause test-kernel to skip module protection that will be needed at the next boot.
Reviewed changes
I reviewed the three commits since 962865a.
- Verified the effective cleanup command with systemd and added fixtures for overrides and stale manager state.
- Serialized kernel mutations across install, remove, boot, unselect, and install rollback.
- Updated direct trials to support a second named kernel and return a failure status when no wake is recorded.
- Updated the direct installer to use root-owned transcripts, propagate setup failures, and skip rewriting a matching loader.
Bash syntax checks and the test-kernel fixture suite passed. The fixture skipped comparison against a live cleanup unit because it was absent here. Live loader, sleep, and polkit behavior were outside this review.
gpt-6.2-sol | 𝕏
…status, read from the device; a status that fails or names another file goes the failed swap's way (Pullfrog on #141) Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…estart (Pullfrog on #141) LoadState reads masked for a unit masked for good and for one masked for this boot only. The second kind is gone at the next boot, which is the one that moves the modules away, and install skipped the drop-in and check said ok on it. Now UnitFileState says which: masked is "it can't run" (no drop-in, and install says why); masked-runtime is not protection: check is NOT OK, list and boot's warning name it, and install fails with nothing installed, since the manager shows no command for a masked unit and a drop-in written then couldn't be shown to be what runs at the next boot. A mask of neither kind is not known. Both forms were read on this Mac, which has a unit of each kind. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…and the umask set; the wake read from the kernel's buffer; arm and restore spare a selection that isn't theirs; the installer selects last sleep-test: umask 022 and LC_ALL=C (pkexec keeps the caller's umask), and the log's directory has to be root's alone; SECONDS is two to four digits with no leading zero; the alarm is taken off on every way out and a closed pipe or an interrupt doesn't end the helper between arming and the sleep; the wake's lines are read with dmesg, since journald may not have them yet; arm needs the bundle as the live second stage, takes test-kernel's lock, and refuses over a pending selection that isn't an experimental kernel's; restore leaves such a selection and says so. install-direct.sh: helper, kernel, loader, and the selection last; in a boot of NAME itself the kernel is left as installed; a failed loader step with a loader that is neither the bundle nor the stock changes nothing more and says not to restart. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
A concurrent restore can leave the next boot pointed at the experimental kernel with the stock loader in place.
Reviewed changes
I reviewed the three commits from 82638cd to d5db74e.
- Required device verification before the direct installer selects the experimental kernel.
- Distinguished persistent and runtime masks when evaluating module cleanup protection.
- Updated the direct helper to check the loader before arming, preserve unrelated selections, validate its log directory, and read wake evidence from the kernel buffer.
Bash syntax checks and the test-kernel fixture suite passed. Live loader and suspend behavior were outside the test run.
gpt-6.2-sol | 𝕏
…s the loader and selects under the lock its restore holds (Pullfrog on #141) Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
The installer can report that the next boot is ready while the experimental kernel's modules are unprotected from boot-time cleanup.
Reviewed changes
I reviewed the installer change from d5db74e to 14b4bbf.
- Delegated final boot selection to
sleep-test arm, which verifies the live loader and sets the GRUB entry under the same lock asrestore.
Bash syntax checks and the test-kernel fixture suite passed. Live loader and suspend behavior were outside this review.
gpt-6.2-sol | 𝕏
…up's protection as the manager would run it, also in a boot of the kernel itself (Pullfrog on #141) Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
I reviewed 14b4bbf..6210634.
- Required the kernel check before arming. The direct installer stops if
test-kernel checkfails, including when it skips reinstalling the running experimental kernel. The check verifies the effective boot-time module cleanup protection.
Bash syntax and the test-kernel fixture suite passed. Live boot behavior remains unverified.
gpt-6.2-sol | 𝕏

After 2026-11-30's finding that the system's
linux-modules-cleanup.serviceremoved the test kernels' module trees between runs (#140).test-kernel:installputs a drop-in for that service in place (and fails if it can't),removetakes it away with the last test kernel,bootrefuses a kernel whose module tree is gone,listsays MODULES MISSING, andcheck <name>says whether a test kernel is whole.ref-sleep: the running kernel's own module tree is a precondition in both modes; in--upstream, "no device bound to apple_sep" is a NOT OK of its own that--xart-writable-okdoesn't cover.direct/:sleep-test, a root-owned helper with five fixed actions (one timed deep sleep on the experimental kernel, select its entry for the next boot, read the PMU notes, status, restore the stock loader), and a polkit rule that lets this Mac's owner run that one program without a password, at their request, so that a series of sleeps can be run from the session without a prompt each time. Installed by hand on the Mac; not part ofinstall.sh.CLAUDE.md,tests/README.md.Not run as root: the tool changes. The helper and its rule are installed on the Mac;
statuswas run through them.🤖 Generated with Claude Code