From ce3c4213b027197db54a9d8481f142d4491dd8ab Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 13 Sep 2026 10:55:43 +0200 Subject: [PATCH] Arch journal cap: 300M -> 4G, vacuum only past the cap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 300M held about two days on kuhy's desktop: one Steam boot wrote 480k journal lines and the evidence for a curfew failure two weeks earlier was already gone when it was needed (2026-09-13). The three Arch copies of the journal tweak (arch_hardware, arch_perf_fixes, arch_perf_report) move to a 4G cap, and "large"/vacuum now mean past that cap — a 2G journal is deliberate retention, not a finding. Tests follow. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_015mLnUeoJ3mUwGRTowTUH6d --- .../contracts/journal-cap-4g-2026-09-13.json | 14 ++++++ .../evidence/journal-cap-4g-2026-09-13.json | 50 +++++++++++++++++++ .../fixes/lib/arch_hardware.sh | 14 ++++-- .../fixes/lib/arch_perf_fixes.sh | 14 ++++-- .../fixes/lib/arch_perf_report.sh | 10 ++-- .../lib/tests/test_arch_hardware_boot.sh | 12 ++--- .../fixes/lib/tests/test_arch_perf_fixes.sh | 10 ++-- .../lib/tests/test_arch_perf_report_fixes.sh | 4 +- 8 files changed, 101 insertions(+), 27 deletions(-) create mode 100644 docs/superpowers/contracts/journal-cap-4g-2026-09-13.json create mode 100644 docs/superpowers/evidence/journal-cap-4g-2026-09-13.json diff --git a/docs/superpowers/contracts/journal-cap-4g-2026-09-13.json b/docs/superpowers/contracts/journal-cap-4g-2026-09-13.json new file mode 100644 index 00000000..03da8e12 --- /dev/null +++ b/docs/superpowers/contracts/journal-cap-4g-2026-09-13.json @@ -0,0 +1,14 @@ +{ + "title": "Arch journal cap 300M -> 4G, vacuum only past the cap", + "objective": "The systemd journal keeps weeks of history on kuhy's desktop, not days: a 300M cap held about two days once one Steam boot wrote 480k lines, and the evidence for a curfew failure was gone when it was needed. Every Arch copy of the journal tweak installs a 4G cap and treats 'large' as past that cap.", + "acceptance_criteria": [ + "fix_arch_performance.sh, optimize_arch_desktop.sh and the perf report write SystemMaxUse=4G and vacuum to 4G only when usage is >= 4G", + "a journal measured in megabytes, or under 4G, is neither vacuumed nor reported as large", + "test_arch_hardware_boot.sh, test_arch_perf_fixes.sh, test_arch_perf_report_fixes.sh and test_arch_perf_report.sh pass unchanged in count" + ], + "out_of_scope": [ + "the Ubuntu copy of the same fix (ubuntu_perf_more.sh) -- not this machine", + "rate-limiting the Steam flood itself -- fixed at source in steam-backlog-enforcer" + ], + "verifier": "bash linux_configuration/fixes/lib/tests/test_arch_hardware_boot.sh; bash linux_configuration/fixes/lib/tests/test_arch_perf_fixes.sh; bash linux_configuration/fixes/lib/tests/test_arch_perf_report_fixes.sh; bash linux_configuration/fixes/lib/tests/test_arch_perf_report.sh" +} diff --git a/docs/superpowers/evidence/journal-cap-4g-2026-09-13.json b/docs/superpowers/evidence/journal-cap-4g-2026-09-13.json new file mode 100644 index 00000000..60cd95af --- /dev/null +++ b/docs/superpowers/evidence/journal-cap-4g-2026-09-13.json @@ -0,0 +1,50 @@ +{ + "intent": "Keep enough systemd journal on the Arch desktop to diagnose a failure two weeks later: raise the installed cap from 300M to 4G and only vacuum a journal that is actually past it.", + "scope": [ + "linux_configuration/fixes/lib/arch_hardware.sh (tweak_journal)", + "linux_configuration/fixes/lib/arch_perf_fixes.sh (fix_journal)", + "linux_configuration/fixes/lib/arch_perf_report.sh (check_journal_size, apply_safe_fixes)", + "the three test suites that pin those values", + "Non-goal: ubuntu_perf_more.sh keeps 300M (not this machine)" + ], + "changes": [ + "SystemMaxUse=300M -> 4G in the drop-in each script writes and in the already-configured check.", + "Vacuum threshold: usage must be reported in G with an integer part >= 4, instead of any value in G; vacuum target 4G.", + "Report: 'journal is large' only past 4G, so a 2G journal is deliberate retention, not a finding." + ], + "verification": [ + { + "command": "bash linux_configuration/fixes/lib/tests/test_arch_hardware_boot.sh", + "result": "pass", + "evidence": "arch_hardware (boot/journal): 26 passed, 0 failed" + }, + { + "command": "bash linux_configuration/fixes/lib/tests/test_arch_perf_fixes.sh", + "result": "pass", + "evidence": "arch_perf_fixes: 21 passed, 0 failed" + }, + { + "command": "bash linux_configuration/fixes/lib/tests/test_arch_perf_report_fixes.sh; bash linux_configuration/fixes/lib/tests/test_arch_perf_report.sh", + "result": "pass", + "evidence": "arch_perf_report (fixes/summary): 21 passed; arch_perf_report (probes): 17 passed" + }, + { + "command": "shellcheck lib/arch_hardware.sh lib/arch_perf_fixes.sh lib/arch_perf_report.sh", + "result": "pass", + "evidence": "no findings" + }, + { + "command": "printf '[Journal]\\nSystemMaxUse=4G\\n' > /etc/systemd/journald.conf.d/size-limit.conf && systemctl restart systemd-journald (host)", + "result": "pass", + "evidence": "journalctl --disk-usage: 305.1M in the file system; cap now 4G" + } + ], + "risks": [ + "Up to 4G of /var/log/journal on a 3.6T disk with 1.8T free -- negligible.", + "Three copies of the same logic still exist; they were changed together but remain duplicates." + ], + "rollback": [ + "git revert the commit and re-run the fix script, or write SystemMaxUse=300M into the drop-in and restart systemd-journald.", + "Validate with journalctl --disk-usage and cat /etc/systemd/journald.conf.d/size-limit.conf." + ] +} diff --git a/linux_configuration/fixes/lib/arch_hardware.sh b/linux_configuration/fixes/lib/arch_hardware.sh index 030b9628..3d9f54c1 100755 --- a/linux_configuration/fixes/lib/arch_hardware.sh +++ b/linux_configuration/fixes/lib/arch_hardware.sh @@ -149,26 +149,30 @@ tweak_journal() { # file system", with no separator, so requiring one made this check -- # and the vacuum below it -- unreachable. Same defect as # arch_perf_report.sh carried before it was fixed. - if [[ $usage_line =~ ([0-9]+\.?[0-9]*)\ ?G ]]; then + # Cap is 4G. 300M held about two days on kuhy's desktop: one Steam boot + # wrote 480k journal lines, and the evidence for a curfew failure two + # weeks earlier was already gone (2026-09-13). Only a journal past the + # cap gets vacuumed, so a healthy 2G journal is left alone. + if [[ $usage_line =~ ([0-9]+)\.?[0-9]*\ ?G ]] && ((BASH_REMATCH[1] >= 4)); then needs_vacuum=true fi if [[ $needs_vacuum == "true" ]]; then - journalctl --vacuum-size=300M + journalctl --vacuum-size=4G else - log_ok "Journal already under 1GiB." + log_ok "Journal already under 4G." fi local dropin_dir="${JOURNALD_CONF_DIR:-/etc/systemd/journald.conf.d}" local dropin_file="$dropin_dir/size-limit.conf" - if [[ -f $dropin_file ]] && grep -q 'SystemMaxUse=300M' "$dropin_file"; then + if [[ -f $dropin_file ]] && grep -q 'SystemMaxUse=4G' "$dropin_file"; then log_ok "Journal size cap already configured." else mkdir -p "$dropin_dir" cat >"$dropin_file" <<'JOURNALEOF' [Journal] -SystemMaxUse=300M +SystemMaxUse=4G JOURNALEOF systemctl restart systemd-journald fi diff --git a/linux_configuration/fixes/lib/arch_perf_fixes.sh b/linux_configuration/fixes/lib/arch_perf_fixes.sh index f999876c..1e306707 100755 --- a/linux_configuration/fixes/lib/arch_perf_fixes.sh +++ b/linux_configuration/fixes/lib/arch_perf_fixes.sh @@ -15,27 +15,31 @@ fix_journal() { local needs_vacuum=false # Optional space before the unit: journalctl prints "305.5M in the file # system", with no separator, so requiring one made this dead code. - if [[ $usage_line =~ ([0-9]+\.?[0-9]*)\ ?G ]]; then + # Cap is 4G. 300M held about two days on kuhy's desktop: one Steam boot + # wrote 480k journal lines, and the evidence for a curfew failure two + # weeks earlier was already gone (2026-09-13). Only a journal past the + # cap gets vacuumed, so a healthy 2G journal is left alone. + if [[ $usage_line =~ ([0-9]+)\.?[0-9]*\ ?G ]] && ((BASH_REMATCH[1] >= 4)); then needs_vacuum=true fi if [[ $needs_vacuum == "true" ]]; then - journalctl --vacuum-size=300M + journalctl --vacuum-size=4G else - log_ok "Journal is already under 1GiB." + log_ok "Journal is already under 4G." fi # Create permanent size cap via drop-in local dropin_dir="${JOURNALD_CONF_DIR:-/etc/systemd/journald.conf.d}" local dropin_file="$dropin_dir/size-limit.conf" - if [[ -f $dropin_file ]] && grep -q 'SystemMaxUse=300M' "$dropin_file"; then + if [[ -f $dropin_file ]] && grep -q 'SystemMaxUse=4G' "$dropin_file"; then log_ok "Journal size cap already configured." else mkdir -p "$dropin_dir" cat >"$dropin_file" <<'JOURNALEOF' [Journal] -SystemMaxUse=300M +SystemMaxUse=4G JOURNALEOF systemctl restart systemd-journald fi diff --git a/linux_configuration/fixes/lib/arch_perf_report.sh b/linux_configuration/fixes/lib/arch_perf_report.sh index 9160b8b7..91d75377 100755 --- a/linux_configuration/fixes/lib/arch_perf_report.sh +++ b/linux_configuration/fixes/lib/arch_perf_report.sh @@ -40,7 +40,9 @@ check_journal_size() { local value unit value="${BASH_REMATCH[1]}" unit="${BASH_REMATCH[2]}" - if [[ $unit == "G" ]]; then + # Large means past the 4G cap arch_perf_fixes.sh/arch_hardware.sh + # install; a 2G journal is deliberate retention, not a finding. + if [[ $unit == "G" ]] && ((${value%%.*} >= 4)); then add_finding "Systemd journal is large (${value}G); excessive logs can waste I/O and disk space." fi fi @@ -66,9 +68,9 @@ apply_safe_fixes() { local journal_line journal_line=$(journalctl --disk-usage 2>/dev/null || true) # Optional space, as in check_journal_size above. - if [[ $journal_line =~ ([0-9]+\.?[0-9]*)\ ?G ]]; then - journalctl --vacuum-size=300M - add_action "Vacuumed systemd journal to 300M." + if [[ $journal_line =~ ([0-9]+)\.?[0-9]*\ ?G ]] && ((BASH_REMATCH[1] >= 4)); then + journalctl --vacuum-size=4G + add_action "Vacuumed systemd journal to 4G." fi } diff --git a/linux_configuration/fixes/lib/tests/test_arch_hardware_boot.sh b/linux_configuration/fixes/lib/tests/test_arch_hardware_boot.sh index 4a9c1c03..dbd33cee 100755 --- a/linux_configuration/fixes/lib/tests/test_arch_hardware_boot.sh +++ b/linux_configuration/fixes/lib/tests/test_arch_hardware_boot.sh @@ -106,7 +106,7 @@ _t_stub_stdin journalctl <<'STUB' exit 0 STUB _t_run tweak_journal -_t_contains "$(_t_calls)" "journalctl --vacuum-size=300M" \ +_t_contains "$(_t_calls)" "journalctl --vacuum-size=4G" \ "tweak_journal: vacuums a 4.2G journal printed without a space" # Case 19: the spaced form still matches, so the fix is a widening. @@ -119,7 +119,7 @@ _t_stub_stdin journalctl <<'STUB' exit 0 STUB _t_run tweak_journal -_t_contains "$(_t_calls)" "journalctl --vacuum-size=300M" \ +_t_contains "$(_t_calls)" "journalctl --vacuum-size=4G" \ "tweak_journal: still vacuums when the unit is spaced" # Case 20: a megabyte-sized journal is left alone. @@ -132,10 +132,10 @@ _t_stub_stdin journalctl <<'STUB' exit 0 STUB _t_run tweak_journal -_t_lacks "$(_t_calls)" "journalctl --vacuum-size=300M" \ +_t_lacks "$(_t_calls)" "journalctl --vacuum-size=4G" \ "tweak_journal: does not vacuum a 305.5M journal" -_t_contains "$out" "already under 1GiB" "tweak_journal: reports the journal is small" -_t_contains "$(cat "${JOURNALD_CONF_DIR}/size-limit.conf")" "SystemMaxUse=300M" \ +_t_contains "$out" "already under 4G" "tweak_journal: reports the journal is small" +_t_contains "$(cat "${JOURNALD_CONF_DIR}/size-limit.conf")" "SystemMaxUse=4G" \ "tweak_journal: writes the size cap drop-in" _t_contains "$(_t_calls)" "systemctl restart systemd-journald" \ "tweak_journal: restarts journald after writing the cap" @@ -143,7 +143,7 @@ _t_contains "$(_t_calls)" "systemctl restart systemd-journald" \ # Case 21: the cap is already configured -> not rewritten, journald not restarted. arch_desktop_reset _t_stub journalctl 'exit 0' -printf '[Journal]\nSystemMaxUse=300M\n' >"${JOURNALD_CONF_DIR}/size-limit.conf" +printf '[Journal]\nSystemMaxUse=4G\n' >"${JOURNALD_CONF_DIR}/size-limit.conf" _t_run tweak_journal _t_contains "$out" "size cap already configured" \ "tweak_journal: reports the cap is already in place" diff --git a/linux_configuration/fixes/lib/tests/test_arch_perf_fixes.sh b/linux_configuration/fixes/lib/tests/test_arch_perf_fixes.sh index b7facfc3..8b83e239 100755 --- a/linux_configuration/fixes/lib/tests/test_arch_perf_fixes.sh +++ b/linux_configuration/fixes/lib/tests/test_arch_perf_fixes.sh @@ -21,9 +21,9 @@ unit="${SYSTEMD_UNIT_DIR}/media-organizer.service" arch_reset _t_stub journalctl 'echo "Archived and active journals take up 4.2G in the file system."' fix_journal -_t_contains "$(_t_calls)" "journalctl --vacuum-size=300M" \ +_t_contains "$(_t_calls)" "journalctl --vacuum-size=4G" \ "fix_journal: vacuums a multi-gigabyte journal" -_t_contains "$(cat "$dropin" 2>/dev/null)" "SystemMaxUse=300M" \ +_t_contains "$(cat "$dropin" 2>/dev/null)" "SystemMaxUse=4G" \ "fix_journal: writes the permanent size cap" _t_contains "$(_t_calls)" "systemctl restart systemd-journald" \ "fix_journal: restarts journald after writing the cap" @@ -32,17 +32,17 @@ _t_contains "$(_t_calls)" "systemctl restart systemd-journald" \ arch_reset _t_stub journalctl 'echo "Archived and active journals take up 240.0M in the file system."' out="$(fix_journal 2>&1)" -_t_contains "$out" "already under 1GiB" \ +_t_contains "$out" "already under 4G" \ "fix_journal: reports a journal that is already small enough" _t_lacks "$(_t_calls)" "journalctl --vacuum-size" \ "fix_journal: does not vacuum a journal measured in megabytes" -_t_contains "$(cat "$dropin" 2>/dev/null)" "SystemMaxUse=300M" \ +_t_contains "$(cat "$dropin" 2>/dev/null)" "SystemMaxUse=4G" \ "fix_journal: still writes the cap for a small journal" # The cap already exists: it is not rewritten and journald is not restarted. arch_reset _t_stub journalctl 'echo "120.0M"' -printf '[Journal]\nSystemMaxUse=300M\n' >"$dropin" +printf '[Journal]\nSystemMaxUse=4G\n' >"$dropin" out="$(fix_journal 2>&1)" _t_contains "$out" "size cap already configured" \ "fix_journal: reports an already-configured size cap" diff --git a/linux_configuration/fixes/lib/tests/test_arch_perf_report_fixes.sh b/linux_configuration/fixes/lib/tests/test_arch_perf_report_fixes.sh index f953835b..f422fac2 100755 --- a/linux_configuration/fixes/lib/tests/test_arch_perf_report_fixes.sh +++ b/linux_configuration/fixes/lib/tests/test_arch_perf_report_fixes.sh @@ -72,9 +72,9 @@ _t_stub systemctl 'exit 0' _t_stub journalctl 'echo "Archived and active journals take up 4.2G in the file system."' apply_safe_fixes >"${TEST_TMPDIR}/out" 2>&1 out="$(cat "${TEST_TMPDIR}/out")" -_t_contains "$(_t_calls)" "journalctl --vacuum-size=300M" \ +_t_contains "$(_t_calls)" "journalctl --vacuum-size=4G" \ "apply_safe_fixes: vacuums a multi-gigabyte journal" -_t_contains "$(_t_actions)" "Vacuumed systemd journal to 300M" \ +_t_contains "$(_t_actions)" "Vacuumed systemd journal to 4G" \ "apply_safe_fixes: records the vacuum as an action" # --- print_summary ----------------------------------------------------------