Skip to content

refactor: track unverified slots as a set, not a flag per slot - #1411

Merged
raman325 merged 1 commit into
mainfrom
refactor/unverified-slot-set
Aug 14, 2026
Merged

refactor: track unverified slots as a set, not a flag per slot#1411
raman325 merged 1 commit into
mainfrom
refactor/unverified-slot-set

Conversation

@raman325

Copy link
Copy Markdown
Owner

Proposed change

LockUsercodeUpdateCoordinator._verified was a dict[int, bool] read through:

return self._verified.get(slot, True)

Absence and an explicit True are 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_read wrote True in 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:

self._unverified: set[int] = set()

def is_verified(self, slot: int) -> bool:
    return slot not in self._unverified

"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:

-        self._verified = {
-            slot: flag for slot, flag in self._verified.items() if slot in out
-        }
+        self._unverified &= out.keys()

Net +35 / −33 across two source files.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

No behaviour change. Every caller goes through is_verified() or mark_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

``_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>
Copilot AI lite review requested due to automatic review settings August 14, 2026 04:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added python Pull requests that update Python code code-quality Pull requests that improve code quality labels Aug 14, 2026
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.96%. Comparing base (452753a) to head (1487dc6).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1411   +/-   ##
=======================================
  Coverage   98.96%   98.96%           
=======================================
  Files          53       53           
  Lines        6668     6668           
  Branches      470      470           
=======================================
  Hits         6599     6599           
  Misses         69       69           
Flag Coverage Δ
python 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...components/lock_code_manager/domain/coordinator.py 100.00% <100.00%> (ø)
...om_components/lock_code_manager/providers/_base.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@raman325
raman325 merged commit d011123 into main Aug 14, 2026
18 checks passed
@raman325
raman325 deleted the refactor/unverified-slot-set branch August 14, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-quality Pull requests that improve code quality python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants