testsAndMisc/docs/superpowers/contracts/shell-splits-batch-2026-08-17.json
Krzysztof kuhy Rudnicki 76e73830f6 shell: split clean_audio, enforce_vbox_hosts and migrate_hosts_guard
clean_audio.sh          419 -> 230 + 204
  enforce_vbox_hosts.sh   443 -> 220 + 236
  migrate_hosts_guard.sh  444 -> 167 + 162 + 141

migrate_hosts_guard needed two libraries: with all ten work functions moved
the single lib was 295 lines, so migrate and rollback were separated.

The extractor's brace matcher required index > start and so silently skipped
one-line `warn() { ...; }` definitions. Fixed, and regression-checked against
the committed fresh-install/main.sh split byte-for-byte.

The harness earned its keep on a fourth file: adding `export` to libre_translate
to satisfy SC2034 changed two function bodies, and verify_shell_split.sh caught
what lint had accepted. Those exports were reverted, and libre_translate.sh is
parked - what remains after its clean seams both assigns and reads the same
globals, so getting it under the cap needs parse_args restructured rather than
relocated, which is a refactor rather than a verbatim move.

That cost is now written down: a lib must contain the readers of every global
it assigns. The precedent at install_pacman_wrapper.sh:29 is about
definitions-only libs, not about assignments as such, and the pre-commit hook
runs shellcheck with no -x, so a source= directive will not make it follow the
link. This is the shell analogue of the monkeypatch-target trap.

Verified: all 8, 13 and 19 functions verbatim; all four libraries source with
no side effects; shellcheck passes standalone on every file with no
suppression; bash -n passes on all seven. None of the three was executed -
they drive ffmpeg over real media, mutate VirtualBox guest disks, and rewrite
systemd units.

Over-cap files 29 -> 26.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-17 14:27:57 +02:00

18 lines
1.3 KiB
JSON

{
"title": "Split three more over-cap shell scripts",
"objective": "clean_audio.sh, enforce_vbox_hosts.sh and migrate_hosts_guard_to_guard_lib.sh are over the 250-line cap with no deployed copy, so the entry+lib shape is safe. Move each script's work functions into libraries beside it, verbatim, leaving the entry owning the CLI, the ordering and the globals it assigns.",
"acceptance_criteria": [
"All seven resulting files are under 250 lines; the over-cap total falls 29 -> 26",
"Every top-level function is verbatim, proved by meta/scripts/verify_shell_split.sh",
"Each library sources with no side effects and defines every function moved into it",
"shellcheck passes on every file standalone, with no suppression added",
"bash -n passes on all seven"
],
"out_of_scope": [
"libre_translate.sh, whose remaining seam needs parse_args restructured rather than relocated - a refactor, not a verbatim move",
"Running any of the three scripts: they drive ffmpeg over real media, mutate VirtualBox guest disks, and rewrite systemd units",
"The phone_focus_mode scripts and the pacman-wrapper pair"
],
"verifier": "bash meta/scripts/verify_shell_split.sh for the verbatim claim; sourcing each library in a subshell; shellcheck standalone on each new file; bash -n on all seven; bash ~/utils/scripts/check_file_length.sh --all."
}