fix(occupancy): stamp past holiday days atomically with the exception write #245

Open
opened 2026-10-03 08:47:08 +00:00 by gabogg · 0 comments
Owner

P3 follow-up from PR #178 review pass 4 (both axes).

Finding

  • add_schedule_exception_async (app/services/occupancy_service.py ~239-249) commits the exception, then stamps the past day in a second transaction. If the stamp raises (for example in a reset race), the exception is saved but the day has no business-day record. That reopens the "readers split" defect from r32 P2-3 for that day.
  • The same 10-line "stamp if no record" block is repeated in classify_holiday_async (~288-299), and only the condition differs.

Acceptance Criteria

  • The exception write and the stamping of a completed day are one transaction, or the stamp failure rolls back the exception.
  • One helper (for example _ensure_completed_day_stamped(day, actor, reason)) is used by both call sites.
  • A test with an injected stamp failure leaves no orphan exception and no missing record.
P3 follow-up from PR #178 review pass 4 (both axes). ### Finding - `add_schedule_exception_async` (`app/services/occupancy_service.py` ~239-249) commits the exception, then stamps the past day in a second transaction. If the stamp raises (for example in a reset race), the exception is saved but the day has no business-day record. That reopens the "readers split" defect from r32 P2-3 for that day. - The same 10-line "stamp if no record" block is repeated in `classify_holiday_async` (~288-299), and only the condition differs. ### Acceptance Criteria - The exception write and the stamping of a completed day are one transaction, or the stamp failure rolls back the exception. - One helper (for example `_ensure_completed_day_stamped(day, actor, reason)`) is used by both call sites. - A test with an injected stamp failure leaves no orphan exception and no missing record.
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#245
No description provided.