fix(s3): a settings read takes exactly what each frame was asked for

Bench 2026-11-04, BE9441 live: frame B of a 1A read arrived one byte long,
ending in a lone 0x10.  When a frame's checksum byte is itself escaped
(02 / 03 / 04, about one frame in 85) the parser keeps the escape's 0x10
and strips only the byte after it.  The 12 recorded reads never hit it,
so the assembled block was 2,091 bytes and SFM refused it as 'monitoring'.
read_compliance_content now passes the lengths it asked for (1024, 1024,
42) and that one stray byte is dropped; any other leftover still fails
is_compliance_content.  The trimmed read decodes exactly as the old
decoder read the same reply.

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-04 13:11:32 -05:00
1 parent 2d237be5ef
commit 9992b25fde
2 files changed
+39 -5

No files matched your search

+22
View File
@@ -99,3 +99,25 @@ def test_read_compliance_content_refuses_a_missing_frame():
with pytest.raises(mp.ProtocolError):
proto.read_compliance_content()
assert len(t.sent) == 3 # probe, B, C -- and no D after C went unanswered
# Bench 2026-11-04 (BE9441, live): frame B of a 1A read came back one byte long,
# ending in a lone 0x10 -- the kept escape of a checksum byte that was itself
# escaped (02 / 03 / 04: about one frame in 85); the parser strips only the byte
# after it. The 12 recorded reads never hit it. The read knows how much it asked
# for, so it takes exactly that; a leftover other than that one 0x10 is kept, and
# the block then fails is_compliance_content.
def test_a_frame_with_an_escaped_checksums_stray_byte_is_trimmed_to_what_was_asked():
sfm_read = READS[8] # SFM's own 1024 + 1024 + 42 pattern
good = assemble_compliance_content(sfm_read, lengths=(1024, 1024, 42))
assert good == assemble_compliance_content(sfm_read) and is_compliance_content(good)
stray = [sfm_read[0] + b"\x10", sfm_read[1], sfm_read[2]]
assert len(assemble_compliance_content(stray)) == 2091 # what the bench saw
assert assemble_compliance_content(stray, lengths=(1024, 1024, 42)) == good
def test_a_leftover_that_is_not_the_stray_escape_is_not_trimmed():
sfm_read = READS[8]
odd = [sfm_read[0] + b"\x55", sfm_read[1], sfm_read[2]]
assert not is_compliance_content(assemble_compliance_content(odd, lengths=(1024, 1024, 42)))