Without Thor's TXT report, save_imported_idf fills only the three PPVs.
The unit's 0x0C record -- already read for the list and the stale check --
also gives the peak vector sum and the sensor location, and they were
dropped: Terra-View showed a blank PVS, and find_twins (which matches on
PVS) could not link the event to its histogram twin.
persist_download now overlays DownloadedEvent.record onto the bridged
event before insert_events, filling only fields the file left empty
(creating PeakValues / ProjectInfo when absent). Not the mic: its 0x0C
decode reads a denormal, parked.
The sidecar is written by save_imported_idf before the overlay, so it
still has no vector sum; the DB row does. No schema change, no migration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
THOR's watcher (and Blastware's ACH) store every event through
/db/import/idf_file and /db/import/blastware_file, with the paired report.
Storing a download of the same event afterwards overwrote that richer copy:
on Series 4 the file, .h5 and sidecar were rewritten (extensions dropped);
on Series 3 the row lost PVS, project strings and ZC frequencies and was
repointed at a second, review-less file set.
persist_download now looks up (serial, timestamp) first. A row there is
returned as it stands -- inserted false, detail.already_stored true -- with
no store call, no insert_events and no sidecar write. Never merge.
- DownloadedEvent gains `timestamp` (the unit's own event time) and
`record` (Series 4's 0x0C fields); both adapters set them.
- The Series-3 `event is None` guard now runs before backfill/save, with a
message that is true there ("nothing was stored").
- Tests build the watcher's state exactly as the import endpoints do and
prove the row dict, the sidecar bytes and the file mtimes are unchanged.
No schema change, no migration, no codec change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44