{ "intent": "Bring music_parallelism.sh under the 250-line cap by moving its nine functions into three sourced libs, leaving its behaviour and its test outcomes unchanged.", "scope": [ "linux_configuration/scripts/periodic_background/digital_wellbeing/music_parallelism.sh (412 -> 135 lines)", "New: lib/music_{detect,monitor,status}.sh", "linux_configuration/tests/test_music_parallelism.sh -- harness only, so the libs reach the temp worktree", "Non-goal: changing any assertion, interval, or detection pattern" ], "changes": [ "Moved wait_seconds, contains_music_process, find_music_services and kill_music_services into lib/music_detect.sh. The first two of those four share the MUSIC_FOUND_PROCESS / MUSIC_FOUND_WINDOW pair, so they stay in one file and no mutable state crosses a boundary.", "Moved notify_user, instant_monitor_loop and monitor_loop into lib/music_monitor.sh; notify_user is called only by those two loops.", "Moved show_status and show_usage into lib/music_status.sh.", "The entry script keeps the header, the common.sh dual-path source, all configuration arrays and the command dispatch case, and sources the three libs after the configuration they read.", "Renamed monitor_loop's local music_services to active_services. shellcheck flagged the local as a possible misspelling of the MUSIC_SERVICES config array (SC2153) once both appeared in the same file; renaming the purely internal local is the fix, not a suppression.", "Taught the test harness to copy the script's lib/ directory into its temp worktree alongside the script. No assertion, expectation or check was changed." ], "verification": [ { "command": "bash linux_configuration/tests/test_music_parallelism.sh", "result": "pass", "evidence": "Exit 0, the same five checks as before the split, by the same names: stable-focus backoff, conflict retry interval, idle interval, conflict-path xdotool deduplication, monitor-loop xdotool deduplication. Baseline was captured before any edit and matches." }, { "command": "shellcheck music_parallelism.sh lib/music_*.sh", "result": "pass", "evidence": "Zero findings across all four files at the repo's no-severity-filter setting, with no suppression added." }, { "command": "bash -n on the entry and each lib", "result": "pass", "evidence": "All four parse. This check earned its keep: the first splice dropped notify_user's closing brace, and shellcheck reported it only as SC1094 'parsing of sourced file failed' on the entry, which reads like a lint nicety rather than a broken file." }, { "command": "bash ~/utils/scripts/check_file_length.sh", "result": "pass", "evidence": "entry 135, detect 133, monitor 91, status 85. None of the four appears in the violation list." }, { "command": "diff of the function set against HEAD", "result": "pass", "evidence": "Identical: all nine functions preserved, each defined exactly once across the four files. No lib sources another; the entry sources all three." }, { "command": "sorted line-set diff of HEAD:music_parallelism.sh against entry+libs concatenated", "result": "pass", "evidence": "The only differences are the three lines carrying the deliberate music_services -> active_services rename, and the three added source lines. No executable line lost." } ], "risks": [ "The test harness previously copied one file; it now copies a directory too. If a future split adds a lib elsewhere the same fix will be needed again, but the failure is loud -- the source line aborts the script and every check fails, which is how this one was caught.", "The entry keeps the existing $0-based SCRIPT_DIR rather than ${BASH_SOURCE[0]}. Safe here because nothing sources music_parallelism.sh: it is invoked as a command by its dispatch case, and grep over linux_configuration finds no other reference than the test.", "The script has a /usr/local/lib/common.sh fallback for its shared library, but no installed copy of the script itself exists (checked /usr/local/bin), so the new libs are only ever resolved from the repo." ], "rollback": [ "git revert the commit; music_parallelism.sh returns to its 412-line single-file form, the three libs disappear, and the test harness stops copying a lib/ directory that no longer exists.", "After rollback, re-run bash linux_configuration/tests/test_music_parallelism.sh and confirm the same five checks still pass." ] }