Repository navigation
fix(v1): serialize the last clean record of the clean summary - #1059
Merged
allenporter merged 2 commits intoNov 22, 2026
Merged
allenporter merged 2 commits into
allenporter merged 2 commits into
Conversation
CleanSummaryWithDetail declared last_clean_record without being a dataclass, so as_dict() and device diagnostics dropped the fetched record, from_dict() ignored it and the constructor rejected it. Make the class a dataclass. The clean summary converter now returns plain CleanSummary objects, so a summary refresh only updates the summary fields and a failed record fetch keeps the previous record.
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, tightly scoped bugfix (a865d54) with all CI checks passing. No blocking issues or defects survived adversarial self-check — this PR is clean and ready to approve.
Layer-by-Layer Assessment
- Priority 1 — Public Trait APIs & Consumer Contracts (
roborock/data/v1/v1_containers.py,roborock/devices/traits/v1/clean_summary.py):- Adding
@dataclass(repr=False)toCleanSummaryWithDetailpromoteslast_clean_record: CleanRecord | None = Noneinto a properRoborockBasedataclass field, fixingas_dict()/ diagnostics serialization (lastCleanRecord),from_dict()recursive deserialization, keyword construction, and__eq__comparison while preservingCleanSummary.__repr__(_attr_repr). lastCleanRecordcontains only cleaning metrics/timestamps (no sensitive user or transport data) and is safe indevice.diagnostic_data().
- Adding
- Priority 2 — Data Lifecycle & State Management (
roborock/devices/traits/v1/clean_summary.py):- Updating
CleanSummaryConverter.convert()to returnCleanSummarypreventsmerge_trait_values()duringsuper().refresh()from overwritingself.last_clean_recordwithNonebeforeget_clean_record()runs. - Verified all refresh paths: successful refresh updates
last_clean_record; failedGET_CLEAN_RECORDretains the previouslast_clean_record(matchingmain); empty/missingrecordsstill explicitly resetsself.last_clean_record = None.
- Updating
- Priority 3 — Wire Protocols, Codecs & Resilient Enums:
- No wire protocol or enum changes;
CleanRecordenum fields round-trip cleanly throughas_dict()/from_dict().
- No wire protocol or enum changes;
- Tests & Fixtures (
tests/data/v1/test_v1_containers.py,tests/devices/traits/v1/test_clean_summary.py,tests/devices/__snapshots__/test_v1_device.ambr):- Tests are properly colocated in their mirror suites, assert on public API behavior (
as_dict()/from_dict()round-trip and retention onGET_CLEAN_RECORDfailure), and update the diagnostics snapshot accurately.
- Tests are properly colocated in their mirror suites, assert on public API behavior (
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
CleanSummaryTraitfetches the clean summary and then the most recent clean record, and exposes the record aslast_clean_recordonCleanSummaryWithDetail.Problem
CleanSummaryWithDetaildeclareslast_clean_recordbut is not a dataclass, so the attribute is not a dataclass field:as_dict()and device diagnostics drop the fetched record.from_dict()ignores it.CleanSummaryWithDetail(last_clean_record=...)raisesTypeError.Changes
CleanSummaryWithDetaila@dataclass(repr=False), keeping the shared attribute repr.CleanSummaryConverternow returns plainCleanSummaryobjects.merge_trait_valuescopies every field of the converted object, so otherwise each summary refresh would reset the new field toNoneand a failed record fetch would lose the previous record.lastCleanRecord; the snapshot is updated.Testing
as_dict()/from_dict()round trip ofCleanSummaryWithDetail. It fails onmain, as does the updated snapshot.main.Evidence
roborock.vacuum.a294, firmware 02.40.54) with this change:as_dict()includeslastCleanRecord,from_dict(as_dict())keeps the record, a second summary refresh keeps the same record, and the record key is present in diagnostics.