fix(schedule): activating a pending schedule exception skips the holiday audit trail #255

Open
opened 2026-10-03 10:45:34 +00:00 by gabogg · 1 comment
Owner

P3 follow-up from PR #177 review pass 5 (spec axis). Confirmed by a probe.

Finding

apply_pending_change_transaction_async (the SCHEDULE_EXCEPTION and SCHEDULE_EXCEPTION_DELETE branches in app/db/occupancy_repository.py) writes occupancy_holidays with raw INSERT and DELETE statements. It bypasses add_holiday_async and delete_holiday_async, so activation writes no occupancy_holiday_audit row (CREATE, UPDATE or DELETE).

  • Probe: get_holiday_audit_async(holiday_date="2026-06-16") returns [] after a pending holiday exception activates.
  • The settings audit still records OPERATIONAL_ACTIVATION, so the change is traceable. But the two audit trails (#114 and #161) disagree.
  • Skipping _sync_record_holiday_async at activation is correct, because syncing would re-cut a frozen day.

Acceptance Criteria

  • Activating or deleting an exception writes the same holiday-audit rows that a direct add or delete would, in the same transaction as the activation.
  • It does not re-cut a frozen business-day record.
  • A test asserts the holiday-audit rows after activation.
P3 follow-up from PR #177 review pass 5 (spec axis). Confirmed by a probe. ### Finding `apply_pending_change_transaction_async` (the `SCHEDULE_EXCEPTION` and `SCHEDULE_EXCEPTION_DELETE` branches in `app/db/occupancy_repository.py`) writes `occupancy_holidays` with raw INSERT and DELETE statements. It bypasses `add_holiday_async` and `delete_holiday_async`, so activation writes no `occupancy_holiday_audit` row (CREATE, UPDATE or DELETE). - Probe: `get_holiday_audit_async(holiday_date="2026-06-16")` returns `[]` after a pending holiday exception activates. - The settings audit still records `OPERATIONAL_ACTIVATION`, so the change is traceable. But the two audit trails (#114 and #161) disagree. - Skipping `_sync_record_holiday_async` at activation is correct, because syncing would re-cut a frozen day. ### Acceptance Criteria - Activating or deleting an exception writes the same holiday-audit rows that a direct add or delete would, in the same transaction as the activation. - It does not re-cut a frozen business-day record. - A test asserts the holiday-audit rows after activation.
Author
Owner

Set to low-priority (maintainer, 2026-10-03). This is only a gap in the admin audit trail: activation already records OPERATIONAL_ACTIVATION in the settings audit, and holiday behavior is correct.

Set to `low-priority` (maintainer, 2026-10-03). This is only a gap in the admin audit trail: activation already records `OPERATIONAL_ACTIVATION` in the settings audit, and holiday behavior is correct.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gabogg/hikcentral#255
No description provided.