Repository navigation
fix(v1): aggregate multi-phase cleaning records - #1058
Merged
allenporter merged 1 commit intoNov 22, 2026
Merged
allenporter merged 1 commit into
allenporter merged 1 commit into
Conversation
Lash-L
reviewed
Nov 21, 2026
Lash-L
left a comment
Collaborator
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
Clean — ready to approve. No findings survived adversarial self-check, and all CI checks pass.
Architectural Review (Priority 1 → 3)
- Priority 1 — Public Trait APIs & Consumer Contracts (
roborock/devices/traits/v1/clean_summary.py): Cleanly typed pure helper_sum_reported(values: list[int | None]) -> int | Noneanddataclasses.replace(records[-1], ...)preserve theCleanRecorddataclass contract without mutating intermediate records or assigning to read-only@propertyattributes (begin_datetime,square_meter_area), which now recompute automatically frombeginandarea. Unreported fields stayNoneinstead of being coerced to0. - Priority 2 — Data Lifecycle & State Management: Removes the broad
except Exception(# noqa: BLE001) that silently swallowed theAttributeErroronbegin_datetime, aligning withAGENTS.md§4 (Specific Exception Narrowing). Mixed dict/non-dict phase lists now raiseValueError("Mixed clean record formats"), whichCleanSummaryTrait.get_clean_recordwraps inRoborockParsingException. - Priority 3 — Wire Protocols, Codecs & Tests (
tests/devices/traits/v1/test_clean_summary.py): Single-dict, wrapped single-dict ([{...}]), legacy flat/nested list, and empty-list paths remain unchanged. Colocated tests cover 3-phase aggregation (including partially reported and unreported counters) and parametrized mixed-format rejection (dict-first/dict-last).
RR_API Cross-Verification
- Checked
com.roborock.tanos(hermes/.../module_2328.js,nonhermes/.../2497.js,2470.js,2573.js) andQrevo 2 Pro Series(module_2363.js): the official Roborock app only readsresult[0]fromget_clean_record(either as a structured dict whenisNewDataForCleanHistoryDetail()is true or a 9-element list otherwise) and does not implement client-side multi-phase aggregation. - Multi-dict aggregation in
python-roborockoriginated in #206 (07ce71a) for firmware returning multiple phase dicts in a singleget_clean_recordreply, and silently broke whenbegin_datetime/square_meter_areawere later converted from dataclass fields to read-only@propertymethods. This PR faithfully restores the intended aggregation semantics without altering single-phase behavior.
Combining a multi-phase clean record assigned to the read-only begin_datetime property. The error was swallowed, so callers got the last phase's duration, area and counters and its start type. Build the record from the last phase with the first phase's begin and start type, and sum duration, area and counters across phases; fields no phase reports stay unset. Replies mixing record formats now raise a parsing error.
hCoureau
force-pushed
the
submit/fix/multiphase-clean-record-totals
branch
from
November 21, 2026 21:36
ca23e47 to
c3ccfc4
Compare
allenporter
approved these changes
Nov 22, 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.
Context
get_clean_recordcan return a list with one record per phase of a clean, for example vacuum then mop.CleanRecordConverteris meant to combine the phases into oneCleanRecord. #1034 noted multi-phase aggregation as a separate existing issue; this addresses it.Problem
The converter combined the phases by assigning to
CleanRecord.begin_datetime, which is a read-only property. The resultingAttributeErrorwas swallowed by a broadexcept, so callers got the last phase's duration, area, counters andstart_typeinstead of totals for the whole clean.Changes
dataclasses.replaceon the last phase. It keeps the first phase'sbeginandstart_typeand sumsduration,area,avoid_countandwash_countacross phases, which is what the existing code was trying to do.Noneand is not filled in as 0.except Exception. A reply that mixes structured and list-form phases now raisesRoborockParsingException.Testing
main.Evidence
roborock.vacuum.a294, firmware 02.40.54), 20 single-phase records read through this branch parse to the same duration, area, begin and end as the raw replies, so the single-phase path is unchanged on hardware.