{ "intent": "Bring phone_focus_mode/lib/monitor.sh under the 250-line cap by moving its health probes into two sibling libraries, without changing any monitoring behaviour.", "scope": [ "phone_focus_mode/lib/monitor.sh — 449 lines, now 215", "phone_focus_mode/lib/monitor_checks_health.sh — new, 138 lines", "phone_focus_mode/lib/monitor_checks_policy.sh — new, 136 lines", "Non-goal: deploy.sh copy lists. lib/monitor.sh is a PC-side library consumed by run_phone.sh; deploy.sh never references lib/ and does not push it to the phone." ], "changes": [ "Moved the six device-health probes (_check_format_indicators, _check_battery, _check_storage, _check_daemon, _check_hosts_daemon, _check_launcher_daemon) into monitor_checks_health.sh.", "Moved the five enforcement-integrity probes (_check_hosts_integrity, _check_dns, _check_launcher, _check_companion_app, _check_boot_persistence) into monitor_checks_policy.sh.", "Partitioned the _MONITOR_* constants by reader so no file assigns a global it never reads (SC2034). The five read only by the policy probes moved into that file; _MONITOR_REMOTE_DIR, _MONITOR_HOSTS_TARGET, _MONITOR_HOSTS_CANDIDATES and the two launcher constants stay in monitor.sh, which reads them or shares them across both children.", "Placed the two source lines after the constant block they depend on, using the already-computed _MONITOR_LIB_DIR rather than recomputing the directory per source line.", "A single-library split was tried first and rejected: it left monitor_checks.sh at 265 lines, still over the cap, which is the net-zero outcome the brief warns about." ], "verification": [ { "command": "bash phone_focus_mode/lib/tests/test_monitor.sh", "result": "pass", "evidence": "9 passed, 0 failed — identical to the pre-split baseline captured before any edit. This is the discriminating check: the count matches exactly." }, { "command": "bash meta/scripts/verify_shell_split.sh HEAD phone_focus_mode/lib/monitor.sh phone_focus_mode/lib/monitor.sh phone_focus_mode/lib/monitor_checks_health.sh phone_focus_mode/lib/monitor_checks_policy.sh", "result": "pass", "evidence": "'IDENTICAL: all 25 top-level functions moved verbatim'. Note the old path must also be listed among the new paths for a partial split, since 14 functions stayed in monitor.sh; omitting it makes the tool report a false DIFFERENCE with an empty after-set." }, { "command": "bash phone_focus_mode/run_phone.sh --help", "result": "pass", "evidence": "Exit 0 with the full usage block, proving the source chain through both new libraries resolves in the real consumer, not just under the test harness." }, { "command": "shellcheck phone_focus_mode/lib/monitor.sh phone_focus_mode/lib/monitor_checks_health.sh phone_focus_mode/lib/monitor_checks_policy.sh", "result": "pass", "evidence": "All three clean, each checked standing alone (no -x), so the constant partition holds without a source directive." }, { "command": "bash meta/scripts/check_file_length.sh --all", "result": "fail-as-expected", "evidence": "24 files over the cap before, 23 after; monitor.sh at 215 and both new libraries at 138 and 136 are all under. No new file was pushed over." } ], "risks": [ "monitor.sh now sources two siblings before defining the helpers they call (_mon_check, _trim_output). This is safe because nothing executes until monitor_collect_snapshot runs, but a future top-level call in either library would break at source time.", "The test covers 9 assertions against helper functions, none of which are the moved _check_* probes; those are device-dependent and unexercised here. The verbatim hash check is what covers them." ], "rollback": [ "git revert the commit; monitor.sh returns to 449 lines and the two libraries disappear. run_phone.sh needs no change because it only ever sourced monitor.sh.", "After rollback, re-run bash phone_focus_mode/lib/tests/test_monitor.sh and confirm 9 passed, then bash phone_focus_mode/run_phone.sh --help and confirm exit 0." ] }