testsAndMisc/docs/superpowers/evidence/swap-switch-stale-grub-cfg-2026-11-27.json
Krzysztof kuhy Rudnicki 652638e920
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Rebuild stale grub.cfg in swap setup scripts
setup_zram.sh/setup_zswap.sh ran grub-mkconfig only when /etc/default/grub
changed, so a run cut off between the two writes left grub.cfg booting the
old setup and every rerun exited 0 (zswap Y plus zram0 after a reboot).
Now grub.cfg is rebuilt whenever a linux line lacks the exact target zswap
words, and the scripts exit 1 before any live change when grub.cfg is still
wrong after the rebuild or a loader entry has no options line carrying them.
vmbox guest zc3: stale-zram, stale-zswap, again and noopts phases all OK.
Prunes the oldest contract (g29, 2026-09-14) to stay at the 60-file cap.

Bug-class-check: fixes/lib/tests/test_swap_switch.sh
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 14:10:34 +01:00

36 lines
2.6 KiB
JSON

{
"intent": "setup_zram.sh and setup_zswap.sh never exit 0 while the next boot would run a different swap setup: a stale grub.cfg is rebuilt, and an unfixable boot config fails loudly before live swap changes.",
"scope": [
"linux_configuration/fixes/lib/swap_switch.sh",
"linux_configuration/fixes/lib/tests/swap_switch_harness.sh, test_swap_switch.sh, vmbox_swap.sh",
"linux_configuration/fixes/DOCS-zswap-vs-zram.md",
"Non-goal: the host (systemd-boot) is not touched or rebooted"
],
"changes": [
"_ss_set_grub rebuilds grub.cfg when the defaults changed OR any grub.cfg linux line does not carry exactly the target zswap words (missing file counts), then re-checks and exits 1 naming the offending line",
"ss_set_boot_tokens checks every systemd-boot entry's options lines carry the target words and exits 1 naming the entry otherwise",
"Harness grub-mkconfig stub writes an Arch-like grub.cfg (tab-indented linux lines, recovery from GRUB_CMDLINE_LINUX); snapshot includes grub.cfg",
"vmbox_swap.sh: new stale-zram, stale-zswap and noopts phases; grub.cfg checks every linux line; again compares grub.cfg mtime"
],
"verification": [
{
"command": "~/.claude/scripts/capped.sh bash linux_configuration/fixes/lib/tests/test_swap_switch.sh",
"result": "pass",
"evidence": "Before the fix: 53 passed, 15 failed (stale grub.cfg not rebuilt, missing options line exited 0). After: 68 passed, 0 failed"
},
{
"command": "vm run zc3 'sudo bash ~/wt/linux_configuration/fixes/lib/tests/vmbox_swap.sh <phase>' (fresh BIOS/GRUB guest zc3 after vm hibernate-setup)",
"result": "pass",
"evidence": "zswap -> reboot -> booted-zswap OK; stale-zram RC=0 (precondition grub.cfg boots zswap; all 2 linux lines carry zswap.enabled=0) -> reboot -> booted-zram OK (cmdline zswap.enabled=0, zram0 prio 100 zstd, zswap N) -> again OK (md5, mtime, swap list unchanged); stale-zswap RC=0 (all 2 lines carry the 4 tokens) -> reboot -> booted-zswap OK -> again OK; noopts on zram and on zswap: exit 1 naming b.conf, GRUB files, swap list and zswap enabled unchanged"
}
],
"risks": [
"A grub.cfg whose kernel lines are not named `linux` (linux16/linuxefi) would read as having no matching line and be rebuilt each run, then fail loudly",
"A systemd-boot UKI entry without an options line now makes the scripts exit 1 instead of silently skipping it"
],
"rollback": [
"git revert the commit; setup_*.sh go back to rebuilding grub.cfg only when /etc/default/grub changed",
"Rerun bash linux_configuration/fixes/lib/tests/test_swap_switch.sh after the revert"
]
}