{ "intent": "Delete the dead _compute_window shim from _usage_report_run.py so the module carries no code without callers, ahead of the remaining file-length split work.", "scope": [ "linux_configuration/scripts/periodic_background/system-maintenance/bin/_usage_report_run.py", "linux_configuration/tests/test_usage_report_segments.py", "Non-goal: any behaviour change to _run_single_day or _run_since", "Non-goal: splitting this file - it is already 86 statements, well under the 250-line cap" ], "changes": [ "Removed _compute_window, a helper documented as 'kept for backwards import compatibility' whose only in-tree callers were its own two tests.", "Removed the two tests that exercised only the shim, and dropped it from the test module docstring.", "Removed the now-unused `from pathlib import Path` TYPE_CHECKING import; Path was referenced only by the deleted signature.", "Kept _SEC_PER_DAY: grep shows two live callers remain at _usage_report_run.py:135 and :181, so only the function was dead, not the constant." ], "verification": [ { "command": "grep -rn '_compute_window' --include='*.py' --include='*.sh' --include='*.md' --include='*.json' . (excluding .venv/node_modules)", "result": "pass", "evidence": "Before deletion: one definition, two tests, and prose mentions in NEXT_SESSION_PROMPT.md plus prior evidence/contract JSON. Zero production callers, and the name appears in no __all__." }, { "command": "grep -c '_SEC_PER_DAY' _usage_report_run.py", "result": "pass", "evidence": "4 hits: the definition, the deleted shim's use, and two live uses at lines 135 and 181. The constant is retained." }, { "command": "python3 -c 'import _usage_report_run as r; print(hasattr(r, \"_compute_window\"), r._SEC_PER_DAY)'", "result": "pass", "evidence": "imports OK / has _compute_window: False / _SEC_PER_DAY: 86400" }, { "command": "python3 usage_report.py --help", "result": "pass", "evidence": "Exit 0, full usage text printed. Unit tests stub subprocesses, so running the real entry point is what proves the post-deletion import graph resolves." }, { "command": "systemd-run --user --scope -p MemoryMax=2G -p MemorySwapMax=0 python3 -m pytest linux_configuration/tests/ -q", "result": "pass", "evidence": "202 passed in 4.21s. Count dropped from 204 by exactly the two deleted shim tests." }, { "command": "pytest --cov=.../system-maintenance/bin --cov-branch --cov-report=term-missing", "result": "pass", "evidence": "_usage_report_run.py: 86 statements, 0 missing, 22 branches, 0 partial, 100%. Coverage held at 100% line+branch after removing both the code and its tests." }, { "command": "bash ~/utils/scripts/check_file_length.sh --all", "result": "pass", "evidence": "36 files over cap, unchanged by this commit; neither touched file is among them. Checked before committing, per the known trap that a split can push a file over." } ], "risks": [ "An out-of-tree consumer could import _compute_window by name. Judged negligible: these bin/ modules are private (leading underscore), are not packaged or installed, and are imported only by usage_report.py and the tests beside them.", "The deleted tests contributed to the module's covered branches; coverage was re-measured rather than assumed, and is still 100%." ], "rollback": [ "git revert the commit; the shim and its two tests return together.", "After rollback, re-run pytest linux_configuration/tests/ and expect 204 passed, and confirm _usage_report_run.py is back to 100% coverage." ] }