fix(minimateplus): size the 5A chunk cap from STRT, refuse a misread STRT, TERM only a tail
Follow-ups from the review of 887e75d (verdict: keep, with fixes; no critical).
- The cap: a caller's max_chunks (client.py passes 128) now bounds only a walk
whose end is unknown. With STRT it cut every event past ~66 KB short --
2,545 of 63,500 archived histograms are bigger (the review's count, DL2).
Strict raised; legacy sent a TERM for most of the event, or a bare ValueError.
- A STRT claiming less than one 0x200 chunk, or more than 4 MiB (a sanity bound,
not a measured limit), is refused as a misread, in both modes -- once a bare
ValueError and a 500.
- TERM is sent only for a true tail (< 0x200). After an early end the legacy
walk returns what arrived and sends none.
- build_5a_request wraps build_bw_frame; the old 5A helpers are marked
superseded (kept for tests/test_5a_protocol.py) and their imports dropped.
Tests: all 8 recorded events (were 4) walk exactly as Blastware and rebuild its
own files; an end key holding escaped bytes; a 300 KB event past a 128 cap; both
misread-STRT refusals; the 1A frames BE9441 answered post-fix; the checksum
vectors retargeted. Mutants the review saw survive (no STRT un-escape; a
standard-request escape revert) and 3 new ones are each caught.
Measured on the way: a reply's checksum is SUM8 of its unescaped payload,
748/748. The 'S3 checksums frequently fail' note was the parser summing its
own kept escape bytes; noted, parser unchanged.
Docs: the crossing count corrected to four (events 1, 3, 5, 7); the remaining
stale 5A sections in CLAUDE.md annotated; the write-frame suspicion recorded as
inferred only. No codec, store or DB change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
f61fc3cc78
commit
8acb9512a9
15 files changed
+285
-73
No files matched your search
@@ -10,7 +10,7 @@ pair — lives in `../terra-view/docs/tmi-stack.md`, which is also loaded as
|
||||
|
||||
---
|
||||
|
||||
## Where things stand (updated 2026-10-25)
|
||||
## Where things stand (updated 2026-10-26)
|
||||
|
||||
Read this first when picking the project back up.
|
||||
|
||||
@@ -150,11 +150,14 @@ Read this first when picking the project back up.
|
||||
|
||||
Series-3 downloads are now checked against the unit's own 0C peaks before
|
||||
being stored. **Re-run 2026-10-26:** every event that does not cross a
|
||||
64 KB page downloaded whole and verified (events 0, 1, 3, 4, 10). The two
|
||||
that cross one (events 2, 19) are refused by name. Stale id gives 409, a
|
||||
repeat gives `already_stored`. ⚠ Still owed before merge: a histogram event,
|
||||
`already_stored` against Blastware's copy, and start/stop through the new path
|
||||
(spec, phase 1b). Next: 1c (webapp).
|
||||
64 KB page downloaded whole and verified (events 0, 1, 3, 4, 10). ~~The two
|
||||
that cross one (events 2, 19) are refused by name.~~ **Later the same day the
|
||||
page bug was fixed** (see the ✅ FIXED entry below): a fresh 8 events, 4 of them
|
||||
crossing a page, all downloaded byte-identical to Blastware's own files. Stale
|
||||
id gives 409, a repeat gives `already_stored`, also against Blastware's imported
|
||||
copy. ⚠ Still owed before merge: a histogram event (and one over ~66 KB, the
|
||||
size a 128-chunk cap used to cut short; now sized from STRT, untested on a unit)
|
||||
and start/stop through the new path (spec, phase 1b). Next: 1c (webapp).
|
||||
- **✅ Phase 3: start / stop monitoring by serial (2026-10-23) — built,
|
||||
reviewed, and bench-verified on UM20147 (2026-10-25).** Start acked in
|
||||
0.46 s and read back as monitoring at the first 2 s poll (during the sensor
|
||||
@@ -246,7 +249,7 @@ Read this first when picking the project back up.
|
||||
relative), so do NOT retune `_GEO_LSB_IPS`.
|
||||
- **✅ FIXED 2026-10-26 (`887e75d`) — was: "KNOWN BUG — the 5A walk breaks once a unit's buffer crosses 64 KB."**
|
||||
Kept below as history. The fix came from a recording of Blastware downloading all 8 of
|
||||
BE9441's events, 3 crossing a page (`tests/fixtures/minimate-bench-10-26-26-blastware/`):
|
||||
BE9441's events, 4 crossing a page (`tests/fixtures/minimate-bench-10-26-26-blastware/`):
|
||||
- **Every MiniMate request DLE-escapes 02, 03, 04 and 10**, payload and checksum alike
|
||||
(748/748 re-encode). `build_bw_frame` had escaped only 0x10.
|
||||
- **A 5A request is an ordinary request carrying a LENGTH and a 4-byte linear ADDRESS.**
|
||||
@@ -260,6 +263,20 @@ Read this first when picking the project back up.
|
||||
⚠ Sections below that describe "partial DLE stuffing", "11-byte params", "offset_hi
|
||||
0x10 raw" and "metadata pages 0x1002/0x1004" are that misreading. They are retracted
|
||||
here, not deleted.
|
||||
**Review follow-ups (2026-10-26):** the walk's chunk cap is now sized from STRT (a
|
||||
caller's 128 cut every event past ~66 KB; 2,545 of 63,500 archived histograms are
|
||||
bigger); a STRT claiming less than one chunk or more than 4 MiB is refused as a
|
||||
misread; a TERM is sent only for a true tail. Still open, none measured: an event
|
||||
ending exactly on a chunk step sends a zero-length TERM (as the old code did; 1 in
|
||||
512, never seen); with no STRT the legacy walk still reads `max_chunks` blind.
|
||||
🔶 **Inferred only, do not act on it without a capture:** `build_bw_write_frame`
|
||||
("raw except BW_CMD", "DLE-aware checksum") carries the same fingerprints as the
|
||||
retracted 5A model: SUB 71's "offset 0x1004" reads as length 0x0400 escaped, and
|
||||
Blastware escapes `03` in write data. A write whose payload holds a bare
|
||||
02/03/04/10 may be malformed. One Blastware config-write capture settles it.
|
||||
🔑 **Replies follow the same rule (measured, 748/748):** every 02/03/04/10 escaped,
|
||||
checksum = SUM8 of the unescaped payload. The "S3 checksums frequently fail" belief
|
||||
is `S3FrameParser` summing its output with the `10` of `10 02/03/04` still in it.
|
||||
~~**⚠ KNOWN BUG — the 5A walk breaks once a unit's buffer crosses 64 KB.**~~
|
||||
`parse_strt_end_offset()` returns only `(end_key[2] << 8) | end_key[3]`,
|
||||
discarding the key's page byte. An event starting at `0x0111F2A2` and ending
|
||||
@@ -530,7 +547,7 @@ Full read pipeline + write pipeline + erase pipeline + monitor log + call home c
|
||||
| Event header / first key | 1E | ✅ |
|
||||
| Waveform header | 0A | ✅ |
|
||||
| Waveform record (peaks, timestamp, project) | 0C | ✅ |
|
||||
| **Bulk waveform stream (event-time metadata + full waveform)** | **5A** | ✅ **byte-perfect against BW captures (v0.14.3, 2026-05-05)** — STRT-bounded chunk walk + correct event-N probe counter + DLE-stuffed `0x10` bytes in params + concatenate-only file body assembly. All 17 5A request frames in the 5-1-26 3-sec capture reproduce byte-for-byte. |
|
||||
| **Bulk waveform stream (event-time metadata + full waveform)** | **5A** | ✅ **(2026-10-26: a LENGTH read at a 32-bit ADDRESS, every 02/03/04/10 escaped — the model in the rest of this cell is retracted, see "✅ FIXED 2026-10-26")** byte-perfect against BW captures (v0.14.3, 2026-05-05) — STRT-bounded chunk walk + correct event-N probe counter + DLE-stuffed `0x10` bytes in params + concatenate-only file body assembly. All 17 5A request frames in the 5-1-26 3-sec capture reproduce byte-for-byte. |
|
||||
| Event advance / next key | 1F | ✅ |
|
||||
| **Write commands (push config to device)** | **68–83** | ✅ new v0.8.0 |
|
||||
| **Erase all events** | **0xA3 → 0x1C → 0x06 → 0xA2** | ✅ new v0.9.0 |
|
||||
@@ -994,6 +1011,11 @@ several events should read 0x1002/0x1004 only once at the start.
|
||||
`read_bulk_waveform_stream`.
|
||||
|
||||
### SUB 5A — STRT record encodes end_offset (NEW 2026-05-01)
|
||||
> ⚠ **SUPERSEDED 2026-10-26:** the end is the FULL 32-bit `end_key`
|
||||
> (`parse_strt_end_key`), read after removing the reply's escape bytes. The 16-bit
|
||||
> `end_offset` below was the 64 KB page bug, and misread any end whose low bytes held
|
||||
> an escaped 02/03/04.
|
||||
|
||||
|
||||
The first A5 response (probe response, or the first chunk for event 2+) contains a STRT
|
||||
record at byte offset 17 of the `data` field. Layout:
|
||||
@@ -1023,6 +1045,11 @@ Verified across 3 events:
|
||||
| 5-1-26 "copy 2nd address" / DA event 2 | `011121F2` | `0111417E` | `0x417E` (event 2 span 0x1F8C = 8,076 B) |
|
||||
|
||||
### SUB 5A — TERM frame formula (FINALIZED 2026-05-01)
|
||||
> ⚠ **SUPERSEDED 2026-10-26:** TERM is `build_5a_request(next_boundary, end -
|
||||
> next_boundary)`: a read of the remainder at the next 32-bit boundary. "offset_word"
|
||||
> is that length; "params[2:4]" are the address's low bytes. The tables below still
|
||||
> hold as numbers.
|
||||
|
||||
|
||||
The TERM frame fetches the partial last chunk *and* the file footer. It is **not** a simple
|
||||
"goodbye" frame — its response payload contains the bytes between the last full 0x0200-aligned
|
||||
@@ -1096,6 +1123,9 @@ confirmed from the BW wire capture. `bulk_waveform_term_params()` returns 10 byt
|
||||
Do not swap them.
|
||||
|
||||
### SUB 5A — event-time metadata source (FINALIZED 2026-05-05)
|
||||
> ⚠ **AMENDED 2026-10-26:** the strings come from the first event's chunks at 0x0200 and
|
||||
> 0x0400, not from "global pages read once per session" (see the retraction above).
|
||||
|
||||
|
||||
The metadata strings come from the two fixed metadata pages at counter `0x1002` and
|
||||
`0x1004` (see "SUB 5A — fixed metadata pages 0x1002 and 0x1004" above). These pages
|
||||
@@ -1137,6 +1167,11 @@ that's an old-walk artifact (the broken `0x0400`-step formula occasionally caugh
|
||||
pages instead.
|
||||
|
||||
### SUB 5A — end-of-stream (FINALIZED 2026-05-01)
|
||||
> ⚠ **AMENDED 2026-10-26:** a reply's `page_key` is not a page. It is the echoed
|
||||
> length plus an escape byte the parser keeps: all 532 chunk replies read `0x0010` and
|
||||
> the 8 TERMs `0x0000`/`0x0001`. The walk relies on it only for the mid-stream
|
||||
> terminator check, and now sends TERM only for a tail (< 0x200).
|
||||
|
||||
|
||||
Under the v0.14.0+ STRT-bounded walk the stream ends cleanly:
|
||||
|
||||
@@ -1302,6 +1337,7 @@ Confirmed from the 5-1-26 "Download All" capture:
|
||||
1F → null sentinel
|
||||
```
|
||||
|
||||
(⚠ 2026-10-26: the walk starts at the 0x46 key itself, as a plain 32-bit address.)
|
||||
This is why event 2's first 5A chunk is at `start_key + 0x46` — that's the address of the
|
||||
"real start" 0x46-record, distinct from the `0x2C`-record at the raw boundary. Use the
|
||||
`0x46` keys as the input to `read_bulk_waveform_stream`, not the `0x2C` keys.
|
||||
@@ -1563,12 +1599,12 @@ All DB endpoints are read-only except `PATCH /db/events/{id}/false_trigger`.
|
||||
|
||||
| Capture | Location | Contents |
|
||||
|---|---|---|
|
||||
| 1-2-26 | `bridges/captures/1-2-26/` | SUB 5A BW TX frames — confirmed 5A frame format, 11-byte params, DLE-aware checksum |
|
||||
| 1-2-26 | `bridges/captures/1-2-26/` | SUB 5A BW TX frames — confirmed 5A frame format, 11-byte params, DLE-aware checksum (⚠ that model retracted 2026-10-26: a standard frame, length + 32-bit address) |
|
||||
| 3-11-26 | `bridges/captures/3-11-26/` | Full compliance setup write, Aux Trigger capture |
|
||||
| 3-31-26 | `bridges/captures/3-31-26/` | Complete event download cycle (148 BW / 147 S3 frames) — confirmed 1E/0A/0C/1F sequence; only 1 event stored so token=0xFE appeared to work |
|
||||
| 4-3-26 | `bridges/captures/4-3-26/` | Browse-mode S3 capture with 2+ events — confirmed all-zero params for 1F, 1F response layout, null sentinel, 0A context requirement |
|
||||
| 4-27-26 | `bridges/captures/4-27-26/` | BW "open 2sec waveform" + "copy event to disk" + paired SFM "seismo_dl" — first proof that SFM was over-reading 5× past event end. BW reads 14 chunks at 0x0200 increments + TERM at end_offset; SFM was reading 37 chunks at 0x0400 increments. STRT end_key field located. |
|
||||
| 5-1-26 | `bridges/captures/5-1-26/comcheck/` | Three sub-captures: SFM 3-sec download (`seismo_dl_…`), BW comms-check + 3-sec download (`bwcap3sec/`), BW second-event download + "Download All" (`raw_*_170945`/`_171216`). Confirmed: TERM frame formula across 3 events; metadata pages 0x1002/0x1004 are global (read once per session); event-1 vs event-N chunk-pattern split; WAVEHDR length 0x46 vs 0x2C disambiguates real events from boundaries. |
|
||||
| 5-1-26 | `bridges/captures/5-1-26/comcheck/` | Three sub-captures: SFM 3-sec download (`seismo_dl_…`), BW comms-check + 3-sec download (`bwcap3sec/`), BW second-event download + "Download All" (`raw_*_170945`/`_171216`). Confirmed: TERM frame formula across 3 events; metadata pages 0x1002/0x1004 are global (read once per session) (⚠ retracted 2026-10-26: event 1's chunks at 0x0200/0x0400); event-1 vs event-N chunk-pattern split; WAVEHDR length 0x46 vs 0x2C disambiguates real events from boundaries. |
|
||||
|
||||
---
|
||||
|
||||
@@ -2184,7 +2220,7 @@ body) because writing a dial string may require DLE escaping for embedded contro
|
||||
|
||||
| Folder / File | Contents |
|
||||
|---|---|
|
||||
| `1-2-26/` | First SUB 5A BW TX capture — established 5A frame format (raw offset_hi, DLE-aware checksum). 10 frames verified. |
|
||||
| `1-2-26/` | First SUB 5A BW TX capture — established 5A frame format (raw offset_hi, DLE-aware checksum). 10 frames verified. (⚠ model retracted 2026-10-26) |
|
||||
| `3-11-26/raw_bw_20260311_170151.bin` | Full compliance write + event download (SUBs 68→83 confirmed, frames 102–112) |
|
||||
| `3-31-26/` | Single-event download (148 BW / 147 S3 frames) — 1E/0A/0C/1F sequence confirmed (single event so token=0xFE appeared to work in either branch) |
|
||||
| `4-2-26/` | Download-mode BW TX capture — POLL×3 requirement confirmed (frames 68-73 between 1F and first 5A) |
|
||||
@@ -2196,7 +2232,7 @@ body) because writing a dial string may require DLE escaping for embedded contro
|
||||
| `4-20-26/geo sensitivity/` | Geo sensitivity changes: 1.25 in/s (Sensitive), 10 in/s (Normal) |
|
||||
| `4-20-26/call home settings/` | Call home config read/write captures |
|
||||
| `4-27-26/` | BW "open 2sec waveform" + "copy event to disk" + paired SFM "seismo_dl" — first proof of 5× SFM over-read. STRT end_key field located. |
|
||||
| **`5-1-26/comcheck/`** | **Triplet of captures that nailed the v0.14.0 walk:** SFM 3-sec download (`seismo_dl_…`), BW comms-check + 3-sec download (`bwcap3sec/`), BW second-event download + "Download All" (`raw_*_170945` / `_171216`). Confirmed: TERM frame formula across 3 events, metadata pages 0x1002/0x1004 are global session metadata, event-1 vs event-N chunk pattern split, WAVEHDR off=0x46 vs 0x2C disambiguates real events from boundaries. |
|
||||
| **`5-1-26/comcheck/`** | **Triplet of captures that nailed the v0.14.0 walk:** SFM 3-sec download (`seismo_dl_…`), BW comms-check + 3-sec download (`bwcap3sec/`), BW second-event download + "Download All" (`raw_*_170945` / `_171216`). Confirmed: TERM frame formula across 3 events, metadata pages 0x1002/0x1004 are global session metadata (⚠ retracted 2026-10-26: event 1's chunks at 0x0200/0x0400), event-1 vs event-N chunk pattern split, WAVEHDR off=0x46 vs 0x2C disambiguates real events from boundaries. |
|
||||
| **`5-1-26/comcheck/bwcap3sec/`** | **The byte-perfect reference for v0.14.3.** All 17 BW 5A request frames (probe, 2 metadata, 13 samples, TERM) reproduce byte-for-byte from SFM's framing helpers — including the `10 10 00` DLE-stuffed counter for sample @ 0x1000 that was the long-standing failure mode. |
|
||||
| `5-4-26/` | BW MITM captures of "copy 3sec / 2sec / Download All" + paired SFM session (`seismo_dl_20260504_145701`) showing the +0x46 event-N probe bug producing 110-chunk runaway walk. Cross-references against 5-1-26 confirmed device behavior is identical. |
|
||||
|
||||
|
||||
Reference in new issue
Block a user