summaryrefslogtreecommitdiffhomepage
path: root/packaging
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-01 10:41:35 +0900
committerAdam Malczewski <[email protected]>2026-06-01 10:41:35 +0900
commitdbabca525ee70126b3d2264dad88c0dcca630b83 (patch)
tree3682514520e2108f3b318f9a9c1896744a1da545 /packaging
parentee8af7448a72fbd49710d8df24ecda4c23a58a8d (diff)
downloaddispatch-dbabca525ee70126b3d2264dad88c0dcca630b83.tar.gz
dispatch-dbabca525ee70126b3d2264dad88c0dcca630b83.zip
fix(api): wake-schedule — accept skewed toggles, atomic persist, boot-recovery reason
Three review-finding fixes in models.ts + regression tests: 1. POST /wake-schedule/toggle no longer rejects 'past' timestamps (Gemini #1, High). Client-server clock skew + request latency meant a freshly-computed nextOccurrenceAt(HH:MM) for an imminent slot could land in the past by the time the server validated it, silently failing the UI toggle. The scheduler's recoverScheduleEntry already fires within MISSED_WAKE_GRACE_MS and rolls forward by 24h × N, so the strict <= now check was actively harmful. Kept Number.isFinite + slot-present validation. 2. persistSchedule is now transactional (Gemini #3, Medium). The old DELETE-then-N-INSERTs path, when an INSERT failed mid-loop, left the table empty (DELETE had committed) and silently wiped the user's schedule on next boot — the catch swallowed the error. Wrapped both in db.transaction(...): on failure everything rolls back, in-memory state is untouched, and the previously persisted snapshot stays intact. 3. Boot-recovery reason no longer masked when boot recovery + due slots coincide (Gemini #5, Nit). Capture bootFireRequested before clearing the flag and append ' (boot recovery)' to the reason so the lastWake/pendingRetry surface tells the truth. Tests: - Replaced 'POST toggle rejects past timestamp' (the bug-as-feature test) with 'POST toggle ACCEPTS a slightly-past timestamp (clock skew / latency)' regression guard. - Added 'POST toggle rejects NaN / Infinity / non-number slot values' to lock the malformed-input path. - Added 'snapshot remains consistent across toggle round-trips (persistSchedule atomicity)' — exercises GET/POST cycles to ensure the transactional impl agrees with itself across add/remove. All 427 tests pass; biome clean.
Diffstat (limited to 'packaging')
0 files changed, 0 insertions, 0 deletions