Commit Graph
244 Commits
Author SHA1 Message Date
serversdownandClaude Opus 5.5 f24913189b merge: dev 9b458b5 into the parity branch (group A/B, #51 histogram timing)
Brings the checker's file-only decode work onto the parity branch so the
phase-5 bench runs on the code that will ship.  One conflict, the CRLF
Series-III reference changelog: both kept, phase 5's row numbered
'2026-11-03 (5)' above dev's (4)/(3)/(2).  test_event_ingest's live-
histogram dedup test asserted the stored row sits a second off the 0C
time -- the #51 bug, fixed on dev -- so its premise now reads the event's
own second; the dedup it tests still holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-04 12:31:21 -05:00
serversdownandClaude Opus 5.5 08d0a6c0d4 fix(settings): final-review fixes -- revision, resulting limits, logical writes
From the whole-branch review of phase 5:
- The preview's revision now covers the changes asked for, so a live
  change must be exactly what was previewed (any API caller, not only the
  page).  It covers what the preview showed -- the settings block (and a
  Micromate's setup name) -- not the blocks a write only echoes, which are
  re-read at send and sent as read (a MiniMate's trigger block byte 5
  differs by session, #46).
- The units' limits hold on the block that would result: a range, rate or
  mode change alone can no longer leave a held trigger, alarm or record
  time over them.
- Every MiniMate block read is logical, so push_config_raw no longer
  unescapes again (a job number of 4098, 10 02, was refused at Send); the
  preview runs the write's own block check, so a block it would refuse is
  shown as blocked.
- A MiniMate's monitoring refusal says a stop makes it call in (spec).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 22:10:49 -05:00
serversdownandClaude Opus 5.5 385716d8e1 feat(webapp): edit a unit's settings by serial: preview, send, read back
The Config tab by serial is now the unit's edit form, headed 'On the
unit <serial> -- read HH:MM' and built from the server's editable
fields.  Preview runs a dry run and shows old -> new, notes and anything
that blocks the change; Send (confirm) sends exactly what was previewed,
with its revision, then shows what the unit now holds and re-reads it.
An edit after a preview disables Send until the next preview.  The
by-host form loses its write button; the read stays.  Logic in
device_routing.js (Node-tested), glue in sfm_webapp.js, no inline JS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 21:57:17 -05:00
serversdownandClaude Opus 5.5 e8eabee4a2 feat(sfm): POST /device/settings/change; retire the legacy config write
DeviceAccess.change_settings refuses before any I/O a request with no
changes, a live change without its preview's revision, or no audit log,
then dispatches the series' change (never retried).  The route returns
the preview (fields old -> new, warnings, blocked, revision) or the
result (fields old/new/now), statuses as the other changes, and marks
the cached by-host config dirty after a live change.

/device/config and /device/config/project now answer 410 with a pointer.
Deleted with them: MiniMateClient.apply_config / set_project_info and
the raw-offset _encode_compliance_config (#46 found it wrong), the
lab script poc_set_project.py and experiments.py's EXP6, both of which
wrote a live unit through it.  Git keeps them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 21:51:20 -05:00
serversdownandClaude Opus 5.5 66bb29b9d4 feat(s3): change a MiniMate's settings by serial on the shared codec
Series3Adapter.settings reads the 1A block assembled into its 2,090
logical bytes and decodes it with micromate.setup_fields (a monitoring
unit's device-info answer is refused with 'stop monitoring first').
change_settings runs the shared change core: read the four settings
blocks, patch the settings block's fields, send Blastware's sequence
through push_config_raw with the event index, trigger and waveform blocks
as read, re-read.  Refused before sending: monitoring, a value the unit
does not allow, a stale preview.  push_config_raw's pre-check now raises
ImageRefused, so a refused image is audited as nothing sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 21:46:50 -05:00
serversdownandClaude Opus 5.5 c082f72d62 feat(s4): change a Micromate's settings by serial, audited, schedule-checked
s4_change_settings runs the shared change core with a read-back verdict
for its state (as asked / unchanged / differs).  It reads the active
setup's name (unstripped), the preferences, trigger and setup blocks and
the schedule; patches the setup through micromate.setup_fields; sends
THOR's setup push (0xDA 68 73 82 83 71 72, now enableable) once; reads
the setup back.  Refused before sending: a monitoring unit, a value the
unit does not allow (422), a stale preview (SettingsChanged, 409), and --
shown as 'blocked' in the preview -- the factory setup, a schedule that
loads another setup, an unreadable schedule, or a block SFM has not seen
(ChangeRefused, 409).  s4_settings carries the editable fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 21:43:03 -05:00
serversdownandClaude Opus 5.5 d0335dbbbd feat(micromate): read the schedule file (read-only)
MicromateProtocol.read_file: 0x94 + path, then 0x48 pages to an
all-zero reply -- THOR's frames byte for byte (UM12947, 2026-09-24),
including params[3] = 1 on 0x94 and params[7] = 1 on the first 0x48.
micromate.schedule parses the 260-byte records (two- and five-entry
schedules from THOR's captures) and names the scheduled starts that
would load a setup other than the active one, ignoring case.  The
client gains the raw (unstripped) active-setup name and the prefs /
trigger / setup content reads a setup push sends back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 21:37:30 -05:00
serversdownandClaude Opus 5.5 9cfa82117b feat(decode): histogram interval times and peak times (#51 group C)
With the start right, the rest of Blastware's histogram timing follows,
measured on a 2,000-histogram DL2 sample:
- each interval's printed time is its end, start + (i + 1) x interval,
  capped at the stop: 2,308,524 / 2,308,524 rows
  (event_file_io.interval_times)
- each of Tran / Vert / Long / PVS / MicL's peak date and time is that of
  the interval holding its first maximum: 2,000 / 2,000 each.
The checker compares intervals.Time and the ten peak date/time fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-03 21:35:54 -05:00
serversdownandClaude Opus 5.5 a9bb9f08c0 fix(decode): a histogram's start and stop come from its own event record (#51)
The footer's start runs a second early on 97% of histograms.  Each
histogram carries an event record like a waveform's -- lead 00 28 05 00,
source 04 00, marker fe f5, then start and stop -- and it holds
Blastware's Histogram Start and Stop on 63,490 / 63,490 DL2 histograms.
On all 63,500 there is exactly one, its start 0 or 1 s after the
footer's and its stop 0 or 1 s before; that is the validation rule.
Without a validated record the footer's start stands, as a decode
problem.

Ships with the unit + time + type key (ea2dfc2), without which a
waveform and its histogram at the same second would collide.  Three
tests that pinned the old footer start (one said 'for now', pointing at
#51) now pin the record's, which equals the file's Blastware name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-03 21:33:32 -05:00
serversdownandClaude Opus 5.5 5ba72740dd feat(codec): one settings codec for both series, on the shared layout
micromate/setup_fields.py: the fields an operator can change (record
mode, sample rate, interval, record time, geophone trigger, Series 3's
range and -- read-only until benched -- alarm, job number and its report
flag, the four notes by slot), the units' own limits from Instantel's
manuals, field-only byte patching (bit fields bit by bit; Series 3's
[26:28] as Blastware writes it; Series 4's CRC recomputed), the
read-back verdict compared by bytes, and the preview revision.

All 11 Blastware compliance writes reproduce from the block before them
(BE11529's first also shows Blastware re-rendering two mic levels
through its dB value; SFM echoes the unit's bytes); Series 4 keypad
fixtures reproduce pairwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 21:33:01 -05:00
serversdownandClaude Opus 5.5 e24e77bfd0 test: the estimate guard's neighbour is an event of the same type (#51)
Under the unit + time + type key, the test's untyped neighbour no longer
shared the imported waveform's key, so the waveform was stored as its
own row -- the neighbour untouched, which is what the test's name asks.
The guard's job is an estimate landing on another waveform's second, so
the neighbour is now a waveform.  A companion test pins the case the new
key allows: an estimate beside a histogram at its second is stored
alongside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-03 21:30:51 -05:00
serversdownandClaude Opus 5.5 ea2dfc21b7 feat(db): events are identified by unit + time + type (#51)
The events table was UNIQUE(serial, timestamp): one event per unit per
second.  A unit records a waveform and a histogram in the same second
legitimately -- 209 times in prod's 2026-09-30 store once histograms
carry Blastware's start -- so the key is now (serial, timestamp,
record_type).  Agreed with Brian 2026-11-03.

- Migration 3 rebuilds the table from its own current definition with
  only the key swapped, in one transaction: every column, row and id is
  kept (Terra-View reads rows by id) and the indexes are recreated.
  Migration 1's check no longer mistakes the new key for a missing one.
- The upsert, the estimate guard and the restamp match on the type too.
  The restamp also re-types a file's own row in place: before v0.33.0 a
  row's type came from the filename, and a re-import under the file's
  own type must not add a second row.
- An untyped event still refreshes the untyped row at its second (a
  UNIQUE key treats NULLs as distinct).
- scripts/repair_unknown_serials.py checks the new key.

No time changes yet: that is the next commit, and they ship together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-03 21:29:46 -05:00
serversdownandClaude Opus 5.5 1bb15573fc feat(s3): assemble a settings read into the 2,090-byte block
Unescape each 1A data frame, take data[11:], drop the one non-content
byte that starts every frame but the last: 2,090 bytes headed by
N = 2090, Series IV's 0x1A layout.  Measured on BE9441's 10-26
recording (12 reads, both frame patterns); the read after each
Blastware write equals the image written.  read_compliance_content is
strict (a missing frame raises) and unjudged (a monitoring unit's
device-info answer comes back for the caller to recognise).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 21:28:04 -05:00
serversdownandClaude Opus 5.5 13f2769736 feat(decode_check): an OORANGE interval vector sum is saturation
Blastware prints OORANGE for an interval's vector sum when it exceeds
the range in an interval where Blastware also clamped a channel: 17 / 17
DL2 cells, SFM's sum 10.01 .. 17.33 in/s (sqrt 3 x 10.005).  The
saturation carve-out now covers intervals.Geo PVS in/s with that rule,
per interval, as it already did for PeakVectorSum.  The 4 other cells
left mismatching sit 4e-6 past a rounding boundary (Blastware's
arithmetic is a hair lower) and stay mismatches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-03 18:02:51 -05:00
serversdownandClaude Opus 5.5 2b698e74cf feat(decode): a histogram's interval detail -- frequencies (#50), vector sums, interval size, 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.  #50: half_period_to_hz took 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, '<1.0' below 1 Hz.
- Each interval's vector sum, sqrt(PVS^2) at the event's range:
  771,354 / 771,354.
- Interval size: uint16 seconds at k - 40 (Series IV [8:10]).
- Stop: the footer's (2,995 / 2,999 sampled; 4 print a second earlier).

Event gains histogram_interval_sec, interval_half_periods, interval_pvs
and stop_time; the .h5 gains /intervals/half_period/<ch>,
/intervals/pvs_ips and a histogram_interval_sec attr.  The decoder walks
a histogram once (histogram_codec.channels_from_records) and takes the
event's PVS from the same records.  The checker compares each interval
column, number or Blastware's word; the test that pinned Tran Freq Hz
as blank now pins the match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-03 17:34:27 -05:00
serversdownandClaude Opus 5.5 cbce00f8e1 merge: dev into feat/series4-sfm-parity -- the decode checker's file-only fields (job number, codec by STRT[18], last-26-byte footer)
Brings be5bab4 and its history from the decode checker's branch: a Blastware
file's job number; decode_blastware_bytes choosing the codec by STRT[18] and the
histogram layout check by peak <= PVS <= sqrt(3) peak; the footer as the file's
last 26 bytes (no day-late histograms); docs (reference Appendix D.6, the
file-only status).

Conflicts, both kept whole:
- CLAUDE.md: this branch's 'Narrowed 2026-10-26' 5A block stays, followed by
  dev's 'Open, not blocking' line (the 8x sensitive-range item struck out --
  resolved by the file's range).
- docs/instantel_protocol_reference.md (CRLF, byte-safe): the change-log rows in
  date order -- dev's 2026-11-03 and 2026-11-02, this branch's 2026-11-03
  (call home), 2026-10-29 and 2026-10-27 (#46, this branch only).

Suite on the merged tree: 1399 passed, the 16 known failures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 15:34:59 -05:00
serversdownandClaude Opus 5.5 f35845d403 fix(sfm): a Micromate's call-home is refused while monitoring, and only a real call-home block is ever edited
Measured at the bench 2026-11-03 (UM20147): monitoring, a Micromate returns its
real call-home block and ACKS a call-home write, but does not apply it -- three
read-backs unchanged, and its own menu says 'Feature disabled while monitoring'.
SFM now refuses up front (UnitStateUnknown, 409: '... is monitoring -- a Micromate
ignores call-home changes while monitoring ...; stop monitoring first -- nothing
sent'), dry run included, instead of sending a write the unit ignores.

And the block must be the call-home block: micromate.writes.is_call_home_content
checks its header is its own length (00 7C, N = 124 -- 00 7C DC on every read,
UM12947 and UM20147).  plan_call_home_enabled refuses any other 126 bytes, the
change refuses before sending, and call_home_state says why (enabled = None).
At the bench this was checked by eye before the monitoring write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 15:32:02 -05:00
serversdownandClaude Opus 5.5 5326e99ac2 fix(sfm): a monitoring MiniMate's call-home says 'stop monitoring first', not 'unknown(0x6E)'
Measured at the bench 2026-11-03 (BE9441): while monitoring, a MiniMate answers
the 0x2C call-home read with its DEVICE-INFO block ('Instantel', 'MiniMate Plus',
its serial) -- as it answers 1A -- and idle again, minutes later, the call-home
block.  SFM writes back only a block it just read, so a monitoring MiniMate's
call-home cannot be changed; the change core already refused (byte 5 read as
'unknown(0x6E)', nothing sent), but said so cryptically.

- minimateplus.protocol.is_call_home_block(raw): the block starts with its own
  length 0x7C and is N (or N + 2) bytes unescaped; the device-info block fails it.
- The Series-3 change raises UnitStateUnknown (409) with 'did not return its
  call-home settings -- a MiniMate answers the call-home read with its
  device-info block while monitoring; stop monitoring first ... nothing sent',
  for a dry run too.  call_home_state returns enabled = None with that reason.
- The page's callHomeRows shows the reason in place of 'Unknown (byte 5 = ...)'.

A blind write while monitoring stays untested on purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-03 14:19:19 -05:00
serversdownandClaude Opus 5.5 8d5a9987c9 fix(decode_check): compare a mic level in the unit it is printed in
K441LA17.IN0W's report says Units 'in/s and psi(L)' yet prints
MicTriggerLevel '125.0 dB(L)'.  The value states its own unit, so that
is the one compared; the report's Units is the fallback.  It was the
only MicTriggerLevel mismatch in DL2 (SFM's 0.005158 psi is 125.0 dB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-03 14:02:27 -05:00
serversdownandClaude Opus 5.5 6c2eda5f63 feat(decode): a Blastware file's identity, battery and trigger settings
Group A of the file-only decode, every field 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, firmware k-147, DSP version k-138, calibration
  date k-132 + 'by' k-128, manufacturer k-94, model k-72, firmware
  minor k-193.  Event.device_info (DeviceInfo gains calibration_date /
  calibrated_by).  Serial, Version and Calibration 69,983 / 69,983.
- Battery: uint16 hundredths of a volt at k-190 (Event.battery_volts).
  69,729 exact; the other 254 are Blastware rounding half up.
- Trigger source: the two bytes between the embedded event record's
  lead and fe 80, a bitmask (0x01 Tran 0x02 Vert 0x04 Long 0x08 MicL
  0x200 Manual): 6,493 / 6,493.  Event.triggered_by.
- Trigger settings in Series IV's 0x1A layout: sources bitmask k-19,
  stop mode k-31 (0 = Fixed), each channel's float32 level at
  label+30 (geo in/s, mic psi), mic type code at MicL+4 (2 = Linear
  Weighting).  Geo level 6,447 / 6,447, mic 4,403 / 4,403; Blastware
  prints a level when its channel is a trigger source and the event
  was not Manual.  The mic level's dB uses 6895 Pa/psi (4,272 / 4,272
  against 4,271 at 6894.757).
- .h5 attrs for all of them (additive).
- Checker: SFM's side reports the ten fields; the mic trigger level
  follows the report's dB/psi.  Carve-out
  units-is-a-display-preference: dB or psi is Blastware's PC setting
  when it wrote the report -- DL2's reports switch fleet-wide in 61
  clean runs by write time, and no byte of the file separates them.
  Two tests that pinned BatteryLevel / Calibration as blank now pin the
  match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-03 13:38:39 -05:00
serversdownandClaude Opus 5.5 8a40eb638a fix(decode): a Blastware file's footer is its last 26 bytes -- no more day-late histograms
Every DL2 file ends in a valid footer: 0e 08 and two valid times on
70,041 / 70,041.  The decoder took the first '0e 08 + plausible year'
instead, and 14 files also hold an earlier record, ~1.1 KB before the
end, with the stop time followed by zeros:
- a histogram started at its own stop -- a day late on BE9558's daily
  histograms (K558L9XP.FK0H: 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 the trigger was never computed and the
  stop was stamped instead (K440I4LG.JK0W: 11:14:12 for 11:14:08).

The last 26 bytes are now taken when they are a footer; otherwise the
old search stands unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-03 12:10:44 -05:00
serversdownandClaude Opus 5.5 9e03b3f0ab fix(sfm): a Micromate in an unknown run state gets no call-home write, and a lost ack keeps its snapshot (phase-4 review)
- s4_change_call_home's read_state now returns an unknown(0xNN) run state as
  it is, so the change core refuses it (UnitStateUnknown, nothing sent), as
  start/stop already does; it checked only for calling_home.
- run_change records the snapshot on the lost-ack path too: after an ack is
  lost, what the unit now holds (and, on Series 4, whether [118:120] moved) is
  what tells whether the write landed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 17:23:59 -05:00
serversdownandClaude Opus 5.5 bdd76b8f74 fix(minimateplus): a built call-home image is framed once, never unescaped again (phase-4 review)
call_home_image returns the unescaped N + 2 image, but the send path handed it
to write_call_home_config, whose write_image unescapes again -- and unescaping
is not idempotent: a real 0x10 before 02/03/04 loses its 0x10.  A call-in time
of 16:02-16:04 (hour 0x10) is exactly that.  One such time made the send refuse
before the wire yet audited as 'sent, acknowledgement lost'; two made it send a
block shifted by two bytes from [101] (num_retries and the time fields wrong).
The Blastware-frame test could not see it: it checked the image builder, not
the bytes the protocol framed.

- MiniMateProtocol.write_call_home_image(image) frames a built image once
  (0x7E, ack 0x81, 0x7F, ack 0x80), raising ImageRefused before any byte when
  it is not a whole block; write_call_home_config (the legacy multi-field path)
  is write_image once + that.  Its stale 127-byte docstring is gone.
- MiniMateClient.write_call_home_image uses it.
- The Series-3 change passes is_refusal=ImageRefused, so a pre-wire refusal is
  audited as nothing sent (sent = 0), not as a lost ack.

Tests drive the real client -> protocol over a stub answering with BE11529's
recorded acks: the unit's own read, a 16:02 time, and 16:03 + 16:04 all go out
exactly as built; a short image is refused with nothing written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 17:23:59 -05:00
serversdownandClaude Opus 5.5 51e7dddcb3 test(micromate): corpus counts are floors, and 0x71 is the over-the-ceiling example
Two test-side breaks, found by the full suite after phase-4 task 6:
- test_micromate_framing's three whole-session tests pinned exact counts of a
  gitignored corpus (bridges/captures/9-24-26 - micromate2, a symlink into the
  main checkout).  The full copy of the BW VM's captures on 2026-11-02 added
  sessions: 287 responses / 241 reads / 287 requests, every one passing the same
  per-frame checks.  The counts are now floors (>= 251 / 218 / 251), so a lost
  file still fails and a grown corpus does not.
- test_micromate_opcodes' beyond-the-ceiling permit took 0x7E, enableable since
  the call-home commit (eeb55ef); 0x71 (the setup write, phase 5) replaces it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 17:07:04 -05:00
serversdownandClaude Opus 5.5 84c142f36c feat(sfm): the page's Call Home tab by serial -- state and audited On / Off (phase 4)
device_routing.js (Node-tested): call_home_state / call_home_on / call_home_off
routes (serial required); controlsFor gains callHomeChange (by serial, a
confirmed Series 3 or 4) and callHomeRead now covers a Series 4 by serial;
serialPanes gains callHomeForm / callHomeBox; callHomeRows renders the switch
(On / Off / 'Unknown (byte 5 = 0xNN)'), dial string and series;
changeErrorText takes the whole label ('Start monitoring', 'Enable call-home').

sfm_webapp.js: by serial the Call Home tab hides the legacy multi-field form
(Series 3 by host only) and shows the unit's switch with On / Off.  Each asks
confirm(), sends one audited change, reports it with changeSummary /
changeErrorText, then re-reads quietly so the change's own result stays on
screen.  A different unit's switch is never left showing.  The new buttons are
wired with addEventListener, not onclick= (no inline JS).

Checked in jsdom against the real page: placeholder, read, Off (confirm, the
disable route, 'confirmed -- enabled -> disabled'), a serial edit clearing it,
legacy mode unchanged, no script errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 17:05:00 -05:00
serversdownandClaude Opus 5.5 06fa56db09 feat(sfm): call-home state and enable/disable by serial -- GET /device/call_home/state, POST /device/call_home/{enable,disable} (phase 4)
- DeviceAccess.call_home_state (a read) and set_call_home (change=True: never
  retried, audit required for a live change, dry run without one), routed by
  series like start/stop.  A config write is read back on its own window: up
  to 3 reads, 1 s apart, not the monitoring one.
- Routes, serial required (422 without), all three serial-aware: the state as
  a dict; enable / disable through _change_response, so their statuses are
  start/stop's and an unconfirmed change carries sent + audit_id.  The legacy
  GET / POST /device/call_home are unchanged (a Micromate serial is still
  refused there, 501).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 17:01:14 -05:00
serversdownandClaude Opus 5.5 453d42e32a test(s3): SFM's call-home write equals Blastware's, frame for frame -- opens the live send
Ground truth: Blastware changing BE11529's call-home settings on 2026-04-20
(Remote Access -> Setup Unit), paired raw files of what it sent and what the
unit answered: the read, the enable (read 0x00 -> wrote 0x01), the disable
(read 0x01 -> wrote 0x00).  From the unit's own read before each write, SFM's
0x7E frame (call_home_image + build_bw_write_frame) is Blastware's byte for
byte -- nothing but byte 5 differs from the read -- and the 0x7F confirm too.
Mutation-checked: inverting the byte SFM writes fails the test.

S3_CALL_HOME_FRAME_VERIFIED is now True; the gate stays tested shut by
monkeypatch, and a test pins that its comment names this proof.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 16:59:15 -05:00
serversdownandClaude Opus 5.5 8612cd9df7 feat(sfm): Series-3 call-home state and audited enable/disable, live send gated until its frame is verified (phase 4)
- minimateplus.protocol: call_home_enabled(raw) reads byte 5 of the UNESCAPED
  0x2C payload (0x01 on / 0x00 off, measured 2026-04-20; anything else None --
  bench finding #1's lesson: an escaped byte before it would move the raw
  index); call_home_image(raw, enabled) is write_image's N + 2 image with byte 5
  set and everything else as read, refusing a byte 5 never measured.
- MiniMateClient.read_call_home_raw() / write_call_home_image(image) (0x7E then
  0x7F, each ack checked, never retried).
- Series3Adapter.call_home_state (wake, then 0x2C; no serial read, like status)
  and change_call_home: the shared change core with a connect() identity check,
  state 'enabled' / 'disabled' / 'unknown(0xNN)' (unknown sends nothing), the
  plan showing both exact frames, a snapshot of both unescaped images.
- S3_CALL_HOME_FRAME_VERIFIED = False: a live change is refused (501) before any
  connection until the frame is reproduced from Blastware's (next commit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 16:57:55 -05:00
serversdownandClaude Opus 5.5 eeb55effe9 feat(sfm): Series-4 call-home state and audited enable/disable (phase 4)
- micromate: ENABLEABLE_WRITES gains 0x7E/0x7F (the call-home write and its
  confirm; spec row 9, enable/disable only); MicromateClient.get_call_home_content()
  returns the 126-byte 0x2C content.
- sfm/device_access: CallHomeState (serial, series, enabled, dial_string, detail
  with byte5 and the whole block); s4_call_home_state reads bit 0 of [5] and the
  dial string at [6:46]; s4_change_call_home runs the shared change core with
  micromate.writes.plan_call_home_enabled -- built from the read run_change made
  just before, and that same plan is the one sent.  A unit calling home (run
  state 0x03) is refused, nothing sent.  The read-back judges the edited bit
  only; the snapshot records both blocks and every changed offset -- [118:120]
  is unit-maintained and always moves.
- The write-ceiling tests take 0x71 (the setup write, phase 5) as their
  over-the-ceiling example now that 0x7E is enableable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 16:56:04 -05:00
serversdownandClaude Opus 5.5 1dd5bfa464 refactor(sfm): run_change takes a ChangeKind -- start/stop unchanged, call-home next (phase 4)
run_change named its change and its target state from a start/stop bool.  A
ChangeKind (action, want, became) now says what the change is called and which
state read back means it took; monitoring_change(start) gives exactly today's
names, call_home_change(enabled) the new ones.  An optional snapshot hook
records what the unit holds after the change in the result and the audit row
(never the verdict; one that raises is recorded as its error).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 16:53:48 -05:00
serversdownandClaude Opus 5.5 8123d75d72 fix(sfm): page polish from the 1c bench -- #6, #10, #12, #16 (Batch 2)
- #6 Config tab by serial: the empty legacy edit form stays hidden (settings
  are read-only until phase 5); the settings box shows from the start, 'Not read
  yet', and a different unit's settings are never left on screen.
- #10 A start/stop that went out but was not confirmed is no longer called
  'failed'.  The route now adds 'sent' (acknowledged / unknown) and 'audit_id'
  to a ChangeUnconfirmed -- same status, same message -- and the page says
  'Start monitoring not confirmed: <what happened, audit record>'.
- #12 Device tab by serial: the empty legacy Compliance/Project tables are
  hidden behind a pointer to the Config tab; a Micromate's Firmware card reads
  'Thor line (version not read)' (its version string is in 0x01, undecoded).
- #16 A 504 with nothing sent adds: the connection opened, so the modem is
  reachable -- another program (THOR or Blastware) may be holding the line, or
  the unit is busy.  Measured 2026-10-29: THOR polling leaves SFM a 0-byte 504.

New logic lives in sfm/static/device_routing.js (firmwareLabel,
deviceErrorText, changeErrorText, serialPanes) under Node tests; the page glue
in sfm_webapp.js only applies them.  Checked in jsdom against the real page
(served at a fake origin, /static from disk): all four, legacy mode unchanged,
no script errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 16:22:22 -05:00
serversdownandClaude Opus 5.5 aec4a38473 fix(decode): histograms go to the histogram codec, and a loud interval no longer hides a short one
Three causes behind the histograms the checker found decoding wrongly:

1. The file decoder tried the waveform codec first, whatever the record
   type.  It accepted BE9440 / BE9557 / BE17354's 2018 5 s histograms and
   returned ~5x too many 'samples' (K440HDXX.XH0H: SFM 44,504, Blastware
   6,976).  The codec now follows STRT[18] (0x46 / 0x0A on 70,041 /
   70,041 DL2 files); only an unknown type falls back to trial order, and a
   chosen codec that fails is a decode problem rather than a silent switch.

2. The sub-minute layout check required each record's 'zero word' to be
   0000.  It is the high word of the interval's PVS squared, non-zero above
   1.28 in/s, so a one-block histogram with a loud interval was not
   recognised (T193KR5M.X90H, K440HA3C.JM0H, R352HFZ7.530H decoded to
   nothing).  The check is now the measured relation peak <= PVS <=
   sqrt(3) * peak, which holds on 34,502,955 / 34,502,955 DL2 sub-minute
   intervals.  The no-terminal-tail trim uses the same test.  Two test
   builders wrote PVS bytes no real record has (one still in the retracted
   little-endian layout); they now write peak^2 in the measured layout, and
   the retraction test keeps a legacy builder of its own.

3. Checker carve-out interval-count-is-duration: Blastware's Number of
   Intervals is (stop - start) / interval from the footer times, and its
   own interval table lists one block fewer when the unit never wrote the
   last minute.  SFM matches the table (T193KSWP.FF0H: 2,880 vs 2,850).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-02 16:20:32 -05:00
serversdownandClaude Opus 5.5 2b886c4f39 refactor(sfm): move the page's JavaScript out of sfm_webapp.html into sfm/static/ (no code change)
Stack-wide rule since 2026-11-02 (terra-view docs/tmi-stack.md, Terra-View's
rule 4): no inline JavaScript, because a test cannot load it.  This page's tests
had to regex their code out of the HTML.  Batch 2 edits both of the page's
scripts, so they come out first, verbatim:

- sfm/static/device_routing.js: the tested routing rules (157 lines)
- sfm/static/sfm_webapp.js: the rest of the page (2,274 lines)

The page loads them with <script src="static/..."> where the inline scripts
were, so load order and the onclick handlers are unchanged.  Verified: putting
the files back inside those tags reproduces the old sfm_webapp.html byte for
byte, and a jsdom page check (served at http://sfm.local/, /static from disk,
no network) gives identical output before and after.

The server serves sfm/static/ at /static/, with Cache-Control: no-cache so a
browser revalidates (a cheap 304) and a new SFM never runs a cached old
script.  Opened from disk, the page needs its static/ folder beside it.

Tests: the routing tests load the file instead of regexing the HTML; new
test_webapp_static pins no inline <script> in the page and the /static route
(through the whole app, middleware included).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 16:17:44 -05:00
serversdownandClaude Opus 5.5 7a58bad28d feat(decode): a Blastware file's job number, and whether Blastware shows it
The setup block has Series IV's 0x1A layout here too: report flags at
k - 9 (bit 0x02 = job number shown) and the number, uint16 BE, at k - 8,
kept while switched off.  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 and matches; hidden ones hold real numbers
(802, 1012, 1013, 622), so the value is only proven for 1.

- ProjectInfo.job_number_enabled / job_number, named as in
  micromate.setup_block.
- write_event_hdf5 stores both as .h5 attrs when read (additive).
- The checker reports the number only when shown, and scores a number
  only SFM shows as a mismatch.  The old test that pinned JobNumber as
  sfm_blank now checks only the ZC cases it also covered.

Not carried into the DB, the API or the PDF report yet (needs a column).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-02 14:31:23 -05:00
serversdownandClaude Opus 5.5 f98c4ff129 fix(sfm): a MiniMate download stores what its own file says, at the range it was recorded at (#17)
With the decode checker's fixes merged (histogram vector sum 625bc39, mic psi
5644dbd, the file's geophone range 4844135), the event file reads everything
Blastware reports.  So a live download's row and samples are now the file's:
peaks, vector sum, mic -- and the geophone range from the file's own setup
block, the setting when the event was recorded.  The live 1A is the unit's
setting now, which may have changed since; it is the fallback only when the
file's range does not read.

Measured: K557J1KB.RQ0W (Sensitive waveform) downloaded with its settings unread
-- e.g. while monitoring -- stores 0.019 / 0.055 / 0.019 and PVS 0.061,
Blastware's report; its .h5 read 0.155 / 0.44 (8x) before.  M010HR6K.OA0H
(Sensitive histogram) likewise.  K441LTON.900 (Normal) stores Blastware's
values whatever the unit's current settings say, and its mic is 5.80e-4 psi
(Blastware: 106.0 dB(L)).

The unit's 0C summary stays the download check, and fills in the channel peaks
and vector sum only when the file's range does not read (never seen in DL2) and
the unit is not confirmed Normal -- the impossible-vector-sum guard kept there.
The mic is the file's always.  Closes the range part of open finding #17.

Store consequence: new live downloads only; no backfill, no migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 13:48:59 -05:00
serversdownandClaude Opus 5.5 d0c14aaec8 merge: dev into feat/series4-sfm-parity -- the geophone range from the file, and v0.33.0
Brings 057df47 (fix 4844135, changelog be58b4f) from the decode checker's branch
-- Event.geo_range from the file's setup channel block (label+29: 0 Normal,
1 Sensitive, None not read), peaks and histogram PVS scaled by it,
write_event_hdf5(geo_range=None) using it -- and dev's v0.33.0 release commit
(6c7c6b0).

Conflicts, resolved as agreed with the decode session:
- sfm/waveform_store.py save_imported_bw: dev dropped the forced
  geo_range="normal"; this branch keeps its geo_range parameter, now
  Optional, default None -- an import uses the file's own range, an explicit
  value (a live download's) still wins.
- CLAUDE.md: dev's newer 'Where things stand (updated 2026-11-01)' date.

Measured on the merged tree: K557J1KB.RQ0W (Sensitive waveform) decodes
0.019 / 0.055 / 0.019, PVS 0.061 -- Blastware's report -- and its imported
.h5 peaks 0.0194 / 0.055 / 0.0194 (forcing 'normal' gives 8x: 0.155 / 0.44).
M010HR6K.OA0H (Sensitive histogram) likewise.  The live path still passes the
unit's 1A range or 'normal' when unread -- unchanged by this merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 12:06:35 -05:00
serversdownandClaude Opus 5.5 4844135f01 fix(decode): a Blastware file's geophone range comes from its setup -- Sensitive events no longer read 8x
In the setup's channel blocks, the byte 29 after each geophone label is
the range: 0x00 Normal (10 in/s), 0x01 Sensitive (1.25 in/s).  It matches
Blastware's GeoRange on 70,042 / 70,042 DL2 events, all three channels
agreeing on every one (35 Sensitive).  SFM's live 1A has the same byte
at label+33.  SFM assumed Normal, so every Sensitive event's peaks,
vector sum and .h5 samples read 8x high.

- Event.geo_range (0 / 1, None when not read -- channels disagreeing,
  an unknown value or a missing block -- with a decode_problems entry).
- decode_blastware_bytes scales peaks and the histogram vector sum by it.
- event_hdf5.write_event_hdf5: geo_range defaults to None = the event's
  own, else Normal; an explicit argument still wins.
- waveform_store.save_imported_bw and scripts/backfill_sidecars.py stop
  forcing 'normal', so imports and the backfill store the file's range.
  The waveform_store line was agreed with the parity session, which owns
  that file; its own branch keeps a geo_range parameter, defaulting to
  None at its next dev merge.
- The checker's SFM side converts at the event's range and reports
  GeoRange; tests that pinned the old 8x gap now pin the fix, and the
  saturation carve-out is still tested against an 8x value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-01 16:26:15 -05:00
serversdownandClaude Opus 5.5 1141a15543 merge: dev into feat/series4-sfm-parity -- one MicL count is 0.25 Pa
Brings 30a249e (fixes 5644dbd + 1895150, changelog 287ef2a) from the decode
checker's branch: the file's mic psi was ~95x low (_MIC_PSI_PER_COUNT =
0.25 Pa / count), and Blastware's dB offset is 81.9384.  K441LTON.900's mic
reads ~5.80e-4 psi from the file, as Blastware's 106.0 dB(L).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-31 02:20:32 -04:00
serversdownandClaude Opus 5.5 18951505f0 fix(decode): Blastware's mic dB offset is 81.9384, a hair above exact 0.25 Pa
The checker caught 280 regressions in the first mic fix: every one a dB
value at count 129, where 20 log10(129 x 0.25 Pa / 20 uPa) = 124.149997
rounds to 124.1 and Blastware prints 124.2.  Blastware's dB offset sits in
[81.9383, 81.9385] -- any value there matches its dB(L) on 1,729,252 /
1,729,253 DL2 intervals (the last printed '0.000'); exact 81.93820 rounds
count 129 down, and the old 81.94 misses counts 119 and 132.  Single
precision does not explain it.  psi keeps 0.25 Pa per count, which
matches every interval.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-10-31 01:55:45 -04:00
serversdownandClaude Opus 5.5 5644dbd5ad fix(decode): one MicL count is 0.25 Pa -- the mic psi was ~95x low
SFM converted mic counts to psi with a '~0.5 psi full-scale' guess
(0.0125 / 32768 psi per count).  Measured against 1,729,253 DL2
histogram intervals' 'MicL Peak' columns: one count is exactly 0.25 Pa.
count x 0.25 Pa matches Blastware's psi(L) on every interval, and
20 log10(count x 0.25 Pa / 20 uPa) its dB(L) on all but 17 exact
half-way cases.

- event_file_io: _MIC_FS_PSI -> _MIC_PSI_PER_COUNT = 0.25 / 6894.757
  (3.626e-5 psi per count, was 3.81e-7).  The event's mic peak in psi,
  and with it the .h5 mic trace (event_hdf5 back-solves its scale from
  that peak), come right on events with no report.
- waveform_codec.mic_count_to_db: the offset is 20 log10(0.25 / 20e-6)
  = 81.938, not 81.94 -- the old value missed 49 of those intervals at a
  rounding edge (count 119 printed 123.4, 81.94 gave 123.451).

The decoded count was always right: count 16 on K441LTON.900 is
Blastware's 106.0 dB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-10-31 01:28:23 -04:00
serversdownandClaude Opus 5.5 0a87d85202 fix(sfm): a MiniMate download's peaks come from its file when the unit confirms Normal range
Since the decode checker's histogram-PVS fix (625bc39, merged 6945009) the file
reads a histogram's vector sum as the unit stored it: K441LTON.900 stores
0.200 / 0.385 / 0.255 and a vector sum of 0.3852, as Blastware's report (was
0.503).  The 0C summary, read at fixed offsets, can shift (BE9441 read 0 and
-0.0, bench #4) -- and a shifted value can look plausible and pass the
impossible-value guard.  So the row now takes the file's channel peaks and
vector sum.

Only when the unit's settings confirm Normal range: the file reader computes
every peak as if the range were Normal (_GEO_SENSITIVE_FS_INS is defined but
unused), so a Sensitive unit's file peaks are 8x off (the checker's 33
waveforms).  For Sensitive, or a range not read (a monitoring unit's 1A has no
settings), the unit's own peaks stand, as before.  The mic is always the
unit's: the file still reads it as 0.  The 0C peaks remain the download check.

Store consequence: new live downloads only; no backfill, no migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-31 00:17:57 -04:00
serversdownandClaude Opus 5.5 69450093f6 merge: dev into feat/series4-sfm-parity -- a histogram's peak vector sum from the unit's stored value
Brings 0fc6806 (fix 625bc39, changelog dc42ae0) from the decode checker's
branch: a histogram's peak vector sum is the largest per-interval PVS the unit
stores (PVS^2 as uint32 BE), not a vector magnitude of per-channel interval
peaks.  K441LTON.900 reads 0.385, as Blastware's report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-31 00:13:15 -04:00
serversdownandClaude Opus 5.5 625bc39116 fix(decode): a histogram's peak vector sum is the one the unit stores
Every histogram interval carries its peak vector sum SQUARED, 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').  sqrt(stored) x 0.005 is
the Geo PVS Blastware prints: 1,668,073 / 1,668,074 standard and 34.5 M
sub-minute DL2 intervals checked against the _XML.XML reports.

SFM computed the event's PVS from each channel's interval peak, which
can come from different moments, and read high on 86% of DL2's
histograms (T004JTRF.ME0H: 1.782 against Blastware's 1.358).  It now
takes the largest stored interval value.  histogram_codec.interval_pvs
returns the per-interval series; records gain 'pvs_sq'.  Waveforms are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-10-30 01:29:58 -04:00
serversdownandClaude Opus 5.5 b6ed5f5bd5 feat(sfm): SFM's MiniMate files carry the W/H type letter Blastware's direct downloads leave off
Blastware names a direct download K441LTON.900 and only its call-in copy
K441LTON.900H, so a folder of directly downloaded events cannot be sorted by
kind.  SFM's own files now always carry the letter.  It is read from the file's
own record-type byte (STRT[18], #41) by the new with_type_letter() -- not from
the recording mode: BE9441's K441LTOK.R10 is a waveform that triggered 2 s into
histogram K441LTOK.QZ0 (Histogram+Continuous).  A file whose type does not read
keeps the plain name; a name never fails a download.

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

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-30 00:36:26 -04:00
serversdownandClaude Opus 5.5 50a0501147 test(sfm): a live MiniMate histogram is labelled Histogram (#8, via #41)
K441LTON.900 -- a direct download's name, with no type letter -- read
'Waveform' before #41 came in with a1d2b61 (verified failing first), and
'Histogram' from STRT[18] after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-29 23:58:52 -04:00
serversdownandClaude Opus 5.5 a1d2b61f22 merge: dev into feat/series4-sfm-parity -- #41, a Blastware event's record type from its bytes
Brings ede6292 (fix 46daea1, changelog b6fc71b) from the decode checker's
branch.  Completes #8's live S3 download path: a live histogram, whose direct
download name (K441LTON.900) carries no type letter, is now labelled from
STRT[18] instead of defaulting to Waveform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-29 23:57:41 -04:00
serversdownandClaude Opus 5.5 a72d3a98a9 fix(minimateplus): refuse a settings write whose four fields would not read back as asked (#1 review)
_encode_compliance_config patches the raw SUB 1A bytes at offsets measured at
1024 sps (April 2026), where the escape before 04 sits between the mode and the
anchor.  b320a53 moved the decoder to the measured layout (unescaped: mode -7,
rate -6, interval -4, record time +6), which exposed the encoder: on BE9441's
recorded 10-25 Continuous / 4096 block a mode change rewrote the byte in front
of the mode, and on the 10-26 Histogram+Continuous / 2048 block a sample-rate
change landed one byte off.  The old decoder read the same wrong bytes, so such
a write looked as if it had taken.

The encoder now decodes its own result with the decoder and raises ValueError
when mode, sample rate, interval or record time would not read back as asked
(or a field not asked for would change) -- before push_config_raw sends a byte.
No write offset is moved: rewriting the encoder on unescaped bytes is #46's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-29 23:56:44 -04:00
serversdownandClaude Opus 5.5 3a1d34ae92 fix(sfm): a download the store already holds is found by its Blastware name, not only its time (#8 review)
persist_download checked 'already stored' on the unit's 0C time only, but a
histogram's row is stored at its file's time, a second earlier on most
histograms (#51): K441LTOK.QZ0 decodes to 16:06:34, its 0C says 16:06:35.  So a
live download of an event the watcher had imported missed the check and
re-stored it -- UPSERTing over the watcher's row (Blastware's ZC frequencies and
vector sum lost) and rewriting its sidecar as sfm-live -- and every repeat live
download rewrote the files again.

New SeismoDb.find_event_by_blastware_name(): the row stored under the same
Blastware name (the event's second, per blastware_filename_time; the rule
_restamp_by_file uses), matching a direct name to the call-in copy's W/H name.
Any other name matches nothing.  Also two comments from 9492e49 that said the
opposite of the code (the unit's peaks are overlaid; source.kind is a parameter).

Store consequence: none for existing rows; no schema change, no migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-29 23:56:44 -04:00
serversdownandClaude Opus 5.5 dbd8a91661 fix(sfm): wake a MiniMate before the read-back reconnect reads its serial (#9 review)
The reconnect in ce441a0 opened a fresh connection and sent a bare 0x15 (the
identity check) before any SESSION_RESET + POLL.  It exists for a unit that has
just started -- sensor check, then monitoring -- and a monitoring MiniMate
ignores a bare request until woken (measured 2026-04-08), so the identity read
would have timed out and the start reported unconfirmed anyway.  Now: open,
wake (the same retried wake the read-back uses), read the serial, read 0x1C --
the order the status read and the legacy write routes use.  Still one
reconnect, TCP only, nothing re-sent.

The fake gains bare_requests_ignored (off unless a test asks): a fresh
connection's reads time out, with the real client's TimeoutError, until woken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-29 23:56:44 -04:00
serversdownandClaude Opus 5.5 9492e49400 fix(sfm): store a MiniMate download through the Blastware-file import path, as production does (#8)
A live Series-3 download was stored from the live 5A decode (store.save): a
histogram got no samples and nothing to plot (bench 2026-10-29).  The download
now carries the assembled Blastware file (DownloadedEvent.bw_bytes, built by the
new blastware_file_bytes -- byte-identical to Blastware's own K441LTON.900 and
K441LTOK.R10), and persist_download stores it through save_imported_bw, the
path the watcher uses for Blastware's files, the way Series 4 already uses
save_imported_idf.  The event is decoded from the file: histogram samples,
setup-block sample rate and record time (#44/#45).  source.kind is 'sfm-live'.

The file path does not yet read three things right (measured on BE9441): a
histogram's vector sum (0.503 where Blastware and the unit say 0.385 -- the
decode checker's open finding), the mic peak (0), and a sensitive range.  So the
unit's own 0C channel peaks, mic and vector sum are overlaid, as Series 4 does,
except an impossible vector sum (below the largest channel; BE9441's 0C read
-0.0, bench #4), and the unit's range is passed through for the stored samples.

Store consequence: new live MiniMate downloads only; existing rows and files are
untouched; no backfill, no migration.  The record type still reads 'Waveform'
for a live histogram until #41 (record type from STRT[18]) lands from the decode
checker's branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-29 23:27:44 -04:00