Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions app/verify/promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
22 changes: 21 additions & 1 deletion tests/verify/test_promote_crossref.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Loading