Search peer artist catalogues for unmatched import entries

With the user's consent and federation enabled, entries that the local
library and known federated tracks do not match wait for resolver stage 3.
It looks up each artist group by its original name, its spelling without
Latin diacritics and, if those find nothing, its collaboration parts, and
decides the entries against the federated tracks of the catalogues.

The new artist_catalogs_bounded in the federation client asks at most 16
owners, a given number at a time, in a JoinSet owned by one task; dropping
the stream aborts the search and every catalogue request. The player's
stream_artist_catalogs keeps its behaviour and shares the owner parsing.
Imports search two groups at a time process-wide, give a group 60 s, retry
failed searches after 2/4/8 s, stop after 500 groups or 30 minutes per pass
and cancel running lookups on cancellation or lease loss. Lost catalogues
are counted in the statistics.

POST /api/imports/{id}/items/{item_id}/match takes a stored candidate of
an ambiguous entry for its owner after checking it again, and queues a
finished import so that the choice is published.

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

No files matched your search

+11 -2
View File
@@ -162,8 +162,17 @@ 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`.
panics proves no network access without consent. Peer catalogues come from a
fake catalogue source: the tests cover matches through the original, folded and
split artist names, repeated failed searches, lost catalogues, the budget of a
pass, a stopped node, manual choices with tampered candidates, and cancellation
that leaves no catalogue request running. The database needs the `pg_trgm`
extension; the tests install it into `public`.
`cargo test federation::client` checks bounded artist catalogue lookups without a
database: at most 16 owners and the given number of parallel requests, timeouts,
errors, oversized catalogues, and that dropping a lookup stops its search and
requests.
The matcher's reference table (`src/library_import/matcher/tests.rs`) runs
without a database and documents the matching rules case by case.