mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 21:34:05 +01:00
Location/curfew goes to daemon_location.sh, the derived state files to daemon_state.sh, the app layer to daemon_apps.sh. All 23 functions moved verbatim -- nothing restructured, which matters more here than anywhere else in this session. focus_daemon.sh has five `while IFS= read -r pkg; do ... done <file` loops and EVERY body calls pm. Piping any of them in lets pm inherit and drain the loop's stdin, so it would process one package instead of all of them -- measured elsewhere in this repo as 1 of 54. That audit ran BEFORE the extraction, not after coverage came back short, and all five moved untouched with a note above them saying why. CURRENT_MODE and _CURFEW_TICK_CACHED are each written in both the entry script and a library, so both stay declared with main, same call as NET_BUILT in the curfew split. 110 assertions and 33 mutations, all killed. Two survived the first run and both were defects in my own tests: the whitelist and sysprotect exactness checks used a SUPERSTRING of a listed entry, which fails under grep -qF and grep -qxF alike and so proved nothing about which was in use. Two subjects are NOT at 100%, and the numbers are reported as measured: daemon_state.sh 67/67 = 100.00% daemon_location.sh 26/40 = 65.00% daemon_apps.sh 71/76 = 93.42% Both shortfalls are kcov attribution failures, shown to be artifacts rather than gaps. daemon_location.sh's missing lines are all inside the embedded awk Haversine; mutating the Earth radius and dropping the longitude term both fail the suite, and an isolated probe shows a one-line awk measuring 100% where the identical multi-line one measures 0%. Collapsing the formula to satisfy the tool would cost the readability of the only real mathematics in the repo, so it stays. daemon_apps.sh's five are the trailing `done <file` of the very loops described above. That is the same artifact piping fixed in curfew_net.sh, and it is exactly what must NOT be done here. Redirecting two of them from /dev/null fails the suite, so the lines run; all three are pinned in the mutation spec instead. Over-cap count 19 -> 18. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
22 lines
2.6 KiB
JSON
22 lines
2.6 KiB
JSON
{
|
|
"title": "Split focus_daemon.sh into three tested libraries",
|
|
"objective": "Take focus_daemon.sh from 543 lines to under the repo's 250-line cap by extracting its location/curfew logic, its state-file builders and its app layer into three flat siblings, and test all three. is_allowed is the single decision that determines whether an app keeps working; it had no test at all.",
|
|
"acceptance_criteria": [
|
|
"bash meta/scripts/check_file_length.sh --all no longer lists phone_focus_mode/focus_daemon.sh, and no new file is over the cap.",
|
|
"Every stdin-draining `while read ... done < file` loop is identified BEFORE extraction and moved verbatim. None may be converted to a pipe: each body calls pm, which would drain the loop's stdin.",
|
|
"Every assertion is mutation-proofed with zero survivors, including mutations targeting code kcov cannot attribute — the embedded awk Haversine and the trailing `done < file` redirect lines.",
|
|
"Where kcov cannot reach 100%, the shortfall must be shown to be a measurement artifact by mutation, and reported as an explicit exception with the real number — never by restructuring code in a way that risks behaviour.",
|
|
"meta/scripts/verify_shell_split.sh reports every function moved verbatim.",
|
|
"All three siblings are added to BOTH of deploy.sh's hardcoded lists, and the two lists remain in exact correspondence.",
|
|
"shellcheck passes on each touched file individually, with no -x and no disable directive; sh -n passes on all four phone-side scripts.",
|
|
"A reproducible mutation spec lands in meta/scripts/fixtures/mutations/."
|
|
],
|
|
"out_of_scope": [
|
|
"Deploying to the phone or verifying on-device; there is no device in this session.",
|
|
"Splitting init, main, acquire_lock or the logging helpers out of the entry script, which is under the cap without the three extracted clusters.",
|
|
"Moving CURRENT_MODE or _CURFEW_TICK_CACHED out of the entry script: both are written there and in a library, so they are genuine shared globals.",
|
|
"Collapsing the multi-line awk Haversine onto one line to satisfy kcov; readability of the distance formula outweighs a measurement artifact."
|
|
],
|
|
"verifier": "bash phone_focus_mode/lib/tests/test_daemon_libs.sh (expects 110 passed, 0 failed), plus shell_coverage.sh reporting 100.00% for daemon_state.sh and the documented artifact figures for the other two, plus python3 meta/scripts/mutate_shell.py meta/scripts/fixtures/mutations/daemon_libs.json at 33 killed / 0 not killed, plus check_file_length.sh --all showing 18 files, plus deploy-list parity, plus pre-commit run --files on the touched files."
|
|
}
|