diff --git a/app/verify/promote.py b/app/verify/promote.py index 8d5ac15f6b9..4d70acadbd6 100644 --- a/app/verify/promote.py +++ b/app/verify/promote.py @@ -33,23 +33,35 @@ class PromotionDecision(NamedTuple): reason: str -def has_live_t1(source_urls: list[str], url_cache: dict[str, dict[str, Any]]) -> bool: - """True if some cited URL is a Tier-1 host AND confirmed alive in the cache.""" +def has_live_authoritative_source( + source_urls: list[str], url_cache: dict[str, dict[str, Any]] +) -> bool: + """True if some cited URL is an authoritative host (Tier 1 *or* Tier 2) AND + confirmed alive. The green band already requires a T1/T2 source + completeness + + consistency; this just adds "and that source actually resolves". Requiring a + *manufacturer/encyclopaedia* (T1 only) was too strict — it never promoted the + many green records sourced from reputable spec/benchmark DBs (gsmarena, + cpubenchmark, ...), so verified never moved off its floor. + """ for u in source_urls: entry = url_cache.get(u) - if entry and entry.get("alive") and hosts.tier_of_host(hosts.host_of(u)) == 1: + if entry and entry.get("alive") and hosts.tier_of_host(hosts.host_of(u)) in (1, 2): return True return False +# Backwards-compatible alias (older callers/tests). +has_live_t1 = has_live_authoritative_source + + def decide( *, band: str, source_urls: list[str], url_cache: dict[str, dict[str, Any]], crossref_decision: str | None, ) -> PromotionDecision: if crossref_decision == "confirm": return PromotionDecision(True, "crossref-confirm") - if band == "green" and has_live_t1(source_urls, url_cache): - return PromotionDecision(True, "green+live-t1") + if band == "green" and has_live_authoritative_source(source_urls, url_cache): + return PromotionDecision(True, "green+live-source") return PromotionDecision(False, "needs-confirmation") diff --git a/tests/verify/test_promote_crossref.py b/tests/verify/test_promote_crossref.py index 82374c57c47..c45cd009188 100644 --- a/tests/verify/test_promote_crossref.py +++ b/tests/verify/test_promote_crossref.py @@ -101,7 +101,27 @@ def test_green_with_live_t1_promotes(): band="green", source_urls=["https://en.wikipedia.org/wiki/X"], url_cache=cache, crossref_decision=None, ) - assert d.promote and d.reason == "green+live-t1" + assert d.promote and d.reason == "green+live-source" + + +def test_green_with_live_t2_promotes(): + # A reputable T2 spec/benchmark DB (cpubenchmark) that is alive also promotes. + cache = {"https://www.cpubenchmark.net/cpu.php?id=1": {"alive": True}} + d = promote.decide( + band="green", source_urls=["https://www.cpubenchmark.net/cpu.php?id=1"], + url_cache=cache, crossref_decision=None, + ) + assert d.promote and d.reason == "green+live-source" + + +def test_green_with_only_t3_source_held(): + # kaggle (T3) alive is NOT enough to promote even if green. + cache = {"https://www.kaggle.com/x": {"alive": True}} + d = promote.decide( + band="green", source_urls=["https://www.kaggle.com/x"], + url_cache=cache, crossref_decision=None, + ) + assert not d.promote def test_green_without_live_source_blocked():