fix(mlg): final-review fixes
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
This commit is contained in:
1 parent
35bac40dd5
commit
ba826dfac6
16 files changed
+359
-77
No files matched your search
+12
-5
@@ -167,8 +167,10 @@ CREATE TABLE IF NOT EXISTS mlg_files (
|
||||
empty INTEGER NOT NULL, -- 1: the 18-byte prefix alone
|
||||
call_in INTEGER NOT NULL DEFAULT 1, -- 0: a cable / direct download
|
||||
file_mtime TEXT, -- the file's modified time, when the sender gave it
|
||||
received_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
|
||||
received_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%S+00:00', 'now')),
|
||||
stored_path TEXT, -- the original file, relative to the waveform store
|
||||
last_stop TEXT, -- the stop of the file's last record: the call that sent it
|
||||
no_file_stops TEXT, -- JSON: earlier Modem Exit stops in it, calls that left no file
|
||||
UNIQUE(file_name, sha256)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_mlg_files_serial ON mlg_files(serial);
|
||||
@@ -1320,25 +1322,30 @@ class SeismoDb:
|
||||
file_mtime: Optional[datetime.datetime],
|
||||
stored_path: Optional[str],
|
||||
records: list[MlgRecord],
|
||||
last_stop: Optional[datetime.datetime] = None,
|
||||
no_file_stops: Optional[list[datetime.datetime]] = None,
|
||||
) -> tuple[Optional[str], int, int]:
|
||||
"""Store one .MLG file and its log records, in one transaction.
|
||||
|
||||
Returns (file_id, inserted, skipped); (None, 0, 0) when this file name
|
||||
with these bytes is already stored. A record already stored (from an
|
||||
earlier file) is skipped and keeps pointing at that file."""
|
||||
earlier file) is skipped and keeps pointing at that file; the file's own
|
||||
call summary (last_stop, no_file_stops) is kept on its row either way."""
|
||||
file_id = self._new_id()
|
||||
inserted = skipped = 0
|
||||
no_file_json = json.dumps([self._iso(t) for t in (no_file_stops or [])])
|
||||
with self._connect() as conn:
|
||||
try:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO mlg_files
|
||||
(id, serial, file_name, sha256, size, record_count, empty,
|
||||
call_in, file_mtime, stored_path)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
call_in, file_mtime, stored_path, last_stop, no_file_stops)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(file_id, serial, file_name, sha256, size, len(records), int(empty),
|
||||
int(call_in), self._iso(file_mtime), stored_path),
|
||||
int(call_in), self._iso(file_mtime), stored_path, self._iso(last_stop),
|
||||
no_file_json),
|
||||
)
|
||||
except sqlite3.IntegrityError:
|
||||
return None, 0, 0
|
||||
|
||||
Reference in new issue
Block a user