Skip to content

Commit fc0ad8f

Browse files
committed
fix(verify): require live sources for green promotion
1 parent 0e5eb02 commit fc0ad8f

3 files changed

Lines changed: 31 additions & 20 deletions

File tree

‎app/verify/cli.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,13 +632,13 @@ def cmd_pr(args: argparse.Namespace) -> int:
632632

633633
# Tier 2 — external cross-reference (network, exact-heading only).
634634
fetcher = crossref.WikidataFetcher()
635-
xref: dict[str, str] = {}
635+
xref: dict[tuple[str, str], str] = {}
636636
decisions: Counter[str] = Counter()
637637
for r, _ in scored:
638638
try:
639639
xres = crossref.crossref_record(r.data, fetcher)
640640
if r.slug:
641-
xref[r.slug] = xres.decision
641+
xref[(r.category, r.slug)] = xres.decision
642642
decisions[xres.decision] += 1
643643
except Exception:
644644
decisions["error"] += 1
@@ -655,8 +655,12 @@ def cmd_pr(args: argparse.Namespace) -> int:
655655
hold = 0
656656
for r, s in scored:
657657
urls_r = [u for u in r.data.get("source_urls", []) if isinstance(u, str)]
658-
dec = promote.decide(band=s.band, source_urls=urls_r, url_cache=url_cache,
659-
crossref_decision=xref.get(r.slug) if r.slug else None)
658+
dec = promote.decide(
659+
band=s.band,
660+
source_urls=urls_r,
661+
url_cache=url_cache,
662+
crossref_decision=xref.get((r.category, r.slug)) if r.slug else None,
663+
)
660664
if dec.promote:
661665
promote_rows.append((r, dec.reason))
662666
else:

‎app/verify/promote.py‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,10 @@ def decide(
6666
# Reality confirm: external source agrees -> strongest promotion.
6767
if crossref_decision == "confirm":
6868
return PromotionDecision(True, "crossref-confirm")
69-
# green = passed the offline inspection: an authoritative source (T1/T2) IS
70-
# cited, cross-field consistency holds, the record is complete, and there are
71-
# no hard violations. That is the verification result, so promote it (unless
72-
# crossref contradicted above). The earlier live-HTTP source re-check was
73-
# dropped: most green records cite spec DBs (phonedb/cpubenchmark) that block
74-
# automated requests, which kept verified stuck far below the green band.
75-
if band == "green":
76-
return PromotionDecision(True, "green")
69+
# green is only an offline candidate. Promotion still requires a cited
70+
# authoritative source to have been confirmed alive by Tier 1.
71+
if band == "green" and has_live_authoritative_source(source_urls, url_cache):
72+
return PromotionDecision(True, "green-live-source")
7773
return PromotionDecision(False, "needs-confirmation")
7874

7975

‎tests/verify/test_promote_crossref.py‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,32 @@ def test_write_back_atomic_lf_preserved():
113113
# --- promotion decision ----------------------------------------------------------
114114

115115

116-
def test_green_promotes():
117-
# green = passed the offline inspection -> verified. The live-source state no
118-
# longer gates (green already requires a cited authoritative source).
119-
d = promote.decide(band="green", source_urls=[], url_cache={}, crossref_decision=None)
120-
assert d.promote and d.reason == "green"
116+
def test_green_requires_live_authoritative_source():
117+
d = promote.decide(
118+
band="green",
119+
source_urls=["https://www.intel.com/x"],
120+
url_cache={},
121+
crossref_decision=None,
122+
)
123+
assert not d.promote
124+
125+
126+
def test_green_promotes_with_live_authoritative_source():
127+
cache = {"https://www.phonedb.net/x": {"alive": True}}
128+
d = promote.decide(
129+
band="green", source_urls=["https://www.phonedb.net/x"],
130+
url_cache=cache, crossref_decision=None,
131+
)
132+
assert d.promote and d.reason == "green-live-source"
121133

122134

123-
def test_green_promotes_regardless_of_source_liveness():
124-
# Even with a dead / unchecked source, a green record promotes.
135+
def test_green_does_not_promote_with_dead_authoritative_source():
125136
cache = {"https://www.phonedb.net/x": {"alive": False}}
126137
d = promote.decide(
127138
band="green", source_urls=["https://www.phonedb.net/x"],
128139
url_cache=cache, crossref_decision=None,
129140
)
130-
assert d.promote and d.reason == "green"
141+
assert not d.promote
131142

132143

133144
def test_yellow_without_confirm_holds():

0 commit comments

Comments
 (0)