Make the artist a gate, not a quarter of the score

Requesting "Michael Jackson - Chicago" filed The Fall's "Chicago, Now!" from
Extricate. The chain: the artist name is filtered by the Soulseek server, so
the ladder correctly fell back to the bare title -- at which point the result
set is every song anyone has ever called Chicago, and the artist is the only
thing telling them apart.

match_ratio weights the artist at 0.25, so a perfect title with no artist
anywhere scores 0.75. That clears MIN_MATCH, and the ~22 point gap it leaves
against a genuine match is nothing next to the 340 points score() awards for a
free upload slot and a short queue. An idle peer holding the wrong song
therefore beat a busy peer holding the right one, every time.

That is the failure the confidence score was explicitly designed to prevent --
"a fast peer must not be able to raise the confidence of a wrong match" -- and
rewriting score() to rank availability first reintroduced it on the other side
of the wall. Availability is a tiebreak among plausible files; it is never a
reason to take a different song.

Candidates whose path names the artist are now kept outright and the rest
discarded, falling back to title-only matches only when there are none. The
downstream confidence gate still ran correctly here: it scored 0.75, said
"artist not found in path", and held the file for review.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Aryan SinghandClaude Opus 5 committed 2026-09-02 14:10:34 -05:00
1 parent f0c5b5af00
commit 5b17d5fc8d
3 files changed
+85 -3

No files matched your search

+29
View File
@@ -161,6 +161,35 @@ def main() -> int:
check("reordered filename still matches",
app.match_ratio(r"x\Creep - Radiohead.mp3", "Radiohead", "Creep") == 1.0)
print("\nthe artist gate")
check("artist named in the folder is confirmed",
app.artist_confirmed(r"m\Michael Jackson\Xscape\02 Chicago.flac",
"Michael Jackson"))
check("a different band's song with the same title is not",
not app.artist_confirmed(
r"@@jwbvv\Music\The Fall\1990-Extricate\08-Chicago, Now!.flac",
"Michael Jackson"))
check("out-of-order naming still counts",
app.artist_confirmed(r"x\Jackson, Michael - Chicago.flac",
"Michael Jackson"))
# The real regression: bare-title search returns every song called
# "Chicago", and an available stranger used to outrank a queued match.
gate = FakeSlskd(per_query={"Chicago": [
peer("stranger", r"@@x\Music\The Fall\1990-Extricate\08-Chicago, Now!.flac",
slot=True, queue=0),
peer("correct", r"m\Michael Jackson\XSCAPE\02 - Chicago.flac",
slot=False, queue=300),
]})
app.slskd_client = gate
make_job("j6", "Michael Jackson", "Chicago")
asyncio.run(app.pick_and_enqueue("j6", "Michael Jackson", "Chicago"))
r = job_row("j6")
check("the right artist wins even from a peer with 300 queued",
r["username"] == "correct", f"picked {r['username']}")
check("and the wrong-artist file is dropped, not merely ranked lower",
len(json.loads(r["candidates"] or "[]")) == 0, r["candidates"])
print("\ncandidate ladder")
fake = FakeSlskd(per_query={
"Billie Jean": [peer("alice", r"m\Michael Jackson\Billie Jean.flac"),