Files
seismo-relay/docs/superpowers/specs/2026-11-03-sfm-phase5-settings-design.md
serversdownandClaude Opus 5.5 3564c4a744 docs: phase 5 benched on both series (2026-11-04)
Both protocol references, the spec's bench section and CLAUDE.md record
the bench: every settings change acknowledged, read back and confirmed on
the unit's screen, both units restored byte for byte; the escaped-
checksum stray byte (fixed); a MiniMate's open setup menu writes its
whole-block copy back on Cancel or Save, losing a remote change; the
alarm write at channel +38; [26:28] re-set by the unit while monitoring;
the first Micromate setup push with the unit's CRC equal to SFM's; the
Micromate scheduler switch in none of the blocks SFM reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-04 16:16:40 -05:00

23 KiB
Raw Permalink Blame History

Phase 5: changing a unit's settings by serial (design)

Date: 2026-11-03. Status: approved by Brian 2026-11-03; built 2026-11-03 (plan docs/superpowers/plans/2026-11-03-sfm-phase5-settings.md); benched 2026-11-04 on both series (results at the end). Phase 5 of docs/superpowers/specs/2026-10-20-sfm-series4-parity-design.md (row 10, "change recording settings"; build phase 5, "setup push: one field first, then several"). Branch: feat/series4-sfm-parity.

Intent (Brian, 2026-11-03)

Change any of a unit's settings from SFM, and make it as easy and reliable as possible. The goal is to fix what makes Blastware finicky. Three real cases:

  • One wrong number on a deployed unit. UM6047 was out monitoring with its geophone trigger at 0.03 instead of 0.300. Brian remoted into the THOR PC, stopped it (it called in), changed the setup, made sure it was sent, then restarted monitoring.
  • A typo in the notes.
  • A backup unit. The unit set up at the office fails in the field, so a backup from the truck goes in with blank or stale notes and settings. There is no computer in the field, so the office re-does the whole setup remotely, by hand, while the person in the field stands by to press Start or power-cycle if the link breaks.

What is wrong with THOR, as Brian and his dad experience it:

  • The same screen edits a setup on disk and views a unit's setup.
  • Setups get saved under random number strings.
  • Editing a setup does not change the unit; you verify separately that it was sent.

Saved setups as templates would be acceptable. Not knowing whether you are changing the unit or a file is not.

Goals, non-goals, anti-goals

Goals

  • Edit the unit's live settings, both series.
  • Show exactly what will change, old → new, before anything is sent.
  • After sending, re-read the unit and show what it now holds.
  • Make every refusal say why, in plain words.

Non-goals (this phase)

  • Templates, saved setups, copying from another unit.
  • Restarting monitoring. Brian presses Start, as today; SFM never restarts on its own.
  • Setting the unit's clock. That is a later call-home receiver rule.
  • Writing the Micromate scheduler. Next project, agreed 2026-11-03: "record during work hours" as a plain, configurable setting on the unit's page, both series, no schedule library and no setup files. On the Micromate, it relies on the firmware's setup-less scheduler start (found in the firmware, never sent; one bench session). On the MiniMate, its own timer setting (undecoded). Brian's dad despises THOR's scheduler; Brian is willing to retire it in SFM.
  • Fields not yet decoded. "Any and all" grows as decoding grows.

Anti-goals: things that would make it a failure even if it "works"

  • Any doubt about whether the unit changed.
  • A screen where a file and a unit look alike, or a name SFM made up.
  • Writing a byte SFM did not just read. Every byte SFM does not deliberately change goes back exactly as read. The one exception is a byte that Blastware's (or THOR's) own writes always set to a fixed value. Each such byte is named in the codec with its evidence (so far: Series 3 [26:28] → 00 00; my call, below).
  • Sending to a monitoring unit.
  • A retry. A write is sent once; what happened is read back.

Measured basis

1. Series 4 (Micromate): the 0x1A setup content map. Measured from 47 keypad snapshots on UM20147 and checksum-verified. micromate/setup_block.py (decode_setup) reads it, with 69 tests on 15 fixtures.

content field
[5] record mode
[6:8] sample rate
[8:10] histogram interval
[12:16] pre-trigger, f32, negative
[17] stop mode
[18:22] record time, f32
[23] auto-stop
[25] active sensors
[29] trigger sources
[30:34] distance
[34:38] charge
[39] report flags
[40:42] job number
[42:86] setup name
[122+64n] / [144+64n] notes (label / value)
from [1708] 48-byte channel blocks: sensor code +4:8, trigger +30 (geo in/s, mic psi)

