refactor(db): dedupe cross-bundle wrappers into shared mixins (#1135)#1283
Open
axisrow wants to merge 1 commit into
Open
refactor(db): dedupe cross-bundle wrappers into shared mixins (#1135)#1283axisrow wants to merge 1 commit into
axisrow wants to merge 1 commit into
Conversation
…1135) bundles.py duplicated identical repository pass-through methods across bundles (ChannelBundle/CollectionBundle channel+task ops, get_setting/ set_setting in four bundles, account reads in three, message search/batch insert in two, scheduler task reads). jscpd flagged 5 clone pairs inside the file — the top cluster of issue #1135. Consolidate each duplicated wrapper group into a repo-scoped plain-class mixin (_ChannelOps, _CollectionTaskCreateOps, _CollectionTaskReadOps, _SettingsOps, _NotificationQueriesOps, _MessageOps, _AccountReadOps, _SearchLogReadOps). Mixins are deliberately NOT dataclasses: their attribute annotations do not become dataclass fields, so every bundle's positional constructor order is unchanged. Public API is byte-identical (verified by inspect.signature diff) except PipelineBundle.list_accounts/list_account_summaries which gain the return annotations the duplicates already had. Bundle method count 138 -> 111; the test_db_access_conventions ratchet baseline is lowered accordingly. Part of #1135 (axis 5 of #1130). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Part of #1135 (axis 5 of #1130). Stays off the parity surface — only genuine within-repo duplication is touched.
What
src/database/bundles.pyduplicated identical repository pass-through methods across bundles:ChannelBundle+CollectionBundleget_setting/set_setting— four bundles (Collection, Notification, Search, Scheduler)list_accounts,list_account_summaries) — three bundlessearch_messages/insert_messages_batch— Collection + Searchget_recent_searches— Search + Schedulerjscpd flagged 5 clone pairs inside the file — the top cluster of #1135.
How
Each duplicated wrapper group moves into a repo-scoped plain-class mixin (
_ChannelOps,_CollectionTaskCreateOps,_CollectionTaskReadOps,_SettingsOps,_NotificationQueriesOps,_MessageOps,_AccountReadOps,_SearchLogReadOps). A bundle mixes in only the groups whose repository field it already carries.Mixins are deliberately NOT dataclasses: their attribute annotations (
channels: ChannelsRepository, …) do not become dataclass fields, so every bundle's positional constructor order is unchanged.Verification
inspect.signaturediff of all 10 bundle classes before/after. The only diffs arePipelineBundle.list_accounts/list_account_summaries, which gain the return-type annotations the duplicates already carried.test_db_access_conventionsratchet baseline is lowered accordingly (it is a downward-only cap by design).tests/test_bundles.py(42) + bundle consumers (scheduler, search_queries, notifier, photo_loader, pipeline_service, regression-services: 178) green.jscpd
bundles.py:19↔facade.py:18import block;bundles.py:734↔photo_loader.py:456repo pass-through) are import-boilerplate / single thin wrappers, not worth a helper.Part of #1135 / #1130. Not for merge — review requested.
🤖 Generated with Claude Code