fix(minimateplus): push_config_raw checks every block before the first write goes out (#46 review)

Review of b5037b0 (measured on 12 recorded SFM compliance reads): the read
keeps three escape bytes from its reply headers, so every real config image is
refused by write_image -- correctly, but only after 68 and 73 had been sent,
with a message saying nothing was.  All four blocks are now checked first; the
test feeds the block exactly as SFM's read produces it and asserts no frame is
sent (two went out without the check).

Config push stays unusable on purpose: fixing that read alone would let the
compliance encoder write some fields to the wrong bytes (e.g. 4,096 sps as
4,112) while the image still passes.  The rework -- logical read, encoding at
measured offsets with #48, a diff check, N pinned per SUB, an idle check, the
start/stop safeguards on POST /device/config -- is recorded in the spec and on
#46.  Start/stop frames are unchanged (verified byte-identical by the review).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-10-27 03:17:34 -04:00
1 parent 329f7f2abb
commit 20ea61e0e9
3 files changed
+45

No files matched your search

+19
View File
@@ -247,3 +247,22 @@ def test_apply_config_writes_the_units_own_trigger_block():
trig = [a[0] for n, a in c._proto.writes if n == "write_trigger_config"]
assert trig == [_image(0x82)[:-2]]
assert trig[0][5] == 0x01 # BE9441's; the March copy had 0x03
def test_a_bad_block_is_refused_before_the_first_write_goes_out():
"""Review of #46 (2026-10-27, measured on 12 recorded SFM reads): the compliance
read keeps three escape bytes from its reply headers and unescapes to
00 + cfg[0:1024] + 00 00 + cfg[1024:2090]. That block was refused -- but only
after 68 and 73 had been sent. push_config_raw now checks all four first.
(The read is deliberately not 'fixed' on its own: the encoder would then write
some fields to the wrong bytes while the image still passes -- see #46.)"""
from minimateplus.client import MiniMateClient
cfg = _image(0x71)[:-2]
as_sfm_reads_it = b"\x00" + cfg[:1024] + b"\x00\x00" + cfg[1024:]
p, t = _proto()
c = MiniMateClient(transport=object())
c._proto = p
with pytest.raises(ValueError, match="not a whole block"):
c.push_config_raw(_image(0x68)[:-2], as_sfm_reads_it + b"\x00\x00",
_image(0x82)[:-2], _image(0x69))
assert t.sent == []