Before, the report (data/reports/YYYY/MM/DD/report.db, plus pictures and
videos stored next to it) only moved to a new day inside
updateStats(SESSION_START) - and that branch never ran, because
updateStats() skipped every call with evt=false/video=false, which is how
all session status changes are reported. So the report only changed day
when the process restarted; everything after midnight went into the
previous day's report.
- mojoKernel::handleDayChange() (every second from validateReports):
at local midnight an open session that started on the previous day is
closed (END event goes into the old report). If a video segment with
events is still recording, wait for it at most DAY_CHANGE_MAX_VIDEO_WAIT
(90 s) so the video is stored next to its events. After the END event is
written, the report is switched to the new day. The next event starts a
new session in the new day's report.
- sqliteDBC::switchReportToCurrentDay() / openDayReport(): opens (creates)
the current local day's report directory and database, retried until it
succeeds. Report state is protected by a recursive mutex because the
switch runs on the kernel thread while events are written on the event
thread.
- updateStats(): no longer drops SESSION_START/END/DROP calls, so the
session counters in stat.db are updated and SESSION_START also switches
the report if needed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16