A fresh whole-branch review found four Important issues; three of its
Minors and one item it set aside were re-graded up. Each has a test that
failed first.
- A windowed timeline 500'd when a file came without its modified time
(Python 3.10 rejects the 'Z' of received_at). received_at is now
+00:00 and timeline times parse 'Z' too.
- On the clock-step day an event-triggered call-in moved the event into
the next session and lost the step. An event now joins the 'monitoring
started' record of its own file.
- A call-in whose records came first in another file (a cable download)
read 'nothing_new'. Each file now keeps its own call summary
(last_stop, no_file_stops) from when it arrived.
- Sessions and call-ins now carry record_ids / file_ids / file_id, the
shot report's proof (spec 5).
- A non-'started' record with no stop made the unit's timeline 500 for
good; it now opens a session whose end is unknown.
- A serial from a file's bytes (or a hint) could write outside the store;
only plain serials are used, and records with no serial are refused, not
dropped.
- Times with a UTC offset, an empty 'at', or a bad mtimes value gave 500s
(or stored half a request); they are now 400s, checked first.
- A missing call-in file made the gap after its Modem Exit read 'not
monitoring' for days. Files are numbered <serial><counter>; a gap
across a missing number is now 'records missing' (unknown). A long gap
after a call-in with no number missing is 'no restart after a call-in':
real outages on the DL2 data (BE6907 14 days from 2026-10-07; BE8081
over Labor Day 2019). Real fixtures BE6907 #899-#902 added.
- Docs: BE8081 did write one empty file (BE80811.MLG).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R9LdWawLzUxwewZGA1
POST /db/import/mlg_file (per-file status; good files stored even when
another in the request is refused; each file's modified time as a JSON
form field), GET /db/units/{serial}/timeline (optionally windowed),
GET /db/units/{serial}/monitoring_at, GET /db/mlg_records, and
GET /db/mlg_files/{id} (the original, byte for byte, for printing).
Tested by calling the route functions directly: httpx is not in this
venv, so TestClient tests would skip silently.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R9LdWawLzUxwewZGA1
sfm/mlg_timeline.py builds, from a unit's stored records: sessions (with
how each ended, its events and its trigger level as logged), the gaps
between them and what each means (call-in, scheduled off, lost power,
stopped by a person, memory full), clock steps (a session starting
before the previous one stopped, as at the end of daylight saving), and
call-ins: delivered, no_file (a Modem Exit that left no file) and
nothing_new (an empty file). monitoring_at() answers monitoring /
not_monitoring / unknown, never claiming more than the records show.
Tested on real files, including BE8081's weekend: Battery Low Exit
Saturday 10:47, back Monday 12:47, two calls that left no file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R9LdWawLzUxwewZGA1