feat(sfm): SFM's MiniMate files carry the W/H type letter Blastware's direct downloads leave off

Blastware names a direct download K441LTON.900 and only its call-in copy
K441LTON.900H, so a folder of directly downloaded events cannot be sorted by
kind.  SFM's own files now always carry the letter.  It is read from the file's
own record-type byte (STRT[18], #41) by the new with_type_letter() -- not from
the recording mode: BE9441's K441LTOK.R10 is a waveform that triggered 2 s into
histogram K441LTOK.QZ0 (Histogram+Continuous).  A file whose type does not read
keeps the plain name; a name never fails a download.

All three paths that name a MiniMate file SFM builds: the device-access
download (the page's event list), WaveformStore.save (the legacy route's store
copy, the bench call-in server), and the legacy /device/event/{i}/blastware_file
download.  Verified on BE9441's recorded 5A walk: 0111f210 -> K441LTON.900H,
011106a0 -> K441LTOK.R10W, byte-identical to Blastware's files.

find_event_by_blastware_name tightens with it: a lettered name matches itself
and the letterless form, not the other letter (a waveform and a histogram in the
same second are different events); a letterless name still matches all three.

Store consequence: new downloads only; rows and files stored before keep their
names, and 'already stored' still finds them.  No schema change, no migration.
The event list shows the plain name until the event is downloaded (the type is
not known before the 5A).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-10-30 00:36:26 -04:00
1 parent 50a0501147
commit b6ed5f5bd5
10 files changed
+200 -21

No files matched your search

+5 -4
View File
@@ -38,7 +38,7 @@ from pathlib import Path
from typing import Optional, Union
from minimateplus import event_file_io
from minimateplus.blastware_file import blastware_filename, write_blastware_file
from minimateplus.blastware_file import blastware_file_bytes, blastware_filename, with_type_letter
from minimateplus.framing import S3Frame
from minimateplus.models import Event
from sfm import event_hdf5
@@ -75,7 +75,7 @@ class WaveformStore:
"""
Persistent store for Blastware-format waveform files + their A5 source frames.
Thread safety: write_blastware_file is single-shot; concurrent saves of the
Thread safety: the event file is written single-shot; concurrent saves of the
*same* filename would race, but the filename encodes second-resolution
timestamps + serial, so collisions across threads/processes are vanishingly
unlikely in practice.
@@ -184,7 +184,8 @@ class WaveformStore:
if not serial:
raise ValueError("WaveformStore.save: serial is required")
filename = blastware_filename(ev, serial)
bw_bytes = blastware_file_bytes(ev, a5_frames)
filename = with_type_letter(blastware_filename(ev, serial), bw_bytes) # ...900 -> ...900H
bw_path, a5_path = self.paths_for(serial, filename)
sidecar_path = self.sidecar_path_for(serial, filename)
hdf5_path = self.hdf5_path_for(serial, filename)
@@ -195,7 +196,7 @@ class WaveformStore:
bw_path.unlink()
except FileNotFoundError:
pass
write_blastware_file(ev, a5_frames, bw_path)
bw_path.write_bytes(bw_bytes)
filesize = bw_path.stat().st_size
sha256 = event_file_io.file_sha256(bw_path)