mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 22:54:01 +01:00
lib/monitor.sh was 199 lines over the cap. Its eleven _check_* probes move into two siblings: monitor_checks_health.sh (format indicators, battery, storage, the three enforcer daemons) and monitor_checks_policy.sh (hosts blocklist, DNS chain, launcher, companion app, boot persistence). A single monitor_checks.sh was tried first and left at 265 lines — still over, the net-zero outcome. Two libraries split the cluster at its own seam and land both comfortably under. The _MONITOR_* constants are partitioned by reader so no file assigns a global it never reads. The five read only by the policy probes move into that file; the ones monitor.sh reads itself or shares between both children stay put. shellcheck is clean on each file standing alone. Not a deployment concern: lib/monitor.sh is PC-side, consumed by run_phone.sh, and deploy.sh never references lib/ — so neither copy list changes. Verified three ways: test_monitor.sh reports 9 passed / 0 failed, the same count as before; verify_shell_split.sh confirms all 25 top-level functions moved verbatim; and run_phone.sh --help exits 0, proving the source chain resolves in the real consumer. Over-cap count 24 -> 23. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
52 lines
4.1 KiB
JSON
52 lines
4.1 KiB
JSON
{
|
|
"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."
|
|
]
|
|
}
|