fix(sfm): Series-3 events list with no record type, not a wrong one

minimateplus's _extract_record_type returns "Waveform" for every 0C
record layout -- it cannot tell a histogram -- so a MiniMate histogram
was listed as "waveform".  The fake's "Histogram" was a value the real
client never produces, which is why no test saw it.

- _s3_ref: record_type is always None, with
  detail.record_type_note = "Series 3's event record does not say
  waveform or histogram; not decoded yet".
- default_s3_events(): both events "Waveform", as the real client gives.
- The shared-shape contract test allows exactly {"record_type"} to be
  None for Series 3 and nothing for Series 4.

Rows SFM stores for Series 3 still carry "Waveform" from the decode (the
same as the legacy blastware_file route); parked in the spec.  No codec,
store or DB change.

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-21 17:40:26 -04:00
1 parent 59dff06f1c
commit 4e1e6a9d5c
4 files changed
+16 -5

No files matched your search

+9 -2
View File
@@ -57,7 +57,13 @@ def _s3_filename(ev: Any, serial: str) -> Optional[str]:
return None
S3_RECORD_TYPE_NOTE = "Series 3's event record does not say waveform or histogram; not decoded yet"
def _s3_ref(ev: Any, serial: str) -> EventRef:
"""record_type is always None: minimateplus's 0C decode reports "Waveform"
for every record layout, histograms included, so it cannot be trusted
here. Null rather than wrong until a histogram's 0C is captured."""
dt = _s3_dt(ev)
pv = ev.peak_values
peaks = {}
@@ -67,10 +73,11 @@ def _s3_ref(ev: Any, serial: str) -> EventRef:
return EventRef(
event_id=make_event_id(serial, ev._waveform_key, stamp_of(dt)),
serial=serial, series=3, index=ev.index, timestamp=iso_of(dt),
record_type=ev.record_type.lower() if ev.record_type else None,
record_type=None,
peak_vector_sum_ips=pv.peak_vector_sum if pv is not None else None,
peaks_ips=peaks, filename=_s3_filename(ev, serial),
detail={"mic_psi": pv.micl if pv is not None else None},
detail={"mic_psi": pv.micl if pv is not None else None,
"record_type_note": S3_RECORD_TYPE_NOTE},
)
+1 -1
View File
@@ -69,7 +69,7 @@ def _iso(ev):
def default_s3_events():
return [
s3_event(0, "01110000", datetime.datetime(2026, 10, 1, 8, 0, 0)),
s3_event(1, "0111245a", datetime.datetime(2026, 10, 2, 9, 30, 15), record_type="Histogram"),
s3_event(1, "0111245a", datetime.datetime(2026, 10, 2, 9, 30, 15)),
]
+3 -1
View File
@@ -34,11 +34,13 @@ def test_both_series_list_events_in_the_same_shape():
def test_no_shared_field_is_empty_for_either_series():
# A field one series cannot fill belongs under `detail`, not at the top level.
# Except Series 3's record_type: its 0C cannot tell a histogram yet, and null beats a wrong type.
allowed = {3: {"record_type"}, 4: set()}
for out in (access(s3=[FakeMiniMateClient()]).list_events(ADDR, "BE18193"),
access(s4=[FakeMicromateClient()]).list_events(ADDR, "UM20147")):
for e in out.events:
empty = {k for k, v in dataclasses.asdict(e).items() if v is None}
assert empty == set(), (out.series, empty)
assert empty == allowed[out.series], (out.series, empty)
def test_a_micromate_list_and_download_share_one_held_line():
+3 -1
View File
@@ -38,7 +38,9 @@ def test_listing_maps_each_header_into_the_shared_shape():
assert (out.serial, out.series, len(out.events)) == ("BE18193", 3, 2)
e = out.events[1]
assert e.event_id == "BE18193:0111245a:20261002093015"
assert (e.index, e.timestamp, e.record_type) == (1, "2026-10-02T09:30:15", "histogram")
assert (e.index, e.timestamp) == (1, "2026-10-02T09:30:15")
# The 0C record does not say waveform or histogram (every layout reads "Waveform").
assert e.record_type is None and "not decoded yet" in e.detail["record_type_note"]
assert e.peaks_ips == {"tran": 0.05, "vert": 0.08, "long": 0.03}
assert e.peak_vector_sum_ips == 0.12 and e.detail["mic_psi"] == 0.0001
assert e.filename and e.filename.startswith("T193")