feat(discovery): build_similarity_sources + worker sweep/trigger wiring
Adds registry.build_similarity_sources() (always constructs ListenBrainzSource; reachability is a per-run health() concern, not a startup gate) and wires discovery into the worker's main loop: a scheduled sweep gated on discover.enabled + DISCOVER_TICK_SECONDS, and a one-shot discover.requested trigger mirroring the existing scan.requested pattern. Also hardens run_discovery's health-check pass: a source whose health() raises is now logged and skipped instead of aborting the whole sweep (accepted finding from the Task-3 review). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -72,6 +72,21 @@ def test_unhealthy_source_contributes_nothing(conn):
|
||||
assert _artist_rows(conn) == []
|
||||
|
||||
|
||||
def test_source_with_raising_health_is_skipped_not_fatal(conn):
|
||||
insert_watched_artist(conn, mbid="s1", name="Seed")
|
||||
|
||||
class BoomSource:
|
||||
name = "boom"
|
||||
def health(self):
|
||||
raise RuntimeError("boom")
|
||||
def similar_artists(self, mbid):
|
||||
return []
|
||||
|
||||
good = FakeSimilaritySource(similar={"s1": [SimilarArtist("c1", "X", 0.9)]})
|
||||
result = run_discovery(conn, [BoomSource(), good], FakeMbBrowser(), DiscoveryConfig())
|
||||
assert result.artists == 1 # good source still processed; boom skipped, no crash
|
||||
|
||||
|
||||
def test_config_from_config_parses_and_defaults():
|
||||
cfg = DiscoveryConfig.from_config({"discover.enabled": "true", "discover.maxSeeds": "10",
|
||||
"discover.minScore": "0.3"})
|
||||
|
||||
Reference in New Issue
Block a user