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:
Jonathan
2026-07-12 00:22:34 +02:00
parent 6f504a7c04
commit a15f4ae8bb
6 changed files with 119 additions and 2 deletions
+14
View File
@@ -0,0 +1,14 @@
from lyra_worker.registry import build_similarity_sources
from lyra_worker.similarity._listenbrainz import ListenBrainzSource
def test_build_returns_listenbrainz_by_default():
sources = build_similarity_sources({})
assert len(sources) == 1
assert isinstance(sources[0], ListenBrainzSource)
assert sources[0].name == "listenbrainz"
def test_base_url_override_from_config():
src = build_similarity_sources({"discover.listenBrainzUrl": "http://lb.local"})[0]
assert src._base == "http://lb.local"