Repository navigation
fix: decode product families when generating feature docs - #1033
allenporter merged 3 commits into
Conversation
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 by Architectural Layer
- Priority 1 — Public Trait APIs & Consumer Contracts: No changes to public traits, domain models, or consumer contracts.
- Priority 2 — Data Lifecycle & State Management: Only
tests/devices/test_device_manager.pyis touched (test_start_connect_failure). Waiting onready_callbackviaasyncio.Event(instead of pollingis_connected, which can becomeTruewhen the channel subscribes beforev1_properties.start()finishes) and closingdevice_managerin afinallyblock is a sound fix for the CI race. - Priority 3 — Wire Protocols, Codecs & Cryptography: No wire protocol or codec changes.
- CLI Tooling, Generated Docs & Tests (
roborock/cli.py,SUPPORTED_FEATURES.md,tests/test_cli.py):update_docsnow resolves YAMLproduct_nicknamestrings toRoborockProductNicknameenum members and fails fast withclick.ClickExceptionon invalid names before writing output.- When
product_nicknameisNone,"", or"Unknown", the fallback (SHORT_MODEL_TO_ENUM.get(model.split(".")[-1], RoborockProductNickname.PEARLPLUS)) matches runtimeHomeDataProduct.product_nickname/DeviceData.product_nicknameinroborock/data/containers.py. - Filtering
features_dicttoboolvalues prevents raw diagnostic fields onDeviceFeatures(new_feature_info,new_feature_info_str,feature_info) from overwriting metadata rows withXor emitting a spuriousfeature_inforow. SUPPORTED_FEATURES.mdis cleanly regenerated andtests/test_cli.pyverifies parity directly againstHomeDataProduct.product_nicknameandDeviceFeatures.from_feature_flags.
Verdict
Ready to approve — no blocking defects found and all CI checks pass. One minor non-blocking PR scoping note is attached inline regarding the unrelated reconnect test fix (b10bbe5).
| ready_devices: list[RoborockDevice] = [] | ||
| device_manager = await create_device_manager(USER_PARAMS, ready_callback=ready_devices.append) | ||
| devices = await device_manager.get_devices() | ||
| ready = asyncio.Event() |
There was a problem hiding this comment.
PR Scoping (non-blocking): Per AGENTS.md §6 (PR Hygiene & Sizing), commit b10bbe5 (fix: wait for device readiness in reconnect test) addresses an unrelated subsystem compared to the CLI feature-doc generator fix in this PR.
The fix itself is sound (self._channel.subscribe() sets is_connected before v1_properties.start() completes and _ready_callbacks fires, and try...finally ensures teardown), so this is fine to merge as-is if maintainers prefer, or can be split into a separate PR to keep history scoped.
There was a problem hiding this comment.
Good call. I've dropped that commit from this PR and opened it separately as #1071.
4950c9e to
cf86bc3
Compare
allenporter
left a comment
There was a problem hiding this comment.
Thanks for splitting out #1071 and cleaning up the update-docs nickname decoding! The core fix and test coverage look good, and I left a few inline notes below:
- Non-V1 protocol gating in
update_docs(): Gating V1DeviceFeaturesdecoding onprotocol_versionavoids attributing 10 V1 vacuumPEARLPLUSfeatures toB01vacuums and theA01washing machine (roborock.wm.a102) inSUPPORTED_FEATURES.md. - Field-type filtering (non-blocking): Filtering by
fields(DeviceFeatures)(f.type is bool) instead of runtimeisinstance(is_supported, bool)avoids thebool-as-intedge case onroborock.vacuum.a27(new_feature_info: False). - Test coverage polish (non-blocking): Two small suggestions in
tests/test_cli.pyto exercise the explicit YAML nickname override happy path and truthynew_feature_infopreservation.
Minor housekeeping: the PR description still mentions the reconnect test fix that was moved to #1071.
| nickname_name = data.get("product_nickname") | ||
| product_nickname = SHORT_MODEL_TO_ENUM.get(model.split(".")[-1], RoborockProductNickname.PEARLPLUS) | ||
| if nickname_name not in (None, "", "Unknown"): | ||
| try: | ||
| product_nickname = RoborockProductNickname[nickname_name] | ||
| except KeyError as err: | ||
| raise click.ClickException(f"Unknown product nickname {nickname_name!r} for {model}") from err | ||
| # Reconstruct the DeviceFeatures object from the raw data in the YAML file | ||
| device_features = DeviceFeatures.from_feature_flags( | ||
| new_feature_info=data.get("new_feature_info", 0), | ||
| new_feature_info_str=data.get("new_feature_info_str", ""), | ||
| feature_info=data.get("feature_info", []), | ||
| product_nickname=data.get("product_nickname", ""), | ||
| product_nickname=product_nickname, | ||
| ) |
There was a problem hiding this comment.
Protocol isolation / SUPPORTED_FEATURES.md accuracy: DeviceFeatures.from_feature_flags is only used by DeviceFeaturesTrait on V1 (pv == "1.0") devices at runtime. Running it unconditionally here with the PEARLPLUS fallback gives B01 vacuums (sc01, sc05, ss07) and the A01 Zeo One washing machine (roborock.wm.a102) 10 V1 vacuum features in SUPPORTED_FEATURES.md (adding 8 new X cells such as is_ai_recognition_obstacle_supported, is_pure_clean_mop_supported, is_max_plus_mode_supported, is_clean_route_setting_supported, etc.).
Since protocol_version is already present in data, gating V1 feature decoding on data.get("protocol_version") in (None, "", "1.0") keeps non-V1 devices in the table with their metadata rows without fabricating V1 vacuum capabilities for them.
| for feature, is_supported in features_dict.items(): | ||
| if not isinstance(is_supported, bool): | ||
| continue |
There was a problem hiding this comment.
Non-blocking: Filtering by runtime value type (isinstance(is_supported, bool)) does not exclude new_feature_info when YAML supplies a boolean—which actually happens for roborock.vacuum.a27 (new_feature_info: False) in device_info.yaml. It happens to be harmless today only because False is falsy and special_rows subtracts new_feature_info later.
Matching DeviceFeatures.from_dict (roborock/device_features.py) by iterating over declared boolean fields ([f.name for f in fields(DeviceFeatures) if f.type is bool]) avoids both the bool-is-int edge case and the asdict() copy.
| [ | ||
| ("PEARLPLUS", "a87"), | ||
| ("TANOS", "s6"), | ||
| ("ULTRONLITE", "a73"), | ||
| ("Unknown", "test"), | ||
| ("", "test"), | ||
| (None, "test"), | ||
| ("Unknown", "s6"), | ||
| ("", "s6"), | ||
| (None, "s6"), | ||
| ], |
There was a problem hiding this comment.
Non-blocking: In the three named cases (("PEARLPLUS", "a87"), ("TANOS", "s6"), ("ULTRONLITE", "a73")), short_model already maps to the exact same enum in SHORT_MODEL_TO_ENUM, so all 9 cases would still pass even if the RoborockProductNickname[nickname_name] branch were removed. Adding a case where an explicit YAML nickname overrides an unmapped model's PEARLPLUS fallback (e.g., ("TANOS", "test") asserting RoborockProductNickname.TANOS) would directly cover that happy path.
| { | ||
| model: { | ||
| "product_nickname": nickname_name, | ||
| "new_feature_info": 0, |
There was a problem hiding this comment.
Non-blocking: Because 0 is falsy, assert rows["new_feature_info"] == "0" would pass even without the non-bool filter (unlike "new_feature_info_str": "0", which is truthy and does catch the overwrite bug). Using a non-zero integer (e.g., 16) verifies both raw new_feature_info preservation and bitflag decoding.
Merge upstream main and regenerate the capability table. Address review feedback by decoding V1 flags only for V1 and legacy entries, selecting declared boolean fields, and covering family overrides and nonzero flags.
The feature-doc generator passes YAML nickname strings into a decoder keyed by
RoborockProductNickname, so family-derived flags differ from runtime decoding. Explicit family names now resolve to enum members, and unknown names produce an error before the output is written. Missing, empty, andUnknownfamily values use the runtime model lookup, including itsPEARLPLUSfallback for unrecognised models.The generator decodes V1 capability flags for V1 devices and legacy entries with no protocol. A01 and B01 devices keep their columns and raw metadata. The table uses declared boolean fields for decoded capabilities and preserves the raw flag values.
SUPPORTED_FEATURES.mdwas regenerated from the current catalogue and Home API fixtures.CLI tests cover an explicit nickname overriding the fallback, nonzero raw flag preservation and decoding, and protocol gating. The local unit suite passed on Python 3.11 and 3.14 with 2,692 passing tests on each. Pre-commit, commitlint, and the source and wheel builds passed. Repeated generation produced byte-identical output.
Related to #1016.