Repository navigation
fix(b01): isolate Q7 map response assemblers per subscription - #1051
Merged
allenporter merged 1 commit intoNov 16, 2026
Merged
Conversation
Lash-L
reviewed
Nov 15, 2026
Lash-L
left a comment
Collaborator
There was a problem hiding this comment.
Automated code review by Gemini 4 Argon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Summary by Layer
- Protocol (
roborock/protocols/b01_q7_protocol.py):- Anchors
_complete_payload()atseq == 1(seqs != list(range(1, seqs[-1] + 1))) so multi-part B01 map frames (protocols300/301) cannot complete prematurely if trailing chunks (seq >= 2) arrive beforeseq = 1and happen to form a 16-byte-aligned base64 suffix. - Moves the
message.version == B01_VERSIONguard intocreate_map_response_assembler()so each assembler instance is self-contained when used directly as a channelresponse_matcher.
- Anchors
- Channel / RPC (
roborock/devices/rpc/b01_q7_channel.py):- Replaces the shared
self._map_assemblerinstance onB01Q7Channelwith an isolatedcreate_map_response_assembler()persend_map_command()invocation and persubscribe_map_pushes()subscription (consistent withv1_channel.pycreating a fresh map decoder per command). - Fixes a race where an active
subscribe_map_pushescallback (registered byQ7PropertiesApi.start()) drainedpendingfragments from the shared assembler beforesend_map_command()'s subscriber callback processed the completing301frame.
- Replaces the shared
- Tests (
tests/devices/rpc/test_b01_q7_channel.py,tests/protocols/test_b01_q07_protocol.py):- Consolidates in-order and out-of-order channel reassembly tests with
@pytest.mark.parametrizeand addstest_send_map_command_with_active_map_push_subscriptioncovering concurrent push subscription + map command execution. - Adds direct unit tests for
create_map_response_assembler()covering single-part passthrough, 2-part and 3-part out-of-order arrival (including block-aligned suffix arrival beforeseq = 1), FIFO eviction past_MAX_PENDING_MAP_RESPONSES, and non-matching frames.
- Consolidates in-order and out-of-order channel reassembly tests with
No blocking issues or defects found. LGTM!
Lash-L
approved these changes
Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #1048:
B01Q7Channelpreviously stored a single stateful_map_assemblershared betweensubscribe_map_pushes()(registered for the lifetime of a connected Q7 device inQ7PropertiesApi.start()) andsend_map_command()(MapContentTrait.refresh()). When a fragmented(300, 301)frame arrived onMqttChannel, the push listener drainedpending[key]on the final fragment beforesend_map_command's matcher saw it, causingsend_map_command()to time out (or fail decoding if block-aligned). Eachsend_map_command()call andsubscribe_map_pushes()registration now uses its owncreate_map_response_assembler()instance.seq=1and checkB01_VERSIONin the assembler: Unlike V1 (#1004), B01 map fragments have no header marker onseq=1. Checkingrange(1, seqs[-1] + 1)ensures 3+-part frames arriving out of order (e.g.[3, 2, 1]) do not prematurely emit a block-aligned suffix beforeseq=1arrives. Checkingmessage.version == B01_VERSIONdirectly increate_map_response_assembler()also removes the wrapper helpers fromB01Q7Channel.create_map_response_assembler()intests/protocols/test_b01_q07_protocol.pyand concurrentsubscribe_map_pushes+send_map_commandcoverage (plus parametrized ordering) intests/devices/rpc/test_b01_q7_channel.py.Fixes #1043
Testing
main(6 failedacross concurrent push+command timeouts, 3-part out-of-order suffixes, and version filtering), then applied fixes.uv run pytest(2302 passed)uv run pre-commit run --all-files(all hooks passed)