mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 22:14:01 +01:00
focus_mode_daemon.py has been 509 lines since 22e22c1, over the repo's
cap. It went unnoticed because the Python tests workflow only triggers on
python_pkg/** changes, so that commit never ran CI; the next commit to
touch python_pkg/ exposed it and turned main red.
Extract configuration, logging, notification, /proc process inspection and
the killers into _focus_mode_lib.py, leaving the daemon its policy: the
whitelist, the FocusMode state machine, and main(). log/notify move with
the process code that calls them, so the dependency runs one way and there
is no cycle. The helper is underscore-prefixed and registered in pylint's
init-hook path, mirroring the existing usage_report.py / _usage_report_*.py
sibling-import precedent.
The daemon runs from a symlink in /usr/local/bin, so a sibling import only
works if Python resolves that symlink before setting sys.path[0]; verified
that it does, and the installer symlinks rather than copies, so the sibling
travels with it. Confirmed against the running service: restarts clean and
resumes enforcing, process detection unchanged, status output matches the
pre-split version.
Structural only; no behaviour change.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RG3eEn8rwZbcXaJrKJxdv8
18 lines
1.4 KiB
JSON
18 lines
1.4 KiB
JSON
{
|
|
"title": "focus_mode_daemon: bring back under the 500-line limit",
|
|
"objective": "focus_mode_daemon.py has been 509 lines since commit 22e22c1, breaching the repo's 500-line cap. It went unnoticed because the Python-tests workflow only triggers on python_pkg/** changes, so that commit never ran CI; the first later commit touching python_pkg/ exposed it and main is red. Split the file along a real seam with no behaviour change, and keep the live focus-mode.service working throughout.",
|
|
"acceptance_criteria": [
|
|
"No tracked Python file exceeds 500 lines",
|
|
"The split follows a real responsibility boundary, with the dependency running one way and no import cycle",
|
|
"The daemon still runs through /usr/local/bin/focus-mode-daemon, the symlink systemd uses",
|
|
"focus-mode.service restarts cleanly and resumes enforcing Steam/browser mutual exclusion",
|
|
"Process detection behaviour is unchanged",
|
|
"No behaviour change of any kind: this is a structural split"
|
|
],
|
|
"out_of_scope": [
|
|
"Any change to the daemon's mutual-exclusion policy, whitelist behaviour, or poll interval",
|
|
"The brother_printer work in a12e696/69242e4"
|
|
],
|
|
"verifier": "ruff check; /usr/local/bin/focus-mode-daemon --help and status compared against the pre-split version from git; systemctl --user restart focus-mode.service plus journal inspection; wc -l over tracked *.py; CI (Python tests)"
|
|
}
|