fix(sfm): a Micromate's call-home is refused while monitoring, and only a real call-home block is ever edited

Measured at the bench 2026-11-03 (UM20147): monitoring, a Micromate returns its
real call-home block and ACKS a call-home write, but does not apply it -- three
read-backs unchanged, and its own menu says 'Feature disabled while monitoring'.
SFM now refuses up front (UnitStateUnknown, 409: '... is monitoring -- a Micromate
ignores call-home changes while monitoring ...; stop monitoring first -- nothing
sent'), dry run included, instead of sending a write the unit ignores.

And the block must be the call-home block: micromate.writes.is_call_home_content
checks its header is its own length (00 7C, N = 124 -- 00 7C DC on every read,
UM12947 and UM20147).  plan_call_home_enabled refuses any other 126 bytes, the
change refuses before sending, and call_home_state says why (enabled = None).
At the bench this was checked by eye before the monitoring write.

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-03 15:32:02 -05:00
1 parent 5326e99ac2
commit f35845d403
4 files changed
+74 -4

No files matched your search

+34
View File
@@ -114,3 +114,37 @@ def test_a_lost_ack_still_records_what_the_unit_holds():
assert (r.outcome, r.sent) == ("failed", True)
snap = r.detail["snapshot"]
assert snap["changed_offsets"] == [] and snap["before"] == snap["after"] # the write did not land
# Measured at the bench 2026-11-03 (UM20147): a MONITORING Micromate returns its
# real call-home block and ACKS a write, but does not apply it -- its own menu says
# "Feature disabled while monitoring". SFM refuses up front and says why, rather
# than send a write the unit will ignore.
@pytest.mark.parametrize("dry_run", [True, False])
def test_s4_call_home_is_refused_while_monitoring(dry_run):
from sfm.device_access.errors import UnitStateUnknown
fake = FakeMicromateClient(run_states=[0x02])
with pytest.raises(UnitStateUnknown) as e:
change(fake, enabled=False, dry_run=dry_run)
msg = str(e.value)
assert "monitoring" in msg and "stop" in msg and "nothing sent" in msg
assert fake.executed == []
# The block's header is its own length (00 7C, N = 124); SFM flips a bit only in a
# block that carries it, never in whatever 126 bytes came back.
def test_s4_a_block_that_is_not_the_call_home_block_sends_nothing():
from sfm.device_access.errors import UnitStateUnknown
fake = FakeMicromateClient(call_home=bytes(126))
with pytest.raises(UnitStateUnknown) as e:
change(fake, enabled=False)
assert "not its call-home block" in str(e.value)
assert fake.executed == []
def test_s4_state_of_a_block_that_is_not_the_call_home_block_says_why():
st = s4_call_home_state(FakeMicromateClient(call_home=bytes(126)), "UM20147")
assert st.enabled is None and "not its call-home block" in st.detail["reason"]
+7
View File
@@ -265,3 +265,10 @@ def test_setup_push_refuses_a_block_whose_own_length_header_is_wrong():
bad[0:2] = (int.from_bytes(bad[0:2], "big") + 1).to_bytes(2, "big")
with pytest.raises(ValueError, match="header"):
plan_setup_push(reads[0x08], reads[0x2E], bytes(bad), "x.mmb")
def test_call_home_refuses_a_block_whose_header_is_not_its_length():
# 126 bytes, but not the call-home block: its header must be its own length (00 7C).
with pytest.raises(ValueError, match="header"):
plan_call_home_enabled(bytes(126), True)