refactor: track unverified slots as a set, not a flag per slot - #1411
Merged
Conversation
``_verified`` was a ``dict[int, bool]`` read through ``self._verified.get(slot, True)``, which made absence and an explicit ``True`` indistinguishable. Two of its three values meant the same thing, so every writer had to remember which one to use -- and the "verified" branches disagreed with each other for no reason: ``_apply_read`` wrote ``True`` in one place and popped in another to express the identical outcome. Membership is the whole state, so a set says it directly. Absence is no longer a convention the docstring has to explain; it is the only representation of "verified" there is, and the redundant third value stops existing. The lockstep pruning drops out too. Rebuilding a filtered dict comprehension after every read and push becomes ``&= keys()``. No behaviour change: every caller goes through ``is_verified`` or ``mark_verified``, both of which keep their signatures, and the suite passes untouched apart from one test that named the attribute directly. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1411 +/- ##
=======================================
Coverage 98.96% 98.96%
=======================================
Files 53 53
Lines 6668 6668
Branches 470 470
=======================================
Hits 6599 6599
Misses 69 69
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Proposed change
LockUsercodeUpdateCoordinator._verifiedwas adict[int, bool]read through:Absence and an explicit
Trueare indistinguishable, so two of the type's three values meant the same thing. Every writer had to remember which one to use, and the "verified" branches disagreed with each other for no reason —_apply_readwroteTruein one branch and popped in another to express the identical outcome.Membership is the whole state, so a
set[int]of unverified slots says it directly:"Absence means verified" stops being a convention the docstring has to explain and becomes the only representation there is. The impossible-but-writable third value no longer exists.
The lockstep pruning simplifies as a side effect — rebuilding a filtered dict comprehension after every read and every push becomes one set intersection:
Net +35 / −33 across two source files.
Type of change
Additional information
No behaviour change. Every caller goes through
is_verified()ormark_verified(), both of which keep their signatures, so the suite passes untouched apart from a single test that named the private attribute directly (tests/test_coordinator.py, one rename).1480 passed / 3 skipped, coverage remains 100%.
Found while auditing for over-complicated implementation details after #1410 — the write-confirmation lifecycle was the area worth looking at, since it is where #1397's non-convergence lived.
🤖 Generated with Claude Code