Eight tasks: the XML report parser, SFM's side from the bytes alone, the field-by-field comparison, carve-outs (saturation first), the parallel runner, the summary and grouped detail report, run-to-run changes with a one-event view, and the first full run checked against what is known. While pinning the plan's test values on real files: T438HGTZ.B30W, called "3 samples short" by the setup-field harness, matches Blastware exactly. Its Tran, Vert and MicL end 3 samples before Long, and Blastware's own sample table does the same -- its last three rows carry only the Long cell. The harness compared Tran's length with the table's row count. The spec now says so, and the plan compares samples row by row by running channel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
14 KiB
Series 3 decode checker — design
Date: 2026-10-29 · Branch: feat/s3-decode-checker · Status: design
Why this exists
SFM is meant to replace Blastware. Today, when a Series 3 event arrives with Blastware's ASCII report, SFM takes many of its values from the report: ZC frequency, acceleration, the sensor check and so on. Two of the four ways events will reach SFM, its own serial/modem download and its future call-in server, never have a report. So SFM must produce everything Blastware reports, from the event file alone, and we need proof that it does.
The checker is that proof, and the to-do list for getting there. It decodes each event file the way SFM ingest does, with no report, and compares every field with Blastware's own report of the same event. Then it says what matches, what doesn't, and what SFM can't produce yet.
It is the first of four pieces, agreed with Brian on 2026-10-29:
- This checker.
- Completing SFM's file-only decode, one field group at a time, each slice
done when the checker shows it matching. Slice 1, the setup fields and
notes (#44/#45), merged to dev as
42fe35f. - Flipping ingest to file-only. Reports are kept for checking only. This happens only when piece 2 leaves no blanks and the checker proves it. Prod keeps its current behaviour until then.
- The watcher: it forwards the XML report while we verify, then stops forwarding reports.
The reference: Blastware's XML event reports
Every Blastware ACH machine keeps, in Sent/, a full XML event report for each
event: <stem>_<ext>_XML.XML next to the binary <stem>.<ext>. DL2's backup
holds 70,042 of them for Series 3 events, from 2016 to 2026. Its ASCII
reports, by contrast, cover only 2025–26.
Local copies on the dev box (tmi-dev, 10.0.0.44):
| what | where | count |
|---|---|---|
| event binaries (Series 3) | ~/dl2-archive/files/ (root + Sent/ mirror, dedupe by basename) |
70,112 distinct |
| XML reports | ~/dl2-archive/xml/ (flat) |
75,958 = 70,042 Series 3 + 5,916 Micromate (UM…_IDF?_XML.XML) |
| ASCII reports | ~/dl2-archive/files/ |
14,338 (2025–26 only) |
What the Series 3 XML contains (surveyed across all 75,958 on 2026-10-29):
- Identity:
EventType(Full Waveform6,524,Full Histogram63,518),SerialNumber,Version(V 10.72-8.17 MiniMate Plusor… BlastMate III),FileName. - Time: waveform
EventDate/EventTime; histogramHistogramStart*/HistogramStop*. - Setup:
Channels,Trigger,GeoTriggerLevel,MicTriggerLevel,Pre-triggerLength,RecordTime,RecordStopMode(onlyFixedoccurs),SampleRate,IntervalSize(2 s / 5 s / 15 s / 1 min / 5 min),NumberofIntervals,GeoRange(10.000: 75,923; 1.250: 35),Units(in/s and dB(L)/psi(L)/dB(A)/in/s),Microphone(weighting). - Unit:
BatteryLevel,Calibration(date + by whom),MicCalibration. - Notes:
JobNumber, then up to four user notes. Each is tagged with its operator-editable label (Project,Location,Seis.Loc,SeisLocation,SeismographLoc,Company,General, …), and empty notes are omitted. They sit between the top-level</Units>and<GeoRange>. - Results: per channel
PPV,ZCFreq,TimeofPeak,PeakAcceleration,PeakDisplacement(waveform) orPeakDate/PeakTime(histogram);PeakVectorSumwith its time; micPSPL, time,ZCFreq(dB(A) histograms carryMicA*fields instead). - Sensor check: per geophone
TestFreq,TestRatio,TestResults; micTestFreq,TestAmplitude,TestResults. MonitorLog: the session's start, stop and status text.- Data: waveform
WaveformDataChannels/Data/Row/Cell(4 cells per sample: Tran, Vert, Long in in/s, MicL in the event's mic units); histogramHistogramDataIntervals(aTimeand a 10-cellRowper interval: Tran/Vert/Long peak + freq, geo PVS, MicL psi, dB and freq).
Value forms the parser must handle: numbers with units in the text (6.7 Volts, 7.6 Hz., 3.0 sec., -0.250 sec); >100 (ZC frequency above
range; 71,823 files), N/A (37,293 files), OORANGE (59 files: the channel
clipped), Check (2,193 files), and XML entities. Two _XML.XML details
matter:
- Blastware prints each number to a fixed number of decimals and rounds halves away from zero (−0.0625 s prints as −0.063).
- The small
<stem>_<ext>.XMLsummary next to it uses decimal commas. It is not the reference; the_XML.XMLis.
Goals
- For every Series 3 event file with an XML report, compare every field the XML carries, plus every waveform sample and every histogram interval, against SFM's file-only decode.
- Give each comparison one verdict: match, mismatch, SFM blank (SFM produced nothing), accepted difference (covered by a written carve-out), no reference (the XML lacks the field), or error (the decode or parse failed).
- Produce two outputs:
- A short summary for Brian: per field, the counts of each verdict and how far we are from done.
- A detailed report for Claude that groups failures by what the failing events share, so 17,000 mismatches read as "one bug on 2048 sps histograms". It gives example files with Blastware's value and SFM's, and a one-line command to re-run a single event.
- Run again and again. Each run is compared with the previous one, so a fix shows as numbers moving, and anything that used to match and stops is called out.
- Keep the comparison as library code, so ingest can later run it on one event as it arrives (piece 3/4).
What counts as "SFM's side"
The SFM side is what SFM produces from the event's bytes alone:
- The
Eventthatdecode_blastware_bytesreturns when given the bytes and no filename.- SFM's own download and call-in paths never have a Blastware name.
- Today the event type comes only from the filename's extension, so every histogram decodes as "Waveform". The checker reports that as it is: a mismatch until the decoder reads the type from the file (#41). It must not borrow the name to make it match.
- Anything else SFM reads from those bytes outside the decoder, such as the
serial.
- Ingest's
sfm/waveform_store._serial_from_bw_bytesuses the filename to validate what it finds. - Whatever SFM can't get from the bytes alone is "SFM blank".
- Ingest's
- Values the codec computes but never puts on the
Eventcount as SFM blank until they are wired through (piece 2). For example, histogram half-periods inhistogram_codec.decode_histogram_body_fullgive the per-interval frequency. - SFM's assumptions included.
- SFM cannot yet read the geophone range from the file, and assumes Normal
(10 in/s):
_peaks_from_samplesdoes, and ingest writes.h5withgeo_range="normal". - The checker compares what SFM actually produces under that assumption. The range field itself is SFM blank.
- So the 35 events recorded on the 1.250 in/s range show as 8× mismatches,
not blanks. Example:
T438L713.QP0Wgives PPV 0.015/0.02/0.015 against Blastware's 0.002. - The range is never taken from the reference.
- SFM cannot yet read the geophone range from the file, and assumes Normal
(10 in/s):
So the comparison takes an SFM-side record plus the parsed reference. The
runner assembles that record from the decoder and any SFM helpers. The
comparison itself stays pure codec-library code; only the runner (a lab tool)
may import from sfm/.
The rule for disagreements (decided by Brian)
Every mismatch is an SFM bug until shown otherwise. A mismatch becomes an "accepted difference" only through a written carve-out that names the fields it covers and the rule it applies. Its evidence must not rest on SFM's own output: Blastware contradicting itself, the instrument's own data (counts in the file, the unit's embedded record), a third source (another instrument, a known signal), or Instantel documentation. Each run reports how many events each carve-out covers.
The carve-out list starts with one entry, already proven in
scratch/verify_against_ascii.py: saturation. On a clipped channel,
Blastware clamps its numbers to the range maximum and writes OORANGE, while
the file holds counts past full scale. Rounding to Blastware's printed
precision is a comparison rule, not a carve-out.
Non-goals
- Series 4 / Micromate. Thor's IDF decode has its own CSV-based check, and the 5,916 Micromate XMLs are noted for a later Series 4 checker.
- Changing what SFM decodes. The checker reports gaps; filling them is piece 2.
- Wiring the check into ingest, the watcher or Terra-View. That's pieces 3/4. Nothing on prod changes.
- ASCII reports as a reference. The XML covers every year, including the 2025–26 events that have ASCII. The reference is parsed into a shape another report format could fill later, but no ASCII adapter is built now.
Anti-goals (would make it a failure even if it runs)
- Comparing SFM with Blastware's own numbers. The SFM side must come only
from the event file, through
decode_blastware_byteswith no report overlay. Nothing from the XML or ASCII report may reach the SFM side. - Hiding mismatches: a carve-out without evidence, a tolerance looser than Blastware's printed precision, or blanks counted as matches.
- Wrong conversions: counts converted to in/s with a range or scale that came from the reference rather than the file. If SFM can't read the range from the file yet, that is a gap to report, not something to borrow.
- A report that only says "N mismatches" without grouping and examples. It must be usable to find the cause.
- A full run so slow it isn't run after every fix.
Constraints
- Hardware: runs on the dev box (4 cores, ~17 GB free disk after the 22 GB XML copy; Brian can add space).
- Read-only: it never writes to the corpus folders and needs no network.
- Speed: a full run over all 70,042 events in under an hour. A
partial run (by serial, year, event type or field group, or a random sample)
in a few minutes. The setup/notes harness covering ~6 fields took ~4
minutes with 4 processes. Samples and intervals add parsing 22 GB of XML.
The standard library parses at ~45 MB/s per core (
lxmlis not installed), which fits the budget. - Codec library purity (ADR 0003): the codec library stays pure. Bench and lab tools stay out of the production image.
- Results contain customer project names, so run output is kept outside the repo and never committed.
What's decided, and by whom
Brian:
- SFM's data comes only from the binary; reports are for checking.
- The disagreement rule and carve-outs above.
- The two outputs: a summary for him, a detailed report for Claude to diagnose.
- Repeated runs with run-to-run comparison.
- It lives in seismo-relay, and the comparison is library code.
- Series 3 only. Nothing on prod or in Terra-View changes.
Claude's calls (correct if wrong):
- The XML is the single reference.
- Placement:
- The XML report parser belongs in the codec library, a sibling of
minimateplus/bw_ascii_report.py. - The comparison (one decoded
Event+ one parsed report → verdicts per field) is pure and belongs in the codec library too. - The batch runner is a lab tool (
scratch/), per ADR 0003. - The carve-out list lives in the repo next to the comparison, as code or data the comparison reads, with each entry's evidence written beside it.
- The XML report parser belongs in the codec library, a sibling of
- Grouping attributes for the detailed report:
- device model (from
Version), serial - event type, event year
- sample rate, geophone range, mic units/weighting, interval size
- whether the setup is named "Standard Recording Setup"
- which decoder path produced the samples, where the decoder exposes it
- device model (from
scratch/verify_bw_fields_against_xml.py(committedf46afaf) is the starting point. It already handles the notes/job-number layout and the rounding rule. The checker replaces it.
Left to the builder:
- module, function and file names; the output file formats
- how runs are stored and compared
- parallelism and any caching of decode or parse results
- the CLI shape, as long as the partial-run filters and single-event re-run exist
What success looks like
- One command produces the summary and the detailed report for all 70,042 events within the time budget.
- The first run reproduces what is known, which is how we tell the
checker is honest:
- sample rate, record time, pre-trigger and notes match everywhere
T438HGTZ.B30Wmatches. Its Tran, Vert and MicL end 3 samples before Long, and Blastware's own table does the same: its last rows carry only the Long cell. An earlier harness that compared one channel's length with the table's row count called this a decoder truncation; it was not.- samples and histogram intervals match on the 2025–26 events, as
verify_against_ascii.pyshowed, except the events on the 1.250 in/s range, which are 8× high (5 of them in 2025–26, 35 in all) - event type mismatches on every histogram, because no filename is given (#41)
- job number and the calculated values (ZC frequency, acceleration, displacement, time of peak, sensor check, battery, calibration, trigger levels, range, units, monitor log) show up as SFM blank
- the three
#53files fail loudly as waveform time mismatches, 4 s off. The decoder picks an earlier, false footer and records nodecode_problems. The#53description indocs/instantel_protocol_reference.md, which says they decode as histograms, is out of date.
- Every non-match group in the detailed report carries example files and a re-run command.
- Tests cover the XML parser on real fixture reports with literal expected
values, every comparison rule (rounding,
>100,N/A,OORANGE, units), carve-out accounting, and a guard that the SFM side never sees the reference.