fix(sfm): a Series-4 record whose timestamp did not decode is not called stale

Mirrors the Series-3 fix (F3): an unreadable 0C timestamp is a decode or
comms fault, not proof the unit was erased.  Nothing is downloaded.

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-21 17:58:18 -04:00
1 parent 67a0fece34
commit a130107fdf
2 files changed
+15

No files matched your search

+4
View File
@@ -282,6 +282,10 @@ def s4_download_event(client: Any, serial: str, key: bytes, stamp: Optional[str]
if ref.key != key:
continue
found = stamp_of(ref.timestamp)
if stamp is not None and found is None:
raise MalformedReply(
f"could not read event {key.hex()}'s record (0C) timestamp to confirm it "
"is the one listed -- not downloaded; try again")
if stamp is not None and found != stamp:
raise StaleEvent(
f"the event at {key.hex()} on {serial} is from {found}, not {stamp} -- "
+11
View File
@@ -69,3 +69,14 @@ def test_a_stale_id_is_refused_and_nothing_is_downloaded():
def test_a_key_that_is_not_stored_is_404():
with pytest.raises(EventNotFound):
s4_download_event(FakeMicromateClient(), "UM20147", bytes.fromhex("deadbeef"), None)
def test_a_record_whose_timestamp_did_not_decode_is_not_called_stale():
# Mirrors Series 3 (F3): an unreadable 0C timestamp is a comms/decode fault,
# not proof the unit was erased -- and nothing is downloaded.
from sfm.device_access.errors import MalformedReply
fake = FakeMicromateClient()
fake.event_refs[0].timestamp = None
with pytest.raises(MalformedReply, match="0C"):
s4_download_event(fake, "UM20147", W_KEY, "20250531135901")
assert fake.fetched == []