Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
207 KiB
Changelog
All notable changes to seismo-relay are documented here.
Unreleased
Fixed
- ✅ #51: events are identified by unit + time + type, and histograms take
Blastware's times.
- The new key. The events table was
UNIQUE(serial, timestamp), one event per unit per second. A waveform and its histogram share a second legitimately: 209 times in prod's 2026-09-30 store. The key is nowUNIQUE(serial, timestamp, record_type)(agreed with Brian 2026-11-03).- Migration 3 rebuilds the table from its own definition with only the key swapped, in one transaction. Every column, row and id is kept, and the indexes are recreated.
- Lookups: the upsert, the estimate guard and the restamp match on type. The restamp also re-types a file's own row in place. An untyped event still dedups against an untyped row.
- Histogram times. A histogram's start and stop now come from its own
event record (lead
00 28 05 00, source04 00, markerfe f5). That is Blastware's Histogram Start and Stop on 63,490 / 63,490 DL2 histograms; the footer's start was a second early on 97%. Without a validated record, the footer stands and the decoder logs a decode problem. - Interval times and peak times follow:
- each interval's printed time is its end, start + (i + 1) × interval,
capped at the stop (2,308,524 / 2,308,524 rows;
interval_times) - each peak's date and time is its interval's
- each interval's printed time is its end, start + (i + 1) × interval,
capped at the stop (2,308,524 / 2,308,524 rows;
- Decode checker: 760,410 comparisons fixed, 0 regressions, 47 of 88 fields fully match (was 34). Histogram start and stop times, interval times and the ten peak date/time fields match every DL2 histogram.
- Rehearsed on a copy of prod's 2026-09-30 snapshot (15,432 events):
- The migration kept every row identical, rebuilt the indexes and passed the integrity check, in 0.27 s.
backfill_sidecars.py: 11,944 files, 0 errors. 9,852 Series-3 histograms moved +1 s in place, with no id lost and review state untouched. The 209 same-second pairs coexist, and 0 collisions were refused. (It also created 341 rows for store files that never had one: the known one-time behaviour, not duplicates.)backfill_event_shape.py: exit 0,cleared_stale0.
- ⚠ Schema migration + codec change. SFM migrates the events table by
itself on first start: back up
seismo_relay.dbfirst. The release backfill (backfill_sidecars.pythenbackfill_event_shape.py) moves every Series-3 histogram's stored time by one second, in place.- Terra-View pairs twins by peak values and reads rows by id: no change needed there.
- Note for Terra-View's changelog: Series-3 histograms move forward one second, so an event can cross a deployment-window edge.
- Three tests that pinned the old footer start now pin the record's. The estimate-guard test's neighbour is now the same type.
- The new key. The events table was
- A Blastware file's geophone range comes from its setup, so Sensitive
events no longer read 8× high.
- Where it is: in the setup's channel blocks, the byte 29 after each
geophone label.
0x00is Normal (10 in/s full scale),0x01is Sensitive (1.25 in/s). SFM's live 1A read has the same byte at label+33. - Measured: it matches Blastware's GeoRange on 70,042 / 70,042 DL2 events, all three channels agreeing on every one (35 Sensitive).
- Before: SFM assumed Normal, so every Sensitive event's peaks, vector
sum and
.h5samples read 8× high. Event.geo_rangeis new: 0 or 1, or None when it isn't read (the channels disagree, an unknown value, or a missing block). None comes with adecode_problemsentry, and peaks then assume Normal as before.decode_blastware_bytesscales peaks and the histogram vector sum by the range.event_hdf5.write_event_hdf5:geo_rangenow defaults to None, meaning the event's own range, else Normal. An explicit argument still wins.waveform_store.save_imported_bwandscripts/backfill_sidecars.pyno longer force"normal". Thewaveform_storeline was agreed with the parity session, which owns that file.- Decode checker: GeoRange 70,042 / 70,042, and geophone samples exact on 6,524 / 6,524 waveforms (was 6,491). PPV mismatches about halved, and 10 of 88 fields fully match (was 6). 70,287 comparisons fixed, 0 regressions.
- ⚠ Codec change: bump
TOOL_VERSIONat the next release. The backfill (backfill_sidecars.pythenbackfill_event_shape.py) rewrites stored Sensitive events' peaks and.h5files. No schema change.
- Where it is: in the setup's channel blocks, the byte 29 after each
geophone label.
- Histograms go to the histogram codec, and a loud interval no longer hides
a short one. These were the histograms the decode checker found decoding
wrongly.
- The codec now follows the record type. The file decoder used to try the
waveform codec first, whatever
STRT[18]said. That codec accepted BE9440, BE9557 and BE17354's 2018 5 s histograms and returned about 5× too many "samples" (K440HDXX.XH0H: 44,504 against Blastware's 6,976). Only an unknown type still falls back to trying both, and a chosen codec that fails is now a decode problem rather than a silent switch. - A loud interval no longer breaks the sub-minute layout check. The check
required each record's "zero word" to be
0000. That word is the high word of the interval's PVS², which is non-zero above 1.28 in/s, so a one-block histogram with a loud interval decoded to nothing (T193KR5M.X90H, K440HA3C.JM0H, R352HFZ7.530H).- The check is now the measured relation peak ≤ PVS ≤ √3·peak. It holds on 34,502,955 / 34,502,955 DL2 sub-minute intervals.
- The trim for a stream with no terminal tail uses the same test.
- New decode-checker carve-out,
interval-count-is-duration. Blastware's "Number of Intervals" is (stop − start) / interval. When the unit never wrote the last minute, Blastware's own interval table lists one block fewer, and SFM matches the table. It covers 8 events. - Decode checker: 462 comparisons fixed, 0 regressions, 16 of 88 fields
fully match (was 11).
- Every DL2 histogram's Tran / Vert / Long interval peaks now match Blastware (bar the clipped intervals the saturation carve-out covers).
- Channels 70,042 / 70,042.
- Histogram start dates a day off: 26 → 9.
- Peak vector sum mismatches: 45 → 18.
- ⚠ Codec change: it rides the next release's
TOOL_VERSIONbump and backfill (backfill_sidecars.pythenbackfill_event_shape.py). Those files are stored wrongly on prod today, and the backfill rewrites them. No schema change.
- The codec now follows the record type. The file decoder used to try the
waveform codec first, whatever
- A Blastware file's footer is its last 26 bytes: no more day-late
histograms.
- Measured: every DL2 file ends in a valid footer (
0e 08and two valid times), 70,041 / 70,041. - The bug: the decoder took the first "
0e 08+ plausible year". On 14 files there is an earlier record, about 1.1 KB before the end, holding the stop time followed by zeros.- A histogram then started at its own stop: a day late on BE9558's daily histograms (K558L9XP.FK0H read 2025-10-08 19:10:01 for Blastware's 2025-10-07 19:14:08).
- T003LCYV.JD0H got no time at all.
- A waveform lost its stop, so its trigger was never computed and the stop was stamped instead (K440I4LG.JK0W: 11:14:12 for 11:14:08).
- The fix: the last 26 bytes are now taken when they are a footer, and the old search remains only as the fallback.
- Decode checker: event times 6,524 / 6,524 and histogram start dates 63,518 / 63,518. 13 comparisons fixed, 0 regressions, 18 of 88 fields fully match (was 16).
- Also: the protocol reference records where the 1995 default-clock events come from (units back from calibration with the battery unplugged; 17 in DL2).
- ⚠ Codec change: it rides the next release's
TOOL_VERSIONbump and backfill. It moves the stored time of those ~14 events on prod. No schema change.
- Measured: every DL2 file ends in a valid footer (
Added
- A histogram's interval detail: frequencies, vector sums, interval size and
stop (group B of the file-only decode). Measured on DL2 2026-11-03.
- Frequency = (sample rate / 2) / half-period: 527,915 / 527,915 cells
at 1024 sps and 1,725 / 1,725 at 2048.
- ✅ Fixes #50.
half_period_to_hzused a fixed 512 and halved every 2048-sps frequency. It now takes the rate (default 1024). - Blastware prints "N/A" for a half-period of 0, ">100" (">200" at 2048) at 5 samples or fewer, and "<1.0" below 1 Hz.
- ✅ Fixes #50.
- Each interval's vector sum, √PVS² at the event's range.
- Interval size: uint16 seconds at
k − 40(Series IV[8:10]). - Stop time: the footer's.
Eventgainshistogram_interval_sec,interval_half_periods,interval_pvsandstop_time.- The
.h5gains/intervals/half_period/<ch>and/intervals/pvs_ips, plus ahistogram_interval_secattribute. - Decoder: a histogram is now walked once
(
histogram_codec.channels_from_records). - Decode checker: 508,080 comparisons fixed, 0 regressions, 34 of 88
fields fully match (was 28).
- Frequencies on all four channels, interval size and stop date match every DL2 histogram.
- Interval vector sum: 63,497 match, plus 17 clipped intervals now under the saturation carve-out. Blastware prints OORANGE when the sum exceeds the range in an interval where it clamped a channel (17 / 17).
- 4 cells sit 4e-6 past a rounding boundary and stay mismatches.
- 58 stop times are Blastware a second earlier, part of #51.
- ⚠ Codec change: it rides the next release's
TOOL_VERSIONbump and backfill. The.h5additions are additive. No schema change.
- Frequency = (sample rate / 2) / half-period: 527,915 / 527,915 cells
at 1024 sps and 1,725 / 1,725 at 2048.
- A Blastware file's identity, battery and trigger settings (group A of the
file-only decode). Every field is matched against every DL2 report
(2026-11-03).
-
Identity block before the setup name: what the live read gets from SUB FE.
- serial
k − 202, firmwarek − 147, DSP versionk − 138, firmware minork − 193 - calibration date
k − 132and "by"k − 128 - manufacturer
k − 94, modelk − 72 - Filled into
Event.device_info;DeviceInfogainscalibration_date/calibrated_by. - Serial, Version and Calibration match 70,042 / 70,042.
- serial
-
Battery: uint16 hundredths of a volt at
k − 190(Event.battery_volts), 70,042 / 70,042. Blastware rounds half up (6.25 → "6.3 Volts"). -
Trigger source: the two bytes between the embedded event record's lead and
fe 80, a bitmask (0x01Tran,0x02Vert,0x04Long,0x08MicL,0x200Manual). 6,524 / 6,524 (Event.triggered_by). -
Trigger settings, in Series IV's
0x1Alayout:- the sources bitmask at
k − 19 - the stop mode at
k − 31(0 = Fixed) - each channel's float32 level at label + 30 (geo in/s, mic psi)
- the mic type code at MicL + 4 (2 = Linear Weighting)
Blastware prints a level when its channel is a trigger source and the event wasn't Manual. Geo level 6,484 / 6,484, mic level 4,412 / 4,412 (its dB uses 6895 Pa/psi).
- the sources bitmask at
-
.h5: all of them as attributes (additive). -
Decode checker: 444,188 comparisons fixed, 0 regressions, 28 of 88 fields fully match (was 18).
- A mic level is now compared in the unit it is printed in: K441LA17.IN0W prints dB under psi Units.
- New carve-out
units-is-a-display-preference(3,532 events). dB or psi in a Blastware report is that PC's Blastware preference when it wrote the report (Blastware manual §4, Preferences → Units and Channel), not the unit's Microphone Units setting (MiniMate Plus manual §3.9.7). DL2's reports switch fleet-wide in 61 clean runs by write time, and no byte of the file separates them.
-
Single-value fields are proven for that value only: Version
10.72-8.17, stop mode Fixed, mic type Linear. -
⚠ Codec change: it rides the next release's
TOOL_VERSIONbump and backfill. No schema change.
-
- A Blastware file's job number, and whether Blastware shows it.
- Where it is: the setup block has Series IV's
0x1Alayout here too. The report flags sit at 9 bytes before the setup name, with bit0x02meaning the job number is shown. The number is a uint16 BE at 8 bytes before the name, and it is kept while switched off. - Measured: the flag matches Blastware's JobNumber on 2,997 / 2,997 DL2
events that print one, and 66,986 / 66,986 that don't.
- Every printed value is 1, so the value is only proven for 1.
- Hidden ones hold real numbers (802, 1012, 1013, 622).
ProjectInfo.job_number_enabled/job_number, named as inmicromate.setup_block.write_event_hdf5stores both as.h5attributes when they were read.- Decode checker: JobNumber 2,997 / 2,997, and 11 of 88 fields fully match (was 10). 0 regressions. A job number only SFM shows now counts as a mismatch.
- Not in the database, the API or the PDF report yet. That needs a column.
- ⚠ Codec change: it rides the next release's
TOOL_VERSIONbump and backfill (backfill_sidecars.pythenbackfill_event_shape.py). The new.h5attributes are additive. No schema change, no migration.
- Where it is: the setup block has Series IV's
Protocol / Documentation
- Histogram timing in the protocol reference (D.6.10):
- the histogram's own event record
- the interval-time and peak-time rules
- "histograms stay on ts1" retracted in place
- CLAUDE.md records the unit + time + type key
- Docs only.
- Group B in the protocol reference (D.6.9):
- interval size, the stop, and per-interval frequency, with Blastware's
words (
N/A,>100/>200,<1.0) - each interval's vector sum, with its OORANGE rule
- #50's fixed-512 formula is retracted in place
- CLAUDE.md and the README roadmap follow
- Docs only.
- interval size, the stop, and per-interval frequency, with Blastware's
words (
- Group A in the protocol reference, and the three meanings of mic
"units".
- D.6.8: the identity block, the trigger-source bitmask and the trigger settings.
- D.6.6: recorded data vs report units vs unit peaks, with the MiniMate Plus and Blastware manual sections. CLAUDE.md carries the same glossary.
- 🔶 Inferred: the histogram "terminal tail"
9c 06 00 42is9c 06 00plus the serial'sB. - Docs only: no code change, no migration.
- Where file-only decoding stands, and that prod's ASCII overlay is
scaffolding.
- CLAUDE.md "Where things stand" now says plainly that a paired Blastware ASCII report overwrites SFM's decode on import, and that only report-less events run on the decoder alone. The overlay is to be retired at step 3 of the plan.
- The checker status is brought up to
dev: 18 of 88 fields match on every DL2 event, with the remaining groups A–F in the proposed order. The README roadmap is updated to match. - The protocol reference records:
- the footer as the file's last 26 bytes (D.3.3, with
[18:24]retracted as "fixed") - the codec chosen by STRT[18]
- the job number
- the PVS² high word and the peak / PVS consistency check (retracting "reads 0000")
- Blastware's interval count
- a refreshed "not read yet" list
- the footer as the file's last 26 bytes (D.3.3, with
- Docs only: no code change, no migration.
docs/instantel_protocol_reference.mdgains Appendix D.6: the bytes and DL2 verification for every field SFM reads from a Blastware event file.- the record type,
STRT[18] - the recording-setup block: sample rate, pre-trigger, record time and the four notes
- the geophone range
- each histogram interval's PVS²
- the mic scale
- the record type,
- Retracted in place:
STRT[20]as the record time: it is00on every DL2 file.- The 2026-08-26 reading of sub-minute histogram records as little-endian: they are big-endian from byte 5 (#47/#49), and the "2-word tail" is the PVS². This is corrected in CLAUDE.md too.
- #48 is still open. The event file's setup block puts the pre-trigger where
the 1A "stable anchor"
be 80 00 00 00 00sits. In the file, though, it is each event's own pre-trigger, not the unit's setting: it varies on the same unit on the same day, and Blastware reports it per event. So the files say little about whether the live 1A read loses its anchor. (Corrected the same day; the first version read the file's value as the setting.) - CLAUDE.md "Where things stand" now reflects the range fix.
- Docs only: no code change, no migration.
v0.33.0 — 2026-11-01
SFM reads Series-3 events from the file alone, and proves it against Blastware.
What was broken. A Blastware event that reached SFM without its ASCII report used to come in half-decoded:
- no sample rate
- a "70 s" record time, which was really the record-type byte
- blank notes
- every histogram typed as a waveform
- a histogram vector sum built from channel peaks taken at different moments
- a mic reading about 95× low in psi
That matters more now: every DL2 event from before 2025 arrives with no report, and SFM's own download and call-in paths never have one.
What this release does. It reads all of those from the event file itself,
and adds the decode checker that proves it. The checker compares SFM's
file-only decode, field by field and sample by sample, with Blastware's own
_XML.XML event reports for the 70,042 DL2 events that have one (2016–2026).
Where that stands now:
- sample rate, record time, pre-trigger, notes and event type match on every event
- geophone samples are exact on 6,491 / 6,524 waveforms (the 33 others are on the 1.250 in/s range, which SFM cannot read from the file yet)
- the histogram vector sum matches on 69,919
- the mic matches on all but a few dozen
Events imported with an ASCII report are unchanged on prod; the report still overlays.
⚠ This release owes prod a backfill. It does not move stored event times; see Migration below.
Fixed
- The mic in psi was ~95× low: one MicL count is 0.25 Pa.
-
SFM converted mic counts with a "~0.5 psi full-scale" guess (0.0125 / 32768 psi per count). The decoded count was always right: count 16 on
K441LTON.900is Blastware's 106.0 dB. -
Measured against 1,729,253 DL2 histogram intervals' "MicL Peak" columns: count × 0.25 Pa matches Blastware's psi(L) on every one.
-
event_file_io._MIC_FS_PSIis now_MIC_PSI_PER_COUNT= 0.25 / 6894.757 (3.626e-5 psi per count). -
The event's mic peak comes right on events with no report, and so does the
.h5mic trace (event_hdf5derives its scale from that peak). -
dB offset:
waveform_codec.mic_count_to_dbnow uses 81.9384, not 81.94. Blastware's dB sits in a measured window, [81.9383, 81.9385], a hair above the exact 81.93820. Any value in the window matches on 1,729,252 / 1,729,253 intervals.- The checker's first run of this fix flagged 280 regressions, every one count 129, which exact 0.25 Pa rounds to 124.1 against Blastware's 124.2.
- The old 81.94 misses counts 119 and 132.
-
Decode checker, against the pre-fix baseline: 45,035 fixed, 0 regressions.
Field Mismatches before After interval psi 42,783 26 interval dB 974 20 mic peak 345 40 waveform mic samples 1,056 37 -
⚠ Codec change, covered by the same release bump. The backfill rewrites stored mic values on report-less events; report-paired events keep the report's. No schema change.
-
- A histogram's peak vector sum is now the one the unit stores. SFM
computed it from each channel's interval peak, and those can come from
different moments. So on 86% of DL2's histograms with no report it read
high:
T004JTRF.ME0Hgave 1.782 against Blastware's 1.358.- Every interval carries its peak vector sum SQUARED, a uint32 BE in
0.005 in/s units:
- bytes [21:25] of a standard block, long documented as "constant
00 00" plus "purpose unknown" - the last 4 bytes of a sub-minute record (the undecoded
meta_var)
- bytes [21:25] of a standard block, long documented as "constant
- √stored × 0.005 is the "Geo PVS" Blastware prints. It matches on 1,668,073 / 1,668,074 standard and 34.5 million sub-minute DL2 intervals.
- The event's value is the largest interval's.
histogram_codec.interval_pvsreturns the per-interval series, and records gainpvs_sq. Waveforms are unchanged. - Decode checker:
PeakVectorSummatches on 69,919 events (was 15,097): 54,822 fixed, 0 regressions. The 80 left are three things:- the 35 Sensitive-range events (8×, SFM's Normal-range assumption)
- 27 of the 5-second histograms that decode wrongly
- about a dozen waveforms Blastware prints
OORANGEfor when the vector sum alone exceeds 10 in/s — a likely carve-out, still to be shown
- The per-interval series is not stored yet, so the checker still scores
intervals.Geo PVSas SFM blank. - ⚠ Codec change, covered by the same release bump as #44/#45 and #41. The backfill rewrites stored histogram PVS, but only where no ASCII report overlays it. Report-paired events keep the report's value. No schema change.
- Every interval carries its peak vector sum SQUARED, a uint32 BE in
0.005 in/s units:
- A Blastware event's record type comes from its bytes, not its filename
(#41).
- STRT[18] is the record-type byte:
0x46on every one of DL2's 6,577 waveform files and0x0Aon every one of its 63,535 histograms. - The decoder used to read the type from the filename's last letter. So an
event with no Blastware name came out "Waveform" whatever it was: SFM's
own downloads, the call-in path, and a manual download (
.QZ0). - The filename is now only a cross-check that logs a disagreement.
- An unknown byte gives
record_typeNone and adecode_problemsentry, not a guess. Manual, Event and Combo types never occur in DL2, so their bytes are unknown. - Decode checker:
EventTypematches on 70,042 / 70,042 events (was 6,524), 0 regressions. - ⚠ Codec change, covered by the same release bump as #44/#45. The
backfill rewrites stored
record_type. Files named…W/…Hkeep their type. A histogram stored from a 3-character manual-download name flips from Waveform to Histogram, which also changes how it pairs with its waveform twin. No schema change.
- STRT[18] is the record-type byte:
- A Blastware event imported without its ASCII report now carries its
setup and notes (#44, #45). Until now such an event stored no sample
rate, a record time of "70 s" (the STRT record-type byte, 0x46), a
pre-trigger and sample count read from STRT bytes that are neither, and
blank project / client / operator / location (the reader stopped at the
NUL after each label). All of DL2's 2016–2024 events arrive this way.
- The recording-setup block is found by structure (
1c 08, the setup name, NUL), not by the name "Standard Recording Setup", which 37% of DL2's files do not use. - Sample rate, pre-trigger and record time come from that block; a waveform's sample count is the decoded count. A histogram gets a sample rate only: Blastware reports no record time or pre-trigger for one.
- The setup name and the four notes are read by position, as the ASCII parser does: their labels are operator-editable.
- Verified against Blastware's own
_XML.XMLreports for the 70,042 DL2 events that have one (2016–2026): sample rate 70,042/70,042, record time 6,524/6,524, pre-trigger 6,484/6,484, notes 70,042/70,042, sample count 6,523/6,524. The one miss is the harness's, not the decoder's:T438HGTZ.B30W's Tran, Vert and MicL end 3 samples before Long, in Blastware's own sample table too, and the harness compared Tran's length with the table's row count. - Events imported with an ASCII report are unchanged: the report still overlays. Not yet read: the job number (2,997 archive events carry one). The waveform-time estimate still finds the record time by the name, pending a measurement. The Micromate half of #44/#45 (SFM's own downloads, no report) stays with the parity branch.
- ⚠ Codec change: bump
TOOL_VERSIONat release and runbackfill_sidecars.pythenbackfill_event_shape.pyon prod (~2 h on the NAS) so stored report-less events pick the fields up. No schema change, no migration.
- The recording-setup block is found by structure (
Added
- The Series 3 decode checker. It proves SFM can produce everything
Blastware reports from the event file alone, the first of four pieces
toward retiring Blastware's reports.
scratch/check_s3_decode.py <binaries> <xml reports>decodes each event the way ingest does, from its bytes alone (no filename, no report).- It compares every field, waveform sample and histogram interval with
Blastware's
_XML.XMLreport of the same event. DL2'sSent/holds those reports, every sample included, for 70,042 events back to 2016; its ASCII reports start in 2025. - Each comparison gets one verdict: match, mismatch, SFM blank, accepted (a written carve-out with evidence), no reference, or error.
- Any disagreement counts as SFM's bug unless a carve-out covers it.
The only carve-out so far is saturation: Blastware clamps a clipped
channel and prints
OORANGE. - Output goes to
~/dl2-archive/checker-runs/<time>/, outside the repo, because it carries customer names:summary.md: per-field counts and how many fields fully matchdetails.json: failures grouped by what the failing events share, with example events and one-event re-run commandschanges.md: regressions against the last run of the same scope
- Running it: a full run takes ~22 min at
--jobs 4.--file NAMEchecks one event in seconds. Partial runs:--serial,--year,--type,--field,--sample. - Code: the comparison is pure codec-library code that ingest can
call later:
minimateplus/bw_xml_report.py,minimateplus/decode_check.py,minimateplus/decode_check_carveouts.py. The runner and reports are lab tools inscratch/. Design and plan are indocs/superpowers/. - First full run (70,112 files; 70 have no report): 5 of 88 fields
fully match: sample rate, record time, pre-trigger, notes and waveform
event date.
- Geophone samples are exact on 6,491 / 6,524 waveforms in every year. The 33 others are on the 1.250 in/s range, read 8× by SFM's Normal-range assumption.
- Every histogram reads as a waveform without its filename (#41).
- Histogram start times are 1 s early (#51).
- Open findings:
- histogram PVS: SFM takes the vector magnitude of each channel's interval peak; Blastware takes the per-interval vector sum
- mic psi conversion
- mic dB on ~1,000 events
- 35 sub-minute histograms plus 2 one-minute no-mic ones
- 26 histogram start dates
- job number, ZC frequency, acceleration, displacement, time of peak, sensor check, battery, calibration, range, units and monitor log are not read yet
- Later in this release, the record type (#41), the histogram vector sum and the mic conversion were fixed. See their entries above; each was proven by a full checker run with 0 regressions.
- It replaces
scratch/verify_bw_fields_against_xml.py, added and removed within this release. - Operational consequence: none. Nothing on the ingest path changes.
No schema change, no migration,
TOOL_VERSIONunchanged by this item.
- README roadmap: a bulk event importer, parked.
Changed
-
CLAUDE.md: the 14,338 ASCII-report pairs were said to reach "back to 2018"; they are all 2025–26 events. Corrected in place. A "Where things stand" entry records the decode checker and its first run. -
docs/instantel_protocol_reference.md: the #53 note is corrected in place.K440I4LG.JK0W,K888HW07.7K0WandR349KPNU.FK0Wdo not decode as histograms. They decode as waveforms with Blastware's full sample count; only their time falls back to the footer start, 3–4 s late, with nodecode_problemsentry. -
The SFM / SDM tier model in
CLAUDE.mdis marked superseded by Terra-View's ADR 0003 (docs/adr/0003-stack-components-and-names.md).- SFM is the whole seismograph module, and "SDM" is retired as a name.
- The codec library stays pure.
- Lab tools (
bridges/bench tools,scratch/,seismo_lab.py) are to leave the production image, and are ported intosfm/when they become production tools. - The call-in server becomes SFM's front door after a staged proof.
- The repo becomes
sfmafterfeat/series4-sfm-paritymerges.
The old section stays below the banner as history. Docs only: no code or schema change, no migration,
TOOL_VERSIONunchanged.
Migration
⚠ This release owes prod a backfill. It does not move stored event times.
Before you start:
TOOL_VERSIONis bumped to 0.33.0, which gates the regeneration, so no--forceis needed.- No parser change, so no
--reparse-txtis needed. - No schema change.
- Back up
seismo_relay.dbfirst.
Then, in the sfm container, in this order (the scripts default to
bridges/captures/seismo_relay.db and its waveforms/):
python scripts/backfill_sidecars.pyre-decodes every Series-3 event file whose sidecar predates 0.33.0. Sidecars and.h5files regenerate, and each DB row refreshes in place (id and review kept). ⚠ ~2 h on the NAS.- Report-less events pick up the new values: sample rate, record time, pre-trigger, notes, record type, histogram vector sum, mic.
- Report-paired events keep the report's values.
- The record type stays the same for every ACH file (
…W/…H). Only a histogram stored under a 3-character manual-download name flips from Waveform to Histogram.
python scripts/backfill_event_shape.py --db-path bridges/captures/seismo_relay.db --store-root bridges/captures/waveformsrecomputes the shape and offset metrics from the regenerated files.
Series-4 (Thor) events are untouched; nothing in their decode changed.
Not rehearsed on a prod snapshot (v0.32.0 was). The risk is lower:
- Event times do not move, so every row is matched in place.
- No row is created or removed.
- The full decode checker ran clean against all 70,112 DL2 event files before release.
Afterwards, the DL2 watcher can be widened for the 2016–2024 backfill:
MAX_EVENT_AGE_DAYS = 2130 reaches 2021. Set it back to 365 when done,
because the same setting widens the heartbeat's scan.
v0.32.0 — 2026-10-27
Event times you can trust, and Series 4 mapped end to end. Two threads.
The first is correctness on stored data. Series-3 waveforms were stamped with
the monitoring-session start, hours off; they now carry the instrument's own
trigger time, read from the event record the unit sends inside its 5A stream,
which matches Blastware's reports on every one of 1,320 report-paired
waveforms -- no filename needed. Getting the correction into prod safely
needed three more fixes found on the way: re-storing an event at its corrected
time duplicated it, prod's ISO-dated reports were never read, and the binary's
own estimate is a second off often enough to land waveforms on their histogram
twins. Sub-minute histograms recorded with the mic off now decode, and mic-on
ones are read right (#47, #49). Micromate .h5 samples are on Thor's own
scale (#42). The deploy was rehearsed on prod's own (snapshot) store before
release: every waveform on Blastware's exact time, every row id kept.
The second is Series IV. The Micromate live wire protocol is reverse-engineered
end to end (docs/micromate_protocol_reference.md), with a read-only live
client in micromate/, the call-home session captured, and a Micromate's setup
decoded. None of it is on a shipped code path yet -- SFM's Series-4 device
work lands with the parity branch. The SFM webapp gains a Diagnostics tab.
⚠ This release owes prod a backfill, and moves stored event times -- see Migration below.
Fixed
-
Waveform event times were the monitoring-session start, not the trigger (~hours off).
read_blastware_filestamped events with footerts1, which for a waveform is the session start a unit shares across every event that day (a unit arming at 06:00 stamped 06:00 on all of them — the modal and PDF both showed it, since it's the stored value). The event time is footerts2(the recording stop), and Blastware's trigger =ts2 - record time. The record time is a big-endian float32 in the recording-setup config block (30 bytes before theStandard Recording Setupmarker), so the exact trigger is now recovered from the binary alone — all 7 BE12844 oracle events decode to their exact Blastware time (e.g. N844LQHB 10:33:29), no paired.TXTneeded. Histograms keepts1(the ~24 h window start). A paired report'sevent_datetimestays authoritative (unit-clock drift). ⚠ Needs a re-decode backfill to correct existing stored events' timestamps. ⚠ As released, the time comes from the instrument's embedded event record (entry below):ts2 - record timeturned out a second off on 260 of prod's 1,394 waveforms, and the backfill this needs duplicated every corrected event until the restamp fix below. See Migration. -
scratch/mm_frame_parse.pyaccepted either checksum rule, so it could not falsify either. It tried plain SUM8 and a DLE-aware variant and reported whichever matched, which is why it never flagged a bad frame and why the protocol reference carried the wrong rule for two days — "zero bad checksums across three sessions" was true and carried no information. It now validates against SUM8 alone and names the DLE-aware result only as a near-miss, never as a pass. Still zero bad frames across all captures, strictly tighter. -
A 64 KB download cap, one event away from biting. The
0x5Achunk offset was written as a uint16 atparams[2:4], because every offset THOR was observed to send fits in two bytes (largest0x3400= 13,312) — which capped a download at 65,536 B. UM20147 holds a 72,560-byte event, so that cap was not hypothetical: the event could not have been fetched at all.params[0:4]is demonstrably one 4-byte field (chunk 0 puts the 4-byte event key there), so writing the offset as a uint32 BE is byte-identical below 65,536 — the replay test still matches all 74 of THOR's frames — and reaches past it. ✅ Confirmed on the unit: 71 chunks, exact size. ⚠ This is the Series III 64 KB page-boundary bug wearing a different hat, and that one is still open —parse_strt_end_offset()discards the key's page byte and the5Awalk crashes once a unit's buffer crosses 64 KB. The transferable lesson: an address field whose high bytes are zero in every capture is not a narrow field, it is an untested one. Same mistake, found twice, in code written years apart. -
The probe's own control was circular.
scratch/mm_stream_probe.pycompared each candidate request size against a reference download that used the library default chunk size — which the same change had just raised to 16,384. A fault at 16 KB would have been shared by the control and every comparison would have passed. Pinned toTHOR_CHUNK_SIZE, the only size with THOR's captures behind it. -
mm_client_check.pyreported THOR's request count, not its own. It printed "71 chunks" for a download that made 5 requests, computingsize / 1024while the download used the 16 KB default — nearly reading a working 16 KB download as a broken 1 KB one. A diagnostic that misreports what it did is worse than one that says nothing. -
The ACH server buffered its own output and mislabelled modem chatter. stdout was block-buffered, so the log read empty while a call was in progress — useless for a tool whose job is being watched during a one-shot event. It also left
RADIO RINGas a hex dump; it now names known modem strings and, on rings without aCONNECT, says what to check. And its docstring promised scanners leave no trace on disk while the failure path created a session directory regardless. -
.gitignoremissed capture artefacts beside the bridge scripts. Targets*.bin/*.log/*.setspecifically — not/bridges/s3-bridge/, which holds tracked source. -
The Series-4 config watcher overwrote the previous session's snapshots.
scratch/mm_config_diff.py watchsaved every run aswatch-000…NNN, so each session silently replaced the last -- harmless while they were clock ticks, data loss once they were findings. Labels are nowwatch-MMDD-HHMM-NNN. -
mm_client_check.pycarried two stale labels. It still printed0x06content[4:8] as "unexplained" (it is very likely the monitor-log count -- see Changed) and announced UM20147 as "the FIRST 11.0BD unit this code has met". -
Micromate
.h5samples used the MiniMate's count scale (#42). Every idf-import.h5converted Thor's raw geo counts withfull_scale / _GEO_INT16_FS, the MiniMate body codec's count. A Thor count is_GEO_LSB_IPS= 0.000310308 in/s, so the samples disagreed with the event's own peak by a constant: −1.65% while that divisor was 32768 (before 2026-08-25) and +0.71% after it became 32000. v0.30.0's LSB fix corrected the decoder's peaks, and those were right everywhere (DB, sidecar, h5peak_*_ips, PDF numbers). It never reached the sample arrays, which go through the shared writer. Off-scale: waveform and histogram charts, FFT magnitudes, and the offset detector's 0.025 in/s floor. Crest factor and ZC frequency are scale-free.write_event_hdf5now takesgeo_ips_per_count.save_imported_idfandbackfill_thor_events.pypass Thor's LSB, and MiniMate callers are unchanged. Measured: the 8 thor-idf fixtures (24 channels) go from max|sample| / peak = 1.00706 to 1.00000 through the real ingest path. ⚠ Existing Thor.h5files keep the wrong scale until regenerated. Runscripts/backfill_thor_events.py(bumpTOOL_VERSIONat release so it is gated, or pass--force), thenbackfill_event_shape.py, because the offset metrics read these samples. No schema change, no migration. Series-3.h5files are unaffected and do not needbackfill_sidecars.py. ATOOL_VERSIONbump would make that script regenerate them anyway (~2 h on the NAS), so don't run it for this. -
Sub-minute histograms recorded with the microphone off decoded to nothing (#47), and mic-on ones were read one byte off (#49). A multi-interval block is a 5-byte header, then one record per interval of big-endian peak/half-period pairs (20 bytes with the mic, 16 without), then a 7-byte trailer; the last block is short and ends on
9c 06 00 42. The old reader took the records as little-endian from byte 6, which agrees while every high byte is zero, and misread 2 intervals across the archive (a mic peak and a Long half-period). Verified against every archived histogram with a Blastware export: 13,089/13,089 exact (was 13,087), and BE9441's mic-offK441LTOK.QZ066/66 peaks and 66/66 frequencies. ⚠ Decoder change: needs theTOOL_VERSIONbump plusbackfill_sidecars.pyandbackfill_event_shape.pyto regenerate stored histograms -- the same run this release's other fixes need (~2 h on the NAS). No schema change. It changes none of the 10,433 histograms in prod's store (2026-09-30 snapshot): the misread needs a half-period of 256 or more, below ~2 Hz at the archive's and prod's 1,024 sps. At 4,096 sps it is common -- below ~8 Hz -- and on BE9441's 3,398-intervalK441LTON.900the old reader got 87 intervals wrong (~2.6%); the new one gets all 3,398. -
Re-storing an event at a corrected time duplicated it. The event-time fix above moves a waveform's time, and
eventsis unique on(serial, timestamp), so re-storing an old event -- the release backfill, a watcher re-forward -- found no row at the new time and inserted a second one. Measured by storing real files with v0.31.0 and running this release'sbackfill_sidecars.py --force:N844LQHB.ZT0Wcame out at 06:00:13 and 10:33:29, its false-trigger mark on the wrong copy.insert_eventsnow matches a row by its Blastware filename first and moves it to the new time in place -- same id, review kept. When a different stored file already holds that second, nothing moves and nothing is written (the old upsert wrote this event over that one). Only Blastware names are matched (every unnamed upload isimported.bw); of several copies a reviewed one with a time moves first. Follow-ups: #52. No schema change, no migration. -
A paired report's event time was never read from prod's reports.
_parse_event_dateread only "August 14, 2026"; all 81 report-paired waveforms in prod's store (2026-09-30 snapshot) write "2026-08-14" -- Blastware follows the PC's settings. It reads both now (81/81, was 0/81). The sidecar'sbw_reportblock also never stored the event time and the backfill's overlay never applied it; both do now, and--reparse-txtre-reads the saved.TXTs. Codec-library change. -
A Series-3 waveform's time comes from the instrument's own event record. The unit sends a copy of its event record inside the 5A stream, so it is in every Blastware file and every SFM download:
00 28 05 00 ?? ?? fe 80 [trigger][stop], each timedd mm yyyy(BE) 00 hh mm ss.- Measured on 7,935 waveforms. Its trigger equals Blastware's report
1,320/1,320, the filename 7,935/7,935 and the unit's
0Crecord 10/10. - Provenance. It occurs once in the unit's own A5 replies for each of 8 recorded events, and in SFM-only downloads.
- Why it mattered. The footer's
ts2 - record timeis a second off on 260 of prod's 1,394 (199 late, 61 early). On BE9558 the 61 early ones landed on their histogram twin's second, so a fresh import wrote each waveform over its histogram's row (888 files -> 827 rows). The backfill would also have moved 161 rows that v0.31.0 had right a second off. - Validation. A record counts only if its lead bytes, marker, both times, its relation to the footer and its length all check out, and exactly one candidate does.
- Fallbacks. Without one the estimate stands, recorded in the event's new
decode_problemsand the sidecar'stimestamp_source. A filename is never a time source, only a cross-check, logged when it disagrees. A paired report fills in only when there is no record. - An estimate is kept, never trusted. An event is never discarded for
want of an exact time. But an estimated time never moves a row, never adds a
second row for an event already stored, and never lands on another event's
row (
insert_eventswrites nothing and logs a warning naming both). The file and sidecar are kept either way. - API. New
decode_blastware_bytes(raw, name=None)needs no file (the import no longer writes a temp file);blastware_file.blastware_filename_time()decodes a name for cross-checks. - Histograms keep
ts1. It runs a second early against Blastware on 97% of them, though their record (markerfe f5) holds the exact start. With both on exact times, a waveform and its histogram share a second 209 times in prod's store, which(serial, timestamp)cannot hold -- #51. - Open. 3 archive files named as waveforms are not recognised by the waveform codec and keep the footer start, as before (none in prod). Series-III reference §7.8.9.
Codec-library change.
- Measured on 7,935 waveforms. Its trigger equals Blastware's report
1,320/1,320, the filename 7,935/7,935 and the unit's
Added
-
Diagnostics tab in the SFM standalone webapp. Surfaces the device endpoints that previously existed only as
curl:events/storage_rangeandevents/indexalongsidemonitor/status, then stop monitoring, disable ACH (rescue?erase=false, so stored events survive), and erase. The wedged-unit ladder — slow drip and blind stop — sits under its own heading pointing atdocs/runbooks/wedged_unit_recovery.md, with the reminder thatslow_drip's success signal isbytes_received > 0and not a clean duration. Erase is guarded by typing the unit's serial: auth answers who, not did you mean it, and Swagger's try-it-out button on/device/events/eraseis live on:8200/docs. -
docs/sfm_tool_status.md— an honest per-capability maturity assessment: what is production-grade (the codec library, the data side), what is emergency-grade (the device side), what is a research artifact, the known-issues table, and the gap to a real tool. Also records the 5A page-boundary bug as known:parse_strt_end_offset()discards the key's page byte, so once a unit has recorded more than 64 KB since its last erase, an event spanning the boundary reads anend_offsetbehind its own start — the chunk loop fetches nothing and TERM packs a negativeoffset_word, which 500s. Reproduced on BE12599. Production is unaffected: it ingests complete files via the watcher path and never runs this walk. -
The Micromate (Series IV) live wire protocol, reverse-engineered end to end —
docs/micromate_protocol_reference.md. Worked out against a bench UM12947 over USB and a recording relay, with THOR driving every write so that no command has ever been originated against a unit by this project. A Micromate answers Series III command frames, with three framing differences: responses carry no leadingDLE,payload[1]is0xC5(Blastware firmware) or0x03(Thor firmware) rather than0x10, and the data length is a uint16 BE atpayload[8:10]— read as a single byte it under-readsSUB 0x1Aby 47x. Read path, event chain, andSUB 0x5Astreaming the.IDFWfile verbatim are all confirmed. -
Series IV setup management, fully mapped.
0x41reads the active setup name,0x1Aits config block,0xDAnames the target.MMB,0x71/0x72write it back. Setups are read-modify-write — the written block is the read block, 91% byte-identical at a fixed 11-byte shift.0xDAcreates files rather than only overwriting, confirmed on the unit's own screen, and an overwrite is protocol-identical to a create: no handshake, no warning, and no protection even over the active setup of a monitoring unit. -
The scheduler file decoded —
\system\schedule\schedule.dat, 260-byte records carrying an action bitmask (2 start, 4 stop, 8 self-check, 16 ACH), a half-hour slot (48/day), day-of-week (0 = Sunday) and a length-prefixed setup name. Verified entry-for-entry against the operator's own THOR screen. -
A generic file transfer addressed by full path —
0x94/0x48read,0x8D/0x8Ewrite. This retracts an earlier conclusion in the same document that no such command existed; that was inferred from absent firmware strings and was wrong. -
Monitoring control and per-event delete.
0x96/0x97start and stop as on Series III, but the monitoring flag atSUB 0x1Cdata[12]must be tested for non-zero (observed as both0x0Eand0x0C) rather than compared to a constant. Deletion is per-event —0xA8with the event key, then0xAA— which is safer than Series III's erase-everything.SUB 0x1Calso carries the device clock. -
bridges/mm_probe.py— distinguishes the four faults THOR reports identically as "disconnected": refused, connect timeout (the silent-drop signature of a trusted-IP whitelist), connected but no reply (the modem answered and the unit did not), and replied. Each verdict names what to try next.--slots Ntests single-session modem behaviour. -
bridges/mm_link.py— a bench stand-in for a cellular modem, with a decoded timestamped log and fault injection (blackhole,drop,delay,onewaydev) driven by a control file. No pyserial; stdlibtermiosonly. -
scratch/mm_frame_parse.py,socat_log_split.pyandfake_unit.py— a Micromate-aware frame parser (S3FrameParsercannot see these responses at all, since it scans forDLE+STX), byte-exact capture recovery from asocat -xrelay log, and a serial-port stand-in that answers as a unit. -
A live client for Series IV —
micromate/{framing,protocol,client}.py.micromate/was codec-only; it can now talk to a unit. Connect over TCP (a cellular modem) or serial/USB, identify a unit, read its state, clock, battery, memory and setups, walk the event chain and download events as.IDFW/.IDFHbytes the existing codec already decodes. 98 offline tests, every response constant a real captured data section.minimateplus/transport.pyis reused as-is;minimateplus/framing.pydeliberately is not — see Changed. ⚠ Read-only. Setups, schedules, call-home config, monitoring start/stop and per-event delete are all mapped and none are implemented. No command has ever been originated against a unit by this project; every write in the protocol reference was performed by THOR while we recorded. -
Verified on real hardware, both transports, both firmware lines. Identical wire bytes over USB CDC-ACM and an RX55 in PAD mode — 11,580 B in and 761 B out to the byte. Every
11.0BDinference confirmed on UM20147, including the four extra trailing bytes inSUB 0x1Cthat make Series III's from-the-end offsets report a battery voltage of 577.92 V. A monitoring unit answers reads with noSESSION_RESET, which Series III requires. All six bench events decode with the existing IDF codec — 4 waveforms at 12,288/12,288/12,288/8,192 samples and 2 histograms — so/db/import/idf_fileingests a directly downloaded event unchanged. -
bridges/mm_client_check.py— drives the read client against a unit and reports per-command timings, read counts and byte totals, so two transports or two firmware lines can be diffed.--capture DIRwrites araw_bw_*/raw_s3_*pair in the layoutscratch/mm_frame_parse.pyreads, turning a field run into a test fixture. No pyserial — stdlibtermios, becausepip installis refused outright by PEP 668 on the distros the bench hosts run. -
The Series-4 event chain.
MicromateEventRefpluslist_events(),iter_events(),download_event(),get_event()anddecode_error()onMicromateClient. Walk a unit's events with full metadata — key, size, type, timestamp, sensor location, setup name, per-channel peaks, peak vector sum — then download and decode any of them, waveform or histogram.ref.filenamegenerates the name THOR would have used (UM12947_20260923163319.IDFW), returning None rather than guessing when the record type is unknown, becauseread_idf_file()dispatches on exactly that suffix. The load-bearing test replays THOR's captured six-event session and asserts every byte we emit matches its 74 frames, decoding all six events along the way. Read-only, like the layers under it. -
A per-event decode self-check.
get_event(verify=True)recomputes the peak vector sum from the decoded samples and compares it against the float the device put in the0x0Crecord — two independent computations over the same samples, so a disagreement means our decode is wrong. Agreement on the bench events is 0.000%. Worth having in a codebase whose decode failures have historically been silent: unhandled block tags shorten a channel and nothing raises. ⚠ It is a decode-correctness check, not a truncation detector — a channel cut after its peak still yields the right PVS. -
SUB 0x06content[0:4] is the event count. Three for three across both firmware lines (0 events→0, 6→6, 5→5), and THOR reads it before the chain walk then stops without ever reading the sentinel.list_events()still walks to the sentinel — correct on evidence, one round trip slower — but this lets a caller ask "is there anything here?" in one command.content[4:8]reads 9 on both units regardless of count, so it is a constant, not a count. -
bridges/mm_ach_server.py— an inbound Auto Call Home receiver. Read-only, and deliberately more so than its Series III sibling, which has rescue actions that stop monitoring and disable ACH. Its grace window is the experiment: it stays silent after accepting, to answer the one question no packet capture can — does the unit speak first? Captures land asraw_bw_*/raw_s3_*soscratch/mm_frame_parse.pyreads the pair unchanged. ⚠ Implements the listener path only. See Changed — there are two. -
🔑
MicromateClient.get_setup()-- a Micromate's setup, decoded. OneSUB 0x1Aread returns aMicromateSetup: record mode, sample rate, histogram interval, pre-trigger, stop mode, record time, auto-stop, active sensors, trigger sources, the three geophone trigger levels, mic type and (linear) mic trigger, job number, scaled distance, and the four notes. Measured fields only -- anything the reference grades inferred stays in.raw. A failed checksum raisesSetupChecksumError(aProtocolError) unlessverify=False; a short block raises either way. The decode lives in the new pure modulemicromate/setup_block.py. Verified on hardware: against UM20147, every decoded value matched the unit's own screen. 69 tests on 15 real reads (14 UM20147, one UM12947 cut from Thor's 9-24 capture), with expected values taken from the operator's screen, never from the decoder. -
One checksum rule for three config blocks --
micromate.setup_block.crc_ok().content[0:2]is a length N; a CRC-16/AUG-CCITT over[0:N-2]is stored at[N:N+2]. Holds for0x1A(setup, 48 distinct states),0x08(preferences) and0x2E;0x2Chas none. Thor's0x71write omits it -- the unit computes it -- so it is a read-side integrity check, not a write obligation. -
scratch/mm_config_diff.py-- the config diff harness (volatile/snap/watch/diff), read-only. An operator changes one setting on the unit's own keypad whilewatchreports which bytes moved; this is how the map below was built. Checks the CRC on every change to a checksummed block. -
bridges/mm_client_check.pyprints the decoded setup, laid out to be checked line by line against the unit's screen.
Changed
-
Connecting to a unit no longer walks its event chain.
/device/eventsreads every event header over the cellular link; on a unit with a large or wrapped chain that takes minutes or fails outright, and it fired automatically on every connect. Connect now uses only ~2 s probes —/device/info(which already carried the compliance config the walk was re-reading) plusevents/storage_range— and the Device tab gains an Event Chain card. The walk moved behind a Load events button in the Events toolbar. Knowing whether a unit's ACH is on no longer requires reading every event it has stored. -
Recorded what THOR actually does on the wire, measured rather than assumed. A "status check" is eleven commands, ~2.2 KB including TCP setup — 18.8 MB/day per unit at a 10 s cadence, against ~0.2 MB/day for a
POLL+MONITOR_STATUScheck at 60 s. The status interval is honoured; the connection interval is not — it sets(status / connection) - 1checks per cycle, so equal values yield zero cheap checks and every connection becomes the expensive one. -
Two THOR defects reproduced with timestamps. After a connection drops mid-download it retries once, stops polling entirely and never resumes, while displaying
Connectedfor as long as it is left alone — andIdlefor a unit that is actively recording. Separately, THOR's own log shows a subscription leak: one logical event dispatched to a growing number of handlers, 1 to 12 over ten hours of uptime, consistent with the field report that only a restart recovers it. -
The Micromate's USB host supports FTDI and CDC-ACM only — no Prolific, in either firmware line. A PL2303 cable (Benfei) leaves a unit with no working modem port; an FTDI cable (Sabrent) works. Both are in circulation and indistinguishable by eye — identify by
lsusbVID,0403against067b. -
Six rules in the Series-4 client spec were wrong, and measuring against the captures caught all six before any code shipped. Each fails silently — a frame the unit ignores, or a checksum that reads as bad: requests escape four byte values (
0x02 0x03 0x04 0x10), not one, so the Series III builder reproduces only 161 of THOR's 218 read frames and misses everySUB 0x5Adownload; the response checksum is plain SUM8 of the de-stuffed payload, not the DLE-aware variant, which disagrees with the wire on 55 of 251 frames;SUB 0x5Ais a 1024-byte chunk loop, not one request per event;SUB 0x0Ais the monitor-log walk (same request repeated, device-side cursor), not a keyed event-header read;1E/1Fcarry token0xFEatparams[7]; andSUB 0x01has no THOR precedent at all. Recorded indocs/micromate_protocol_reference.mdas corrections in place. -
SUB 0x0C's peak float is the per-sample peak vector sum — resolved after being marked do-not-rely-on. Exact to 0.000% on all four bench waveforms against a PVS recomputed from decoded samples, so its offset (Tranlabel − 12) is established rather than inferred. The earlier "not the vector sum" reading compared againstsqrt(Σpeak²)from the three reported peaks, which is an upper bound: the channel maxima do not occur at the same instant. This gives the decoder a free self-check — the device computed that number from the same samples, independently of our codec, so a mismatch means the decode is wrong. Worth having in a codebase whose channel truncations have historically been silent. -
Cellular costs ~0.65 s per round trip, independent of payload size. Measured on UM12947 over an RX55:
list_setups()on a unit with 24 setups takes 16.0 s, against 0.46 s over USB, for 24 commands. A 1,024-byte chunk and a 16-byte state read cost the same. Over cellular, minimise round trips, not bytes — cache the setup list rather than refreshing it on a timer, and note a 13 KB event is 14 chunks ≈ 8.4 s of latency against ~0.03 s of data. The modem also needs fewer reads than USB, not more: it buffers ~1 s then forwards one large segment where CDC-ACM delivers many small ones. -
Event keys collide across units. UM20147's first event and UM12947's first event are both
055d4a81— different sizes, different contents, identical key. The counter starts from the same value on every unit, so a key is meaningless without its serial. Anything that stores, deduplicates or addresses Series IV events must key on(serial, event_key); keyed on the event key alone, one unit's event is silently treated as a duplicate of another's and simply never ingested. Series III has the cousin of this — its counter resets after an erase, so keys are reused within a unit, which is whyach_state.jsonalready tracksmax_downloaded_keyper serial. -
Setup file names are spelled three ways by three commands. In one session on one unit:
0x41reportedtest2.MMB,0x40reportedtest2.mmb, and0x0Creportedtest2. Compare setup names case-insensitively and without the extension — an exact-string test of "is the active setup one I know about?" answers no. -
16,384 bytes per
0x5Arequest, up from THOR's 1024. Measured on UM20147 with every size checked byte-for-byte against a 1024 B control: 1 K / 2 K / 4 K / 8 K / 16 K all served in full, and anything larger is silently clamped to 16,384 — correct bytes, short length, no error. ⚠ That clamp is why the download loop now tracks its offset by bytes received rather than striding by chunk index. A fixed stride would either fail on a clamp or skip the bytes it never collected; tracking what arrived makes a clamp cost one extra request and makes the loop self-correcting against any short response. Consequence worth stating because it reverses an earlier decision: a short chunk is no longer an error. The device returns short legitimately; the protection is the offset arithmetic plus the final total-length check, which still raises on a genuinely truncated event.THOR_CHUNK_SIZE = 1024remains available and the replay tests pin it. Confirmed over a cellular PAD as well as USB: 14,176 B in one frame, intact. -
⚠ Corrected: cellular cost is NOT independent of payload. This changelog and the protocol reference both previously said "~0.65 s per round trip, regardless of payload", and the design advice drawn from it — minimise round trips, not bytes — was too strong. Every measurement behind that claim had a payload under 1 KB (59 B status, 266 B setup records, 1024 B chunks), so the byte term was small and similar across all of them and per-command cost looked constant. It was a narrow-range fit extrapolated past its evidence. Measured against a 14,176 B single response over an RX55:
t ≈ 0.21 s + bytes / 2,350, fitting within ±11% across a 14× size range. The old figure is that model evaluated at 1 KB. The advice splits in two: status work is round-trip bound (a 24-setup walk really is 16 s, so cache it), while a download is throughput bound — the 16 KB chunk size saves ~30% on a large event, not 14×, because most of the time is bytes on the wire and batching does not touch it. A 72,560-byte event is ~46 s at 1024 B and ~32 s at 16,384 B. -
⚠ Retracted: there is no
SUB 0x5Astreaming mode. The reference hypothesised thatoffset_hi = 0x10meant "stream until done", reconciling THOR's chunk loop with a 2026-09-23 note about a single request returning an entire 11 KB event. Measured directly:offsetis simply a byte count and the device returns exactlyoffset + 11bytes in one frame.0x1000is not a marker, it is part of the number. The probe tried both escapings ofoffset_hi, which is what makes the negative meaningful — a malformed frame would have produced the same silence, and Series III requires that byte raw in this very command. -
Verified on real hardware across both firmware lines and both transports. Identical wire bytes over USB CDC-ACM and an RX55; every
11.0BDinference confirmed on UM20147 — including the four extra trailing bytes inSUB 0x1Cthat make Series III's from-the-end offsets report 577.92 V; a monitoring unit answers reads with noSESSION_RESET; and0x0Ccontent[11] gives the record type (0x07waveform /0x08histogram) on 7 events across both lines. ⚠ Event keys collide across units — UM12947 and UM20147 both have an event055d4a81, different sizes, different contents. Anything that stores or deduplicates must key on(serial, event_key);MicromateEventRef.uidis that pair. -
🔑 The Series-4 call-home session is captured end to end. A MITM between a unit's modem and THOR 1.5.0.29: 101 request frames, 101 responses, 0 bad checksums, 34,872 B of event data in 65 s. Every command in a real ACH session is one
micromate/protocol.pyalready implements —POLL×36,BULK_DOWNLOAD×27,STATE×10,EVENT_RECORD×8,EVENT_NEXT×7,STORAGE_RANGE×4,MONITOR_STATUS×3,ARM_EVENT×3,SERIAL,EVENT_FIRST— bar one. The last protocol unknown is closed. -
🔑 Call-home has TWO paths, and timing decides which runs. If anything already holds the modem's single TCP session, the unit's
RADIO RINGtravels up that existing connection; if nothing is connected, the modem dials out to a listener. THOR'sUnitWatchDogTimerreconnects continuously, so THOR usually holds that slot — which is why probes and relays see "connected, no reply". That is contention, not a fault, and it accounted for a full afternoon of apparent failures. -
⚠⚠
SUB 0xA2ends a call-home on Series IV — and is CONFIRM ERASE on Series III. Same opcode, same0x5Dresponse, opposite consequence: on a MiniMate Plus it is the final step of the erase-all sequence.minimateplusandmicromatealready share a transport, so any shared path must dispatch on series before that byte reaches a wire. Corroborates the firmware stringCMD_EXIT_CALL_HOME_DELETE_EVENTS_START_MONITORINGfound by static analysis. -
⚠ "Monitor While Calling Home" silently blocks erase, and THOR reports the session successful anyway. Both refusals are INFO lines. Delete-after- download is the necessary fleet setting; a unit left on monitor-while-calling accumulates events forever while looking healthy. Consequence: a receiver cannot rely on erase to manage storage — the server-side high-water mark is load-bearing, not an optimisation. Detectable on any call from
0x06's event count plus0x1C's memory fields. -
⚠ Corrected:
0x06content[4:8] is the monitor-log count, not a constant. Recorded in this file as "9 on both units regardless". It reads 47 against THOR'sMonitor Log count: 45twelve minutes earlier on the same unit; both units simply held 9 records. -
⚠ Corrected:
SUB 0x49has a third state.0x00idle,0x02monitoring, and0x03in-call-home — ten for ten through a session. Exactly why the rule is test for non-zero:== 0x02calls a unit mid-call-home idle. -
THOR rewrites a unit's stored IP from the call-home source address, so a relay silently poisons its record of where that unit lives.
-
CLAUDE.md's "Where things stand" refreshed — it still claimedmicromate/had no live client, and that the call-home was the only protocol unknown. -
🔑 The Series-4 setup block (
0x1A) is mapped. Two keypad passes on UM20147 (10-17, 10-19), every moved byte attributed to a setting the operator named: record mode[5](01Waveform,02Manual,03Histogram,04Combo -- S3's codes), sample rate[6:8], histogram interval[8:10], pre-trigger[12:16](f32, negative seconds), stop mode[17], record time[18:22], auto-stop[23], active-sensor / trigger-source bitmasks[25]/[29], scaled distance[30:38], report flags[39], job number[40:42], notes from[122], trigger level at channel+30. Full map and grades indocs/micromate_protocol_reference.md. -
⚠ The six channel blocks are three geophones, the ACTIVE mic, and two stored mic setups. Switching mic type copies block 5 or 6 into block 4. Reading the mic from 5 or 6 describes a mic that is not fitted.
-
⚠
0x1Areads the keypad's edit buffer, live, and a discard reverts it. Loading a setup replaces the active config byte-for-byte; the setup name is the only link to the file, and its spelling varies (.MMBafter a keypad save,.mmbafter a load). -
⚠ The unit converts units with its own constants: distance ft ÷ 3.2808 to metres, charge weight lb ÷ 2.21 to kg (not 2.20462). Convert back with them or 45 lb reads 44.89. Scaled distance is computed for display, not stored.
-
0x08is the preferences block, not an event index. Display units live there (content[31]); switching them moves nothing in0x1A. -
The geophone scale is in the unit's own config. Channel
+24reads3.1030800342559814; ÷ 10,000 it equals_GEO_LSB_IPSto 1.1e-8 -- an independent confirmation of a value previously pinned only statistically. -
0x1Ccontent[6] is a ~64 ms sub-second tick, not a status byte -- read once a second it aliases into a tidy-looking slow counter. A0x1Cblock is never byte-identical to itself; compare named fields, never whole blocks. -
⚠ Rule recorded: never write modem baud rate or modem type remotely. The remote link is the modem port; a mismatch strands the unit until a site visit. (Baud is in none of the six blocks we read; nothing writes it.)
-
⚠ Corrected in the reference: two 16-byte slips in the 9-24 write map -- note labels at
0x7A(not0x8A), channel blocks from0x6AC(not0x6BC). -
🔶 Series III, inferred only: S3's 6-byte "stable anchor"
be 80 00 00 00 00sits exactly where Series IV keeps pre-trigger (−0.25 s) and stop mode (Fixed). An S3 unit in Auto stop mode would lose it and decode no mode / rate / interval / record time. Production is unaffected (Blastware file ingest). Recorded ininstantel_protocol_reference.md; no code changed -- one Blastware capture in Auto mode settles it.
Migration
⚠ This release owes prod a backfill, and it moves stored event times.
TOOL_VERSION is bumped to 0.32.0, which gates the regeneration. Back up
seismo_relay.db first. Then, in the sfm container, in this order (the
scripts default to bridges/captures/seismo_relay.db and its waveforms/):
python scripts/backfill_sidecars.py --force --reparse-txt-- re-decodes every Series-3 event: sidecars and.h5regenerate, waveform times move to Blastware's (each DB row in place -- id and review kept), and--reparse-txtre-reads the saved.TXTreports. ⚠--reparse-txtis required the first time: prod's sidecars were written by the old parser, and a run without it leaves report-paired rows on the binary's estimate. ⚠ ~2 h on the NAS.python scripts/backfill_thor_events.py-- Series-4.h5samples onto Thor's own LSB (#42).python scripts/backfill_event_shape.py --db-path bridges/captures/seismo_relay.db --store-root bridges/captures/waveforms-- the shape/offset metrics read the regenerated samples.
Rehearsed on prod's 2026-09-30 store snapshot (11,827 Series-3 files; stale
-- prod has more since): stored with v0.31.0 exactly as the watcher does, then
step 1 with this release. Waveforms on Blastware's exact time 1,016 → 1,394
of 1,394: 373 had been hours off (up to 14.3 h) and 5 a second off. Every row
id kept, none lost or merged, no refusals, no errors. Histograms do not move
(#51). One known extra row: a histogram whose time does not decode
(BE18003 T003LCYV.JD0H) gains a duplicate on every backfill -- pre-existing,
#52. A log line "nothing stored" from insert_events names a file whose
corrected second another file already holds; expected zero. (The rehearsal
ran when waveform times came from the filename; the event record that replaced
it gives the identical time on all 1,394 of those waveforms, so it stands.) A
log line "no validated embedded event record" names a waveform kept on the
footer estimate; expected zero (every prod waveform has one).
Terra-View reads SFM's rows by id and needs no change, but its views show the corrected times: waveforms move up to hours later in the day, so an event can land in a different day, deployment window or summary, and waveform / histogram twin matching can change. That is the correction, not a fault.
The webapp is served from the image, so its changes appear after the next
sfm rebuild.
The Series-4 live client adds new modules under micromate/
(framing.py, protocol.py, client.py) and appends three dataclasses to
micromate/models.py; micromate/idf_file.py — the codec — is untouched, and
nothing under sfm/ or minimateplus/ changed. The new modules are additive
and nothing imports them yet, so an existing deployment behaves identically.
⚠ The chunk-size and short-chunk changes are internal to
micromate/protocol.py's download loop, which no shipped code path calls — the
only callers are the new client and the bench tooling. Nothing in sfm/ or the
ingest path is affected.
⚠ Likewise bridges/mm_ach_server.py and the bench tooling have no shipped
caller, and micromate/client.py gained only a ring-answering branch inside
that ACH path. Nothing under sfm/ or minimateplus/ changed.
⚠ The SUB 0xA2 collision above is documentation, not a fix. minimateplus
can already send 0xA2 as the last step of its erase sequence; nothing yet
prevents a future shared path from confusing the two meanings. A guard is
outstanding.
The Series-4 config work adds one new module, micromate/setup_block.py
(pure, no I/O), a MicromateSetup dataclass in micromate/models.py, and
MicromateClient.get_setup(). All additive; nothing under sfm/ or
minimateplus/ changed, and nothing shipped calls the new code. No codec,
store or DB change, no TOOL_VERSION bump, no backfill. Its 15 test fixtures
are force-added under the gitignored tests/fixtures/micromate-setup/.
v0.31.0 — 2026-09-18
Report parity, and a second way to rescue a runaway unit. Two threads.
The first closes out Blastware Event/FFT-Report parity: the FFT, the USBM
RI8507 compliance chart and the sensor self-check now render on the event
report, reverse-engineered against BE12844 (MiniMate Plus) and UM (Thor)
events. The sensor check is decoded for both series and standardized into
the .h5 (schema v2, a new /sensor_check group), so SFM serves it
device-agnostically rather than decoding at report time. The Inspector — an
annotated hex reader for series-3 binaries — is what made the trailing-block
structure findable, and it earned its keep by ruling out a stored FFT block
and proving Blastware computes it from the samples.
The second came out of a field emergency. BE12599's connector fault drove its
Tran channel to its trigger level, so the unit recorded back-to-back and dialed
the office ACH server every ~75 s, unreachable the whole time.
bridges/ach_server.py gained --stop-monitoring / --disable-ach /
--rescue, which invert the recovery: instead of racing a Stop into the
gaps between dial-outs, point the modem's Destination at our own ACH server and
answer the call. Proven in production the same night — the stop landed on the
first call-in and held. See docs/runbooks/wedged_unit_recovery.md.
⚠ This release owes prod a backfill — see Migration below.
Added
-
Rescue-on-connect for
bridges/ach_server.py—--stop-monitoring(SUB 0x97),--disable-ach(SUB 0x2C read → 0x7E write → 0x7F confirm) and--rescue(both). They fire immediately after the startup handshake and before the event walk, so a unit that is recording back-to-back on a stuck-triggered geophone is quieted as early in the session as possible. Each action is independently guarded — a failure does not abort the download — and the outcome is written torescue.jsonin the session directory.This inverts the
docs/runbooks/wedged_unit_recovery.mdapproach. That runbook reaches the unit inbound and clears the modem's Destination Address to stop it dialing. When the device is instead wedged mid-modem-init — ALEOS logstcpmode trying to send to invalid socketand re-runsInitialize Auto answerevery ~75 s, orphaning any held inbound session — inbound cannot win. Pointing the modem's Destination at anach_serverand letting the unit call us gives a device-initiated session the modem bridges properly.⚠ Prefer
--stop-monitoringalone on first contact.--disable-achstops the unit calling, which is the only channel to a unit in this state; stopping the recording ends the call-home loop on its own when ACH is "after event recorded". -
Blastware-compatible channel FFT (
waveform_fft). Reproduces Blastware's FFT Report: DC-removed, no window, zero-padded to 4096 (0.25 Hz bins at 1024 sps), single-sided2/Namplitude. Matches Blastware's dominant frequency to the exact bin and the amplitude to report precision across all 28 channels of the 7-event BE12844 oracle set.channel_spectrum()/dominant_frequency(); tests intests/test_waveform_fft.py. -
USBM RI8507 / OSMRE compliance chart on the event-report PDF (
sfm/compliance.py). The velocity-vs-frequency blasting-compliance scatter Blastware draws in the upper-right of its Event Report: each channel's significant cycles as(frequency, peak velocity)points (zero-crossing method, so each channel's cloud tops out at its PPV) plotted against the RI8507 Drywall (0.75 in/s) and plaster (0.50 in/s) limit curves, drawn continuous (constant-displacement bounds meeting the plateaus — no vertical steps). Sized and positioned to match a Blastware report, measured off the reference PDF. A technical breakdown of the curve is indocs/ri8507_compliance_curve.md. -
Sensor self-check waveforms decoded and drawn — both series. The little "Sensor Check" traces (geophone ring-downs — the transducer's damped impulse response — plus a MicL pulse train, the mic's known-signal gain check) are the unit's proof its sensors were healthy when it recorded the event.
- Series-3 (
minimateplus.sensor_check): four records (0x3c–0x3f) in the binary's trailing block, same delta-block codec as the main waveform. Verified against all 7 BE12844 reports (mic zero-crossing = 20.1 Hz exact; geophone ring-downs ~7.5 Hz, overswing ~3.5). - Series-4 (
micromate.sensor_check): the same self-test in the Thor IDFW fixed header — four01 0e 3c/3d/3e/3frecords (same channel ids) storing raw int16 traces; three-channel (mic-disabled) units carry only the three geophones. Validated by shape + cross-event consistency. - Standardized into the
.h5(/sensor_check, schema v2): each series' decoder attaches the traces to the event at decode, the writer persists them, andgather_report_datareads them back — so SFM renders the strip (flush against the waveform panel) plus the Sensor Check → Frequency / Overswing Ratio sub-rows without knowing the source instrument. - Tests:
tests/test_sensor_check.py,tests/test_sensor_check_idf.py,tests/test_event_hdf5_sensor_check.py.
- Series-3 (
-
Inspector tab in
seismo_lab.py— annotated hex reader for series-3 binaries (minimateplus/binary_annotate.py). Tiles a raw Blastware file into labeled spans (header / STRT / body record-chain / trailing metadata + calibration + sensor-check records / footer) so a binary can be combed by eye.
Fixed
- Event-report waveform panel — stacked-lane y-tick collision. The lanes
touch, so each lane's bottom
-1.0overprinted the next lane's top1.0at the shared boundary. Prune the extreme ticks so each lane shows clean interior ticks only. - Event-report header — serial+firmware line ran off the page. The long
BE##### V ##.##-#.## MiniMate Plusstring overflowed the right margin; tighter right-column indent + BW's slightly smaller header size so it fits.
Migration
⚠ The sensor-check needs a backfill. Existing .h5 files are schema v1
and carry no /sensor_check group, so their reports show no sensor-check strip
until regenerated. TOOL_VERSION is bumped to 0.31.0, so the standard
backfill regenerates every event and picks up the traces with no --force:
scripts/backfill_thor_events.py for series-4 (it already owed a v0.30.0 Thor
backfill — this rides along) and the series-3 sidecar/shape backfill for
MiniMate events. Purely additive — no decoded value changes, and v1 .h5
files read fine until then (empty strip). DB backup first, as always.
⚠ Budget ~2 h on the NAS — ~1.5 files/sec there versus ~85/sec on the dev
box (gzip-4 in sfm/event_hdf5.py against a Synology CPU).
Everything else in this release owes nothing: the FFT, the USBM compliance
chart and the ach_server rescue flags are additive and read data already on
disk — no schema change, no DB migration.
v0.30.0 — 2026-09-12
The series-4 correctness release — the Thor / Micromate counterpart to v0.26.0's series-3 work. The decoder is now verified per-sample against Thor's own CSV exports: 459 waveform files, 3,807,158 / 3,807,165 samples exact across three independent ground-truth corpora, and production IDFW is 575/575 with zero truncations and zero decode failures. Series-3 re-verified unchanged at 14,338/14,338 after every shared-codec change.
⚠ This release owes the prod store a Thor backfill. Every stored
series-4 geophone value is 3.3% low, and histogram peaks from monitoring
runs longer than ~4 hours can be far worse (the interval cap discarded the
tail, frequently the part holding the peak). Run
scripts/backfill_thor_events.py — TOOL_VERSION is bumped to 0.30.0, so
regeneration is gated correctly and no --force is needed. DB backup
first. Series-3 events are untouched by this release and do not need
re-running.
⚠ Terra-View displays these values. Series-4 geophone readings will rise ~3.3% after the backfill, and some histogram PPVs will rise a great deal more. That is a correction, not a regression.
Fixed — event-report PDF used a per-trace geo Y scale
The waveform plot scaled each geo lane to its own peak, so a small channel
filled its lane and looked as large as a big one, and the Geo: X in/s/div
footer reflected only whichever channel was measured first — wrong for the
other two. All three geo lanes now share one symmetric scale (max |sample|
across them, padded, 0.05 in/s floor), matching the event modal and BW's
single amp/div; the footer reflects that shared scale. Mic keeps its own psi
scale. Large events are unchanged.
Fixed — series-4 (Thor / Micromate) decoder is now per-sample exact
Verified against Thor's own CSV exports, which carry a per-sample
four-column block beside every binary (CSV/<name>.IDFW.csv) — 1,012 paired
files that had been sitting in the corpus unused. Previous notes asserted
"Thor has no ASCII ground truth", which is why the decoder stayed pinned to a
superseded walker with an unverifiable scale factor.
| metric | before | after |
|---|---|---|
| IDFW per-sample exact | 39.1% | 100.000% (1,057,536/1,057,536) |
| IDFW files fully exact | 0/153 | 153/153 |
| IDFW PPV median error | −3.32% | −0.002% |
| IDFH within 2% of Thor PPV | 51.1% | 100.0% (858/858) |
| prod IDFW PPV median error (8 units) | −3.3% | −0.001% |
| decode cost | — | 6 ms/file |
Four independent root causes:
- Geo LSB was
0.0003, should be0.000310308— the old value was Thor's 4-decimal display rounding of the LSB mistaken for the LSB, so every series-4 geophone sample read 3.3% low. Pinned to ±6e-11 by intersecting 991,415 rounding constraints; corroborated by the ±full-scale seed (±32226) in unwritten IDFH slots. Applies to IDFH too, which had a separate (also wrong)10.0/32768. - IDFH histograms were capped at 250 intervals — the segment validator required the interval counter's high byte to be zero, but the counter is a uint16 cumulative index, so every segment past interval 255 was rejected. Any run over ~4 hours lost its tail, often the part holding the peak. 540/858 corpus files affected.
- Record mode
00 00(raw int16, 10-byte header) was unhandled — the record fell through the dispatch, silently dropping each channel's first 512 samples. This produced the long-standing "loud events truncate" symptom.MODE_ABSOLUTEis now also accepted as a segment-0 preamble. - Body-offset search matched
00 02 00inside record headers — picking a candidate part-way down the chain, which decodes a rotation-shifted body that drops each channel's segment 0. The search now anchors on record headers and takes the chain head.
Also fixes the separately-tracked "UM-series decodes ~1000× low" bug
(UM11402_20260406130113.IDFW now matches its device report exactly).
Series-3 re-verified unchanged at 14,338/14,338 exact after the shared
waveform_codec change.
⚠ This is a codec change: the Thor store owes a regeneration. Run
scripts/backfill_thor_events.py (bump TOOL_VERSION first, or pass
--force), DB backup first. All stored series-4 .h5/sidecar peaks are
currently ~3.3% low, and histogram peaks for runs over ~4 hours may be
badly low.
⚠ Thor's histogram PPV has a 0.0050 in/s display floor — 41.4% of prod IDFH sidecars report a component PPV larger than their own vector sum. On quiet files the decoder is now more accurate than that reference.
New: scratch/verify_thor_against_csv.py, tests/test_idf_binary_codec.py
(10 tests, fixtures under tests/fixtures/thor-idf/).
Fixed — mic-disabled (3-channel) units
Verified on a second corpus (9-10-26-csv-req: UM11402, UM12947, UM20147) —
139/139 waveforms per-sample exact (1,273,380 samples), 877/877 histograms
within 2% (was 66.9% and 56.6%).
- Waveform body head sat below the scan floor. A 3-channel unit's shorter
header puts the record chain head at
0x0dba, under the old_BODY_SCAN_FLOORof0x0E00. The scan couldn't see it and fell through to the Vert segment-0 record, decoding a body shifted one position around the channel rotation — Vert came up exactly 512 samples short. Floor lowered to0x0C00; body-offset scoring now accepts 3 channels as "equal" instead of demanding 4. - Histogram interval record is 56 bytes, not 72. It is
16 × n_channels + 8, so mic-disabled units pack 56. Assuming 72 read 7 intervals out of every 10-interval segment then walked off alignment into garbage decoding as ~10 in/s peaks (errors up to +191,000%). The interval count now comes from the segment's cumulative counter and the stride is derived from it; also recovers 4 files that decoded no intervals at all.
Combined across both corpora: 292/292 waveform files, 2,330,916/2,330,916 samples exact. Production IDFW truncations 41 → 22.
Fixed — 40 NN int16 blocks with NN > 8
data_block_len() rejected any 40 NN block with NN > 0x08. The cap had
no evidence behind it: every corpus available when it was written used only
NN ∈ {1,2,3,4,8}, so it was never exercised. Loud UM12947 events use NN of
12, 16, 20 … up to 196, and because the block walker stops at the first
unrecognised tag rather than raising, rejecting them surfaced as silently
short channels (e.g. Tran 1812 / Vert 2132 / Long 2324 on a file whose
export has 2324 for all three). The bound is the buffer, not a constant.
Verified against Thor exports for UM12947 (2025-07-14 … 09-25, 167 waveforms): length mismatches 22 → 0, 1,476,242/1,476,249 samples exact. These are not truncated recordings — the exports carry full sample counts.
tests/test_waveform_codec.py asserted the cap as intended behaviour; that
assertion was wrong and has been replaced with one pinning the opposite,
carrying the evidence.
Result across all three ground-truth corpora
459 waveform files, 3,807,158 / 3,807,165 samples exact. Production IDFW: 575/575, zero truncations, zero decode failures, median PPV error −0.0007% across 8 units. Series-3 re-verified unchanged at 14,338/14,338 after every shared-codec change.
The 7 residual samples each differ by one 4th-decimal tick and are Thor's
own rounding: intersecting the per-sample rounding constraints over that
corpus is infeasible (the binding pair contradict by 2.3e-11, 7e-5 relative),
so no single linear LSB reproduces every printed value. _GEO_LSB_IPS is
already pinned to ~1e-11 — do not retune it to chase these.
v0.29.0 — 2026-09-04
First release to reach prod since v0.27.0, so it ships both the
false_trigger_reason column below and the v0.28.0 offset (DC-baseline)
detector: v0.28.0 was version-bumped in-tree (TOOL_VERSION, CHANGELOG) but
never tagged or deployed, so 0.29.0 is the first build to carry either to prod.
Pairs with Terra-View ≥ 0.24.0. The false_trigger_reason column auto-migrates
on startup; the offset detector still needs the shape backfill on the prod store
(scripts/backfill_event_shape.py) to populate shape_offset* on existing rows.
Added
events.false_trigger_reason— optional FT cause. A nullableTEXTcolumn recording why an event is a false trigger (e.g."offset"), as a subtype of the FT flag: setting a reason via the sidecar review PATCH impliesfalse_trigger=1, and the reason is cleared whenever FT ends up 0 (confirm-real, clear-FT,set_false_trigger(false)).propagate_review_to_twinscarries the reason to the histogram/waveform twin alongside the flag. Auto-migrated (_SCHEMA+_migrateADD COLUMN — not the Migration-1 rebuild); exposed via/db/events. Terra-View surfaces it as a manual "Flag as offset" action + anFT · offsetbadge.
Fixed
-
BlastMate serials — the family prefix is read from the file, not guessed. The Blastware filename encodes only the serial number (
L895…→ 10895); the two-letter prefix is not in it.waveform_storesynthesised"BE", so an imported BlastMate (serialsBA…) was filed under a MiniMate Plus serial that does not exist — silently, and Terra-View read it straight through.save_imported_bwnow resolves serial as hint → file body → filename guess, via a new_serial_from_bw_bytesthat accepts a candidate only when its numeric part matches the filename.client._decode_0a_partial_headerlikewise matched a literalb"BE"in monitor-log partial records; on a BlastMate that returned −1 and skipped the whole block, losing the geo threshold along with the serial. It now matches any two-letter prefix and requires the NUL terminator — stricter than the search it replaces.BlastMate is the MiniMate Plus's larger Series III sibling and its files are byte-compatible: all 1,493 in the DL2 archive decode through the existing codec at 100%, same four channels. The serial string was the only thing blocking BlastMate support in SFM. Four archive units were affected — BA9229, BA10060, BA10895, BA15957.
No backfill and no
TOOL_VERSIONbump: this changes which serial an import is filed under, not any decoded value, so existing sidecars and.h5files are untouched. No migration either — prod holds no BlastMate events (the archive's BA units last recorded 2018-10 through 2023-11; the prod backfill reaches back only to ~May 2025).
v0.28.0 — 2026-09-02
Offset (DC-baseline) false-trigger detector. Productionizes the validated
pre-trigger detector: a geophone event whose baseline sits off zero and stays
flat across the record (sensor bumped / settled / drifted) is now flagged and
surfaced in Terra-View as an offset false-trigger reason — catching offsets the
crest/near-peak spike rule misses (an offset is low-crest and flat).
Added
shape_metrics.offset_from_samples/offset_from_h5: per geophone channel,|median(pre-trigger)| ≥ 0.025 in/sANDpre/mid/end spread ≤ 0.02→ offset; the consistency test rejects transients (a real event moves one third). Reads the.h5samples + thepretrig_samplesattr, range-aware via the in/s float samples. ConstantsOFFSET_FLOOR/OFFSET_MAX_SPREADare tunable.events.shape_offset/shape_offset_axis/shape_offset_pre/shape_offset_spreadcolumns (auto-migrated:_SCHEMA+ the_migrateADD COLUMN loop), computed at all three ingest paths and bybackfill_event_shape.py, exposed via/db/events.
Requires the shape/offset backfill on the prod store to populate existing events:
python scripts/backfill_event_shape.py --db-path … --store-root ….
v0.27.0 — 2026-08-28
Per-sample decoder verification at scale, plus the offset investigation. The series-3 codec is now verified sample-by-sample against 14,338 preserved Blastware ASCII exports — 1,249 waveform and 13,089 histogram, spanning 45 units and files back to 2018. That is 11x the ground truth the production store carried, and it found one real codec bug (below).
Fixed
-
Sub-minute histograms with a partial final block decoded to nothing (
histogram_codec.detect_multi_interval_stride). The stride search confirmed itself on a third block header whenever the body was long enough to hold one — but a body can exceed two strides and still contain only two real blocks, because a partial final block leaves trailing padding. BE18193T193L0XM.CI0H(51 intervals at 2 s = one full 30-interval block plus a 21-interval remainder, in a 2787-byte body) therefore had its correct stride of 612 discarded and produced an empty decode. A missing third header now means end-of-stream rather than disqualification; the block-counter check, which is what actually prevents the false positives that once mis-dispatched 9,082 files, is unchanged.Found by decoding the full DL2 archive against its preserved Blastware ASCII exports. Across 63,535 unique histogram binaries the fix recovers 4 files —
K440HJCN.3C0HandK557IF1U.8K0H(stride 252),T191HVNP.0S0H(92) andT193L0XM.CI0H(612) — with zero files regressed. Verification over all 14,340 archive pairs goes 14,337 → 14,338 exact, the only remainder being two series-4 IDF files that belong to a different codec.(The DL2 export keeps a byte-identical
Sent/mirror of its root, so a naive walk double-counts every binary — 127,035 paths are 63,535 distinct files. The ASCII exports are not mirrored, so the 14,340 pair count is already distinct.)No prod backfill is required for this. Verified after the fact: all four recovered files are archive-only — none exists in the production store or the events DB — and re-running stride detection over the production store's 10,215 histogram binaries shows 0 files whose decode changes. The fix matters for future ingests of sub-minute histograms with a partial final block, not for anything already stored.
(
TOOL_VERSIONmoves with the release, so whenever a backfill is next run for some other reason it will regenerate the whole store rather than skipping. That is harmless — the output is byte-identical for every currently-stored file — but it means the run takes its full ~2 hours on the NAS.) -
Histogram/waveform twin matching is now interval-based (
find_twins). A real trigger is recorded twice — as a triggered waveform (stamped at the trigger instant) and inside the scheduled histogram whose interval contains it (stamped at the 7am/7pm interval start) — so the two twins can be hours apart. The old ±5-minute window silently missed them, which broke review propagation (flagging one twin didn't flag its twin). Twins are now matched by same serial + identicalpeak_vector_sum+ opposite record type + the waveform falling within the histogram's interval (bounded by the next same-serial histogram).window_secondsis retained but ignored. Fixes terra-view #102 sub-task 2. -
/healthreported a hard-coded0.1.0instead of the real service version.sfm/server.pynow derives its version fromminimateplus.event_file_io.TOOL_VERSION, making that constant the single source of truth for the service version and the sidecar stamp alike — one place to bump at release. -
CLAUDE.mdhad 793 NUL bytes appended after its last line, which madegreptreat the file as binary and silently skip it. Present since at least v0.21.0. Stripped.
Added
docs/offset_investigation.md— a dated journal of the "offset" hardware fault: base rate, detector design, per-unit case files, ruled-out hypotheses (each kept with the evidence that killed it), and Instantel's own autozero procedure with its 2027–2069 acceptance window.scratch/verify_against_ascii.py— decodes a corpus of BW binaries and diffs every sample against the paired_ASCII.TXT. Includes a saturation carve-out: BW clamps clipped events to the range maximum and writesOORANGE, while the decoder faithfully reports counts past nominal full scale.scratch/offset_scan3.py— offset detector. Measures the resting floor in the pre-trigger window (definitionally quiet) and requires it to hold across pre / middle / end. Result: 5 of 45 units (11%), stable across a 2x threshold range. Supersedesoffset_scan.pyandoffset_scan2.py, both kept as the reasoning trail.
Verified
- 19,244 healthy channel-events sit at a pre-trigger floor of exactly 0.000 (62.7%), 94.5% within ±1 quantisation unit, median +0.0000. No systematic zero-point bias in the decoder — an independent confirmation of the 32000-count geo full scale, arrived at from a different direction than the ASCII sample comparisons.
v0.26.0 — 2026-08-27
Series-3 decode correctness. Two body-model rewrites, a systematic scale error affecting every geophone reading ever produced, a recovered file format, and two artifact-hygiene bugs where stale files outlived the decodes that made them. All 11,603 series-3 binaries in the production snapshot now pass every check.
Fixed
-
Series-3 health sweep: 11,603 / 11,603 binaries now clean on every check. Swept every series-3 file with the live decoder against five independent checks — decode exceptions, zero samples, unequal geo channel lengths, peaks above range full scale, decoded peak vs the device-reported PPV, and waveform length vs the declared record time. Three real defects surfaced and were fixed:
-
block[22]is not a constant and must not be tested. It was documented as always0x00but carries data on loud blocks, and rejecting those threw away the interval holding the event peak.BE18350/T350L7HR.NL0Hblock 92 hasblock[22]=0x26and a Tran peak of0x0563= 1379 counts = 6.895 in/s — exactly the device-reported PPV — while the file as a whole decoded to 0.015 in/s.block[0]==0x00,block[4]==0x0Aand the 4-byte tail are six bytes of constraint, which is what keeps trailer content out. -
Block-model dispatch now goes on signature strength, not on whichever decoder returns first. A multi-interval body also yields scattered standard-tail blocks by coincidence; dispatching on "first non-empty" handed 193 BE18193 files to the standard walker and produced peaks of 149 in/s against a 10 in/s full scale.
-
Multi-interval stride detection requires the block counter to increment by exactly 1. Without it the detector false-positives on ordinary standard-block bodies: those carry a header every 32 bytes, and
192 = 12 + 20×9and512 = 12 + 20×25are both multiples of 32, so a stride "fits" while actually skipping 6 or 16 real blocks. That misrouted 9,082 files.
Partial-block garbage is now trimmed within the final block only, stopping at the first slot with a non-zero tail word or a geo peak above full scale. Trimming purely from the end left garbage stranded behind one slot that happened to have a zero tail word; trimming on the tail word alone truncated four BE9440 files by up to 2,800 intervals.
-
-
Sub-minute histogram intervals are packed several to a block — 415 files recovered. The device always writes one minute of data per block, so a shorter interval just means more intervals in a longer block:
interval intervals/block stride 1 min 1 32 (the standard block) 15 s 4 92 2 s 30 612 stride = 12 + n * 20. Each 20-byte record carries 8 × uint16 little-endian values — peak and half-period per channel — plus a 2-word tail whose first word is0000on every real interval (a session ending mid-block leaves buffer garbage in the remaining slots, which decoded as peaks thousands of times the real value until that check was added). The standard 32-byte block is big-endian; this variant is not.These 415 files (216 on BE18193 at 2 s intervals, 199 on BE9440 at 15 s) previously decoded to nothing at all — and before that were being accepted by the waveform codec, which returned garbage peaking up to 400× the device-reported PPV.
Ground truth
BE9440/K440L3AQ.T70H— 5,710 intervals — matches its Blastware ASCII export on 17,130/17,130 geo peaks, 22,840/22,840 frequencies and 5,710/5,710 mic dB(L) values. Across all 455 affected files, 1,354/1,365 (99.2%) channel peaks match the device-reported PPV; the 11 that don't are under-reads on BE9440 where the walk stops early. -
backfill_sidecars.pynow removes a stale.h5when nothing decodes. It previously skipped the write "so we don't replace whatever's there with an empty placeholder", which silently preserved output from a superseded decoder. After the record-chain fix, 415 histogram files stopped decoding (an unmapped block variant on BE18193 and BE9440) but kept.h5files whose peaks ran up to 400× the device's own reported PPV — garbage feeding the charts and the false-trigger detector with nothing marking it. Reports astale_h5_removedcount. -
The series-3 waveform body is a RECORD CHAIN, not a tag stream — this supersedes the segment-header model, including the fixes made earlier the same day.
Records are self-delimiting.
off+2is auint16 BElength andnext_record = off + 2 + len; the chain ends on a record whosechan_idis0x06.off+8carries a 3-valued mode enum:mode header data section 02 0014 B anchors, then cumulative deltas 01 0010 B no anchors, absolute values 00 0310 B no tags at all — raw 12-bit packed absolute 40 NNis an ordinary int16 BE data block (2*NN + 2), never a segment header. Reading it as a2*NN + 16header is what made walks drift — and the "variable-prefix segment descriptors" reported earlier today were not a format feature at all, just walker drift of exactly4 - (old_stop - true_record_start)on all 25 affected files.Measured against the production snapshot:
before after all four channels equal length 156 / 1388 1388 / 1388 ASCII sample-count exact 72 / 75 75 / 75 ASCII fully exact 70 / 75 73 / 75 device PPV, waveform (live decode) 1288 / 1306 1306 / 1306 device PPV, histogram (live decode) 4434 / 4459 4458 / 4459 Mean absolute PPV ratio error on waveforms is now 0.00000. The 2 remaining ASCII imperfections differ by exactly 1 LSB on samples sitting at the ±10.000 in/s rail.
This also eliminated the walker-over-read class. 24 of those 35 files were histograms that
read_blastware_filefed to the waveform codec first; the old walker accepted them and returned garbage (one yielded 98,923 "intervals"), while the record-chain decoder correctly returnsNoneso they fall through tohistogram_codec.00 03records are decoded rather than skipped. Skipping them does not merely lose samples — it silently shifts the time base of everything after them on that channel (observed onBE9558/K558LOF2.820W, MicL displaced by exactly 512 samples with nothing marking the gap).Footer detection now prefers whichever
0e 08candidate yields a chain terminating on0x06, since the signature can occur inside a sample stream. Blast radius: 1 file of 1,388.The superseded model is retained as
decode_waveform_legacyand pinned bymicromate/idf_file.py, whose Thor IDFW body-offset search trial-decodes candidate offsets and keeps whichever yields the most samples — the new decoder correctly returnsNonewhere the old one returned garbage, which changes that heuristic's winner. Switching Thor over is deferred until that search is reworked to use the record chain directly. -
Series-3 histogram block is uniformly big-endian, and the stream's final block has its own tail — the codec was clipping large peaks and dropping the last interval of nearly every histogram.
- Peaks and half-periods are
uint16big-endian, notuint8plus an "annotation" byte:T_peak[5:7],T_halfperiod[7:9],V_peak[9:11], and so on. Onlyblock_ctr[2:4]is little-endian. The old model silently clipped any peak above 1.275 in/s — the final interval ofBE18193/T193LQ9K.OE0Hreads 8.270 in/s in Blastware's own export and decoded as 0.590. The "annotation" byte was the half-period's high byte, which is why it was non-zero exactly on the sub-Hz intervals BW renders as<1.0. - The marker is
block[4]alone. Testing[4:6]as auint16 LEmarker forcedblock[5] == 0— which is what capped the peak at one byte in the first place. - The last block of each stream carries tail
9c 06 00 42instead of1e 0a 00 00, with arbitrary bytes at[21:23]. Rejecting it dropped the final interval of nearly every histogram, and that interval is frequently the one holding the event peak — so the file's reported PPV came out low.
Verified against 1211 production histograms paired with their preserved Blastware ASCII exports, which carry a full per-interval data table: 1211/1211 now decode exactly (interval count plus every per-interval peak), and 842,442 per-interval frequency comparisons match with zero mismatches. Before this fix: 1 of 1196.
decode_histogram_body_fullrecords now exposeis_terminalin place of the removedannotationstuple. - Peaks and half-periods are
-
Geophone full scale is 32000 ADC counts, not 32768 — every geo reading was 2.3% low. The verified body codec emits geo samples in 16-count units whose documented LSB is exactly 0.005 in/s, and
decoded_to_adc_countsmultiplies by 16, so one ADC count is0.005/16in/s and Normal range (10.000 in/s) is10.0 / (0.005/16)= 32000 counts. Bothsfm/event_hdf5.pyandminimateplus/event_file_io.pydivided by 32768, scaling every geophone sample and every derived peak down by1 - 32000/32768= 2.34%.Measured against 216 per-channel comparisons with preserved Blastware ASCII exports: 32768 → 151/216 exact (worst error 0.238 in/s on a 10 in/s event); 32000 → 216/216 exact, worst error 0.005 in/s (exactly 1 LSB — pure quantization). The error scales with amplitude, so it was invisible on quiet events and worst on the loud ones that matter for compliance.
The mic path is unaffected — it back-solves its own per-count factor from the device-reported peak.
Scope: the scale lives in
_samples_to_float, which every event passes through regardless of which codec produced the samples — so this affected waveforms, histograms and series-4 (Thor IDF) alike, not just waveforms. Verified after regeneration: series-3 histogram peaks vs their ASCII reports now sit at a median ratio of 1.0000 across 1,137 comparisons (0.9766 under 32768); series-4 peaks vs device peaks moved from a median 0.960 to 0.983 across 1,468 comparisons. The four block-framing fixes below are waveform-only — histograms decode viahistogram_codec.decode_histogram_body, which is untouched. -
Series-3 waveform codec: four block-framing cases caused silent channel truncation.
walk_bodyhit its unknown-tagbreakmid-stream and every channel decoded after that point came out short — typically Vert/Long/MicL, sometimes at a third of their true length, with no error raised.- Wide-NN RLE
0X NN— the 12-bit NN encoding already handled for1X NN/2X NNalso applies to the00 NNRLE tag. Runs longer than 252 samples must use the wide form (e.g.01 0c= 268 repeats). 30 NNwith NN > 0x10 — the0 < NN <= 0x10guard was arbitrary; data-section30 NNblocks reach at least NN = 0x18. The length formula (NN × 1.5 + 2) was already correct.- Variable-width
40 NNsegment headers — NN is the count of previous-channel continuation deltas, so the header is2 × NN + 16bytes and every field after the deltas shifts by2 × NN. Only40 02(20 bytes) was handled;40 01(18) and40 03(22) both occur. - Tagless segment headers — a segment header can appear with no
40 NNtag at all: just the 14-byte tail[field2:2][len:2][channel_id:4][marker:2][anchors:4]. This is the NN=0 case (no continuation deltas needed, so no tag and no delta bytes). It is where the walk stopped in 7 of the 8 events still truncating after the first three fixes.
- Wide-NN RLE
Changed
-
Segment channel now comes from the header's own channel-id byte rather than from rotation position. The field previously documented as a "monotonic uint32 LE counter" is really
[channel][00][00][segment_index]with0x46=Tran0x47=Vert0x48=Long0x49=MicL — verified on 1697 of 1697 segment headers across the ground-truth corpus with zero disagreements. Rotation-by-position is kept only as a fallback for unknown ids; it was fragile because a single missed or extra header (exactly what tagless headers caused) desynced every channel after it. -
parse_segment_headerreturn shape — nown_prev_deltas,prev_deltas,marker,anchors,channel,segment_indexin place of the fixed-offsetanchor_bytes/fixed_pattern/tailkeys. The oldfixed_pattern(02 00 00 01) conflated the 2-byte constant marker with the first anchor.counteris retained as the raw uint32 of the id field.
Verification
Against the 75 ground-truth events (BW binary paired with its preserved
_ASCII.TXT export), decoding end-to-end through the production path:
| before | after | |
|---|---|---|
| exact (full length, within 1 LSB) | 37 | 72 |
| truncated | 23 | 3 |
| full length, value error > 2 LSB | 15 | 0 |
Worst remaining error among the 72: 0.0050 in/s = exactly 1 LSB.
No regressions — the byte-exact fixture suite still passes, and the full-suite failure list is unchanged from baseline (16 pre-existing failures from gitignored fixtures).
Notes
-
The "DC offset" symptom is not a decode bug. Events whose geo trace sits at a constant level instead of oscillating around zero (dominant-axis
|mean| / peak>> 0) reproduce exactly in Blastware's own ASCII export — e.g.BE12599/N599LQD7.8E0WTran reads mean +0.345, min +0.335, max +0.355 in both. It is a known recurring hardware fault (the operators call it an "offset"): the affected channel's baseline exceeds the unit's own geo trigger level, so the unit retriggers continuously and floods the ACH queue with garbage events. Store-wide it affects 2 units of 21 across 6 episodes; seescratch/offset_candidates.csvand the project memory notes. -
Still open: 3 of 75 ground-truth events truncate at a segment-header variant with a variable-width prefix.Resolved later the same day — the record-chain rewrite (above) showed there is no variable prefix; it was walker drift. All 75 are now sample-count exact. -
Still open after this release:
- Series-4 (Thor / Micromate) is not verified — UM-series sits at ~48%
against device peaks with a ~1.7% systematic bias and a near-zero tail.
Thor IDFW is pinned to
decode_waveform_legacydeliberately. - 14 sensitive-range files show a decoded/truth ratio of exactly 8.0 (= 10.0/1.25) — a units bug, not a codec one. Never chased.
backfill_sidecars.py --forcealso inserts DB rows for store files that have none (1,286 on the snapshot; one-time per store), and the dry-run does not report that count before you commit to it.- Verification is uneven: per-sample proof on the 11% of files with a
preserved
_ASCII.TXT, peak-and-structure consistency on the other 89%.
- Series-4 (Thor / Micromate) is not verified — UM-series sits at ~48%
against device peaks with a ~1.7% systematic bias and a near-zero tail.
Thor IDFW is pinned to
v0.25.0 — 2026-08-25
reviewed_real 3-state review flag + twin review-propagation. The
events table and the /db/events feed now carry reviewed_real, a
3-state review flag mutually exclusive with false_trigger, mirrored from
the sidecar review block — plus histogram/waveform twin review-propagation
(flagging one flags both, matched by serial + identical PVS + timestamp
window).
Added
eventscolumnreviewed_real—INTEGER NOT NULL DEFAULT 0, added via the existing incremental_migrateADD COLUMN pass (auto-migrates onSeismoDb()construction, no manual migration).query_events/get_event(and thus/db/events) return it automatically (SELECT *).- Mutual exclusivity with
false_trigger— settingreviewed_real=1clearsfalse_trigger, and vice versa, enforced on both review paths: the sidecar review PATCH (update_event_review) and the quickPATCH /db/events/{id}/false_triggerendpoint (set_false_trigger). find_twins— matches an event's histogram/waveform twins by serial + identical peak-vector-sum + a timestamp window.propagate_review_to_twins— copies an event'sfalse_trigger/reviewed_realstate onto its twins, wired into both thePATCH /db/events/{id}/sidecarreview path and the quickPATCH /db/events/{id}/false_triggerpath, so flagging one flags both regardless of which endpoint made the change.
v0.24.0 — 2026-08-22
Waveform-shape metrics on events. The events table and the /db/events
feed now carry per-event crest factor and points-near-peak, computed from the
decoded waveform samples at ingest — groundwork for Terra-View's
false-trigger detection (Phase B).
Added
eventscolumnsshape_crest_factor,shape_near_peak_count,shape_sample_count,shape_axis. Added via the existing incremental_migrateADD COLUMN pass — auto-migrates onSeismoDb()construction, no manual migration.query_events/get_event(and thus/db/events) return them automatically (SELECT *).- Populated at ingest — crest factor + near-peak-count are computed from
the decoded samples in every save path (
shape_from_h5/shape_from_samples), andinsert_eventspersists them on INSERT and UPSERT. - Backfill
scripts/backfill_event_shape.py— fills the columns for existing events from their on-disk.h5waveform samples (idempotent, UPDATE-only).
Upgrade Notes
Run the backfill once after deploying, against the events DB + waveform store:
python3 scripts/backfill_event_shape.py --db-path <seismo_relay.db> --store-root <waveforms/>
Events with no decodable samples (or no waveform file) stay NULL and render
"—" downstream.
v0.23.0 — 2026-08-04
Per-channel ZC frequency in the events store. The events table and the
/db/events feed now carry per-channel zero-crossing frequency, so consumers
(Terra-View's Vibration Summary) get frequency in bulk instead of one sidecar
fetch per event.
Added
eventscolumnstran_zc_freq,vert_zc_freq,long_zc_freq,mic_zc_freq(Hz) +*_zc_above_rangeflags (the Blastware>N Hzdevice-ceiling case). Added via the existing incremental_migrateADD COLUMN pass — auto-migrates onSeismoDb()construction, no manual migration.query_events/get_event(and thus/db/events) return them automatically (SELECT *).- Populated at ingest —
PeakValuesgains the ZC-freq fields; bothapply_report_to_eventandapply_bw_report_dict_to_eventcopy per-channelzc_freq_hz/zc_freq_above_rangefrom the parsed report onto them, andinsert_eventspersists them on INSERT and UPSERT. - Backfill
scripts/backfill_event_zc_freq.py— fills the columns for existing events from their.sfm.jsonsidecars (idempotent, UPDATE-only).
Fixed
sfm/server.pyapp-version string was stale at0.17.0; now tracks the real version.
Upgrade Notes
Run the backfill once after deploying, against the events DB + waveform store:
python3 scripts/backfill_event_zc_freq.py --db-path <seismo_relay.db> --store-root <waveforms/>
Events whose sidecar carries no frequency (or that have no sidecar) stay NULL and
render "—" downstream.
v0.22.0 — 2026-07-03
Full-snapshot bundle support (SFM side). Adds the DB-snapshot, recent-waveform,
and gated-restore endpoints Terra-View drives to pull a complete prod→dev refresh
— the seismo_relay.db plus the waveform files behind recent events — in one
pass. Pairs with Terra-View v0.17.0's "Create full snapshot (incl. SFM)"
control on Settings → Database. New logic lives in sfm/db_snapshot.py, kept
out of server.py so it's unit-testable without HTTP.
Added
GET /db/snapshot— streams a WAL-safe point-in-time copy ofseismo_relay.db, taken through the SQLite online backup API (not a raw file grab), so the download stays consistent even while the ACH server is writing under WAL.GET /db/waveforms/recent.zip?n=…— zips the on-disk files (event file- its
.h5/ sidecar siblings) for the n most-recent events, arcname<serial>/<filename>, so a dev box can restore chart-openable events without hauling the entire waveform store. Events with no resolvable files on disk are skipped.
- its
POST /db/restore— gated bySFM_DB_RESTORE_ENABLED(dormant → 404 unless explicitly enabled; dev-only). Validates the uploaded DB first, takes a WAL-safe.pre-restore-<ts>safety backup of the current DB, then swaps in the restored DB + waveforms. Zip entries are path-traversal-guarded before extraction.
Fixed
- Restore no longer blocks the event loop.
/db/restoreruns its synchronous DB/file work in a threadpool instead ofasync def, so a large restore can't stall inbound ACH connections or other API requests.
v0.21.1 — 2026-06-01
Bug fixes against v0.21.0 surfaced after the first prod redeploy. Three production-visible symptoms — blank waveform charts on most Thor events, blank histogram charts on all Thor events, and a mic chart that auto-scaled against a dB(L) value treated as psi — all root-caused and fixed.
Fixed
-
Dynamic IDFW body offset. The v0.21.0 codec hardcoded the body at file offset
0x0f1fbased on the example corpus, but only ~52% of production IDFW events use that offset; the rest sit at offsets from0x1033up to0x3082depending on header padding. At0x0f1fthe codec would find a coincidentally-matching00 02 00magic, read the 2-byte Tran preamble, and return empty V/L/M arrays — producing near-empty .h5 files and blank charts.micromate.idf_file._find_waveform_body_offset()now scans every00 02 00magic position past0x0E00, trial-decodes each one, and picks the offset with the most samples. Validated across 483 prod IDFW files: 0 preamble-only events (was ~50%), 355/483 fully decode, 126/483 partial (BW codec walker-stops-early on loud events — pre-existing limitation, samples reached are correct). -
IDFH histograms now render bar charts. Histograms previously skipped the .h5 write because there are no per-sample arrays, but the renderer drives the per-interval bar chart from .h5 channel data +
bw_report.histogram.n_intervals.save_imported_idfnow synthesizes a 1-sample-per-interval array from the decodedIdfhIntervalpeak counts and writes an .h5 so the existing renderer works unchanged — each "sample" is the per-interval peak ADC count, so the writer'scount × geo_fs/32768conversion yields the right bar height. -
Mic chart scaling on Thor events.
PeakValues.micl(consumed by the h5 writer's per-count mic scale factor) expects psi, but the Thor bridge was stuffing the dB(L) value (~99.4) into it, producing a per-count factor 5+ orders of magnitude too large and a flat-looking mic chart. Fixed by addingIdfPeaks.mic_pspl_psialongsidemic_pspl_dbl;read_idf_file()computes it from binary mic counts (max(|MicL|) × 2.14e-6 psi/count) for both IDFW and IDFH paths;save_imported_idfmerges it onto the typed event afterIdfEvent.from_report; the bridge feeds psi toPeakValues.miclwith a dB(L)→psi formula fallback when only the dB(L) value is available. dB(L) for the report header still flows throughbw_report.mic.pspl_dblunchanged.
Operator
After deploy, run python scripts/backfill_thor_events.py to refresh
every existing Thor event's sidecar + .h5 with the corrected codec
output. The script auto-skips events already at the current
TOOL_VERSION, so the bump from 0.21.0 → 0.21.1 is what triggers
the refresh.
v0.21.0 — 2026-05-29
The "Thor / Series IV codec" release. Two big pieces landed: (1) the IDF binary codec actually decodes now, both IDFW and IDFH, and (2) a Thor→BW adapter lets Thor events flow through the existing Series III Event Report PDF pipeline. Combined effect: a Thor event ingested via /db/import/idf_file now lands in the DB with the same fidelity as a Blastware event, gets a per-event PDF on demand, and renders in Terra-View's modal chart with the same plotting code as a BW event.
Added — Thor IDF binary codec (micromate/idf_file.read_idf_file)
- IDFW (waveform) — body sits at fixed file offset
0x0f1f; reuses the verifieddecode_waveform_v2()walker fromminimateplus.waveform_codec. Sample fidelity is 87–99% byte-exact against the ASCII-sidecar reference values on quiet events; loud events hit the same walker-stops-early limitation as the BW codec onSP0/SS0/SV0-style events. - IDFH (histogram) — dedicated segment-based decoder for the Thor histogram body format:
[len_be][0a 00 00 00][00 NN][05 3f]framing plus N × 72-byte interval records (4 × 16-byte per-channel min/max/halfp). All 859 Thor IDFH corpus files decode, totalling 181,071 intervals; per-channel peaks match the sidecar within ~1.8% (ADC quantization). - BW-aliased binary detection — a small number of corpus files (e.g.
BE9439_*.IDFW/IDFH) are actually Series III Blastware binaries that share the IDF filename convention by accident.read_idf_file()detects them via their BWSTRTsignature and raisesNotImplementedErrorpointing the caller atread_blastware_file()instead of trying to decode them as IDF. - Full field layouts in
docs/idf_protocol_reference.md; supporting analysis scripts inanalysis_idf/(decode validators, per-file detail dumps, corpus accuracy reports).
Added — Thor → BW report adapter (micromate/idf_to_bw_report.py)
build_bw_report_from_idf(report_dict, binary_md=, intervals=, is_histogram=)projects a parsed ThorIdfReportplus binary-extracted metadata plus decoded IDFH intervals into thebw_report-shaped dict thatsfm.report_pdf.gather_report_dataconsumes. No need to duplicate the renderer — Thor data is ~95% the same metric set as BW; the adapter handles the field-name mapping (MicPSPL→pspl_dbl,>100sentinel →zc_freq_above_range, free-formCalibration : Nov 22, 2023 by Instantel→calibration_date+calibration_by, etc.).- For IDFH events the adapter derives
histogram.interval_timesby steppingIntervalSizefromHistogramStartTime, matching what the BW pipeline expects from a histogram-mode event. - Wired into
WaveformStore.save_imported_idf— every Thor event ingested via/db/import/idf_filenow gets abw_reportblock in its sidecar in addition to the existingextensions.idf_report(the raw parsed Thor payload). Falls back gracefully (PDF renders from DB-only fields) if the adapter raises — logged as a warning rather than failing the ingest.
Companion releases
- Terra-View v0.13.0 ships in parallel — closes Phase 1 of the SFM integration. The shared event-detail modal now renders the SFM event story (Chart.js waveform/histogram chart, inline PDF preview,
.TXTdownload, FT/reviewer/notes review form) without operators needing to bounce to the standalone SFM webapp on port 8200. Uses only existing seismo-relay endpoints — no API changes here, just better consumption.
Migration / Operations
No DB migration needed. Existing Thor events already in the store don't automatically pick up the new bw_report block — they'd need a re-ingest (post the IDF binary + paired .TXT back to /db/import/idf_file) for the adapter to run. Alternatively, run scripts/backfill_sidecars.py --reparse-txt after a small adapter change (the script currently only re-runs the BW ASCII parser; extending it to handle Thor would be a small follow-up).
cd /home/serversdown/terra-view
docker compose build sfm && docker compose up -d sfm
The bumped TOOL_VERSION = "0.21.0" in minimateplus/event_file_io.py means any subsequent backfill_sidecars.py --force pass will re-write sidecars with the new version stamp; that's expected and harmless.
v0.20.0 — 2026-05-28
The "PDF + parser polish" release. Closes out the Event-Report PDF iteration started in v0.17.x: histogram layouts now render correctly against BW reference PDFs, the ASCII parser handles the real-world edge cases production events were tripping over (OORANGE, >100 Hz, histogram timestamps), and the .TXT preservation rollout lets parser fixes be applied retroactively to ingested events. Adds server-wide timezone support so operator-visible timestamps no longer drift into UTC. Rolls up the substantial "pre-v0.20" body of work that had accumulated under [Unreleased] (PDF generation, histogram codec fix, histogram parser fields, .TXT preservation, backfill safety) — see the trailing "pre-v0.20.0 work" section below for the full list.
Added (2026-05-28)
- Server-wide display timezone via
TZenv var. Both seismo-relay and terra-view now respect aTZenvironment variable (defaultAmerica/New_Yorkon prod). Affects server log timestamps, the PDF report renderer's UTC→local conversions on the "Created" footer line, matplotlib's datetime axes, and any other naïve-vs-aware datetime rendering. DB columns (created_at, etc.) stay UTC regardless — this is a display-side fix, not a storage-side one. Dockerfile now installstzdata(required for the env var to take effect underpython:slim). Override per-deployment via theTZline indocker-compose.yml. - ZC Freq "above-range" handling — render
>100 Hzinstead of—. BW writes">100 Hz"literally when the zero-crossing algorithm sees a peak too fast to count (device cuts off at 100 Hz on V10.72). Previously_parse_number(">100")returned None and the PDF stats table rendered—. Now the parser mirrors the OORANGE pattern: stores 100.0 onzc_freq_hzand sets a newzc_freq_above_rangeflag. Flag rides through the sidecar'sbw_reportblock. Renders as>100in the PDF (per-channel + mic block), as· >100 Hzinline on the event modal's Peaks section, and as a dedicated column on the event-browser stats table. Verified against the real T190LD5Q.LK0W fixture from 2026-05-27 plus a synthetic test case. - Per-channel ZC Freq surfaced in event modals. Neither the main webapp modal (
sfm_webapp.html) nor the standalone event browser (event_browser.html) previously exposed ZC Freq. Now both do — webapp shows it inline alongside PPV (0.04500 in/s · 47 Hz); event-browser gets a dedicated column on its per-channel stats table. Required wiring a parallel sidecar fetch into the event-browser'sloadEvent()(it was only fetchingwaveform.json). Falls back to—for events without a preserved.TXT(pre-2026-05-27 ingests). scripts/backfill_sidecars.py --reparse-txtflag. Before this, the backfill script preserved thebw_reportblock from existing sidecars verbatim — so parser-side fixes (like the>100 Hzaddition above) couldn't reach old events. The new flag re-runs the current parser against the preserved<serial>/<filename>_ASCII.TXT, overwrites the bw_report block, and cascade-regenerates the sidecar. Implies sidecar regeneration on every event (bypasses the sha/version skip). No-op for events without a preserved .TXT (legacy ingests pre-2026-05-27 .TXT-preservation rollout). Idempotent. Run with--skip-hdf5to skip waveform regen — recommended when only the bw_report needs refreshing. Validated end-to-end on prod: 9,999 events refreshed cleanly, ZC Freq + OORANGE flags now populated where the original .TXT had them.
Fixed (2026-05-28)
- Histogram PDFs no longer 500 on the missing
histogram_interval_size_sattribute. The histogram-interval-times derivation block ingather_report_datareferencedrd.histogram_interval_size_s, but the field was never declared on theReportDatadataclass nor read from the sidecar projection (it was inlined intogather_report_datawithout the seconds-numeric counterpart making it onto the dataclass). Every histogram PDF render raisedAttributeError → 500. Waveform PDFs were unaffected. Fix: add the field, read it from the projection's existingbw_report.histogram.interval_size_skey. - Histogram PDF geo channels now share a single nice-quantized y-axis. Previously each geo subplot auto-scaled independently — Tran, Vert, and Long all showed different per-channel maxes, so bar heights weren't directly comparable across channels. The footer "Amplitude Geo: X in/s/div" label was also computed as
max(first_geo_channel) / 5with no LSB quantization, producing nonsense values like0.003 in/s/divwhen the geophone LSB is 0.005. Fix: compute a single shared geo y-axis range frommax(Tran, Vert, Long), quantize the per-division step to BW's 1-2-5 sequence rounded to the 0.005 in/s LSB (0.005, 0.01, 0.025, 0.05, 0.1, 0.25, ...), apply the sameylim+ ticks to all three subplots, and use that step for the footer label. MicL stays on its own auto-scale (different units). Matches BW's chart styling.
Docs (2026-05-28)
- Roadmap entry for a second undecoded histogram body sub-format. BE17353 (S353) events observed on 2026-05-28 use a histogram body where
byte[5] = 0x00(looks like a valid block header by every prior signal) but the walker finds zero data blocks. Different from the existingbyte[5] != 0roadmap entry (T190 / O121). Operationally identical impact — ingestion succeeds, DB peaks come from the bw_report overlay, only the chart is empty. Sample events captured in the roadmap entry for future RE work.
Migration / Operations
- Re-parse existing events to pick up the new parser fields. Run on whichever box hosts the live waveform store:
Idempotent; safe to re-run. Only touches sidecars on disk — no DB writes.
docker exec terra-view-sfm-1 python /app/scripts/backfill_sidecars.py \ --reparse-txt --skip-hdf5 --dry-run -v | tail # Looks reasonable? Run for real: docker exec terra-view-sfm-1 python /app/scripts/backfill_sidecars.py \ --reparse-txt --skip-hdf5 -v | tee /tmp/reparse.log | tail -30 - terra-view docker-compose.yml: add
TZ=America/New_York(or your deployment's zone) to both theterra-viewandsfmserviceenvironment:blocks. Without this, server-rendered timestamps stay in UTC even on the rebuilt SFM image.
Pre-v0.20.0 work (rolled into this release)
The bullets below accumulated under [Unreleased] between v0.19.0 and v0.20.0; kept here so the historical narrative isn't lost.
Fixed
- bw_ascii_report parser now handles
OORANGEsaturation marker. BW writes"OORANGE"(truncation of "Out Of Range") in PPV / PVS / MicL PSPL fields when the underlying measurement exceeded the channel's full-scale. Previously our_parse_number()returned None → DB ended up with NULL peaks for legitimate high-amplitude events. Confirmed on real ASCII files pulled 2026-05-27 from the Windows watcher PC: T190LD5Q.LK0W (Vert saturated at Normal range 10 in/s), T438L713.RY0W (all three channels saturated at Sensitive range 1.25 in/s), K557L3YM.OE0W (Tran+Vert saturated + Mic PSPL OORANGE). New behavior:- Per-channel PPV: substitute
geo_range_ipsas a conservative lower bound + setppv_saturatedflag - Peak Vector Sum: substitute
sqrt(3) * geo_range_ips(the theoretical max when all 3 channels are simultaneously at full-scale) +peak_vector_sum_saturatedflag - MicL PSPL: substitute 140 dB(L) (conservative NL-43 max) +
pspl_saturatedflag - Saturation flags are propagated into the sidecar's
bw_reportblock for downstream UI rendering (> 10 in/sor similar) - Five events on prod (T190 / T438 / K557 + 2 others matching the same fault pattern) will pick up correct DB peaks + saturation flags once re-forwarded
- Per-channel PPV: substitute
- bw_ascii_report parser handles
Peak Vector Sum TimeSumtypo'd label. Real BW output uses this misspelled label (Sum appended twice instead of "Peak Vector Sum Time"). Now accepted as an alias. Confirmed against all three OORANGE example files — every one has the typo.
Added
-
Histogram per-interval aggregation in
waveform.json. Histogram events now render with one bar per BW-reported interval (matching the Blastware printout) instead of ~200 bars per event (the raw codec output). When the sidecar'sbw_report.histogram.n_intervalsis populated (events ingested with the new parser, see next bullet), the/db/events/{id}/waveform.jsonendpoint groups the codec samples into N intervals via max-per-group and returns the aggregated array.time_axisgainshistogram_aggregated: true,n_intervals,interval_size_s, andinterval_times(HH:MM:SS strings). Both the modal chart and the standalone event browser use those interval timestamps as x-axis labels when present. Defensive: no-op for events ingested before the parser extension landed (their sidecars lackhistogram.n_intervals) — those continue to render with raw codec output. -
bw_ascii_reportparser now captures histogram-specific fields. Previously the parser dropped these fields silently (Roadmap item closed):Histogram Start Time/Histogram Start Date(combined intohistogram_start: datetime)Histogram Stop Time/Histogram Stop Date(combined intohistogram_stop: datetime)Number of Intervals(histogram_n_intervals: int)Interval Size("1 minute" string + parsed seconds:histogram_interval_size_str,histogram_interval_size_s)<Channel> Peak Time+<Channel> Peak Datefor histogram events (combined intochannel_peak_when: dict; waveforms continue to usetime_of_peak_srelative)Peak Vector Sum Date(combined with PVS Time intopeak_vector_sum_when: datetime; clears the previous boguspeak_vector_sum_time_sparse that interpreted "22:33:52" as 22.0 seconds)- All new fields land in the sidecar's
bw_report.histogramblock via_bw_report_to_dict. Tested against synthetic K558LLB7.V20H-shaped input.
-
Raw BW ASCII report (.TXT) preservation.
save_imported_bwnow writes the paired_ASCII.TXTto<store>/<serial>/<filename>_ASCII.TXTalongside the binary at ingest time. Previously the .TXT was parsed into the sidecar'sbw_reportprojection and then discarded — meaning parser bug fixes couldn't be applied retroactively without re-forwarding from the watcher PC. Now the raw .TXT lives in the waveform store permanently (~15 KB per event; ~210 MB total for a 14k-event store; negligible). Sidecar'ssource.txt_filenamefield records the saved path; backfill_sidecars preserves it across regens. NewGET /db/events/{id}/ascii_report.txtendpoint serves the raw .TXT for any event ingested after this change. Events ingested before today still return 404 from that endpoint until re-forwarded. Architectural rationale: with BW Mail / Forwarding Agent being phased out of the operator workflow, the XML/PDF/WMF that those tools produced are no longer available — the binary + .TXT (created by BW ACH itself) are our authoritative source for everything going forward. -
Event Report PDF generation —
GET /db/events/{id}/report.pdfreturns a single-page letter-portrait PDF for any event with waveform data on disk. Covers every field a Blastware Event Report includes: header metadata (date/time, trigger source, range, sample rate, project/client/operator/location, serial+firmware, battery, calibration, file name), microphone block (PSPL in dB(L) + psi, ZC freq, channel test), per-channel stats table (rows differ for waveform vs histogram), Peak Vector Sum, and the 4-channel plot. Iterated against real Blastware reference PDFs (uploaded toexample-events/pdfsnstuff/):- Waveform layout: header shows Date/Time, Trigger Source, Range, Sample Rate; stats table has PPV / ZC Freq / Time (Rel. to Trig) / Peak Accel / Peak Disp / Sensor Check; bottom plot is 4-channel line waveform (MicL top → Tran bottom), shared time axis in seconds, dashed trigger line + triangle marker at t=0, symmetric Y on geo channels, zero-anchored on mic, "0.0" baseline label on right per BW convention; footer shows
Time X sec/div Amplitude Geo: Y in/s/div Mic: 0.001 psi(L)/divand the trigger window▶━━◀marker. USBM RI8507/OSMRE compliance chart placeholder upper-right. - Histogram layout: header shows Start / Finish / Intervals At Size / Range / Sample Rate (no Trigger Source — histograms aren't triggered); NO USBM chart; stats table has PPV / ZC Freq / Date / Time / Sensor Check; bottom plot is per-interval bar chart, Y-axis 0-to-peak (never negative), 0.0 baseline at the bottom; footer shows
Time INTERVAL_SIZE /div Amplitude Geo: Y in/s/div Mic: 0.001 psi(L)/div. - Backed by matplotlib (vector PDF, no headless-browser dep). Adds matplotlib>=3.8 to deps.
- Known gap: histogram codec returns per-block granularity (~200 bars for a 4-interval event) instead of BW's per-interval aggregation. Visual difference vs BW's 4-bar display. XML-driven data source (parsing the structured
_XML.XMLfiles BW also exports) is the planned fix; that route also resolves the bw_ascii_report PPV-miss bug. - Stubbed: USBM RI8507 / OSMRE compliance chart curves (separate work item; requires coding the regulatory piecewise functions).
- Waveform layout: header shows Date/Time, Trigger Source, Range, Sample Rate; stats table has PPV / ZC Freq / Time (Rel. to Trig) / Peak Accel / Peak Disp / Sensor Check; bottom plot is 4-channel line waveform (MicL top → Tran bottom), shared time axis in seconds, dashed trigger line + triangle marker at t=0, symmetric Y on geo channels, zero-anchored on mic, "0.0" baseline label on right per BW convention; footer shows
-
"Download PDF" button in the event modal's footer — triggers the new endpoint; opens in a new tab so the browser handles save-or-display + surfaces any 404 / server errors visibly.
-
SFM webapp now opens to Database view by default and the History table is fully interactive. Click any column header to sort ascending / descending (timestamp, serial, per-channel PPV, PVS, mic dB(L), project, client, record type, key — all sortable). Click any event row to open the event modal, which now renders a 4-channel waveform plot inline (MicL / Long / Vert / Tran stacked, Instantel-printout order) alongside the existing sidecar review fields. Headers are sticky so the columns stay visible while scrolling long event lists. No more "where is the viewer" — pick a unit from the filter dropdown, scan the table, click the event, see the waveform.
-
Stored-event browser — new standalone HTML page at
GET /events(sfm/event_browser.html). Pick a serial from the unit dropdown, scroll through that unit's events (newest-first), click any event to render its decoded waveform via the existing/db/events/{id}/waveform.jsonendpoint. Dark-themed Chart.js viewer, channels stacked vertically (MicL / Long / Vert / Tran — Instantel printout order, designed PDF-export-ready), trigger line at t=0, peak labels, search/filter, false-trigger flag honored. Companion to the existing live-device viewer at/waveform; the two routes are now clearly delineated in their docstrings. The webapp's inline plot at/is the primary path;/eventsremains a useful diagnostic when you want just a viewer. -
Histogram body codec — uint8 peak count fix. Per-channel peak fields at
block[6]/[10]/[14]/[18]areuint8, notuint16 LEspanningblock[6:8]etc. The original interpretation was byte-exact on the N844 fixture corpus only because every annotation byte (block[7]/[11]/[15]/[19]) in those fixtures was zero. On non-N844 events with non-zero annotation bytes (observed across BE9558 Tran-drift and BE18003 Histogram+Continuous units), the old interpretation produced peaks up to 268 in/s per channel and 35× inflated PVS sums when first deployed to prod (rolled back same day; properly fixed in this release). Cross-correlated against BW's per-interval ASCII export on K558 / T003 / N599 / N844 corpora — 100% byte-exact on T/V/L, 99%+ on M (sub-precision rounding). Annotation byte preserved on each record asrecord["annotations"]for future RE. Verified against ~3,500 blocks across 5 in-repo fixtures + a synthetic K558 interval-12 regression block. -
apply_bw_report_dict_to_eventhelper inminimateplus.event_file_io. Mirror ofapply_report_to_eventfor the projected sidecar dict shape — used by the backfill path, which has the preservedbw_reportblock but not the original.TXTfile. BW's reported peaks (andsample_rate/record_time) now win over codec output during--forcebackfill, matching ingest-path behavior. -
scripts/check_bw_report_preservation.py— two-step snapshot/diff tool to verify thatbackfill_sidecars.pydoesn't wipe thebw_reportblock from existing sidecars. Classifies every sidecar as PRESERVED / CHANGED / WIPED / STILL_MISSING / NEW / ADDED / REMOVED. Exit code 1 if any WIPED or CHANGED entries are found, so it can gate a CI step or deploy script.
Fixed
scripts/backfill_sidecars.pyno longer wipesbw_report. Before this fix,event_to_sidecar_dictsilently dropped the preservedbw_reportblock during every backfill, since the function only emits abw_reportwhen called with a liveBwAsciiReportdataclass (which the backfill doesn't have — only the projected sidecar dict). Now we read the existing sidecar'sbw_reportand overlay it onto the regenerated sidecar, alongside the existingreviewandextensionspreservation.scripts/backfill_sidecars.py --forceno longer overwrites BW-overlaid DB peaks with codec output. The backfill path now callsapply_bw_report_dict_to_eventbefore the DB upsert, mirroring what the ingest path does (/db/import/blastware_fileparses the.TXTinto aBwAsciiReport, callsapply_report_to_event, then upserts). Without this, events where the codec doesn't fully decode (waveform walker edge cases on SP0/SS0/SV0-style events, histogrambyte[5]!=0sub-format) ended up with PVS=0 in the DB after a--forcebackfill; bit on prod 2026-05-22, rolled back the same day.- Thor IDF files no longer attempted as BW events in backfill.
scripts/backfill_sidecars.pynow filters out.IDFW/.IDFHfiles in_looks_like_event_file(); they share the.X0W/.X0Hsuffix shape but use a separate ingest path (WaveformStore.save_imported_idf) and aren't decodable byevent_file_io.read_blastware_file.
Docs
- CLAUDE.md — added a three-tier conceptual architecture model (SFM / SDM / shared codec library) near the top of the file, with a placement rule for where new code goes. Documents that what is conceptually SDM (database, waveform store, ingest,
/db/*endpoints) still lives undersfm/for historical reasons; rename deferred until the codebase is quiet enough for a clean refactor. - README.md — added a "Strategic direction" lead-in to the Roadmap that frames seismo-relay as a suite of cooperating components (not a single app), and an explicit "Terra-View ↔ SFM device control" roadmap section with a concrete implementation checklist (auth as hard prerequisite, embedded live-monitor view, action history, Series IV live-device support).
docs/histogram_codec_re_status.mdupdated with the uint8 retraction and the annotation-byte status.- Three known issues recorded in the Roadmap that were discovered during prod validation: (1)
bw_ascii_reportparser misses PPV /vector_sumon some.TXTformats (5 events on prod); (2) NULL-timestamp duplicate-row dedup needed (2 events on prod); (3) histogram body sub-format withbyte[5] != 0not yet decoded (~3 events on prod with empty.h5plots).
v0.19.0 — 2026-05-20
The "device-family separation" release. Tightens the boundary between Series III (MiniMate Plus / Blastware) and Series IV (Micromate / Thor) so the UI and storage layer dispatch deterministically by family instead of sniffing filename extensions or magnitude heuristics.
Added — Phase 1: device_family column on events
events.device_family TEXT— new column carrying"series3"or"series4". Populated by every import path (/db/import/blastware_file,/db/import/idf_file, ACH server, BW CLI, sidecar backfill script). Returned through/db/eventssincequery_eventsusesSELECT *.- Self-applying migration — on startup,
ALTER TABLE ... ADD COLUMNlands the new column; a follow-onUPDATEbackfills existing rows from the binary filename extension (.IDFH/.IDFW→series4, everything else →series3). No manual SQL needed. - UPSERT preserves family — re-imports without an explicit family don't blank existing rows (
COALESCE(?, device_family)). - UI dispatches on the column —
sfm_webapp.htmlevents-table mic formatter now branches onev.device_family === 'series4'(Thor stores native dB(L); BW stores psi). Modal usessource.kind === 'idf-import'from the sidecar (sidecars don't carry the DB column). Source-files section labels changed from "BW filename / BW filesize / BW sha256" to format-neutral "Event file / File size / File sha256".
Added — Phase 2: micromate/ package alongside minimateplus/
micromate/— new sibling package for the Thor / Micromate Series IV device. Currently scoped to offline-file ingest; live-device support (TCP transport, framing, protocol, client) will land here when reverse-engineering happens.micromate/idf_ascii_report.py— moved fromsfm/idf_ascii_report.py. No behaviour change.micromate/models.py— typedIdfReport,IdfEvent,IdfPeaks,IdfProjectInfo,IdfSensorCheck. Stores mic in nativemic_pspl_dbl(dB(L)) instead of the pseudo-psi shoehorn that the BW-shaped model uses.IdfEvent.from_report()constructs from a parsed dict + filename;IdfEvent.to_minimateplus_event(waveform_key)bridges to the existing sidecar / DB-insert machinery.micromate/idf_file.py— placeholder for the binary codec (.IDFH/.IDFW). Stubbedread_idf_file()raisesNotImplementedError; documents the planned reverse-engineering path.
WaveformStore.save_imported_idfrefactored to use the nativeIdfEventand bridge at the SQL-insert boundary. Cleaner separation of "parse a Thor event" (inmicromate/) from "store it on disk + write a sidecar" (insfm/waveform_store.py).- Tests —
tests/test_idf_ascii_report.pyimports updated tomicromate.idf_ascii_report. All 1,014 example-data sidecars round-trip throughIdfEvent.from_report()without errors.
Companion releases
- thor-watcher unaffected — it talks to the relay over HTTP only. No version bump needed.
- terra-view unaffected today; can use
device_familyin its event-detail rendering when convenient.
v0.18.0 — 2026-05-19
The "Thor / Series IV ingest adapter" release. Seismo-relay can now accept event files from Instantel Micromate Series IV (Thor) units alongside the existing MiniMate Plus (Series III) Blastware pipeline.
Added — Thor (Series IV) IDF ingest
POST /db/import/idf_file(sfm/server.py) — multipart upload endpoint for.IDFH(histogram) and.IDFW(waveform) event files plus their.IDFH.txt/.IDFW.txtASCII sidecars. Mirrors the shape of/db/import/blastware_file: pairing by filename, optionalserialquery hint, per-file outcome reporting.sfm/idf_ascii_report.py— parser for Thor's TXT sidecars (verified against 1,014 real-world samples). Extracts device-authoritative PPV, ZC Freq, Peak Vector Sum, Mic PSPL, calibration date, firmware version, sensor self-check results, and project/client/operator strings.WaveformStore.save_imported_idf()(sfm/waveform_store.py) — stores Thor binaries verbatim in<root>/<serial>/<filename>, writes a.sfm.jsonsidecar withsource.kind = "idf-import"and the full parsed report underextensions.idf_report. Reuses the existingeventstable — Thor events dedupe on (serial, timestamp) and surface in/db/eventsalongside BW events.tests/test_idf_ascii_report.py— parser tests against thethor-watcher/example-data/corpus.
Changed
event_to_sidecar_dict()(minimateplus/event_file_io.py) allow-list forsource_kindnow includes"idf-import"so the existing sidecar machinery can carry Thor imports.- Bumped
pyproject.tomlversion to0.18.0.
Companion release
This release ships alongside thor-watcher v0.3.0, which adds the SFM forwarder that targets the new /db/import/idf_file endpoint. Operators flip the switch in thor-watcher's new "SFM Forward" Settings tab; events POST to seismo-relay just like the series3-watcher BW forwarder does today.
v0.17.0 — 2026-05-17
The "field rescue + DB management" release. Hardened against units that are stuck in a runaway call-home loop, and added an operator-facing path for purging bogus events that those same units dump into the DB before recovery. All work in this release was driven by the BE9558H incident (full incident log + recovery procedure at docs/runbooks/wedged_unit_recovery.md).
Added — wedged-unit recovery toolkit
A toolkit for breaking the call-home loop on a misbehaving unit whose firmware is too busy to keep up with normal request/response handshakes. Tested in production against BE9558H (16 May 2026) — a unit with a stuck-triggered Long-axis geophone that had been call-homing the office BW ACH server every 30 seconds for hours. Endpoints layered from "single attempt" to "siege mode" to suit different contention levels:
GET /device/events/storage_range— SUB 0x06 probe. POLL + one read; ~2s. Returns first/last event keys and anis_emptyflag. Use to triage whether a unit has stored events without invoking the slowcount_events()1E/1F chain (which choked on BE9558H's corrupted event chain).GET /device/events/index— SUB 0x08 probe. POLL + one read; ~2s. Returns the lifetime event counter (does NOT decrement on erase — usestorage_rangefor "right now" state).POST /device/events/erase— full erase sequence0xA3 → 0x1C → 0x06 → 0xA2(confirmed 2026-04-11, see the protocol reference). Resets event keys to0x01110000. Caller's responsibility to disable ACH first if the underlying trigger condition will re-fill the buffer.POST /device/rescue— one TCP session, short connect+recv timeouts: POLL → disable ACH (compliance config write) → erase events → close. Designed for race-loop usage when the device is busy in another session. 503 on connect-refused, 502 on protocol failure, 200 on full sequence success.POST /device/stop_monitoring_blind— fire-and-forget Stop Monitoring (SUB 0x97), TCP-only. DumpsSESSION_RESET + POLL_PROBE + SESSION_RESET + POLL_DATA + 0x97 × repeatand closes without reading any S3 response. The full POLL preamble is required — write commands without it are silently ignored by the device's protocol parser (false-positive surface area that bit the first version of this endpoint). Use when the device's firmware can't keep up with full request/response but might process inbound bytes at its own pace.POST /device/stop_monitoring_spam— server-side hammer loop, duration-bounded. Open TCP → write the same blind payload → close → repeat as fast as possible untilduration_selapses. Configurableconnect_timeout(default 500ms) andrepeat(frames per session). Reportssent_ok,connect_failed,write_failed,rate_attempts_per_s. Clamped to 5min duration.POST /device/stop_monitoring_slow_drip— opposite of spam. Open ONE TCP session, drip the wake handshake + stop frames atinterval_s(default 3s) forduration_s(default 120s, max 10min). Each drip is ~23 bytes — well under any UART FIFO size. Opportunistically drains any inbound bytes the device sends back;bytes_received > 0in the response strongly suggests the device has started talking and the session is healthy. This is the endpoint that saved BE9558H. Spam mode had been overrunning the device's UART FIFO; slow drip stayed under it.- Six rescue scripts under
scripts/— thin bash wrappers around the endpoints, defaultSFM_BASE_URL=http://localhost:8200(direct, not via Terra-View proxy whose 60s timeout would cut off the longer endpoints):rescue_device.sh— race-loop wrapper for/device/rescueblind_stop.sh— race-loop wrapper for/device/stop_monitoring_blindspam_stop.sh— single-call burst hammerslow_drip.sh— single-call held-session dripwatch_unit.sh— passive periodic reachability check (every N min, logs to file), useful for unattended overnight monitoring of a wedged unit
docs/runbooks/wedged_unit_recovery.md— symptoms, quick-reference recovery procedure, the modem-layer mechanism (Sierra Wireless serial-port mode-flipping is the real failure mode — not the device firmware), and a table of "why simpler approaches don't work" so the next incident skips the dead ends.
Added — operator event DB management
Endpoints powering Terra-View's new /admin/events page (v0.12.0). Designed for purging bogus events from a unit that's been forwarding them in bulk (e.g. a stuck-triggered seismograph dumping hundreds of junk events before it's recovered).
DELETE /db/events/{event_id}— hard-delete one event row. Also unlinks the associated blastware binary (.AB0*),.a5.pkl,.sfm.jsonsidecar, and.h5clean-waveform files via the WaveformStore. Returns the per-file removal status. 404 if the event doesn't exist.POST /db/events/delete_bulk— filter-based or id-list-based bulk delete with safety rails:- Filters (
serial,from_dt,to_dt,false_trigger) combine with AND; same semantics asGET /db/events.idsis an additional inclusion list. Refuses to run with no filters (would wipe the whole table — raises 422). confirmmust betrueto actually delete. Otherwise returns a dry-run summary (status: "dry_run",matched: N,sample_serials: [...]).max_rows(default 10,000) caps how many rows can be deleted by-filter in one call. If exceeded, returnsstatus: "too_many"with a hint to narrow or raise the cap. Bypassed when onlyidsis supplied.
- Filters (
_cleanup_event_files(row)helper insfm/server.py— best-effortunlink()of all four sidecar paths derived from the row'sblastware_filename. Logged at WARN if a path exists but unlink fails; the DB row deletion still proceeds.SeismoDb.delete_event(id)andSeismoDb.delete_events_bulk(...)insfm/database.py— both return the deleted row dict(s) so callers can do file cleanup.delete_events_bulkraisesValueErrorif no filters are supplied.
Changed
- Default protocol recv timeout dropped from 30s → 10s in
_build_client(). The unit usually responds in well under a second over cellular; 10s leaves comfortable headroom for retransmits while failing reasonably fast when a unit is wedged. The two endpoints that perform full 5A waveform downloads still passtimeout=120.0explicitly so multi-minute event transfers are unaffected. _build_client()now accepts an optionalconnect_timeout(TCP-only) so rescue / race-loop endpoints can fail fast on busy modems without affecting the protocol-level recv timeout.
Fixed
GET /device/monitor/statusreturned HTTP 500 + uncaught traceback when the device was unresponsive. The retry-on-Exceptioninner block let the secondclient.poll()'sProtocolErrorpropagate out of the handler. Now wrapped in proper try/except — returns 502 with{"detail": "Protocol error: No S3 frame received within 10.0s ..."}on timeout, 502 on connection errors, 500 only for genuinely unexpected exceptions.
Migration
No schema changes. No data migration required.
If you've been running a previous version against a wedged unit and accumulated bogus events, the new /admin/events page in Terra-View v0.12.0 (or direct POST /db/events/delete_bulk with confirm: true) is the cleanup tool. Watcher state on the upstream DL2 PC does NOT need separate cleaning — the watcher's sfm_forwarded.json keys on file sha256 and won't re-forward the same files.
Pairing
This release pairs with Terra-View v0.12.0, which adds the /admin/events UI that consumes the new bulk-delete endpoints, the bulk false-trigger flagging on /unit/{id}, and the field-deployment workflow that uses the same series3-watcher → SFM ingest path as before.
v0.16.1 — 2026-05-14
Fixed
-
record_typealways "Waveform" for forwarded events.read_blastware_file()hardcodedev.record_type = "Waveform"regardless of the file's actual type. The watcher-forward pipeline (the main BW ACH ingest path) compounds this by parsing files from a tmp path with a.bwsuffix, so even a filename-based fallback inside the parser still wouldn't see the original extension. Now:- New
derive_record_type_from_filename(filename)helper inminimateplus/event_file_io.pyderives the type from the LAST character of the filename's extension (V10.72+ AB0T scheme:H=Histogram,W=Waveform,M=Manual,E=Event,C=Combo). Falls back to"Waveform"for old S338 firmware (3-char extensions ending in0) and any unrecognized suffix. read_blastware_file()now calls the helper with itspath.nameso direct callers (the--dry-runpath inscripts/import_bw.py, tests, ad-hoc scripts) get the right value automatically.WaveformStore.save_imported_bw()overridesev.record_typewith the original filename's derived type after parsing (the tmp file inside the parser doesn't carry the original extension). This is the path the live watcher-forwarder hits, so the DB column now reflects the actual event type going forward.
Events ingested before this fix are stuck with
record_type="Waveform"in the DB; a one-off backfill (UPDATE events SET record_type = ... WHERE blastware_filename LIKE '%H') would fix them retroactively if desired. Terra-view's event modal also derives client-side from the filename, so the UI already shows the correct type for old events even without the backfill. - New
v0.16.0 — 2026-05-11
The "BW ACH ingestion" release. When paired with series3-watcher v1.5.0, every Blastware ACH event (binary + _ASCII.TXT report) lands in SeismoDb with device-authoritative peaks, project metadata, sensor self-check, and ZC/Time-of-Peak data — without depending on the still-undecoded waveform body codec. This is the end-to-end product win discussed in v0.15.0's "out of scope" notes: sortable / filterable monthly-summary review of historical events, populated from the BW ASCII export rather than re-decoded samples.
Added — /db/import/blastware_file rich-metadata ingestion
- Paired BW ASCII reports. The endpoint now accepts the
<binary>_<ext>_ASCII.TXTpartner BW writes alongside each event. Pairing handles both filename conventions: ACH (M529LK44_AB0_ASCII.TXT) and manual-export (M529LK44.AB0.TXT). When both present, ACH wins. minimateplus/bw_ascii_report.py(new) — parser +BwAsciiReportdataclass for BW's per-event ASCII export. Handles every field BW writes: identity, trigger config, per-channel PPV / ZC Freq / Time of Peak / Peak Acceleration / Peak Displacement, Peak Vector Sum + time, MicL PSPL / Time of Peak / ZC Freq, sensor self-check (Test Freq / Test Ratio / Test Amplitude / Pass-Fail per channel), monitor log, PC SW version.- Position-based user-notes parsing. BW's Compliance Setup → Notes tab labels (Project / Client / User Name / Seis Loc) are operator-editable — an operator can rename them to "Building:", "Site Address:", etc. Rather than maintain a label-spelling map, the parser uses positional matching between the
Units :andGeo Range :anchors in the ASCII output. The four canonical slots (project / client / operator / sensor_location) populate by position regardless of label; the original labels BW wrote are preserved inreport.user_note_labelsfor downstream UIs (terra-view) to display verbatim. bw_reportsidecar block. New top-level block in.sfm.jsoncarrying the parsed BW report (trigger config, peaks with per-channel stats, mic block, sensor_check, monitor_log, PC SW version, operator-label labels).apply_report_to_event(event, report)helper. Overlays the report's device-authoritative fields onto an in-memoryEventsoSeismoDb.insert_events()writes correct DB columns instead of the broken-codec values from_peaks_from_samples().
Fixed — three compounding bugs that left forwarded events with garbage data
- Import endpoint inserted under
serial="UNKNOWN"._serial_from_event(ev)was a stub that always returnedNone; the BW-filename-decoded serial thatWaveformStorehad already resolved was never surfaced todb.insert_events. Now usesrec["serial"]as the authoritative source.scripts/repair_unknown_serials.pyrepairs existing DB rows. /db/unitsignored events from non-ACH ingest paths.query_units()only aggregated fromach_sessions— events that arrived viasave_imported_bw()were never visible in the fleet overview even though they populatedeventscorrectly. Now unions both tables.- Re-imports left stale DB rows. The
IntegrityErrorhandler ininsert_events()only refreshed filename / sidecar columns when a duplicate(serial, timestamp)arrived. Peak values, project info, sample_rate, record_type stayed locked at whatever the first (often broken-codec) insert wrote. Now the upsert path refreshes every device-authoritative column from the new data while preservingfalse_triggerand immutable fields (id,created_at). - Server-side TXT pairing only knew the legacy convention. The endpoint stripped
.TXTand looked up<binary>— which works for manual exports (<binary>.TXT) but not BW ACH (<stem>_<ext>_ASCII.TXT). Reports were arriving in the multipart but silently dropped. Now recognises both conventions and registers each report under all matching binary names.
Migration
For existing deployments where events were forwarded by an older watcher (broken pairing) or imported during the UNKNOWN-bucketing window:
python -m scripts.repair_unknown_serials --db <path> --applyto re-attributeserial="UNKNOWN"rows.- Delete the watcher's
sfm_forwarded.jsonstate file and let it re-forward. The server's upsert path will refresh the existing DB rows with the report's authoritative values. - Operator review state (
false_trigger, sidecarreviewblock) is preserved across the re-import.
v0.15.0 — 2026-05-07
Added
-
Layered event storage architecture. Each event now lands as four files in the per-serial waveform store, each with a clear role:
<filename>— the Blastware-readable binary (BW file). Untouched.<filename>.a5.pkl— the raw 5A frames (regenerative source).<filename>.h5— clean per-channel waveform arrays in physical units (in/s for geo, psi for mic) plus event metadata (HDF5 with gzip compression). This is the canonical format for downstream analysis tools.<filename>.sfm.json— the modern review/metadata sidecar (peaks, project, source provenance, review state, extensions).
SQLite (
seismo_relay.db) is the searchable index over all four. -
Plot-ready waveform JSON (
sfm.plot.v1). The/device/event/{idx}/waveformand/db/events/{id}/waveform.jsonendpoints now return samples in physical units with explicit time-axis metadata, peak markers, and per-channel unit hints — no more guessing the ADC-to-velocity scale client-side. The webapp waveform viewer was rewritten to consume this shape. -
In-app waveform viewer accuracy fix. The standalone SFM webapp viewer was scaling geophone amplitudes by
geoAdcScale / 32767(≈ 6.206 / 32767), wheregeoAdcScale = 6.206053is the device's in/s per V hardware constant — not the ADC-counts-to-velocity factor. This silently scaled every plot ~38% too low for Normal-range geophones (the correct full-scale is 10.0 in/s, or 1.25 in/s for Sensitive). Conversion is now done server-side using the geo_range from compliance config; the client just plots. -
New
sfm/event_hdf5.pymodule:write_event_hdf5(),read_event_hdf5(), plus a plot-JSON helper. -
Backfill script extended to also emit
.h5for existing events.
Dependencies
- Added
h5py>=3.10andnumpy>=1.24for the HDF5 storage layer. - Added
python-multipart>=0.0.7(required by FastAPI for the/db/import/blastware_fileendpoint introduced in this release).
v0.14.3 — 2026-05-05
Fixed
-
build_5a_frame— DLE-stuffing rule for 0x10 bytes in params (the long-standing >1-sec event 0 "won't open in BW" bug).Previously
build_5a_framewrote params bytes RAW with no DLE stuffing, based on the incorrect assumption that the device handled all0x10bytes in params literally. It does not. The device's actual de-stuffing rule for the params region is:10 10→ de-stuffs to1010 02/03/04→ kept literal (inner-frame markers)10 Xfor other X → de-stuffs to justX(drops the0x10)
When the counter passed in params has
0x10in the high byte (e.g. counter=0x1000produces params bytes... 10 00 ...), the device silently corrupts the request to counter=0x__00and responds with whatever lives at that wrong address. For counter=0x1000 the wrong address was 0x0000, so the response was a copy of the file header + STRT record. That STRT block then got embedded in the assembled body at file offset0x1016, and Blastware refused to open the file (interprets the second STRT as a malformed multi-event file).This explains the entire >1-sec event-0 failure pattern:
- 1-sec events have
end_offset < 0x1000, so the chunk walk never requests counter0x10__and the bug never triggers. - 2-sec / 3-sec / longer events all need a chunk at counter
0x1000(and longer events also need0x1200,0x1400, etc., none of which have0x10in the high byte except0x1000). Just one corrupted response is enough to embed STRT in the body and break the file.
Verified against BW 5-1-26 "copy 3sec" capture: all 17 5A request frames (probe + 2 metadata pages + 13 sample chunks + TERM) now match BW's wire output byte-for-byte, including the doubled
10 10 00for counter=0x1000.
Notes
0x10bytes inoffset_hi(the standalone offset field at body[5]) are still written RAW — confirmed correct per the 1-2-26 capture.- BW's actual encoding of
10 02/10 04for meta pages 0x1002 / 0x1004 is not doubled — it relies on the device keeping10 02and10 04as literal pairs. This is preserved by the fix.
v0.14.2 — 2026-05-04
Fixed
blastware_file.py— removed harmful "duplicate header+STRT" strip. The v0.13.x strip logic was matching the byte sequence00 12 03 00 STRTin legitimate waveform data — sample chunks at counter0x1000and beyond often contain those bytes coincidentally — and zeroing 25 bytes of valid samples per match. This is why event 0 (event-1 case in the protocol) downloads of >1-sec recordings always failed in BW: the strip destroyed real data at body offset0x1012..0x102Band propagated alignment differences through the rest of the body. Sub-1-sec events worked because theirend_offsetwas below0x1002, so no sample chunks landed in the metadata-page region and the strip's needle never matched. Verified fix by re-feeding the BW 5-1-26 "copy 3sec" capture's A5 frames into the file builder: output is now byte-identical to BW's savedM529LKIQ.G10reference (8708 bytes, 0 differences).- BW already concatenates frame contributions in stream order without any de-duplication; SFM now does the same.
v0.14.0 — 2026-05-02
Changed (major rewrite)
-
read_bulk_waveform_stream— STRT-bounded chunk walk. Replaces the earlier0x0400-step /max(key4[2:4], 0x0400)chunk-counter formula, which over-read ~5× past the actual event end into post-event circular- buffer garbage. The new walk:- Probe at
counter = start_offset(event 1:0x0000; event N:cur_key[2:4]). - Parse
end_offsetfrom the STRT record atdata[17]of the probe response (end_key[2:4]field). - For event 1 only, read the two fixed metadata pages at counter
0x1002and0x1004— these contain the global session-start compliance setup (Project / Client / User Name / Seis Loc / Extended Notes ASCII strings). Continuation events skip these (BW caches them across the session). - Walk sample chunks at
0x0200increments (NOT0x0400), bounded byend_offset— the loop exits whennext_chunk_counter + 0x0200 > end_offset. - Send the proper TERM frame (see new
bulk_waveform_term_v2()) withoffset_word = end_offset - next_boundaryandparams[2:4] = next_boundary BE. The TERM response carries the partial last chunk + 26-byte file footer.
- Probe at
-
New helpers:
bulk_waveform_term_v2(key4, end_offset, last_chunk_counter)andparse_strt_end_offset(a5_data)inminimateplus.framing. -
stop_after_metadata/extra_chunks_after_metadatakwargs are now no-ops under the v0.14.x walk. They are retained on theread_bulk_waveform_streamsignature for backward compatibility but log a DEBUG line when set. The old "scan forb'Project:'and stop one chunk later" workaround is obsolete — the loop is deterministically bounded by the STRT-derivedend_offset. -
Project / Client / User Name / Seis Loc string source corrected. These come from the dedicated metadata pages at counter
0x1002/0x1004, not from "A5 frame 7" of the sample-chunk stream. The earlier "A5 frame 7" claim was an artifact of the broken0x0400-step walk where the bad counter formula coincidentally landed sample-chunk fi=7 on top of the 0x1002 metadata page.
Verified
- Three independent BW MITM captures (4-27-26 + 5-1-26 + 5-4-26) confirm the new walk matches BW's behaviour event-for-event.
end_offsetvalues verified across 3 events:0x1ABE(4-27-26 2-sec),0x21F2(5-1-26 3-sec),0x417E(5-1-26 event-2).
Notes
- Earlier v0.13.0 / v0.13.1 / v0.13.2 entries describe partial steps along the way (some of the file builder fixes, filename bugs, etc.) that were superseded by the full rewrite. Treat this v0.14.0 entry as the definitive landing point for the corrected SUB 5A protocol.
v0.14.1 — 2026-05-04
Fixed
read_bulk_waveform_stream— event-N probe counter off-by-0x46. Continuation events (start_key[2:4] != 0) were being probed at counterstart_offset + 0x0046instead of juststart_offset. In the iteration walk,cur_keyfrom 1F is already the off=0x46 WAVEHDR record key, so the earlier formula effectively double-counted the WAVEHDR offset. The probe landed one WAVEHDR past the actual event start, the response no longer contained the STRT record at byte 17,parse_strt_end_offsetreturnedNone, and the chunk loop fell back to themax_chunks=128cap — walking ~110 chunks of post-event circular-buffer garbage. Verified against the 5-1-26 "copy 2nd address" and 5-4-26 BW 2-sec event captures: BW probes counter=0x2238with key=01112238and STRT is present at byte 17 of the response (end_offset=0x417E).- CLAUDE.md / docs/instantel_protocol_reference.md — corrected the
event-N section to clarify that
start_keyin those formulas is the off=0x46 key, not the off=0x2C boundary key, and removed the spurious+0x46from the chunk-walk pseudocode.
v0.13.2 — 2026-05-01
Fixed
_extract_record_type— third 0C-record header format ("short", 8 bytes). A live SFM download against BE11529 produced files namedM5290000.000(zero-stamped) because the 0C waveform record's first bytes were01 05 07 ea ...— neither the 9-byte single-shot layout (0x10at byte 1) nor the 10-byte continuous layout (0x10at bytes 0 and 2). Investigation showed this is a third format observed in the wild: an 8-byte header with no marker bytes at all ([day][month][year_BE:2][unknown][hour][min][sec]). The detection logic now scans the year (uint16 BE) at byte 2 / byte 3 / byte 4 and picks whichever offset returns a sensible year (2015–2050) — each format has the year at a unique position so this disambiguates cleanly.- New format →
event.record_type = "Waveform (Short)",Timestamp.from_short_record(). - Existing single-shot and continuous parsers unchanged.
- The user's event from May 1, 2026 13:21:37 now correctly resolves to a
filename like
M529LKIQ.G10instead ofM5290000.000.
- New format →
Added
Timestamp.from_short_record(data)— decodes the 8-byte header._detect_record_format(data)— internal helper returning"single_shot" / "continuous" / "short" / Nonevia year-position scan.
v0.13.1 — 2026-05-01
Fixed
-
_extract_record_type— Continuous-mode record headers misclassified as Unknown. In single-shot mode the 0C waveform record's 9-byte header puts the sub_code marker0x10at byte 1, with the day at byte 0. In Continuous mode the header is 10 bytes with the marker at byte 0 and byte 2, and the day at byte 1. Previous logic only inspected byte 1 and treated any value other than0x10/0x03as"Unknown", which preventedevent.timestampfrom being populated for any continuous-mode event whose day-of-month wasn't exactly 3 or 16. As a downstream effect,blastware_filename()sawevent.timestamp == None, fell back tostem="0000"/ab="00", and produced filenames likeM5290000.000. Discovered from a live SFM run on BE11529 in continuous mode (day-of-month = 5). Now disambiguates by checking BOTH byte 0 and byte 2: if both are0x10, it's the 10-byte continuous header; else if byte 1 is0x10, it's the 9-byte single-shot header. Day-of-month no longer matters.Superseded by v0.13.2 — the user's actual record uses a third 8-byte format with no
0x10markers, which v0.13.1 still misclassified.
v0.13.0 — 2026-05-01
Fixed
- SUB 5A bulk waveform stream — over-read bug for events ≥ 2 sec.
read_bulk_waveform_streamwas walking the chunk counter past the actual end of the event, picking up post-event circular-buffer garbage that corrupted reconstructed Blastware files for any waveform > ~1 sec. The loop now extracts the event'send_offsetfrom the STRT record atdata[23:27]of the probe response and stops the chunk walk when the next counter would step past it. Verified against three BW MITM captures (4-27-26 + 5-1-26): 2-sec event drops from 37 over-read chunks to 7 bounded chunks; 3-sec drops to 9; non-zero-start "event 2" drops to 9.
Added
framing.bulk_waveform_term_v2(key4, end_offset, last_chunk_counter)— computes the corrected SUB 5A TERM frame's(offset_word, params)per the formula confirmed across all 3 BW captures. Not yet wired intoread_bulk_waveform_stream(the legacy TERM is still used to preserve the existingblastware_file.write_blastware_fileframe-structure expectations); available for the next iteration that switches to BW's 0x0200 chunk step.framing.parse_strt_end_offset(a5_data)— extracts the event-end pointer from the STRT record in an A5 response payload.
Documentation
- CLAUDE.md and
docs/instantel_protocol_reference.mdextensively rewritten to reflect the corrected SUB 5A protocol. See:- CLAUDE.md "SUB 5A — chunk counter formula (REWRITTEN 2026-05-01)"
- CLAUDE.md "SUB 5A — STRT record encodes end_offset"
- CLAUDE.md "SUB 5A — TERM frame formula"
- CLAUDE.md "SUB 5A — fixed metadata pages 0x1002 and 0x1004"
- CLAUDE.md "SUB 0A — WAVEHDR response length distinguishes events from boundaries" (0x46 = real event, 0x2C = boundary marker)
- protocol reference §7.8.5 / §7.8.6 / §7.8.7 / §7.8.8
- The previous chunk-counter formula (
max(key4[2:4], 0x0400) + (chunk-1) * 0x0400) is now marked DEPRECATED and explicitly tagged WRONG with pointers to the new sections, so future work doesn't re-derive it.
Known minor diffs vs Blastware (deferred to a follow-up)
- We still use the OLD 0x0400 chunk step rather than BW's 0x0200; switching
also requires updating
blastware_file.write_blastware_file's skip values and "extra chunk after metadata" logic, which depends on a fresh capture to verify. - We still use the legacy fixed
offset_word=0x005ATERM frame rather than BW'send_offset - next_boundaryformula, for the same reason. - Two fixed metadata pages at counter
0x1002and0x1004are not yet read explicitly; under the current 0x0400 walk their content is reachable via the sample chunk that covers buffer addresses[0x1000, 0x1400).
v0.12.6 — 2026-05-01
Fixed
-
blastware_file.py— waveform frame classification — A5 frame classification for waveform-only vs header-only frames now usesframe.record_typeinstead of frame index. Only waveform frames (0x46) are written to the file body; metadata frames are skipped. Fixes spurious data corruption from incorrectly classified frames. -
s3_analyzer.py— A5/5A frame naming — Bulk waveform stream frames (SUB 5A response) are now correctly labeled "A5" in analyzer output instead of being conflated with other multi-frame responses (SUB A4, E5, etc.). -
S3FrameParser— frame terminator detection — Corrected the bare ETX terminator detection. Frame termination is now correctly identified by a standaloneETX=0x03byte, not by theDLE+ETXsequence (which is part of the payload when it appears within a frame).
v0.12.5 — 2026-04-21
Added
seismo_lab.py— Download tab — New fourth tab for live wire-byte capture during event downloads. Captures both BW→device and device→S3 frames in real time, allowing inspection of the 5A bulk stream chunk sequence and frame-by-frame analysis without needing a bridge or MITM proxy. Files are saved with user-specified labels for easy tracking.
Changed
-
s3_bridge.py— raw captures always-on by default —--raw-bwand--raw-s3now default to"auto"instead ofNone. Every bridge session automatically generates timestampedraw_bw_<ts>.binandraw_s3_<ts>.binfiles alongside the.bin/.logsession files. Pass--raw-bw ""(explicit empty string) to disable if needed. -
gui_bridge.py— raw capture checkboxes pre-checked — Both "BW→S3 raw" and "S3→BW raw" checkboxes start checked. Path fields are empty by default (bridge auto-names the files). Unchecking a box passes--raw-bw ""to explicitly disable capture. -
Bridge tab— TCP mode added — Serial/TCP radio toggle allows connection via cellular modem (RV50/RV55) instead of direct RS-232. Supports multi-capture design (simultaneous Bridge + Analyzer + Download sessions). -
ach_server.py— TX capture added (raw_tx_<ts>.bin) — Every ACH inbound session now saves both directions:raw_rx_<ts>.bin(device → us, S3 side, as before) andraw_tx_<ts>.bin(us → device, BW side). Both files are usable in the Analyzer. TX bytes are buffered in memory until startup handshake succeeds (same as RX), preventing scanner probes from creating empty files.
v0.12.4 — 2026-04-21 (protocol analysis / docs only — no code changes)
Discovered
-
compliance_raw is wire-encoded, not logical bytes —
read_compliance_config()returns bytes that include DLE prefix bytes (0x10) before any0x03values (because S3FrameParser preserves DLE+ETX inner-frame pairs as two literal bytes). The previous CLAUDE.md claim that "S3FrameParser handles this transparently so compliance_raw contains logical bytes" was wrong. -
anchor-9 behavior per recording mode (confirmed from 4-20-26 BW write captures):
- Single Shot (0x00) / Continuous (0x01): anchor-9 =
0x00 - Histogram (0x03): anchor-9 =
0x10— the E5 DLE prefix for the0x03recording_mode byte - Histogram+Continuous (0x04): anchor-9 =
0x10— an actual stored config byte for this mode Anchor position shifts by ±1 when recording_mode =0x03due to the extra DLE byte; the dynamic anchor search (buf.find(ANCHOR, 0, 150)) handles this correctly without code changes.
- Single Shot (0x00) / Continuous (0x01): anchor-9 =
-
Write frame ETX escaping — BW escapes
0x03bytes in write frame data as0x10 0x03on the wire. Ourbuild_bw_write_framesends data bytes raw without ETX escaping. Device accepts our raw writes for all tested modes. Hypothesis: device write parser uses the offset/length field for frame boundaries, not ETX scanning, making ETX escaping optional. Histogram mode (recording_mode = 0x03) write via SFM from a non-Histogram starting state not yet tested. -
BW write payload vs E5 read payload are byte-identical around the anchor region (confirmed by comparing 3-11-26 BW TX and S3 captures). BW does NOT strip DLE prefix bytes before writing; it round-trips the wire-encoded bytes verbatim with only the modified fields changed.
-
Capture folder content catalogued — see CLAUDE.md "BW capture reference" table for a summary of all available protocol captures and their contents.
v0.12.3 — 2026-04-20
Added
-
Auto Call Home config protocol — Full read/write/decode/encode pipeline for the device's Remote Access → Setup Unit ACH settings, confirmed from 4-20-26 call home settings captures.
Protocol (new):
SUB 0x2C— Call Home Config READ (response0xD3); two-step read; data offset0x7C= 124; raw payload 125 bytes (1-byte longer than DATA_LENGTH due to DLE-escaped\x10\x03at raw[117:119] representing num_retries = 3)SUB 0x7E— Call Home Config WRITE (response0x81); 127-byte payload (125-byte read payload +\x00\x00); offset =data[1]+2 = 0x7E; write format (DLE-aware checksum)SUB 0x7F— Call Home WRITE CONFIRM (response0x80); no data
Field map (confirmed from 10-frame BW TX diff):
raw[5]— auto_call_home_enabled (bool)raw[6:46]— dial_string (40-byte null-padded ASCII)raw[87]— after_event_recorded (bool)raw[91]— at_specified_times (bool)raw[93]— time1_enabled /raw[101]— time1_hour /raw[102]— time1_minraw[95]— time2_enabled /raw[105]— time2_hour /raw[106]— time2_minraw[117:119]—\x10\x03(DLE-escaped 0x03 = num_retries value 3)raw[120]— time_between_retries_sec /raw[122]— wait_for_connection_sec /raw[124]— warm_up_time_sec
Library (
minimateplus/):models.py—CallHomeConfigdataclass (14 fields;rawbytes preserved for round-trip writes)protocol.py—SUB_CALL_HOME = 0x2C,SUB_CALL_HOME_WRITE = 0x7E,SUB_CALL_HOME_CONFIRM = 0x7F;read_call_home_config(),write_call_home_config()client.py—get_call_home_config(),set_call_home_config(),_decode_call_home_config()(handles DLE prefix at raw[117]),_encode_call_home_config()(patches in-place; raisesValueErrorif hour/min = 3)
REST API (
sfm/server.py):GET /device/call_home— reads and decodes call home config from devicePOST /device/call_home— reads, patches specified fields, writes back to deviceCallHomeConfigBodyPydantic model with 9 optional writable fields
Web UI (
sfm/sfm_webapp.html):- New "Call Home" tab with enable flag, dial string (read-only), after-event trigger, at-specified-times flag, two time slots (enable + HH:MM each), and read-only retry settings (num_retries, time_between_retries_sec, wait_for_connection_sec, warm_up_time_sec)
- "Read from Device", "Write to Device", "Clear Form" action buttons
- Client-side guard: rejects hour or minute value equal to 3 with a clear message explaining the DLE-encoding limitation
v0.12.2 — 2026-04-20
Added / Fixed
-
Geophone sensitivity / maximum range field confirmed — 4-20-26 geo sensitivity captures (1.25 in/s vs 10 in/s) diffed across all three SUB 71 write chunks and both E5 read payloads. The
geo_rangeuint8 field per channel is now fully confirmed:- E5 read offset:
channel_label + 33; SUB 71 write offset:channel_label + 29 0x00= Normal 10.000 in/s (standard gain);0x01= Sensitive 1.250 in/s (high gain)- Correction: previous hypothesis (
channel_label+20,0x01=Normal) was wrong.channel_label+20reads0x01on ALL captures regardless of range — not this field. _decode_compliance_config_into: read offset corrected fromtran_pos+20→tran_pos+33_encode_compliance_config: addedgeo_rangeparameter; writes to Tran/Vert/Long at+29apply_config: addedgeo_rangeparameterPOST /device/config: addedgeo_rangetoDeviceConfigBody- Web UI Config tab: added "Maximum Range — Geo" select (Normal / Sensitive)
- Web UI Device tab: added "Max Range (geo)" row to compliance table
- E5 read offset:
-
recording_mode+histogram_interval_secconfirmed and implemented (4-20-26 captures)recording_mode: uint8 at anchor−8 (E5 read) / anchor−7 (write); enum: 0x00=Single Shot, 0x01=Continuous, 0x03=Histogram, 0x04=Histogram+Continuoushistogram_interval_sec: uint16 BE seconds at anchor−4; same offset in read & write; valid: 2, 5, 15, 60, 300, 900 (matching Blastware dropdown: 2s, 5s, 15s, 1m, 5m, 15m)- Both fields added to
ComplianceConfig,_decode_compliance_config_into,_encode_compliance_config,apply_config, REST API body, and web UI
v0.12.1 — 2026-04-16
Added
-
sfm/server.py—_LiveCache— in-memory live device cache that eliminates redundant TCP round-trips between web requests. Plain Python dict +threading.Lock, no extra dependencies.Cache strategy per endpoint:
Endpoint Strategy GET /device/infoIndefinite; invalidated by POST /device/configGET /device/eventsCount-probe fast path — poll()+count_events()(~2 s); returns cached data if event count is unchanged; full download only when new events are detectedGET /device/monitor/status30-second TTL; invalidated immediately on monitor start/stop GET /device/event/{idx}/waveformPermanent per-index (waveforms are immutable once recorded) -
?force=truequery param on all cached endpoints — bypasses cache and forces a fresh read from the device. -
Cache invalidation hooks —
POST /device/configmarks device info and events stale;POST /device/monitor/startand/stopevict the monitor status entry immediately so the next status poll reflects the actual device state.
v0.12.0 — 2026-04-13
Added
-
sfm/server.py—_LiveCache— in-memory live device cache, eliminating redundant TCP round-trips between requests. No extra dependencies (plain Python dict + threading.Lock). Replaces the SQLAlchemy-basedsfm/cache.pyexperiment from thefeature/intelligent-cachingbranch.Cache behaviour by endpoint:
Endpoint Cache strategy GET /device/infoIndefinite; invalidated by POST /device/configGET /device/eventsCount-probe fast path: quick poll()+count_events()(~2s); return cache if count matches; full download only when new events detectedGET /device/monitor/status30-second TTL; invalidated by monitor start/stop GET /device/event/{idx}/waveformPermanent per-index (waveforms are immutable) -
?force=trueparam on all four cached endpoints — bypasses cache and re-reads from device. -
POST /device/configcache invalidation — marks device info + events dirty so the next read reflects the new compliance config. -
POST /device/monitor/start/stopcache invalidation — evicts the monitor status cache entry immediately so the next poll returns the updated state.
Removed
sfm/cache.py— SQLAlchemy-based cache from the experimental caching branch. Its logic has been ported to the sqlite3-native_LiveCacheclass above.sqlalchemyis no longer a dependency.
v0.11.0 — 2026-04-13
Added
-
sfm/database.py— SeismoDb — SQLite persistence layer for all ACH data. Three tables, all unit-keyed by serial number:ach_sessions— one row per inbound call-home: serial, timestamp, peer IP, events_downloaded, monitor_entries, duration_secondsevents— one row per triggered waveform event: serial, waveform_key (dedup), timestamp, Tran/Vert/Long/VectorSum/Mic PPV, project/client/operator/sensor_location strings, sample_rate, record_type, false_trigger flagmonitor_log— one row per monitoring interval: serial, waveform_key (dedup), start_time, stop_time, duration_seconds, geo_threshold_ips- WAL mode, per-request connections — safe for the single-writer / occasional-reader ACH server pattern
- Deduplication by
(serial, waveform_key)UNIQUE constraint — re-runs and repeat call-homes never produce duplicate rows
-
ach_server.py— DB integration — after each successful call-home, writes new events and monitor log entries toseismo_relay.dbthen records the session inach_sessions. DB write failures are logged as warnings and do not abort the session. -
sfm/server.py— DB read endpoints:GET /db/units— distinct serials with last_seen, total_events, total_monitor_entriesGET /db/events— query events with serial / date range / false_trigger filtersGET /db/monitor_log— query monitoring intervalsGET /db/sessions— query ACH call-home sessionsPATCH /db/events/{id}/false_trigger— flag/unflag false triggers (for review UI)
Architecture
- seismo-relay DB is unit-keyed only — no project concepts. Project aggregation is
terra-view's responsibility via
UnitAssignment/DeploymentRecord+ date range queries against the SFM DB endpoints. - DB file lives at
bridges/captures/seismo_relay.dbby default.
v0.10.0 — 2026-04-11
Added
-
MiniMateClient.get_monitor_log_entries(skip_keys=None)— browse-mode walk (1E → 0A → 1F) that collects partial records (0x2Crecord type) from the device's event list without triggering a full waveform download (no 0C or 5A). Returnslist[MonitorLogEntry]. Each entry represents one continuous monitoring interval where no threshold was exceeded. -
_decode_0a_partial_header(raw_data, index, key4)inclient.py— decodes a SUB 0x0A response payload whose record type is0x2C. Extracts:start_time/stop_time— two consecutive timestamps; auto-detects 9-byte (sub_code=0x10, single-shot) vs 10-byte (sub_code=0x03, continuous) format fromraw_data[11]. Handles a 1-byte gap between the two timestamps that occurs when ts1 and ts2 share the same minute:second.serial— device serial string found viab"BE"anchor scan.geo_threshold_ips— trigger level found viab"Geo: "anchor scan.
-
MonitorLogEntrydataclass inmodels.py— new model for partial records:index,key,start_time,stop_time,serial,geo_threshold_ips,raw_header, and aduration_secondsproperty. -
read_waveform_header()return value extended — now returns(data_rsp.data, length)(full payload) instead of(data_rsp.data[11:11+length], length). Callers get the complete payload including the record-type byte at position 0. Full records useraw_data[11:11+length]as before; partial records are detected byraw_data[0] == 0x2C. -
ACH server: monitor log collection — after
get_events(), callsget_monitor_log_entries(skip_keys=seen_keys)and saves new entries tomonitor_log.jsonin the session directory. Monitor log keys are included indownloaded_keysfor state persistence (no re-processing on next call-home). -
_monitor_log_entry_to_dict()inach_server.py— serialises aMonitorLogEntryto a JSON-compatible dict with ISO-format timestamps.
Protocol / Documentation
-
SUB 0x0A partial record (0x2C) format confirmed (✅ 4-11-26 MITM capture, 12 frames):
- Record type
0x2Catraw_data[0]; length < 64 bytes. - Two timestamps at
raw_data[11:]— start and stop of the monitoring interval. - ASCII metadata region after timestamps:
BE<serial>\x00Geo: <float> in/s. - Edge case: 1-byte separator between timestamps when ts1 and ts2 share minute:second.
- 10-byte timestamp format (sub_code=0x03) signalled by
raw_data[11] == 0x10.
- Record type
-
Key reuse detection for monitor log entries — monitor log keys are tracked alongside event keys in
ach_state.jsonso the ACH server does not re-process them after a call-home cycle.
v0.9.0 — 2026-04-11
Added
-
MiniMateClient.list_event_keys()— fast browse-mode walk (1E → 0A → 1F, no waveform download) that returns the list of event key hex strings currently stored on the device. Used by the ACH server as a cheap pre-check before deciding whether to callget_events(). -
get_events(skip_waveform_for_keys=set(...))— new optional parameter. For any key in the set the function performs only 0A + 1F(browse) instead of the full 1E-arm → 0C → POLL×3 → 5A sequence. Eliminates redundant waveform downloads on repeat call-homes when the device still holds previously downloaded events. -
MiniMateClient.delete_all_events()— erases all events from device memory using the confirmed 4-step sequence:- SUB 0xA3
begin_erase_all— initiate erase (token=0xFE) → ack 0x5C - SUB 0x1C
read_monitor_status— intermediate status read (Blastware-required) - SUB 0x06
read_event_storage_range— verify storage state (token=0xFE) → 36-byte response - SUB 0xA2
confirm_erase_all— commit erase (token=0xFE) → ack 0x5D
All four steps confirmed from 4-11-26 MITM capture of a live Blastware ACH session. After a successful call, the device's event counter resets to
0x01110000. - SUB 0xA3
-
MiniMateProtocolerase methods:begin_erase_all(),confirm_erase_all(),read_event_storage_range()added toprotocol.pywith documented SUB constantsSUB_ERASE_ALL_BEGIN = 0xA3andSUB_ERASE_ALL_CONFIRM = 0xA2. -
bridges/ach_mitm.py— transparent TCP-to-TCP MITM proxy. Listens for inbound unit connections, connects upstream to a real Blastware ACH server, and saves both directions toraw_bw_<ts>.bin/raw_s3_<ts>.binfiles matching the existing capture format. Used to capture the 4-11-26 Blastware ACH session including event deletion. Usage:python bridges/ach_mitm.py --bw-host 127.0.0.1 --bw-port 9999 --listen-port 9998 -
ACH server: key-based state tracking —
ach_state.jsonnow storesdownloaded_keys: [hex_strings]andmax_downloaded_key: hex_stringper unit instead ofevent_count: N. This correctly handles the standard workflow where events are deleted from the device after upload — a count-based approach would seecount=0on the next call-home and silently skip new events. -
ACH server:
--clear-after-downloadflag — after a successful download (at least one new event saved), erases all events from the device usingdelete_all_events(). Mirrors the standard Blastware ACH workflow. On success,downloaded_keysandmax_downloaded_keyare reset to empty so the next session starts fresh. -
ACH server: post-erase key-reuse detection — after an external erase (Blastware or manual), device keys restart from
0x01110000, colliding with previously downloaded keys. On each browse walk, ifmax(device_keys) < max_downloaded_key(device counter rolled back), all device keys are treated as new regardless ofseen_keys. This also catches erases performed by Blastware between our sessions.
Protocol / Documentation
-
SUB 0xA3 / SUB 0xA2 — erase-all sequence confirmed (✅ 4-11-26 MITM capture): Both frames use
token=0xFEatparams[7]and are standardbuild_bw_framerequests (not write-format). Response SUBs follow the standard formula: 0x5C and 0x5D. The intermediate 0x1C + 0x06 reads between them are required by Blastware. -
SUB 0x06 — event storage range read confirmed (✅ 4-11-26 MITM capture): Two-step read, data offset = 0x24 (36 bytes). The last 8 bytes of the response contain the first and last stored event keys (4 bytes each). After a successful erase, both keys read as
01110000(device-empty state). -
Event key counter resets to
0x01110000after erase — confirmed by observing key01110000on the device immediately after the MITM erase session.
v0.8.0 — 2026-04-07
Added
-
Write pipeline end-to-end —
push_config_raw(event_index_data, compliance_data, trigger_data, waveform_data)onMiniMateClientorchestrates the full68→73 | 71×3→72 | 82→83 | 69→74→72write sequence. -
build_bw_write_frame(sub, data, *, offset, params)inframing.py— dedicated frame builder for write commands (SUBs 0x68–0x83). Doubles only the BW_CMD byte; all other bytes including offset, params, data, and checksum are written raw. Uses the large-frame DLE-aware checksum (sum(b for b in payload[2:] if b != 0x10) + 0x10) & 0xFF). -
MiniMateProtocolwrite methods —write_event_index(),write_compliance(),write_trigger_config(),write_waveform_data(),write_confirm(),start_monitoring(),stop_monitoring(). -
AchSessioninbound server (bridges/ach_server.py) — accepts call-home TCP connections, runs the full handshake + device-info + event-download sequence, savesdevice_info.json+events.jsonper session.
Protocol / Documentation
- Write frame format confirmed (✅ 3-11-26 BW TX capture, all 11 frames): only BW_CMD
byte
0x10is doubled; all other bytes sent raw. Standardbuild_bw_frameDLE-stuffing is incorrect for write commands. - Write ack responses confirmed as 17-byte zero-data S3 frames.
- Monitoring SUBs 0x96/0x97 confirmed from 4-8-26 capture.
- SESSION_RESET signal (
41 03) required before POLL for monitoring units. - SUB 0x1C monitoring flag at
section[1]:0x00= idle,0x10= monitoring. Confirmed by byte-diff of all 144 data frames in 4-8-26/2ndtry capture.
v0.7.0 — 2026-04-03
Added
- Raw ADC waveform decode —
_decode_a5_waveform(frames_data, event)inclient.py. Parses the complete set of SUB 5A A5 response frames into per-channel time-series:- Reads the STRT record from A5[0] (bytes 7+): extracts
total_samples(BE uint16 at +8),pretrig_samples(BE uint16 at +16), andrectime_seconds(uint8 at +18) intoevent.total_samples / pretrig_samples / rectime_seconds. - Skips the 6-byte preamble (
00 00 ff ff ff ff) that follows the 21-byte STRT header; waveform data begins atstrt_pos + 27. - Strips the 8-byte per-frame counter header from A5[1–6, 8] before appending waveform bytes.
- Skips A5[7] (metadata-only) and A5[9] (terminator).
- Cross-frame alignment correction: accumulates
running_offset % 8across all frames and discards(8 − align) % 8leading bytes per frame to re-align to a T/V/L/M boundary. Required because individual frame waveform payloads are not always multiples of 8 bytes. - Decodes as 4-channel interleaved signed 16-bit LE at 8 bytes per sample-set: bytes 0–1 = Tran, 2–3 = Vert, 4–5 = Long, 6–7 = Mic.
- Stores result in
event.raw_samples = {"Tran": [...], "Vert": [...], "Long": [...], "Mic": [...]}.
- Reads the STRT record from A5[0] (bytes 7+): extracts
download_waveform(event)public method onMiniMateClient. Issues a full SUB 5A stream withstop_after_metadata=False, then calls_decode_a5_waveform()to populateevent.raw_samplesandevent.total_samples / pretrig_samples / rectime_seconds. Previously only metadata frames were fetched duringget_events(); raw waveform data is now available on demand.Eventmodel new fields (models.py):total_samples,pretrig_samples,rectime_seconds(from STRT record), and_waveform_key(4-byte key stored duringget_events()for later use bydownload_waveform()).
Protocol / Documentation
- SUB 5A A5[0] STRT record layout confirmed (✅ 2026-04-03, 4-2-26 blast capture):
- STRT header is 21 bytes:
b"STRT"+ length fields +total_samples(BE uint16 at +8) +pretrig_samples(BE uint16 at +16) +rectime_seconds(uint8 at +18). - Followed by 6-byte preamble:
00 00 ff ff ff ff. Waveform begins atstrt_pos + 27. - Confirmed: 4-2-26 blast →
total_samples=9306,pretrig_samples=298,rectime_seconds=70.
- STRT header is 21 bytes:
- Blast/waveform mode A5 format confirmed (✅ 2026-04-03, 4-2-26 blast capture):
4-channel interleaved int16 LE at 8 bytes per sample-set; cross-frame alignment correction
required. 948 of 9306 total sample-sets captured via
stop_after_metadata=True(10 frames). - Noise/histogram mode A5 format — endianness corrected (✅ 2026-04-03, 3-31-26 capture):
32-byte block samples are signed 16-bit little-endian (previously documented as BE).
0a 00→ LE int16 = 10 (correct noise floor); BE would give 2560 (wrong). - Protocol reference §7.6 rewritten — split into §7.6.1 (Blast/Waveform mode) and §7.6.2 (Noise/Histogram mode), each with confirmed field layouts and open questions noted.
v0.6.0 — 2026-04-02
Added
- True event-time metadata via SUB 5A bulk waveform stream —
get_events()now issues a SUB 5A request after each SUB 0C download, reads the A5 response frames, and extracts theClient:,User Name:, andSeis Loc:fields as they existed at the moment the event was recorded. Previously these fields were backfilled from the current compliance config (SUB 1A), which reflects today's setup, not the setup active when the event triggered.build_5a_frame(offset_word, raw_params)inframing.py— reproduces Blastware's exact wire format for SUB 5A requests: raw (non-DLE-stuffed)offset_hi, DLE-stuffed params, and a DLE-aware checksum where10 XXpairs count onlyXX.bulk_waveform_params()returns 11 bytes (extra trailing0x00confirmed from 1-2-26 BW wire capture).read_bulk_waveform_stream(key4, *, stop_after_metadata=True, max_chunks=32)inprotocol.py— loops sending chunk requests (counter increments0x0400per chunk), stops early whenb"Project:"is found, then sends a termination frame._decode_a5_metadata_into(frames_data, event)inclient.py— needle-searches A5 frame data forProject:,Client:,User Name:,Seis Loc:,Extended Notesand overwritesevent.project_info.
get_events()sequence extended — now1E → 0A → 0C → 5A → 1Fper event.
Fixed
- Compliance config (SUB 1A) channel block missing — orphaned
self._send(build_bw_frame(SUB_COMPLIANCE, 0x2A, _DATA_PARAMS))before the B/C/D receive loop had no correspondingrecv_one(), shifting all subsequent receives one step behind and leaving frame D's channel-block data (trigger_level_geo, alarm_level_geo, max_range_geo) unread. Removed the orphaned send. Total config bytes received now correctly ~2126 (was ~1071). - Compliance config anchor search range —
_decode_compliance_config_into()searchedcfg[40:100]for the sample-rate/record-time anchor. With the orphaned-send bug fixed the 44-byte padding it had been adding is gone, and the anchor now appears atcfg[11]. Search widened tocfg[0:150]to be robust to future layout shifts. - Removed byte-content deduplication from
read_compliance_config()— was masking the real receive-ordering bug.
Protocol / Documentation
- SUB 5A frame format confirmed —
offset_hibyte (0x10) must be sent raw (not DLE-stuffed); checksum is DLE-aware (only the second byte of a10 XXpair is summed). Standardbuild_bw_frameDLE-stuffs0x10incorrectly for 5A — a dedicatedbuild_5a_frameis required. - Event-time metadata source confirmed —
Client:,User Name:, andSeis Loc:strings are present in A5 frame 7 of the bulk waveform stream (SUB 5A), not in the 210-byte SUB 0C waveform record. They reflect the compliance setup as it was when the event was stored on the device.
v0.5.0 — 2026-03-31
Added
- Console tab in
seismo_lab.py— direct device connection without the bridge subprocess.- Serial and TCP transport selectable via radio buttons.
- Four one-click commands: POLL, Serial #, Full Config, Event Index.
- Colour-coded scrolling output: TX (blue), RX raw hex (teal), parsed/decoded (green), errors (red).
- Save Log and Send to Analyzer buttons; logs auto-saved to
bridges/captures/console_<ts>.log. - Queue/
after(100)pattern — no UI blocking or performance impact.
minimatepluspackage — clean Python client library for the MiniMate Plus S3 protocol.SerialTransportandTcpTransport(for Sierra Wireless RV50/RV55 cellular modems).MiniMateProtocol— DLE frame parser/builder, two-step paged reads, checksum validation.MiniMateClient— high-level client:connect(),get_serial(),get_config(),get_events().
- TCP/cellular transport (
TcpTransport) — connect to field units via Sierra Wireless RV50/RV55 modems over cellular.read_until_idle(idle_gap=1.5s)to handle modem data-forwarding buffer delay.- Confirmed working end-to-end: TCP → RV50/RV55 → RS-232 → MiniMate Plus.
bridges/tcp_serial_bridge.py— local TCP-to-serial bridge for bench testingTcpTransportwithout a cellular modem.- SFM REST server (
sfm/server.py) — FastAPI server with device info, event list, and event record endpoints over both serial and TCP.
Fixed
protocol.pystartup()was using a hardcodedPOLL_RECV_TIMEOUT = 10.0constant, ignoring the configurableself._recv_timeout. Fixed to useself._recv_timeoutthroughout.sfm/server.pynow retries once onProtocolErrorfor TCP connections to handle cold-boot timing on first connect.
Protocol / Documentation
- Sierra Wireless RV50/RV55 modem config — confirmed required ACEmanager settings: Quiet Mode = Enable, Data Forwarding Timeout = 1, TCP Connect Response Delay = 0. Quiet Mode disabled causes modem to inject
RING\r\nCONNECT\r\nonto the serial line, breaking the S3 handshake. - Calibration year confirmed at SUB FE (Full Config) destuffed payload offset 0x56–0x57 (uint16 BE).
0x07E7= 2023,0x07E9= 2025. "Operating System"boot string — 16-byte UART boot message captured on cold-start before unit enters DLE-framed mode. Parser handles correctly by scanning for DLE+STX.- RV50/RV55 sends
RING/CONNECTover TCP to the calling client even with Quiet Mode enabled — this is normal behaviour, parser discards it.
v0.4.0 — 2026-03-12
Added
seismo_lab.py— combined Bridge + Analyzer GUI. Single window with two tabs; bridge start auto-wires live mode in the Analyzer.frame_db.py— SQLite frame database. Captures accumulate over time; Query DB tab searches across all sessions.bridges/s3-bridge/proxy.py— bridge proxy module.- Large BW→S3 write frame checksum algorithm confirmed and implemented (
SUM8of payload[2:-1]skipping0x10bytes, plus constant0x10, mod 256). - SUB
A4identified as composite container frame with embedded inner frames;_extract_a4_inner_frames()and_diff_a4_payloads()reduce diff noise from 2300 → 17 meaningful entries.
Fixed
- BAD CHK false positives on BW POLL frames — BW frame terminator
03 41was being included in the de-stuffed payload. Fixed to strip correctly. - Aux Trigger read location confirmed at SUB FE offset
0x0109.
v0.3.0 — 2026-03-09
Added
- Record time confirmed at SUB E5 page2 offset
+0x28as float32 BE. - Trigger Sample Width confirmed at BW→S3 write frame SUB
0x82, destuffed payload offset[22]. - Mode-gating documented: several settings only appear on the wire when the appropriate mode is active.
Fixed
0x082Amystery resolved — fixed-size E5 payload length (2090 bytes), not a record-time field.
v0.2.0 — 2026-03-01
Added
- Channel config float layout fully confirmed: trigger level, alarm level, and unit string per channel (IEEE 754 BE floats).
- Blastware
.setfile format decoded — little-endian binary struct mirroring the wire payload. - Operator manual (716U0101 Rev 15) added as cross-reference source.
v0.1.0 — 2026-02-26
Added
- Initial
s3_bridge.pyserial bridge — transparent RS-232 tap between Blastware and MiniMate Plus. s3_parser.py— deterministic DLE state machine frame extractor.s3_analyzer.py— session parser, frame differ, Claude export.gui_bridge.pyandgui_analyzer.py— Tkinter GUIs.- DLE framing confirmed:
DLE+STX/DLE+ETX,0x41= ACK (not STX), DLE stuffing rule. - Response SUB rule confirmed:
response_SUB = 0xFF - request_SUB. - Year
0x07CB= 1995 confirmed as MiniMate factory RTC default. - Full write command family documented (SUBs
68–83).