The CRC-16/AUG-CCITT over [0:2088] is stored at [2090:2092]; THOR's write omits it and the unit recomputes it.

  • The push sequence (from THOR's captures) is 0xDA (name) → 0x68/0x73 (0x08 preferences) → 0x82/0x83 (0x2E trigger) → 0x71/0x72 (0x1A setup). micromate.writes.plan_setup_push reproduces THOR's frames (phase 2).
  • Not yet mapped on Series 4: alarm level, geophone range, GPS, aux I/O, SLM options.

2. Series 3 (MiniMate) uses the same layout. Measured 2026-11-03. The compliance image as Blastware writes it is logical (unescaped), 2,092 bytes, with N = 2090 at [0:2] and the channel block "Tran" at [1708]. micromate.setup_block.decode_setup reads it correctly:

  • BE9441's 10-26 write (tests/fixtures/minimate-bench-10-26-26-histogram, two whole sends): name, mode, 4096 sps, interval, record time 20 s, trigger 0.04 in/s, mic linear, job number and the notes all decode. Only the CRC fails (Series 3's tail goes out stale).

  • BE11529's nine 2026-04-20 Blastware writes (bridges/captures/4-20-26/, every one with a whole image) each changed exactly the expected bytes:

    Blastware changed bytes that moved
    histogram interval (×4) [8:10]
    recording mode (×3) [5]
    geophone range 1737 / 1785 / 1833, the range byte at each geophone channel label +29
  • The live SUB 1A read starts the same block. Measured on the first data frame of each of the four recorded reads (_settings_replies in tests/test_s3_compliance_anchor_fields.py): unescaped, each carries N = 2090 12 bytes before the old "anchor", and content [5] reads 1 / 4 / 3 / 3. That anchor (be 80 00 00 00 00) is content [12:18], pre-trigger −0.25 plus stop mode Fixed. So Series 3 can be read by content offset rather than by anchor search, which survives an Auto-stop unit (the open question of 2026-10-17).

  • A whole 1A read assembles to exactly the 2,090 content bytes (measured 2026-11-03 on BE9441's 10-26 recording, 12 reads). Unescape each data frame and take data[11:]. Every frame but the last then starts with one 00 byte that is not content; drop it. This holds for Blastware's read (four 512-byte frames plus 42) and SFM's (two 1024-byte frames plus 42).

    • The round trip is exact. Blastware re-read the block after each of its two writes, and each re-read equals the image it had just written, all 2,090 bytes.
    • While monitoring, the read returns 0e 'BE9441' … (the device-info block), as the 10-29 finding says. The unit was monitoring for 5 of the 12 reads.
  • Bytes [26:28]: Blastware always writes 00 00 (all 11 writes), though the unit reads 01 7f after a monitoring session (BE9441 10-26, BE11529 4-20 15:19). The unit sets them again by itself. Meaning unknown.

  • The two bytes after the block are Blastware's own. Blastware sends a per-unit constant: 7c ea on all nine of BE11529's writes, 0c e9 on both of BE9441's. It is not the block's CRC-16/AUG, and no reply in BE9441's three-hour session contains it. SFM's write_image sends 00 00 there. Since a read never returns those bytes, the read-back cannot show what the unit did with them.

  • The mode byte is shared, but its codes are not. Series 3: 00 Single Shot, 01 Continuous, 03 Histogram, 04 Histogram + Continuous. Series 4: 01 Waveform, 02 Manual, 03 Histogram, 04 Combo.

  • Rules from the checker's file-side work (seismo-relay-b6, 2026-11-03; it measured the same content offsets on 70,042 event files and found nothing that contradicts one shared map):

    • A bitmask byte is patched bit by bit, never rebuilt. The trigger-sources byte [29] showed an unidentified 0x80 bit on one unit.
    • On Series 3, stop mode (0 Fixed) and mic type (2 linear) are proven for one value each. They are not offered for writing.
    • An event file's [12:16] is that event's captured pre-trigger, not the setting. SFM writes only from a live read, so this matters only to anyone tempted to build a write from a file.
  • Series-3-only fields (measured on Series 3, not Series 4): the geophone range byte at channel +29; the alarm level at channel +38 (checker-measured on event files; live raw +42).

3. Series 3 write frames are measured (#46). Writes use uniform escaping with a length field. The compliance image goes in 512-byte addressed chunks. 0x68 is written as read plus 02 00, 0x82 plus 00 00. The sequence is 68→73 | 71×n→72 | 82→83 | 69→74→72. push_config_raw refuses any block that is not whole. tests/test_minimate_write_frames.py rebuilds Blastware's frames byte for byte.

4. Monitoring.

  • Series 3: while monitoring, the unit answers 1A (and 0x2C) with its device-info block (measured 10-29 and 11-03).
  • Series 4: it refuses call-home setup while monitoring ("Feature disabled while monitoring", measured 11-03).
  • A stop with call-home on makes the unit call in (measured 10-25, 10-29, 11-03).

5. Series 4 specifics.

  • 0x1A reads the keypad's edit buffer live: unsaved keypad edits show in the read, and a push would commit them.
  • Loading a .MMB replaces the active config byte for byte. The push writes under the active setup's name (0xDA).

The flow

  1. Read. GET /device/settings?serial=… (it exists) returns the unit's settings. The page shows them on the Config tab under "On the unit BE9441 — read 14:03", never anything that looks like a file.
  2. Edit and preview. The operator changes fields, then Preview: a dry run. SFM re-reads the unit's blocks on the same line, builds the new blocks, and returns one row per field: old → new, plus any warnings. Nothing is sent.
  3. Send. The same request, live, is an audited change:
    • identity check, audit row, one send, never retried, read back;
    • refused with "stop monitoring first" if the unit is monitoring, noting that the stop makes it call in when call-home is on;
    • refused if the unit's settings changed since the preview. The preview carries a revision (a hash of the blocks read), and the live call must match it.
  4. Verify. Re-read the blocks. Every changed field must read its new value. Every other decoded field, and every byte SFM did not deliberately change, must read as before. The page shows "the unit now holds": field, old, new, now. Known unit-maintained bytes (the Series-4 CRC) are compared as the unit's own checksum (crc_ok), not byte for byte.
  5. Start stays the operator's button.

Fields in the first version (Brian approved the list)

field Series 3 Series 4
geophone trigger level yes (channel +30) yes (channel +30)
alarm level yes (channel +38; measure live) not mapped, so not offered
notes: the four note slots, by the unit's own labels yes (Project:, Client:, User Name:, Seis. Loc: on BE9441) yes (Location, Client, Company, General Notes)
recording mode yes ([5]; values as measured on Series 3) yes ([5]; Series-4 codes)
sample rate yes yes
record time yes yes
histogram interval yes yes
geophone range yes (channel +29) not mapped, so not offered
job number (+ shown on report) yes yes

A field is offered only where it is measured for that series. Values are refused unless they are among the measured choices: sample rates 1024/2048/4096, intervals 2/5/15/60/300/900 s, and each series' measured mode codes.

  • Numbers: the units' own limits (Brian, 2026-11-03: "I want to use the actual unit limits, not just what we have done in the past"). From Instantel's operator manuals in ~/seismo-relay/manuals/:
    • Geophone trigger: 0.005–10 in/s in steps of 0.001 (MiniMate Plus manual 716U0101 Rev 15, Appendix Series III Specifications; Micromate manual 721U0201 Rev 06, Geophone Trigger Level). It is also capped at the range's full scale (10 / 1.25 in/s). When range and trigger change in one request, check the trigger against the new range.
    • Record time:
      • Micromate: 1–90 s (Record Time).
      • MiniMate: from 1 s to the manual's §4.4 Maximum Record Times for a 1 MB unit, four channels, at the chosen sample rate: 104 s at 1024 sps, 52 s at 2048, 26 s at 4096. In Histogram Combo, 13 s (§3.8.9). The units measured report about 960 KB in total memory (BE11529: 983,026 bytes), the 1 MB model.
    • Job number: 1–9999 (both manuals).
    • The read-back is the safety net. A unit that does not take a value (for instance, cuts a record time to what its memory allows) shows as not taken, with what it actually holds.
    • Values seen across 75,958 Blastware reports (2016–2026) sit well inside these limits: trigger 0.005–0.500 in/s, record time 1–10 s, job number 1.
    • Units: refuse a level write unless the channel's unit string reads the measured one (in. for a geophone). A unit set to Metric is unmeasured.
  • Notes: edited by slot, under the label the unit itself shows (labels can be renamed and are not identifiers). The value is at most its field width less one byte, printable ASCII.
    • Not in v1: Series 3's fifth slot, Extended Notes (value \n on BE9441). Blastware's extended notes are unmeasured and may live elsewhere.
    • Not in v1: Series 4's 16-byte field at content [1064] (Loc 1 on UM12947), undecoded.

Architecture

  • One setup-block codec for both series. Keep micromate/setup_block.py as the field map and add encode_setup(content, changes) -> content: field patches only, every other byte as given. It stays a pure codec library: no I/O, no sfm imports, no import cycle with minimateplus. Series-specific fields (the Series-3 range and alarm) are marked by series.
  • Series 3 read. Assemble the 1A read into the logical 2,090-byte block: unescape, strip the 12-byte reply prefix and the inter-frame headers (read_compliance_config). Decode it by content offset.
  • Series 3 write. The patched logical block plus the tail becomes the compliance image for push_config_raw. Event index (0x08), trigger (0x2E) and waveform data (0x09) are echoed as read, in Blastware's sequence.
    • On 0x09, Blastware echoed the unit's bytes on all nine April writes ([200:202] = 8c 76 read and written). Only BE9441's 10-26 writes changed them (17 17 read, 78 76 written, and read back so). The meaning is unknown, so SFM echoes.
    • The raw-offset _encode_compliance_config is retired.
  • The legacy write (/device/config, /device/config/project) is retired (my call). It retries a whole write on a TCP error, is not audited, does no read-back, does not refuse a monitoring unit, and needs no serial: every anti-goal at once. Its only user is the webapp's by-host Config form, and Terra-View does not call it. Its routes answer with a pointer to the by-serial change, and the by-host form becomes read-only.
  • Series 4 write. plan_setup_push(prefs, trigger, patched_setup, name).
    • No setup files in the operator's view (Brian, 2026-11-03). "We treat the Micromate setups just like Minimate setups … the unit just has its settings, and we change it based on the job. We don't send setups to the unit." A backup unit is usually on whatever setup its previous job left. So SFM rewrites the setup the unit is running, in place, under its own name. It never asks for a file or a name, and never creates one. The name may show as a read-only detail, since the unit's screen shows it.
    • The scheduler can undo a change (Brian, 2026-11-03, with THOR's Manage Schedules screen). Work-hours Micromates run a THOR schedule, e.g. Start Monitoring 07:00 with setup Mele-PWSA-Carroll -Loc 4, stop 18:30, repeat daily. THOR sends the schedule with its setup, and each scheduled start loads the setup it names. So the preview and the send read schedule.dat (format decoded, reference The schedule record format), read-only. A start action naming a setup other than the one being changed blocks the send: "this unit's schedule loads at 07:00, which would replace this change." When the schedule names the active setup (the usual case after a scheduled start), the change survives, and the preview says when the next scheduled start is. SFM never writes the schedule in this phase.
    • The name comes from the 0x41 read, unstripped.
    • Refuse factory.MMB and any target that is not the active setup (spec). The refusal says it plainly: "this unit is running its factory setup; load any other setup on its keypad, then try again." Brian says the team does not use the factory setup, so this should be rare.
    • ENABLEABLE_WRITES gains 0xDA 0x68 0x73 0x82 0x83 0x71 0x72.
    • The keypad edit buffer: warn in the preview that a unit with someone in its menu would have those edits committed. The check the spec names, 0x1A against the active .MMB via 0x94/0x48, is a bench question first.
  • The change path. It keeps run_change's guarantees: identity, audit, one send, read back, ChangeUnconfirmed with sent/audit_id. The "state" is a set of fields, so either run_change takes a verify function or a sibling core shares its parts. The builder decides; the guarantees do not change. The audit row keeps the per-field changes, both blocks (hex) and the verdict.
  • Routes. POST /device/settings/change?serial=… (serial required) with body {changes: {field: value}, revision} and dry_run, caller. The response is per-field old / new / now, through _change_response. A dry run needs no revision and returns one. A live call without the revision of a preview is refused (my call): nothing reaches a unit unless someone saw old → new.
  • Page. The Config tab by serial becomes the unit's edit form: Preview → Send (confirm) → "the unit now holds". New logic goes in sfm/static/device_routing.js with Node tests, and glue in sfm/static/sfm_webapp.js (no inline JS).

Verification

  • Series 3, byte for byte. For each of the 11 Blastware compliance writes, apply the new encoder to the read before it (or the previous image), with the fields Blastware changed. It must reproduce Blastware's content [0:2090]. The two trailing bytes are compared separately, since they are Blastware's constant. Ten writes change one field. BE9441's 16:26 write changes five things: mode, sample rate 2048 → 4096, interval, the mic in the sensors byte [25], and [26:28]. That one is tested with all of them, through the codec, though v1's page does not offer the sensors byte. The frames rebuild through push_config_raw's path (the #46 tests).
  • Series 3, read side. The assembly rule above, pinned as a test on the 12 reads of BE9441's 10-26 recording. Each read-back equals the write before it.
  • Series 4. THOR's setup-push captures still reproduce, with no field changed. Any capture where THOR changed a field becomes a byte-for-byte test.
  • Bench, with Brian's go per send, per series:
    1. A dry run of a trigger change, then send, read back, check the unit's menu, and change it back.
    2. A notes change.
    3. A several-field "backup unit" change.
    4. A dry run while monitoring, expecting the refusal.

Bench 2026-11-04 (results)

Brian at BE9441 and UM20147, each on its own modem; every send with his go. Notes: ~/bench-logs/2026-11-04-sfm-settings/.

  • Both series change correctly. Each change was acknowledged, read back as sent, and confirmed on the unit's own screen; both units ended byte for byte as found.
    • BE9441: trigger each way, a note, several fields at once, the alarm, a full restore.
    • UM20147: trigger, several fields (two notes, job number and its flag, record time), a full restore. The unit's recomputed CRC equalled SFM's.
  • Fixed at the bench (9992b25): the first live MiniMate read came back one byte long. An escaped checksum byte leaves its 0x10 behind (about 1 frame in 85; the recordings never had it). The read now takes exactly the lengths it asked for, and so does the waveform read (c790e20).
  • 🔑 The keypad menu wins. A MiniMate change sent while its setup menu is open is acknowledged and read back, then lost when the operator presses Cancel or Save: the menu writes its copy of the whole block back. SFM cannot see this happen; the MiniMate preview now warns. Rule for the field-plus-office routine: nobody in the unit's menus while the office sends.
  • The MiniMate alarm write is measured, so it is now writable (55c7b7b).
  • Refused while recording, both series, nothing sent. A recording MiniMate sometimes leaves a preview at "no answer" rather than the refusal.
  • The Micromate scheduler switch is in no block SFM reads. UM20147 carries a leftover THOR schedule (Fay setup, 07:00 daily) with the switch Off; SFM blocks it, a false alarm here. The bench used a scratch-only override.
    • Next: a THOR bridge recording to find the switch (parked for work hours).
    • Meanwhile, worth considering: let the operator confirm "scheduler off" in the preview.

Calls I made (Claude), for Brian to check

  • Series 3 [26:28] goes out as 00 00, as Blastware writes it, rather than the 01 7f the unit may read. Measured beats inferred: Blastware's value is on 11 accepted writes, and writing back 01 7f has never been tried.
  • The two bytes after the Series 3 block stay 00 00, as write_image sends them (a unit accepted that in the April 2026 test). Blastware's per-unit constant cannot be derived from anything SFM reads. The first bench write checks that the unit takes the block, and its menu shows the change.
  • The 0x09 block is echoed as read, as Blastware did on all nine April writes.
  • Level writes are refused unless the channel's unit string is the measured in. / in (a unit set to Metric is unmeasured).
  • Notes are edited by slot under the unit's own labels, four slots on each series. Series 3 extended notes and Series 4's separate location field wait.
  • The legacy by-host write is retired; the by-host form becomes read-only.
  • A live send needs a preview's revision.
  • Preview re-reads the unit rather than trusting the page's copy, and Send refuses if the unit changed since the preview.
  • The edit form lives on the Config tab, by serial, replacing the legacy read-modify-write form for units reached by serial.

Left to the builder

  • The module layout for the shared codec, within the no-cycle, pure-codec rule.
  • run_change generalised versus a sibling core.
  • The exact revision hash.
  • Page layout details.