From 658988ef9b12869cad3c0a850540f68817571779 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 16 Aug 2026 18:38:43 +0200 Subject: [PATCH] Split three near-miss linux_configuration scripts turn_off_auto_idle_screen_shutdown.sh 289 -> 180, mtk_root/install.sh 262 -> 141, setup_gitea.sh 255 -> 198. A deliberately small batch to check jscpd before scaling; it stayed well under 2%. The stubbed run earned its place again: mtk_root/install.sh aborted with "SCRIPT_DIR: readonly variable" because it already declared one, and both bash -n and shellcheck were clean on that broken file. Two shellcheck findings the split exposed are fixed at the source, not suppressed: persist_with_systemd_logind now takes the flag as an argument instead of reading the caller's global, and a dead python_bin assignment is gone. Neither was introduced here - the pre-split file already had three SC2034 warnings. No script was executed; all three are installers or enforcement. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY --- ...ux-config-near-miss-batch1-2026-08-16.json | 19 +++ ...ux-config-near-miss-batch1-2026-08-16.json | 51 +++++++ .../scripts/mtk_root/install.sh | 127 +---------------- .../scripts/mtk_root/lib/mtk_udev.sh | 129 ++++++++++++++++++ .../single_use/features/lib/gitea_network.sh | 67 +++++++++ .../single_use/features/setup_gitea.sh | 63 +-------- .../single_use/utils/lib/idle_inhibit.sh | 122 +++++++++++++++++ .../turn_off_auto_idle_screen_shutdown.sh | 117 +--------------- 8 files changed, 398 insertions(+), 297 deletions(-) create mode 100644 docs/superpowers/contracts/linux-config-near-miss-batch1-2026-08-16.json create mode 100644 docs/superpowers/evidence/linux-config-near-miss-batch1-2026-08-16.json create mode 100755 linux_configuration/scripts/mtk_root/lib/mtk_udev.sh create mode 100755 linux_configuration/scripts/single_use/features/lib/gitea_network.sh create mode 100755 linux_configuration/scripts/single_use/utils/lib/idle_inhibit.sh diff --git a/docs/superpowers/contracts/linux-config-near-miss-batch1-2026-08-16.json b/docs/superpowers/contracts/linux-config-near-miss-batch1-2026-08-16.json new file mode 100644 index 00000000..368848b3 --- /dev/null +++ b/docs/superpowers/contracts/linux-config-near-miss-batch1-2026-08-16.json @@ -0,0 +1,19 @@ +{ + "title": "Split three near-miss linux_configuration scripts under the 250-line cap", + "objective": "Bring turn_off_auto_idle_screen_shutdown.sh (289), mtk_root/install.sh (262) and setup_gitea.sh (255) under the cap using the pattern established by the install_joplin.sh split, and prove the pattern holds on a small batch before scaling to the remaining 80 files.", + "acceptance_criteria": [ + "All three entry scripts and all three new libs are at most 250 lines.", + "bash -n and shellcheck pass on every entry script and every new lib, with no new suppression and no shellcheck disable directive.", + "A stubbed run of each entry script -- copied into a mirrored temp tree, with the final main invocation replaced by a declare -F probe -- reports every moved function as defined. This is the check that replaces the pass count; static checks alone are known insufficient.", + "No enforcement script is executed. turn_off_auto_idle_screen_shutdown.sh in particular manipulates idle inhibition and logind and must not run.", + "The two live systemd units that point at repo paths still resolve to existing files.", + "jscpd stays under its 2% duplication threshold on the real git commit, which is the only place it runs.", + "No behaviour change: functions move verbatim, apart from the two shellcheck findings fixed below." + ], + "out_of_scope": [ + "Executing any installer or enforcement step.", + "The digital_wellbeing scripts, which are live enforcement and are deferred to the end with phone_focus_mode.", + "Changing what any script does when run." + ], + "verifier": "The scratchpad verify_split.sh per script (bash -n + shellcheck -x + stubbed run), plus systemctl cat on the two repo-path units, plus pre-commit run --files, plus the real git commit for jscpd." +} diff --git a/docs/superpowers/evidence/linux-config-near-miss-batch1-2026-08-16.json b/docs/superpowers/evidence/linux-config-near-miss-batch1-2026-08-16.json new file mode 100644 index 00000000..5c4811ee --- /dev/null +++ b/docs/superpowers/evidence/linux-config-near-miss-batch1-2026-08-16.json @@ -0,0 +1,51 @@ +{ + "intent": "Split three near-miss linux_configuration scripts under the cap, and confirm the shell-split pattern holds on a small batch before scaling it.", + "scope": [ + "linux_configuration/scripts/single_use/utils/turn_off_auto_idle_screen_shutdown.sh (289 -> 180) + lib/idle_inhibit.sh", + "linux_configuration/scripts/mtk_root/install.sh (262 -> 141) + lib/mtk_udev.sh", + "linux_configuration/scripts/single_use/features/setup_gitea.sh (255 -> 198) + lib/gitea_network.sh", + "Non-goal: no script executed, no behaviour change" + ], + "changes": [ + "Moved the idle-inhibit process and controller watchers, the mtkclient udev/venv setup, and the Gitea firewall/UPnP/router block into sourced libs, each following the pattern from the install_joplin.sh commit: shebang, chmod +x, no set -euo pipefail, and SCRIPT_DIR via ${BASH_SOURCE[0]}.", + "mtk_root/install.sh already declared SCRIPT_DIR readonly, so the split reuses it rather than redeclaring; its existing $0 was upgraded to ${BASH_SOURCE[0]} at the same time.", + "Fixed two shellcheck findings the split exposed. persist_with_systemd_logind now takes the persist flag as an argument instead of reading the caller's global, so the lib is checkable standalone. python_bin in the mtkclient setup was assigned and never read - dead code, deleted rather than carried into the new file.", + "Neither finding was introduced by the split: shellcheck already reported three SC2034 warnings on the pre-split mtk_root/install.sh." + ], + "verification": [ + { + "command": "scratchpad/verify_split.sh