wake-alarm/wake_alarm/tests
Krzysztof kuhy Rudnicki f5cfc3e452 Phase 1: structured JSONL logging with cross-process dedupe
Adds the diagnostic substrate the rest of the hardening work builds on. A
6am failure should be reconstructable afterwards instead of re-debugged.

Two sinks, deliberately. stderr -> journal is unchanged. Alongside it, one
JSON object per line in ~/.local/state/wake_alarm/events.jsonl, so a morning
can be replayed with jq.

The hard constraint is that _trigger is a fresh process every 60 seconds, so
an in-memory rate limiter would reset on every tick and suppress nothing.
_log_dedupe therefore persists the last emitted fingerprint to disk and
flushes a suppressed_repeats count onto the next distinct record. Verified
across separate processes: 4 invocations logging the same routine event
produce 1 record plus an accurate count of 3.

That is what satisfies the standing "do not raise the level of _sync's
degraded-read paths" rule by construction, rather than by keeping levels
artificially low and losing the signal.

The correlation id is derived, never generated: both halves compute
wake-YYYYMMDD-HHMM from the resolved alarm instant, so the PC and the phone
agree with no handshake and no uuid exchange -- which matters precisely when
sync is down.

Logging never raises. An unwritable sink degrades to journal-only.

_alarm.py and _sync.py keep the default component= for now; tagging them
means splitting them for the 250-line gate, which belongs in the phases that
actually restructure those files.

389 tests pass, 100% branch coverage held.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EckWmyfetYq3Mi8MAnUudh
2026-08-26 23:00:08 +02:00
..
__init__.py Add tests and fix pre-commit issues across all projects 2026-04-12 20:45:24 +02:00
conftest.py Migrate the alarm to gatelock v0.2.0 and give it an escape hatch 2026-07-25 15:35:44 +02:00
test_alarm_audio.py Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
test_alarm_challenges.py Fire alarm daily, harden dismissal challenge; ignore wake_state.json 2026-07-10 23:14:40 +02:00
test_alarm_display.py Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
test_alarm_part2.py Migrate the alarm to gatelock v0.2.0 and give it an escape hatch 2026-07-25 15:35:44 +02:00
test_alarm_part3.py Migrate the alarm to gatelock v0.2.0 and give it an escape hatch 2026-07-25 15:35:44 +02:00
test_alarm_part4.py Migrate the alarm to gatelock v0.2.0 and give it an escape hatch 2026-07-25 15:35:44 +02:00
test_alarm_payload.py Discover alarm device directories instead of reading a fixed phone path 2026-08-09 17:06:43 +02:00
test_alarm_playback.py Play alarm audio on every sink, not one hardcoded output 2026-07-11 18:12:39 +02:00
test_alarm_sinks.py Replace sleep-and-hope audio waits with per-cycle presence checks 2026-07-11 18:51:03 +02:00
test_alarm.py Route _alarm.py's dismiss-screen colors through gatelock's LockConfig 2026-07-22 20:09:26 +02:00
test_correlation.py Phase 1: structured JSONL logging with cross-process dedupe 2026-08-26 23:00:08 +02:00
test_escape_flow.py Migrate the alarm to gatelock v0.2.0 and give it an escape hatch 2026-07-25 15:35:44 +02:00
test_log_dedupe.py Phase 1: structured JSONL logging with cross-process dedupe 2026-08-26 23:00:08 +02:00
test_log_sink.py Phase 1: structured JSONL logging with cross-process dedupe 2026-08-26 23:00:08 +02:00
test_logging_setup.py Phase 1: structured JSONL logging with cross-process dedupe 2026-08-26 23:00:08 +02:00
test_smart_plug.py Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
test_state.py Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
test_sync_backends.py Discover alarm device directories instead of reading a fixed phone path 2026-08-09 17:06:43 +02:00
test_sync.py Discover alarm device directories instead of reading a fixed phone path 2026-08-09 17:06:43 +02:00
test_trigger.py Fire the alarm at the phone's time via a per-minute timer 2026-07-19 20:21:17 +02:00