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
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-11-02 16:59:15 -05:00
1 parent 8612cd9df7
commit 453d42e32a
9 files changed
+76 -4

No files matched your search

+5 -3
View File
@@ -33,9 +33,11 @@ S3_MODES = {0x00: "Single Shot", 0x01: "Continuous", 0x03: "Histogram", 0x04: "H
S3_EVENT_TIMEOUT = 120.0 # what the legacy event-download routes use
# A MiniMate call-home write goes out only once SFM's 0x7E / 0x7F frames are
# reproduced from Blastware's own (tests/test_s3_call_home_bw_frames.py). Until
# then a live change is refused before any connection; a dry run still works.
S3_CALL_HOME_FRAME_VERIFIED = False
# reproduced from Blastware's own; shut, a live change is refused before any
# connection (a dry run still works). OPEN since 2026-11-02:
# tests/test_s3_call_home_bw_frames.py rebuilds Blastware's enable and disable
# writes (BE11529, 2026-04-20) byte for byte from the unit's own reads.
S3_CALL_HOME_FRAME_VERIFIED = True
# The 0x1C flag byte (section[1]): the only values ever measured. 0x10 is
# BE11529 monitoring (2026-04-08); 0x0B is BE9441 recording a histogram,
+7 -1
View File
@@ -84,7 +84,13 @@ def test_s3_call_home_state():
assert fake.calls.index("wake") < fake.calls.index("read_call_home_raw")
def test_s3_live_change_is_refused_until_the_frame_is_verified():
def test_the_gate_is_open_and_names_its_proof():
assert s3mod.S3_CALL_HOME_FRAME_VERIFIED is True
assert "tests/test_s3_call_home_bw_frames.py" in open(s3mod.__file__).read()
def test_s3_live_change_is_refused_while_the_gate_is_shut(monkeypatch):
monkeypatch.setattr(s3mod, "S3_CALL_HOME_FRAME_VERIFIED", False)
a = adapter(FakeMiniMateClient())
with pytest.raises(NotSupported) as e:
change(a, enabled=False)
+64
View File
@@ -0,0 +1,64 @@
"""SFM's MiniMate call-home write is Blastware's, frame for frame (phase 4).
Ground truth: Blastware changing BE11529's call-home settings on 2026-04-20
(Remote Access -> Setup Unit), recorded as paired raw files -- what Blastware
sent (raw_bw_*) and what the unit answered (raw_s3_*). Copied from
bridges/captures/4-20-26/call home settings/: the read, the enable, the disable.
For each 0x7E, SFM builds its frame from the unit's own read just before it and
the value Blastware asked for; it must equal Blastware's frame byte for byte.
This test is what opens sfm.device_access.s3.S3_CALL_HOME_FRAME_VERIFIED.
"""
from __future__ import annotations
import os
import sys
from pathlib import Path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test_minimate_write_frames import _frames, _payload # noqa: E402
from minimateplus.framing import S3FrameParser, build_bw_write_frame # noqa: E402
from minimateplus.protocol import ( # noqa: E402
SUB_CALL_HOME, SUB_CALL_HOME_CONFIRM, SUB_CALL_HOME_WRITE, call_home_image, write_image,
)
FIX = Path(__file__).parent / "fixtures" / "s3-call-home-bw"
ACTIONS = ["162148_pull_call_home_options", "162221_enable_auto_call_home", "162255_disable_auto_call_home"]
def _action(tag):
bw = _frames((FIX / f"raw_bw_20260420_{tag}.bin").read_bytes())
requests = [(_payload(f)[2], f) for f in bw]
reads = [bytes(f.data)[11:] for f in S3FrameParser().feed((FIX / f"raw_s3_20260420_{tag}.bin").read_bytes())
if f.sub == 0xFF - SUB_CALL_HOME and len(f.data) > 100]
return requests, reads
def test_sfm_builds_blastwares_call_home_write():
last_read, asserted, confirms = None, [], 0
for tag in ACTIONS:
requests, reads = _action(tag)
subs = [s for s, _ in requests]
if reads and SUB_CALL_HOME_WRITE in subs:
# this action's read went out before its write
last_2c = max(i for i, s in enumerate(subs) if s == SUB_CALL_HOME)
assert last_2c < subs.index(SUB_CALL_HOME_WRITE)
last_read = reads[-1]
for sub, frame in requests:
if sub == SUB_CALL_HOME_WRITE:
bw_image = _payload(frame)[16:]
wanted = bw_image[5]
base = write_image(SUB_CALL_HOME_WRITE, last_read)
assert wanted in (0x00, 0x01)
assert [i for i in range(len(base)) if base[i] != bw_image[i] and i != 5] == []
assert build_bw_write_frame(SUB_CALL_HOME_WRITE, call_home_image(last_read, wanted == 0x01)) == frame
asserted.append((tag, base[5], wanted))
elif sub == SUB_CALL_HOME_CONFIRM:
assert build_bw_write_frame(SUB_CALL_HOME_CONFIRM, b"") == frame
confirms += 1
if reads and SUB_CALL_HOME_WRITE not in subs:
last_read = reads[-1]
# Blastware turned call-home on (read 0x00 -> 0x01), then off (read 0x01 -> 0x00).
assert asserted == [("162221_enable_auto_call_home", 0x00, 0x01),
("162255_disable_auto_call_home", 0x01, 0x00)]
assert confirms == 2