Skip to content

fix(alarm): prevent duplicate restored triggers - #117

Merged
Zoupers merged 1 commit into
VirtualBeingsResearch:mainfrom
Zoupers:fix/alarm-scheduling-reliability
Jul 28, 2026
Merged

fix(alarm): prevent duplicate restored triggers#117
Zoupers merged 1 commit into
VirtualBeingsResearch:mainfrom
Zoupers:fix/alarm-scheduling-reliability

Conversation

@Zoupers

@Zoupers Zoupers commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • bind restored alarm tasks to their own IDs, delays, messages, and repeat settings so multiple restored alarms do not all fire the final entry
  • make alarm restoration idempotent for an already scheduled alarm ID
  • normalize naive and timezone-aware trigger timestamps to the runtime timezone, including UTC timestamps sent by the admin UI
  • persist timezone offsets and replace the alarm state file atomically

Validation

  • uv run --frozen pytest tests/unit/test_alarm_tools.py tests/unit/test_i18n.py tests/unit/test_admin_api.py::test_admin_alarm_accepts_browser_utc_timestamp -q — 52 passed
  • uv run --frozen ruff check src/coworker/tools/alarm_tools.py tests/unit/test_alarm_tools.py tests/unit/test_admin_api.py — passed
  • uv run --frozen mypy src/coworker/tools/alarm_tools.py — passed
  • original two-overdue-alarm reproduction now emits one event for each alarm and leaves no stale persisted entries
  • uv run --frozen pytest tests/unit -q — 1448 passed, with 2 unrelated existing failures:
    • tests/unit/test_admin_api.py::test_config_patch_explicitly_clears_one_override
    • tests/unit/test_api.py::test_api_defaults_bind_locally_and_require_desktop_authentication

Risks and compatibility

  • Existing persisted timestamps without an offset remain supported and are interpreted in the runtime's local timezone.
  • Newly persisted and API-listed timestamps include an explicit timezone offset.
  • This change does not introduce durable inbox acknowledgements; delivery across a hard process crash still follows the existing in-memory inbox semantics.

@Zoupers
Zoupers added this pull request to the merge queue Jul 28, 2026
Merged via the queue into VirtualBeingsResearch:main with commit 11a5831 Jul 28, 2026
7 checks passed
@Zoupers
Zoupers deleted the fix/alarm-scheduling-reliability branch July 28, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant