Repository navigation
Conversation
A V1 command that timed out on the local channel was retried over MQTT. By then the request had already been published, so the device may have received and run it, and the retry could run a write command (start, set, save map) twice. Only read-only commands (get_*, app_get_*) are now retried after a timeout; others raise RoborockTimeout. Failures before publish still fall back as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Neon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Summary
This PR is clean and ready to approve. It tightly scopes the fix to V1 RPC fallback behavior so non-read commands are not resent over MQTT after a local timeout (where the packet was already published and may have executed on the device), while preserving fallback for read-only commands and pre-publish failures.
Review by Architectural Layer
- Priority 1 — Public Trait APIs & Consumer Contracts: No public trait signatures or models changed. Raising
RoborockTimeoutfromRpcChannel._send_rpcis backwards-compatible (RoborockTimeoutsubclassesRoborockException) and aligns withAGENTS.mdexception-narrowing guidelines. - Priority 2 — Data Lifecycle, State & Concurrency:
_is_read_only()is a pure value-returning helper with linear control flow inRpcChannel.send_command().- Request/response
asyncio.Futurecorrelation,unsub()cleanup infinally:,future.cancel(), andhealth_manager.on_timeout()handling remain intact. - Pre-publish failures (disconnected local channel,
LocalChannel.publish()raisingRoborockConnectionException/RoborockException) still fall back to MQTT for all commands; only post-publishRoborockTimeoutsuppresses MQTT resend for non-read commands.
- Priority 3 — Wire Protocols, Codecs & Resilient Enums:
- Verified
_READ_ONLY_PREFIXES = ("get_", "app_get_")against allRoborockCommandmembers and rawstrCommandTypecallers (RoborockCommandsubclasses(str, Enum)): allget_*andapp_get_*commands are read-only, and all mutating/action commands fail closed on local timeout. except RoborockTimeoutis properly ordered ahead ofexcept RoborockException.
- Verified
- Tests & PR Hygiene:
- Parametrized regression test is colocated in the mirror test module (
tests/devices/rpc/test_v1_channel.py), reusesFakeChannel, and asserts on public behavior. - Note: GitHub Actions checks have not yet run on this commit (
647ea28); approve/trigger CI before merging.
- Parametrized regression test is colocated in the mirror test module (
allenporter
left a comment
There was a problem hiding this comment.
It sounds like the way to model this is by not using an RPC strategy that tries both local and mqtt, but instead only send to local. That seems more straight forward that having a strategy that sends to both but then overriding it not to send to both. What do you think?
When a V1 command times out on the local channel,
RpcChannel.send_commandretries it over MQTT. By then the request has already been published, so the device may have received and run it. For a write (app_start,set_*,save_map, ...) the retry can make the device act twice. I saw the local-timeout-then-MQTT resend live on a Saros 20 withget_prop.Change:
_send_rpcraisesRoborockTimeout(aRoborockExceptionsubclass, so existing callers are unaffected) instead of a plainRoborockException.get_*,app_get_*) fall back to the next channel. Other commands raiseRoborockTimeout.Tests: a parametrised case in
tests/devices/rpc/test_v1_channel.pycovers both paths. The write case fails without the change. The rest of the suite is unchanged, and ruff, mypy and codespell pass.AI disclosure: this change was found and written with Claude (Anthropic's AI assistant), then tested before submitting.
🤖 Generated with Claude Code