mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 18:54:03 +01:00
329 -> 230 + 124. The colour constants, human_readable, dir_size_kb, report, confirm and try_clean move to lib/disk_cleanup_common.sh, along with the report-only loop and the summary block as print_report_only and print_summary. The seam passes state -- report accumulates into TOTAL_RECLAIMABLE and confirm reads CLEAN -- so both are set before the source line, and the verification is a trace diff rather than a static check: identical exit status, identical ordered du calls, identical stdout and stderr against a detached worktree at the pre-split commit. Also ran it for real from /tmp (not its own directory) to confirm SCRIPT_DIR resolves the lib from any cwd: 303.7 GB reported reclaimable, nothing deleted. The one shellcheck finding (SC2034 on RED) was fixed by moving the function that uses it, not suppressed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
44 lines
3.0 KiB
JSON
44 lines
3.0 KiB
JSON
{
|
|
"intent": "Bring meta/scripts/disk_cleanup_check.sh (329 lines) under the 250-line cap by moving its formatting, sizing, confirmation and output helpers into a sourced lib.",
|
|
"scope": [
|
|
"meta/scripts/disk_cleanup_check.sh",
|
|
"meta/scripts/lib/disk_cleanup_common.sh (new)",
|
|
"Non-goal: no change to which directories are checked, what is reported, or what --clean deletes"
|
|
],
|
|
"changes": [
|
|
"Move the six colour constants and human_readable/dir_size_kb/report/confirm/try_clean into lib/disk_cleanup_common.sh.",
|
|
"Move the report-only loop and the summary block into print_report_only and print_summary in the same lib; the entry script now ends with two calls.",
|
|
"Add SCRIPT_DIR resolved from BASH_SOURCE so the source line works from any cwd, and set CLEAN/TOTAL_RECLAIMABLE before sourcing, since confirm reads CLEAN and report accumulates into TOTAL_RECLAIMABLE."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "meta/scripts/trace_shell_split.sh <script> --stub du --out before.txt (detached worktree at the pre-split commit), then again after the split, then diff",
|
|
"result": "pass",
|
|
"evidence": "TRACE IDENTICAL -- exit status, the ordered list of stubbed `du -sk` calls, stdout and stderr all byte-identical. This is the check that matters here: the seam passes state (report mutates TOTAL_RECLAIMABLE, confirm reads CLEAN), so a static check could not have caught a break."
|
|
},
|
|
{
|
|
"command": "bash ~/testsAndMisc/meta/scripts/disk_cleanup_check.sh (run for real from /tmp, not from the script's own directory)",
|
|
"result": "pass",
|
|
"evidence": "exit 0, full report against real data: 303.7 GB auto-reclaimable, current usage 1445.6 GB / 3665.4 GB (42%). Running from a different cwd confirms SCRIPT_DIR resolves the lib correctly -- a known failure mode for split scripts. Dry-run default, nothing deleted."
|
|
},
|
|
{
|
|
"command": "bash -n + shellcheck -x on the entry, shellcheck on the lib, shfmt -d on both",
|
|
"result": "pass",
|
|
"evidence": "All exit 0 with no output. An initial SC2034 (RED appears unused) was resolved by moving print_report_only -- which uses RED -- into the lib, rather than by adding a suppression."
|
|
},
|
|
{
|
|
"command": "bash ~/utils/scripts/check_file_length.sh on both files",
|
|
"result": "pass",
|
|
"evidence": "329 -> 230 (entry) + 124 (lib), both under the 250 cap."
|
|
}
|
|
],
|
|
"risks": [
|
|
"The lib depends on CLEAN and TOTAL_RECLAIMABLE being set by the caller before it is sourced. That is documented in its header comment; sourcing it standalone would leave confirm reading an unset CLEAN.",
|
|
"`bc` was briefly stubbed during the first baseline attempt, which produced 'printf: invalid number' noise -- bc is a calculator, not a mutator. The recorded baseline uses real bc and has empty stderr."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; the helpers return inline and lib/disk_cleanup_common.sh disappears.",
|
|
"Re-run the script from any directory and confirm it prints the analysis table and a non-zero total."
|
|
]
|
|
}
|