screen-locker/scripts
Krzysztof kuhy Rudnicki 967e3cd322 Key every workout day on the LOCAL calendar day, not UTC
A manual workout logged at 00:02 CEST on 2026-09-13 was filed under
2026-09-12: every day-key derivation used datetime.now(tz=UTC), and at
that instant UTC was still yesterday. The 09:18 lock check looked for
2026-09-13, found nothing, and locked the PC — for a workout that was on
disk. The budget counter (a trailing window) counted it fine, which is
why the status showed 1/2 used while the locker still locked. Any log
between local midnight and 02:00 CEST hit this; it had happened before.

- New screen_locker/_day.py: today_str() is the one definition of "what
  day is it" — the local calendar day the user sees on the clock, which
  is also what the phone app, RunnerUp verification, the status window
  and the freedays pool already used. All 14 UTC sites (log writer, lock
  predicates, explain chain, early-bird, wake state, shutdown/sick state,
  sick budget, manual CLI, phone verification) now go through it, writers
  and readers together so no new midnight window opens between them.
- write_signed_entry dedups by workout_id across ALL days: a workout id is
  globally unique, and an entry moved to its correct day must not let its
  synced twin (still stamped with the old day) re-ingest as a duplicate.
- scripts/rekey_log_entry.py: move a wrongly-filed entry to its real day
  (the HMAC never covered the day key, so it still verifies).
- test_local_day_key.py freezes the clock at the exact failing instant.

Replayed the real timeline (log at 00:02:35, evaluate at 09:18:53, weekly
3/5) against HEAD in a throwaway worktree vs this tree:
  HEAD  -> logged under 2026-09-12, LOCK
  fixed -> logged under 2026-09-13, no lock (already_logged)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FcU5dCcUNHMAMzUNChdrrJ
2026-09-13 09:50:06 +02:00
..
__init__.py Finish the Python side: scripts, conftest, and the last test modules 2026-08-15 20:57:29 +02:00
_popup_form_check.py Take gatelock 0.8.1: nested LockConfig 2026-09-12 19:52:38 +02:00
_xvfb_reexec.py Finish the Python side: scripts, conftest, and the last test modules 2026-08-15 20:57:29 +02:00
add_scheduled_skip.py Re-point paths for the ~ reorganisation (home-tidy) 2026-09-11 18:46:28 +02:00
annotate_duplicate_credits.py Record which log entries are two recordings of one workout 2026-08-29 22:31:32 +02:00
check_dependency_freshness.sh Re-point paths for the ~ reorganisation (home-tidy) 2026-09-11 18:46:28 +02:00
check_enforcement_armed.py Serve the lock decision, its history and its health at 127.0.0.1:8770 2026-08-29 22:50:19 +02:00
check_file_length.py Enforce the 250-line cap for real, and on Dart 2026-08-15 22:42:57 +02:00
check_flutter_coverage.sh workout_app: add Google sign-in support for the Firebase sync account 2026-08-14 10:56:16 +02:00
check_md_naming.sh Re-point paths for the ~ reorganisation (home-tidy) 2026-09-11 18:46:28 +02:00
check_no_crdt_sync_override.sh Re-point paths for the ~ reorganisation (home-tidy) 2026-09-11 18:46:28 +02:00
check_requirements_sync.py Add CI-mirror pre-push gate + requirements-sync check 2026-07-11 17:42:45 +02:00
check_silent_failures_dart.py Split storage_service.dart (781) into part extensions 2026-08-15 21:12:08 +02:00
check_silent_failures.py Re-arm the locker, and make a disarmed enforcer impossible to miss 2026-08-17 16:47:25 +02:00
ci_mirror.sh Add CI-mirror pre-push gate + requirements-sync check 2026-07-11 17:42:45 +02:00
demo_workout_handoff.py Take gatelock 0.8.1: nested LockConfig 2026-09-12 19:52:38 +02:00
disarm_guard.sh Make disarming survive the install scripts, not just systemd 2026-08-22 12:54:13 +02:00
finish_2026_08_24.sh Tell "could not check" apart from "no workout", and stop double-granting bonuses 2026-08-24 13:07:20 +02:00
fix_2026_07_26_sport.py Grade against 3.14 too, not just run on it 2026-08-29 11:42:47 +02:00
migrate_scheduled_skips.py Replace scheduled skips with the shared free-day pool 2026-09-07 15:42:41 +02:00
refresh_refactor_todo.py Re-point paths for the ~ reorganisation (home-tidy) 2026-09-11 19:07:30 +02:00
rekey_log_entry.py Key every workout day on the LOCAL calendar day, not UTC 2026-09-13 09:50:06 +02:00
restore_and_bonus.py Make the recovery scripts say why they failed, not just print it 2026-08-24 13:10:53 +02:00
revoke_sick_day.py Grade against 3.14 too, not just run on it 2026-08-29 11:42:47 +02:00
setup_mcp.sh Add read-only MCP server exposing workout/lock status 2026-07-10 21:28:09 +02:00
split_dart_test.py Add todo_finish_dart_250_prompt.md and the Dart test splitter 2026-08-15 21:49:15 +02:00
verify_lock_popup_safety.py Finish the Python side: scripts, conftest, and the last test modules 2026-08-15 20:57:29 +02:00
verify_screen_fits.py Re-point paths for the ~ reorganisation (home-tidy) 2026-09-11 18:46:28 +02:00
verify_workout_credited.py Make the recovery scripts say why they failed, not just print it 2026-08-24 13:10:53 +02:00