refactor: extract cross-source Paper merge into service/_merge.py - #26
Merged
Conversation
`LibraryService` imported `_merge_records` straight out of `service/search.py` — a service reaching into another service's private symbol for shared infra. Move the field-by-field merge (and its _pick_* / _merge_metadata helpers and the id-preference table) into `service/_merge.py` as the public `merge_records`, which both SearchService (in-search dedup) and LibraryService (ingest enrichment) import. No behavior change — the search/library service tests cover the merge paths.
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
LibraryServiceimported_merge_recordsdirectly fromservice/search.py— one service reaching into another service's private symbol for what is really shared infrastructure (cross-sourcePaperenrichment). The ROADMAP flagged this under "Code organization."Move the field-by-field merge into
service/_merge.pyasmerge_records, along with its_pick_*/_merge_metadatahelpers and the_ID_PREFIX_RANKid-preference table (all used only by the merge). BothSearchService(in-search dedup) andLibraryService(ingest-time enrichment) now import it from the shared module.No behavior change — the merge logic is byte-for-byte the same, just relocated and renamed (dropping the leading underscore now that it's a module's intended API rather than a private symbol).
Test plan
ruff check src tests— clean (verified no unused imports left behind insearch.py)mypy src— cleanpytest -q --strict-markers— 524 passed, 14 skipped;test_search_service.py(merge/dedup) andtest_library_service.py(enrichment) cover the moved code