Match imported entries against the local library and known federated tracks

Add the matcher and the first two resolver stages of the library import.
The matcher is pure: titles are split into a core, featured artists and
version tags, taken from the album title too, so a remaster or concert
album counts like a marker in the track title. Hard tags (live, remix,
edit and similar) must be equal; remaster, mono, stereo, explicit and
clean never match automatically. A match without a comparable duration
needs the same album, and a single candidate is not a match by itself.
Collaborations are split only into known artists, so "Tyler, The Creator"
stays one artist.

The resolve_local phase matches pending entries by artist group against
the library, then against federated tracks this server already knows from
searches and from the owner's synced likes and playlists, and stores
matched, ambiguous (with up to five candidates) or unmatched decisions
under the lease. A local match without a cached content id is hashed with
ensure_local_content_id from agent_storage_dir, so local imports are
publishable with federation disabled. The network is reached only through
a FederationAccess trait and only with the user's consent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sanapachandClaude Opus 5.5 committed 2026-11-26 16:55:27 +02:00
1 parent ff87d9110d
commit 0a258a3e05
12 files changed
+3134 -17

No files matched your search

+9 -2
View File
@@ -158,8 +158,15 @@ FURU_LIBRARY_IMPORT_TEST_DATABASE_URL=postgresql://... cargo test library_import
The database tests cover per-user isolation, repeated and similar source playlists,
storing a 5000-entry export, exclusive claims, lease ownership, cancellation,
history deletion that keeps target playlists, resumption after a worker stops
without a server restart once its lease expires, and continuing the same Spotify
API import after the user signs in again.
without a server restart once its lease expires, continuing the same Spotify
API import after the user signs in again, and resolving a small library with
federation disabled: local matches get content ids from `agent_storage_dir`,
known federated tracks match without the network, and a federation stub that
panics proves no network access without consent. The database needs the
`pg_trgm` extension; the tests install it into `public`.
The matcher's reference table (`src/library_import/matcher/tests.rs`) runs
without a database and documents the matching rules case by case.
The Spotify export fixture in `src/library_import/adapters/fixtures/spotify_export/`
is synthetic. Add a fresh anonymized real export next to it before relying on the