8 Commits
Author SHA1 Message Date
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
serversdownandClaude Opus 5.5 6f31eca366 docs: the 64 KB page bug is fixed; the 5A 'non-standard frame' model retracted in place
CLAUDE.md: the KNOWN BUG entry marked fixed (887e75d) with what settled it, and
retraction notes under the 5A sections that described the misreading (partial
stuffing, offset_hi 0x10 raw, 11-byte params, metadata pages 0x1002/0x1004).
Series-III reference: a 2026-10-26 (3) row.  Spec: the MiniMate check updated.
Code comments that called the page bug open, updated; the adapter's struct.error
mapping kept as a defence, its message and test no longer naming the old bug.

Verified live on BE9441 the same day: all 8 events downloaded by serial, the 4
that cross a 64 KB page included, each whole and matching the unit's own peaks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-26 14:44:11 -04:00
serversdownandClaude Opus 5.5 a7214c50de test: the Series-3 fake downloads a real event -- c32a9e7 was pushed with 4 tests failing
c32a9e7 made the download check read the 5A body; the Series-3 fake handed
back placeholder frames (['frame']), so 4 plumbing tests in
test_device_access_s3_events.py and test_device_access_event_dispatch.py
failed with "'str' object has no attribute 'data'" -- and that commit was
pushed without the failure set being read.  The fake's one-event download now
carries what a real one does: BE9441 event 1's recorded frames, their decoded
waveform and the unit's own peaks for it.  Those tests now see verified=True
on a whole event.  Suite back to the 16 known fixture failures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-25 18:49:44 -04:00
serversdownandClaude Opus 5.5 4e1e6a9d5c fix(sfm): Series-3 events list with no record type, not a wrong one
minimateplus's _extract_record_type returns "Waveform" for every 0C
record layout -- it cannot tell a histogram -- so a MiniMate histogram
was listed as "waveform".  The fake's "Histogram" was a value the real
client never produces, which is why no test saw it.

- _s3_ref: record_type is always None, with
  detail.record_type_note = "Series 3's event record does not say
  waveform or histogram; not decoded yet".
- default_s3_events(): both events "Waveform", as the real client gives.
- The shared-shape contract test allows exactly {"record_type"} to be
  None for Series 3 and nothing for Series 4.

Rows SFM stores for Series 3 still carry "Waveform" from the decode (the
same as the legacy blastware_file route); parked in the spec.  No codec,
store or DB change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-21 17:40:26 -04:00
serversdownandClaude Opus 5.5 59dff06f1c fix(sfm): the Series-3 header walk fails loudly, and listing uses the normal timeout
One lost 1F reply made the list return 1 of 3 events as a 200, and on a
download gave a false 404.  The list also ran on the 120 s download
timeout, so each lost reply stalled the walk 120 s with the unit locked.

- get_events() strict mode (headers_only, or only_key): a lost 0A reply,
  a lost 1F(browse) reply on the success path and on the partial-record
  path all re-raise their ProtocolError; a 1F that hands back a key
  already walked raises ProtocolError("event chain did not advance ...").
  Legacy calls (none of the new options) behave exactly as before --
  pinned by tests of the same three faults under get_events().
- Series3Adapter.list_events runs on the default timeout (10 s on TCP);
  download_event keeps 120 s.
- FakeProto gains optional lost-reply injection; its default is unchanged.

The repeat-key guard sits at the loop head, which is reached only for a
non-null key -- equivalent to checking each 1F's key, in one place.

Read-only; nothing new on the wire.  No codec, store or DB change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-21 17:39:54 -04:00
serversdownandClaude Opus 5.5 01b9188f25 fix(sfm): a stale Series-3 id is refused before the full download, not after
Series3Adapter.download_event compared the timestamp only after
download_event_by_key had run the whole 5A.  A stale id cost a full
download of the wrong event (minutes on cellular), could surface the
64 KB-page 502 instead of 409, and a lost 0C reply was reported as "the
unit was erased".

- get_events() gains only_key_timestamp: with only_key, if the target's 0C
  says another time (or none), the target takes the existing bypass --
  no 1F(arm), no POLL, no 5A.  A new branch only; it adds no command.
- download_event_by_key(key4, *, expected_timestamp=None) passes it on.
- The adapter converts the id's stamp to that ISO form and checks, in
  order: no event -> 404; no readable 0C timestamp -> 502 MalformedReply
  ("could not read ... record (0C)"); a different time -> 409 StaleEvent;
  no frames -> 502.
- The fake's download mirrors the real walk (no frames on a mismatch) and
  records what it was asked for.
- Legacy get_events() (none of the new options) is pinned by a test of
  its exact call sequence and 5A arguments, written before the change.

Read-only; nothing new on the wire.  No codec, store or DB change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-21 17:38:34 -04:00
serversdownandClaude Opus 5.5 ef096e3082 fix(sfm): a download never downgrades a stored event -- an existing row is returned, nothing written
THOR's watcher (and Blastware's ACH) store every event through
/db/import/idf_file and /db/import/blastware_file, with the paired report.
Storing a download of the same event afterwards overwrote that richer copy:
on Series 4 the file, .h5 and sidecar were rewritten (extensions dropped);
on Series 3 the row lost PVS, project strings and ZC frequencies and was
repointed at a second, review-less file set.

persist_download now looks up (serial, timestamp) first.  A row there is
returned as it stands -- inserted false, detail.already_stored true -- with
no store call, no insert_events and no sidecar write.  Never merge.

- DownloadedEvent gains `timestamp` (the unit's own event time) and
  `record` (Series 4's 0x0C fields); both adapters set them.
- The Series-3 `event is None` guard now runs before backfill/save, with a
  message that is true there ("nothing was stored").
- Tests build the watcher's state exactly as the import endpoints do and
  prove the row dict, the sidecar bytes and the file mtimes are unchanged.

No schema change, no migration, no codec change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-21 17:35:23 -04:00
serversdownandClaude Opus 5.5 b79309eb72 feat(sfm): Series-3 events -- header list, one-event download, stale ids refused
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-21 16:57:26 -04:00