testsAndMisc/docs/superpowers/specs/2026-05-01-phone-focus-recovery/03-monitoring.md
Krzysztof kuhy Rudnicki 346eb1f00b Bring every markdown file under the cap
Twelve prose violations to zero. Eight files split into per-topic
subdirectories with the original left as an index; both SKILL.md files
keep their frontmatter so discovery still works, with detail moved to
references/.

Deleted docs/cleanup-2026-05/ (7 files) and linux_configuration/docs/
VERIFICATION.md on the user's ruling: unreferenced records of finished
work whose rules are now enforced by the polling, shellcheck and shfmt
hooks. PACMAN_WRAPPER_SECURITY.md was split instead - unlike those, it
documents live guarantees.

Every split verified by a sorted diff against HEAD: zero content lines
lost, only the new headings and index links added.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-16 19:25:59 +02:00

120 lines
3.6 KiB
Markdown

# Monitoring scope and the report contract
## Monitoring scope
Monitoring should cover all user-requested areas.
### Battery wear and thermal state
- battery level
- charge status
- health and temperature if exposed
- evidence of abnormal thermal throttling or overheating
### Storage pressure and filesystem issues
- free space on major storage locations
- install/update failures caused by storage exhaustion
- signs of partition or package-management problems
### Performance and resource drift
- memory pressure indicators
- unusually heavy processes
- persistent crash or restart loops in the managed daemons
### Security drift
- focus daemon running or not
- hosts enforcer running or not
- DNS enforcer running or not
- launcher enforcer running or not
- companion app installed or missing
### Network and DNS bypass drift
- Private DNS re-enabled
- expected firewall chain missing
- hosts target hash or mount mismatch
- launcher default changed away from the protected launcher
### Boot persistence drift
- Magisk `service.d` script missing or no longer executable
- expected on-device files missing from `focus_mode`
- companion app missing when it is required for status visibility
## Monitoring report contract
Every monitoring run should produce two outputs:
- a concise human-readable summary
- a machine-readable report file suitable for later diffing and automation
Recommended report path pattern:
- `<backup-root>/<device-id>/monitoring/<timestamp>.json`
- `<backup-root>/<device-id>/monitoring/latest.json`
Recommended trusted-device record path:
- `${XDG_STATE_HOME:-$HOME/.local/state}/phone_focus_mode/trusted_device.sh`
Recommended runtime-automation state paths:
- `${XDG_STATE_HOME:-$HOME/.local/state}/phone_focus_mode/locks/`
- `${XDG_STATE_HOME:-$HOME/.local/state}/phone_focus_mode/last_run/`
Daily automation must not dirty the repository working tree merely by being
used. Trusted-device metadata, lock files, cooldown markers, and last-run
timestamps should therefore live in machine-local state outside the repo.
Recommended latest-backup pointer behavior:
- `latest/` should be a symlink to the newest history snapshot when the host
filesystem supports symlinks
- otherwise `latest/` may be refreshed as a copied mirror of the newest
snapshot
The machine-readable report should distinguish at least these severities:
- `ok`
- `warn`
- `error`
- `fatal`
Each reported check should record:
- check name
- status/severity
- evidence source
- short message
- whether the issue is repairable automatically
Important checks should verify more than just PID existence. For example:
- hosts protection should confirm both the canonical hash and the active
target mount/content state
- DNS protection should confirm Private DNS settings and firewall chain
presence
- launcher protection should confirm installation, stored snapshot metadata,
and current default HOME activity
- boot persistence should confirm the expected Magisk boot script is present
`monitor` should exit nonzero on severe drift. `doctor` should use the same
report format while additionally recording what was repaired.
For the initial implementation, “severe drift” should mean any of:
- target device identity mismatch
- no root access when root-dependent checks are required
- hosts enforcement missing or failing integrity checks
- DNS enforcement missing when it was previously configured
- launcher protection missing when launcher protection was previously
configured
- missing boot persistence for the managed stack
History retention and pruning policy should be locked down in the
implementation plan, but the initial default should favor safety over
aggressive deletion.