refactor: prune dead provider helpers and collapse SlotEntities builders#1266
Merged
Conversation
* `providers/_util.py`: delete `make_legacy_tagged_name` (zero production callers) and inline `parse_tag_with_rewrite` into `parse_tag` (single caller, vestigial `needs_rewrite` signal). The legacy `[LCM:<slot>]` format is now read-only -- `parse_tag` still recognizes it so older lock-stored names continue to identify as LCM-owned until the next write rewrites them. * `websocket.py`: extract `_build_slot_entities()` so the per-lock iterator (`_get_slot_entity_ids`) and the per-slot subscription resolver share one unique_id formula and one `SlotEntities` shape. `_get_slot_metadata()` now takes pre-resolved entities, removing the duplicate registry walk in `_serialize_lock_coordinator`. Drops the thin `_get_slot_entity_data` wrapper -- its only caller now calls `_build_slot_entities` directly. * Tests: port the rich match-priority cases from `TestParseTagWithRewrite` onto `TestParseTag` (adapted to 2-tuple); switch `test_websocket` mocks from `_get_slot_entity_data` to `_build_slot_entities`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1266 +/- ##
=======================================
Coverage 97.15% 97.16%
=======================================
Files 54 54
Lines 6543 6521 -22
Branches 460 460
=======================================
- Hits 6357 6336 -21
+ Misses 186 185 -1
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
Mechanical cleanups surfaced by an audit of
providers/_util.pyandwebsocket.py— net -87 lines across production + tests, zero behavior change.providers/_util.pymake_legacy_tagged_name— zero non-test callers; the providers it was reserved for already emit the canonicallcm:<slot>:format.parse_tag_with_rewriteintoparse_tag— single caller, vestigialneeds_rewriteboolean (no consumer ever flipped on it).[LCM:<slot>]is now strictly read-only:parse_tagstill recognizes it so older lock-stored names continue to identify as LCM-owned until the next write rewrites them in canonical form.websocket.py_build_slot_entities(ent_reg, entry_id, slot_num)— the per-lock iterator (_get_slot_entity_ids) and the per-slot subscription resolver now share oneunique_idformula and one populatedSlotEntitiesshape (the two previously diverged onconfig_entry_idvsevent_entity_id)._get_slot_entity_data— its only call site now invokes_build_slot_entitiesdirectly._get_slot_metadata()to take pre-resolved entities._serialize_lock_coordinatorwas walking the entity registry twice per call (once via_get_slot_metadata, once directly); now it walks once and reuses.Tests
TestParseTagWithRewriteontoTestParseTag(adapted to 2-tuple). No coverage loss forparse_tag.test_websocketmocks updated from_get_slot_entity_datato_build_slot_entities.Type of change
Additional information
Surfaced by a codebase-wide audit for unnecessary complexity. Larger items found in the same audit (parallel circuit breakers in
coordinatorvssync, twin confirmation paths,_verified+_pending_writesparallel state) are intentionally not part of this PR — they need a design call, not a mechanical refactor.Checklist
🤖 Generated with Claude Code