fix(client): 🐛 write RMW results back into the register cache - #62
Merged
Conversation
- async_set_bitmask_flag / async_set_masked_register / async_set_filtration_speed performed a read-modify-write against _cached_result but never stored the new value, so a second write into the same shared register within one poll window started from the stale word and dropped the first change - write the new value back into _cached_result after a successful write so back-to-back writes stay consistent until the next full poll refreshes it - add regression tests for consecutive writes on each affected setter
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 8 8
Lines 1222 1226 +4
=========================================
+ Hits 1222 1226 +4 ☔ View full report in Codecov by Harness. |
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.
🐛 What
Three client setters perform a read-modify-write against
self._cached_resultbut never store the new value back into it. The cache is refreshed only byasync_read_all, so two writes into the same shared register within one poll window make the second write start from the stale word and drop the first change.Concrete failure: turn the hydrolysis cover-reduction flag on, then the high-temperature shutdown flag on before the next poll. Both live in the same register. The second write reads the pre-first-write value from the cache, ORs in only its own bit, and writes a word that has the first bit cleared.
🔧 Changes
async_set_bitmask_flag,async_set_masked_register, andasync_set_filtration_speednow write the new value back into_cached_resultafter a successful write, so back-to-back writes stay consistent until the next full poll refreshes the cache with device truth.✅ Verification
pytest659 passed, 100% coverageruff check/ruff format --checkcleanbasedpyright0 errors