11#!/usr/bin/env python3
22"""Fail when installable catalog packages reference unregistered loaders.
33
4- The machine-readable contract from PR #74 makes package ``family`` and
5- ``audiocpp_cli --list-loaders`` authoritative for integrators. Catalog entries
6- must not advertise installable packages for families that are commented out or
7- missing from ``src/framework/runtime/registry.cpp``.
8-
9- Verified release-tree facts this check encodes:
10-
11- - Parked registry stubs currently include ``kokoro_tts``, ``higgs_tts``, and
12- ``parakeet_tdt``. Those loader *sources are not in this tree* (no
13- ``src/models/<family>`` / matching include); only comments + warm-bench tests
14- remain. Matching catalog packages must be ``UnsupportedSource``.
15- - ``higgs_audio_tts`` is treated as an alias of the parked ``higgs_tts`` stub
16- until one family id is chosen when the loader returns.
17- - ``silero_vad`` is a registered loader without a model_manager package (bundled
18- asset path). That is allowed; see docs/maintainers/loader_and_catalog.md.
4+ ``model_manager list --json`` family fields and ``audiocpp_cli --list-loaders``
5+ must stay aligned. Installable standalone packages cannot advertise a family
6+ that is missing or commented out in ``src/framework/runtime/registry.cpp``.
197
208See docs/maintainers/loader_and_catalog.md.
219"""
3523
3624_LOADER_CALL_RE = re .compile (r"\bmake_([a-z0-9_]+)_loader\s*\(\s*\)" )
3725
38- # Catalog family strings that refer to a differently named parked registry stub.
39- # When re-enabling a loader, collapse these to one id everywhere.
26+ # Optional: catalog family strings that map to a differently named parked stub.
4027PARKED_FAMILY_ALIASES : dict [str , set [str ]] = {
4128 "higgs_tts" : {"higgs_audio_tts" },
4229}
@@ -161,7 +148,6 @@ def check_catalog(
161148 )
162149
163150 if explicit is None and inferred not in active and family in active :
164- # Should be unreachable if family comes from inference, but keep tight.
165151 errors .append (
166152 f"{ package_id } : set ModelPackage.family explicitly "
167153 f"(id inference '{ inferred } ' is not a registered loader)"
@@ -173,7 +159,6 @@ def check_catalog(
173159 f"is not registered in registry.cpp{ parked_hint (family , commented )} "
174160 )
175161 elif family_is_parked (family , commented ):
176- # Active and commented with same name should not happen; still guard.
177162 errors .append (
178163 f"{ package_id } : family '{ family } ' is both active and commented in registry.cpp"
179164 )
@@ -250,37 +235,40 @@ def check_readme(
250235class _SyncCheckSelfTests (unittest .TestCase ):
251236 def test_parse_active_and_commented (self ) -> None :
252237 text = """
253- // make_kokoro_tts_loader (),
254- make_pocket_tts_loader (),
255- make_higgs_tts_loader (), // trailing comment still active
238+ // make_family_a_loader (),
239+ make_family_b_loader (),
240+ make_family_c_loader (), // trailing comment still active
256241 """
257242 active , commented = parse_registry_loaders (text )
258- self .assertEqual (active , {"pocket_tts " , "higgs_tts " })
259- self .assertEqual (commented , {"kokoro_tts " })
243+ self .assertEqual (active , {"family_b " , "family_c " })
244+ self .assertEqual (commented , {"family_a " })
260245
261246 def test_parked_alias_blocks_installable (self ) -> None :
262247 class Pkg :
263248 def __init__ (self , family = None ):
264249 self .family = family
265250
251+ stub = next (iter (PARKED_FAMILY_ALIASES ))
252+ alias = next (iter (PARKED_FAMILY_ALIASES [stub ]))
253+
266254 def payload (package ):
267255 return {
268- "id" : "higgs_audio_v3_tts_4b " ,
269- "family" : "higgs_audio_tts" ,
256+ "id" : "pkg_alias " ,
257+ "family" : alias ,
270258 "installable" : True ,
271259 "standalone" : True ,
272260 "source" : {"kind" : "huggingface_snapshot" },
273261 }
274262
275263 errors , _ = check_catalog (
276- active = {"pocket_tts " },
277- commented = {"higgs_tts" },
278- packages = [Pkg (family = "higgs_audio_tts" )],
264+ active = {"family_b " },
265+ commented = {stub },
266+ packages = [Pkg (family = alias )],
279267 package_payload = payload ,
280- default_family_from_package_id = lambda _pid : "higgs_audio_v3_tts " ,
268+ default_family_from_package_id = lambda _pid : "pkg_alias " ,
281269 )
282- self .assertTrue (any ("higgs_audio_tts" in e for e in errors ))
283- self .assertTrue (any ("parked loader 'higgs_tts '" in e for e in errors ))
270+ self .assertTrue (any (alias in e for e in errors ))
271+ self .assertTrue (any (f "parked loader '{ stub } '" in e for e in errors ))
284272
285273
286274def main () -> int :
0 commit comments