mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 18:34:04 +01:00
The entry point now holds only the parser, mode dispatch and main. Three modules take one concern each: _usage_report_logs (where the logs are, the state file, per-day segment planning), _usage_report_emit (preflight, stdout, clipboard), _usage_report_run (the two run paths and the aggregation they drive). Verified by the 100%-coverage tests from the previous commit. An AST comparison of all 22 top-level defs and classes reports 22 identical, 0 mismatches. All four modules hold 100% line+branch. 204 tests before and after. Both CLI modes were run against the machine's real logs, which is the check the unit tests cannot make: they stub the collaborators, so only a real run proves the new import graph resolves. Two lessons, recorded because the next target is a 498-line file: This cut was too big. Two names had to be relocated after their first placement created an import cycle, and four modules' worth of monkeypatch targets needed re-pointing. A smaller first slice would have been cheaper. Patching a moved function must target the module whose namespace resolves it - the caller's, not the one it was moved to. Getting that wrong on _run_since made main() call the real function, which read the actual atop logs and hung the suite rather than failing. Three import bugs (Path and _fmt_h left under TYPE_CHECKING but used at runtime, dataclass missing where _Aggregates landed) were caught immediately by the coverage from the previous commit. Over-cap 38 -> 37. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
19 lines
1.6 KiB
JSON
19 lines
1.6 KiB
JSON
{
|
|
"title": "Split usage_report.py into an entry point plus three concern modules",
|
|
"objective": "usage_report.py was 426 lines against a 250-line cap, the last over-cap file in its directory. The preceding commit took it from 47% to 100% coverage so this split could be verified against tests that predate the seam. Success means the entry point keeps only argument parsing and dispatch, the three extracted modules each hold one concern, every moved definition is provably unchanged, coverage stays at 100% everywhere, and both CLI modes still produce a real report.",
|
|
"acceptance_criteria": [
|
|
"usage_report.py is under 250 lines and the over-cap total drops (38 -> 37)",
|
|
"Every moved top-level def and class is AST-identical to its HEAD version",
|
|
"All four resulting modules hold 100% line and branch coverage",
|
|
"The test count is 204 both before and after",
|
|
"Every test names the module that owns the symbol it patches - no reaching a moved function through the module it left",
|
|
"Both `usage_report.py --date <today>` and `--since <today>` produce a report from the machine's real logs"
|
|
],
|
|
"out_of_scope": [
|
|
"meta/scripts/optimize_vscode.py (498) and the three transcribe_* files, still over cap and untested",
|
|
"Deleting the dead _compute_window shim, still carried for backwards import compatibility with no callers",
|
|
"Any behaviour change to the report or the CLI surface"
|
|
],
|
|
"verifier": "An AST comparison script for the verbatim-move claim; pytest with --cov of all four modules and --cov-branch; check_file_length.sh --all for the cap; both CLI modes run against the real logs; pre-commit run --files for lint."
|
|
}
|