wake-alarm/wake_alarm
Krzysztof kuhy Rudnicki 9e0cd123ff Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules
Item 14: the fan ramp is gone entirely. It caused anxiety without helping
anyone wake up. Deletes _max_fans/_restore_fans/_find_fan_hwmon, the
_AlarmHardware.fan_state field, both call sites, and their tests.
wake-alarm-fans.sh and its NOPASSWD sudoers entry come out in the install.sh
pass -- dropping a passwordless root helper is a bonus.

_alarm.py was 478 lines and the 250-line gate fires on any commit that stages
it, so this carries the split it has owed for a while. New modules, each a
real seam rather than an arbitrary cut:

  _gating          should-it-run-today + CLI (no time gate; that is _trigger's)
  _beep_loop       the sounding thread, now driving _escalation's planner
  _alarm_timers    self-rescheduling challenge refresh / skip window (mixin)
  _alarm_state     the progress + hardware dataclasses
  _rounds          challenge presentation, re-exporting the view helpers
  _countdown       skip-window arithmetic and demo/production intervals
  _dismiss_view    the post-dismissal banner
  _screen_flash    the ~1.3 Hz attention flash (kept under the 3 Hz threshold)
  _lock_setup      gatelock config + arbiter claim
  _startup         wake display, brightness, plug
  _tone            tone synthesis and cache (out of _audio)
  _brightness      xrandr brightness (was in _audio, never belonged there)

main() deliberately stays in _alarm.py: morning_routine/_orchestrator.py:39
hardcodes "wake_alarm._alarm", and moving it is the exact mistake that caused
a month-long silent production failure once already. Verified after the split
that the module still resolves and accepts --production.

Also fixes the plug pre-roll found while researching speakers: main() fired
turn_on_plug() and the first beep in the same instant, so an amplifier's
soft-start relay swallowed the opening of the alarm. PLUG_PREROLL_SECONDS=4
now sits between them.

Two bugs found by running the code rather than by lint:
- ruff stripped `struct` from the extracted _tone.py because the import
  landed before its first usage; only executing it caught the NameError.
- test fixtures patched _play_on_all_sinks/_set_max_brightness at
  wake_alarm._alarm, which silently stopped intercepting once those moved.

404 tests, 100% branch coverage, no new noqa/type-ignore suppressions.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EckWmyfetYq3Mi8MAnUudh
2026-08-26 23:46:10 +02:00
..
tests Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
__init__.py Add tests and fix pre-commit issues across all projects 2026-04-12 20:45:24 +02:00
_alarm_display.py feat: split oversized modules for 500-line limit, fix kasa coverage gap 2026-06-14 07:19:37 +02:00
_alarm_payload.py Discover alarm device directories instead of reading a fixed phone path 2026-08-09 17:06:43 +02:00
_alarm_state.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_alarm_timers.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_alarm_view.py Size the alarm's type in pixels, and gate every screen on fitting 768px 2026-08-03 16:04:27 +02:00
_alarm.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_audio.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_beep_loop.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_brightness.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_challenges.py Fire alarm daily, harden dismissal challenge; ignore wake_state.json 2026-07-10 23:14:40 +02:00
_constants.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_correlation.py Phase 1: structured JSONL logging with cross-process dedupe 2026-08-26 23:00:08 +02:00
_countdown.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_dismiss_view.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_escalation.py Phase 2b: add the 5-minute audio failsafe, and retune escalation to fit it 2026-08-26 23:17:41 +02:00
_escape_flow.py Size the alarm's type in pixels, and gate every screen on fitting 768px 2026-08-03 16:04:27 +02:00
_gating.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_lock_setup.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_log_dedupe.py Phase 1: structured JSONL logging with cross-process dedupe 2026-08-26 23:00:08 +02:00
_log_sink.py Phase 1: structured JSONL logging with cross-process dedupe 2026-08-26 23:00:08 +02:00
_logging_setup.py Phase 1: structured JSONL logging with cross-process dedupe 2026-08-26 23:00:08 +02:00
_reactivate.py Phase 2a: retry card-profile activation so the HDMI sink can appear 2026-08-26 23:02:52 +02:00
_rounds.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_screen_flash.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_sinks.py Replace sleep-and-hope audio waits with per-cycle presence checks 2026-07-11 18:51:03 +02:00
_smart_plug.py Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
_startup.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_state.py Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
_sync.py Discover alarm device directories instead of reading a fixed phone path 2026-08-09 17:06:43 +02:00
_tone.py Phase 3: remove the max-fan ramp, split _alarm.py, wire the new modules 2026-08-26 23:46:10 +02:00
_trigger.py Phase 1: structured JSONL logging with cross-process dedupe 2026-08-26 23:00:08 +02:00