Skip to content

refactor: decompose discovery.py resolver monolith (1563 LOC) #118

Description

@nikazzio

Summary

src/universal_iiif_core/resolvers/discovery.py is 1563 LOC and growing. It contains search adapters for 8+ providers, manifest validation, probe logic, and result normalization — all in a single file.

#114 tracks the Studio UI monolith split but does not cover this core resolver file.

Current structure (single file)

Section Approx LOC Description
Archive.org search ~120 search_archive_org(), URL builder, result extraction
Harvard search ~80 search_harvard(), enrichment fetch
LOC search ~80 _search_loc(), pagination, result extraction
Europeana search ~60 _search_europeana()
Bodleian search ~50 _search_bodleian()
Institut de France ~40 search_institut()
Vatican search ~40 _search_vatican()
Gallica search ~80 _search_gallica(), smart search
Manifest validation ~100 validate_manifest_url(), _safe_probe()
Provider resolution ~100 resolve_provider_input(), smart_search()
Shared utilities ~80 Constants, headers, helper functions

Proposed split

src/universal_iiif_core/resolvers/
├── discovery.py          # Public API: smart_search(), resolve_provider_input(), validate_manifest_url()
├── search_adapters/      # One file per provider (archive_org.py, harvard.py, loc.py, etc.)
│   └── __init__.py       # Re-exports for backward compat
└── manifest_probe.py     # validate_manifest_url(), _safe_probe()

Relationship to other issues

Acceptance criteria

  • No file in resolvers/ exceeds ~300 LOC (excluding __init__.py re-exports)
  • All existing tests pass unchanged
  • Public API surface (smart_search, resolve_provider_input, validate_manifest_url) unchanged
  • ruff check . --select C901 clean

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:discoveryDiscovery search and provider resolutionpriority:P1High prioritysemver:noneNo release impact by itselfstatus:readyReady to be implementedtype:refactorCode refactor without behavior change

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions